2 $monLibrary= dirname(__FILE__) .
"/../library";
3 $sharedLibrary= dirname(__FILE__) .
"/../../shared/library";
4 require_once(
"$monLibrary/cu_top.i");
5 require_once(
"$monLibrary/ck_hticket.i");
6 require_once(
"$monLibrary/cu_pass.i");
7 require_once(
"$sharedLibrary/cu_flagconst.i");
9 if (!CheckPerm($link, $Hu, basename($_SERVER[
'SCRIPT_NAME']), $_SERVER[
'REMOTE_ADDR'])) {
12 header(
"Location: /hcuadm/hcu_noperm.prg");
16 $dms_ok=array(
'rv'=>
'string',
'btnCont'=>
'string',
'btnUpload'=>
'string',
'selResults'=>
'string',
'selCompare'=>
'string',
17 'chkShowZero'=>
'digits',
'uplMonth'=>
'string',
'uplYear'=>
'string',
'uplFileName'=>
'string',
18 "rdate"=>
"digits",
"enddate" =>
"digits",
"action"=>
"string");
22 $self = $_SERVER[
'PHP_SELF'];
23 if (!empty($_REQUEST[
'rv'])) {
27 $results_dir =
"/home/httpd/monitor/emailrpt/";
28 $xrc_prefix =
"emailrpt";
31 if ( $action ==
"fix_billing_mapping" ) {
32 $dms_ok=array(
'domain'=>
'string',
'selResults'=>
'string',
'selCompare'=>
'string',
'cu_name'=>
'string');
33 dms_import_v2($HB_ENV,
'HCUPOST', $dms_ok);
36 $cuList = GetCUCodeList( $link );
39 $cuName = trim($HB_ENV[
"HCUPOST"][
"cu_name"]);
42 <form action=
'$self' method=
'POST'>
43 <table border=
'0' align=
'center' cellpadding=2 cellspacing=0>
44 <input type=
"hidden" name=
"action" value=
"map_cu_domain">
45 <input type=
"hidden" name=
"domain" value=
"{$HB_ENV["HCUPOST
"]["domain
"]}">
46 <input type=
"hidden" name=
"selResults" value=
"{$HB_ENV["HCUPOST
"]["selResults
"]}">
47 <input type=
"hidden" name=
"selCompare" value=
"{$HB_ENV["HCUPOST
"]["selCompare
"]}">
48 <tr
class=
'barb'><td align=
'center'><font size=+1>Map Credit Union Domain</font></td></tr>
49 <tr><td>Domain Name</td><td>{$HB_ENV[
"HCUPOST"][
"domain"]}</td></tr>
50 <tr><td>Credit Union</td>
51 <td><select name=
"cu_name">
52 <option value=
"">Select one...</option>
55 for ( $i = 0; $i < count( $cuList ); $i++ ) {
56 $selected = $cuName == $cuList[$i] ?
"SELECTED" :
"";
57 print
"<option value='{$cuList[$i]}' $selected>{$cuList[$i]}</option>";
62 <tr><td style=
"text-align:center;"><button type=
"submit">Map it!</button></td></tr>
65 <form method=
'post' action=
'$self' name=
'returnForm'>
66 <input type=
"hidden" name=
"btnCont" value=
"View Report">
67 <input type=
"hidden" name=
"selResults" value=
"{$HB_ENV["HCUPOST
"]["selResults
"]}">
68 <input type=
"hidden" name=
"selCompare" value=
"{$HB_ENV["HCUPOST
"]["selCompare
"]}">
69 <a onClick=
'returnForm.submit();' style=
'text-decoration:underline; cursor:pointer;'>Return to results</a>
78 if ( $action ==
"map_cu_domain" ) {
80 $dms_ok=array(
'domain'=>
'string',
'selResults'=>
'string',
'selCompare'=>
'string',
'cu_name'=>
'string');
81 dms_import_v2($HB_ENV,
'HCUPOST', $dms_ok);
83 $domain = htmlEntities(trim($HB_ENV[
"HCUPOST"][
"domain"]), ENT_QUOTES);
84 $cu_name = htmlEntities(trim($HB_ENV[
"HCUPOST"][
"cu_name"]), ENT_QUOTES);
86 if ( strlen( $cu_name ) > 0 && strlen( $domain ) > 0 ) {
87 $sql =
"SELECT cu_name FROM cubilldomainmap WHERE domain = '$domain'";
89 $sth = db_query($sql, $link);
92 $mapRow = db_fetch_assoc($sth);
94 if ( strlen( trim($mapRow[
"cu_name"]) ) > 0 ) {
95 $operation =
"updated";
96 $sql =
"UPDATE cubilldomainmap SET cu_name = '$cu_name' WHERE domain = '$domain'";
99 $sql =
"INSERT INTO cubilldomainmap VALUES ( '$cu_name', '$domain' )";
102 $sth = db_query($sql, $link);
105 $message =
"Credit union $cu_name mapping to $domain failed!";
107 $message =
"Credit union $cu_name mapping to $domain was $operation successfully.";
112 $_POST[
"btnCont"] =
"View Report";
118 if (isset($_POST[
'btnUpload'])) {
119 $retMsg = ProcessFile($results_dir, $xrc_prefix, $uplFileName, $uplMonth, $uplYear);
122 if (isset($_POST[
'btnCont'])) {
125 $report_view =
"REPORT";
126 }
else if ( $report_view !=
"RAW" ) {
128 $month = Array(
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec");
131 $results_list = Array();
134 if (is_dir($results_dir)) {
135 if ($dir_hndl = opendir($results_dir)) {
136 while (($file = readdir($dir_hndl)) !==
false) {
137 if (filetype($results_dir . $file) ==
"file" && (substr($file, 0, strlen($xrc_prefix)) == $xrc_prefix)) {
138 $results_list[] = substr($file, strlen($xrc_prefix));
144 rsort($results_list);
147 $month_select[date(
'M', mktime(0, 0, 0, date(
'm'), date(
'd'), date(
'Y')))] =
" SELECTED ";
148 $year_select[date(
'Y', mktime(0, 0, 0, date(
'm'), date(
'd'), date(
'Y')))] =
" SELECTED ";
159 switch ($report_view) {
161 $file1_domain = Array();
162 $result_file1 = $xrc_prefix . $selResults;
163 $rptShowZero =
false;
164 if (isset($chkShowZero)) {
165 $rptShowZero = ($chkShowZero == 1);
169 $TTL_Client_Info = Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
170 if (file_exists($results_dir . $result_file1)) {
171 $file1_results = file($results_dir . $result_file1);
172 foreach($file1_results as $key => $value){
173 $file1_domain[] = explode(
"\t", $value);
178 $compareList = array();
179 if ( strlen( $selCompare ) ) {
180 $compareFile = $xrc_prefix . $selCompare;
182 if (file_exists($results_dir . $compareFile)) {
183 $compareResults = file($results_dir . $compareFile);
184 foreach($compareResults as $key => $value){
185 $compareList[] = explode(
"\t", $value);
192 if (count($file1_domain[0]) == 11) {
193 for ( $idxAdjustRow = 0; $idxAdjustRow < count($file1_domain); $idxAdjustRow++) {
195 $file1_domain[$idxAdjustRow][12] = $file1_domain[$idxAdjustRow][9];
196 $file1_domain[$idxAdjustRow][11] = $file1_domain[$idxAdjustRow][8];
197 $file1_domain[$idxAdjustRow][9] = $file1_domain[$idxAdjustRow][6];
199 $file1_domain[$idxAdjustRow][6] = 0;
200 $file1_domain[$idxAdjustRow][7] = 0;
201 $file1_domain[$idxAdjustRow][8] = 0;
207 if ( strlen( $message ) ) {
208 $messageLine =
"<tr><td style='text-align:center; background-color:yellow;'>$message</td></tr>";
214 cu_header(
"Email Domain Report");
216 <form action=
'$self' method=
'POST'>
217 <table width=
'700' border=
'0' align=
'center' cellpadding=3 cellspacing=0
class=
'dmsbg'><tr><td>
218 <table width=
'100%' border=
'0' align=
'center' bgcolor=white cellpadding2 cellspacing=0>
219 <tr
class=
'barb'><td align=
'center'><font size=+1>Report Results</font></td></tr>
220 <tr><td><a href=
"$infourl/hcuadm/cuilist.prg" target=
"parent">Credit Union List</a></td></tr>
223 <table border=0 width=
'100%' align=
'center' cellpadding=1 cellspacing=1>
242 if ( count( $compareList ) > 0 ) {
244 $outputSameList = array();
245 $outputChangeList = array();
246 $outputAddList = array();
247 $outputDropList = array();
248 for ( $i = 0; $i < count( $file1_domain ); $i++ ) {
249 $domainName = $file1_domain[$i][0];
250 $foundCompare =
false;
251 for ( $c = 0; $c < count( $compareList ); $c++ ) {
252 if ( $compareList[$c][0] == $domainName ) {
253 $foundCompare =
true;
257 if ( $foundCompare ) {
259 $diffArray = array_diff( $file1_domain[$i], $compareList[$c] );
260 if ( count( $diffArray ) ) {
261 $outputChangeList[] = $file1_domain[$i];
263 $outputSameList[] = $file1_domain[$i];
267 $outputAddList[] = $file1_domain[$i];
272 for ( $c = 0; $c < count( $compareList ); $c++ ) {
273 $domainName = $compareList[$c][0];
274 $foundInCurrent =
false;
275 for ( $i = 0; $i < count( $file1_domain ); $i++ ) {
276 if ( $file1_domain[$i][0] == $domainName ) {
277 $foundInCurrent =
true;
281 if ( !$foundInCurrent ) {
282 $outputDropList[] = $compareList[$c];
287 $resultStamp = mktime( 6, 0, 0, substr( $selResults, 4, 2 ) + 1, 0, substr( $selResults, 0, 4 ) );
288 $resultName = date(
"F Y", $resultStamp );
289 $compareStamp = mktime( 6, 0, 0, substr( $selCompare, 4, 2 ) + 1, 0, substr( $selCompare, 0, 4 ) );
290 $CompareName = date(
"F Y", $compareStamp );
293 <td colspan='13' style='font-size:larger; font-style:italic; font-weight:normal;'>Comparing $resultName against $CompareName</td> 298 <td colspan='13'>Domains That Didn't Change</td> 300 if ( count( $outputSameList ) > 0 ) {
302 foreach ($outputSameList as $key => $dom_value) {
304 if (intval($dom_value[12]) > 0 || $rptShowZero) {
305 $TTL_Client_Info[0]++;
306 for ($idx=1; $idx <= 12; $idx++) {
307 $TTL_Client_Info[$idx] += intval($dom_value[$idx]);
309 $tr_class = ($tr_class ==
"odd_small" ?
"even_small" :
"odd_small");
310 $cuCode = LookupCUCode( $link, $dom_value[0], $needsLookup );
311 if ( $needsLookup ) {
317 $lookupString =
"<a href=\"$self?action=fix_billing_mapping&domain={$dom_value[0]}&selResults={$selResults}&selCompare={$selCompare}&cu_name=$cuCode\" style=\"color:$classColor;\">$cuCode</a>";
320 <tr
class=
'$tr_class'>
321 <td nowrap>{$lookupString}</td>
322 <td>{$dom_value[0]}</td>
323 <td>{$dom_value[1]}</td>
324 <td>{$dom_value[2]}</td>
325 <td>{$dom_value[3]}</td>
326 <td>{$dom_value[4]}</td>
327 <td>{$dom_value[5]}</td>
328 <td>{$dom_value[6]}</td>
329 <td>{$dom_value[7]}</td>
330 <td>{$dom_value[8]}</td>
331 <td align=
'right'>\${$dom_value[9]}</td>
332 <td align=
'right'>\${$dom_value[11]}</td>
333 <td align=
'right'>\${$dom_value[12]}</td>
339 print
"<tr colspan='13' class='$tr_class'><td>No Entries</td></tr>";
344 <tr><td colspan='13'> </td></tr> 346 <td colspan='13'>Changed Domains</td> 348 if ( count( $outputChangeList ) > 0 ) {
350 foreach ($outputChangeList as $key => $dom_value) {
352 if (intval($dom_value[12]) > 0 || $rptShowZero) {
353 $TTL_Client_Info[0]++;
354 for ($idx=1; $idx <= 12; $idx++) {
355 $TTL_Client_Info[$idx] += intval($dom_value[$idx]);
357 $tr_class = ($tr_class ==
"odd_small" ?
"even_small" :
"odd_small");
358 $cuCode = LookupCUCode( $link, $dom_value[0], $needsLookup );
359 if ( $needsLookup ) {
365 $lookupString =
"<a href=\"$self?action=fix_billing_mapping&domain={$dom_value[0]}&selResults={$selResults}&selCompare={$selCompare}&cu_name=$cuCode\" style=\"color:$classColor;\">$cuCode</a>";
367 <tr
class=
'$tr_class'>
368 <td nowrap>{$lookupString}</td>
369 <td>{$dom_value[0]}</td>
370 <td>{$dom_value[1]}</td>
371 <td>{$dom_value[2]}</td>
372 <td>{$dom_value[3]}</td>
373 <td>{$dom_value[4]}</td>
374 <td>{$dom_value[5]}</td>
375 <td>{$dom_value[6]}</td>
376 <td>{$dom_value[7]}</td>
377 <td>{$dom_value[8]}</td>
378 <td align=
'right'>\${$dom_value[9]}</td>
379 <td align=
'right'>\${$dom_value[11]}</td>
380 <td align=
'right'>\${$dom_value[12]}</td>
386 print
"<tr colspan='13' class='$tr_class'><td>No Entries</td></tr>";
391 <tr><td colspan='13'> </td></tr> 393 <td colspan='13'>Added Domains</td> 395 if ( count( $outputAddList ) > 0 ) {
397 foreach ($outputAddList as $key => $dom_value) {
399 if (intval($dom_value[12]) > 0 || $rptShowZero) {
400 $TTL_Client_Info[0]++;
401 for ($idx=1; $idx <= 12; $idx++) {
402 $TTL_Client_Info[$idx] += intval($dom_value[$idx]);
404 $tr_class = ($tr_class ==
"odd_small" ?
"even_small" :
"odd_small");
405 $cuCode = LookupCUCode( $link, $dom_value[0], $needsLookup );
406 if ( $needsLookup ) {
412 $lookupString =
"<a href=\"$self?action=fix_billing_mapping&domain={$dom_value[0]}&selResults={$selResults}&selCompare={$selCompare}&cu_name=$cuCode\" style=\"color:$classColor;\">$cuCode</a>";
414 <tr
class=
'$tr_class'>
415 <td nowrap>{$lookupString}</td>
416 <td>{$dom_value[0]}</td>
417 <td>{$dom_value[1]}</td>
418 <td>{$dom_value[2]}</td>
419 <td>{$dom_value[3]}</td>
420 <td>{$dom_value[4]}</td>
421 <td>{$dom_value[5]}</td>
422 <td>{$dom_value[6]}</td>
423 <td>{$dom_value[7]}</td>
424 <td>{$dom_value[8]}</td>
425 <td align=
'right'>\${$dom_value[9]}</td>
426 <td align=
'right'>\${$dom_value[11]}</td>
427 <td align=
'right'>\${$dom_value[12]}</td>
433 print
"<tr colspan='13' class='$tr_class'><td>No Entries</td></tr>";
439 <tr><td colspan='13'> </td></tr> 441 <td colspan='13'>Dropped Domains (not counted in totals)</td> 443 if ( count( $outputDropList ) > 0 ) {
445 foreach ($outputDropList as $key => $dom_value) {
446 if (intval($dom_value[12]) > 0 || $rptShowZero) {
447 $tr_class = ($tr_class ==
"odd_small" ?
"even_small" :
"odd_small");
448 $cuCode = LookupCUCode( $link, $dom_value[0], $needsLookup );
449 if ( $needsLookup ) {
455 $lookupString =
"<a href=\"$self?action=fix_billing_mapping&domain={$dom_value[0]}&selResults={$selResults}&selCompare={$selCompare}&cu_name=$cuCode\" style=\"color:$classColor;\">$cuCode</a>";
457 <tr
class=
'$tr_class'>
458 <td nowrap>{$lookupString}</td>
459 <td>{$dom_value[0]}</td>
460 <td>{$dom_value[1]}</td>
461 <td>{$dom_value[2]}</td>
462 <td>{$dom_value[3]}</td>
463 <td>{$dom_value[4]}</td>
464 <td>{$dom_value[5]}</td>
465 <td>{$dom_value[6]}</td>
466 <td>{$dom_value[7]}</td>
467 <td>{$dom_value[8]}</td>
468 <td align=
'right'>\${$dom_value[9]}</td>
469 <td align=
'right'>\${$dom_value[11]}</td>
470 <td align=
'right'>\${$dom_value[12]}</td>
476 print
"<tr colspan='13' class='$tr_class'><td>No Entries</td></tr>";
481 foreach ($file1_domain as $key => $dom_value) {
483 if (intval($dom_value[12]) > 0 || $rptShowZero) {
484 $tr_class = ($tr_class ==
"odd_small" ?
"even_small" :
"odd_small");
485 $TTL_Client_Info[0]++;
486 for ($idx=1; $idx <= 12; $idx++) {
487 $TTL_Client_Info[$idx] += intval($dom_value[$idx]);
489 $cuCode = LookupCUCode( $link, $dom_value[0], $needsLookup );
490 if ( $needsLookup ) {
496 $lookupString =
"<a href=\"$self?action=fix_billing_mapping&domain={$dom_value[0]}&selResults={$selResults}&selCompare={$selCompare}&cu_name=$cuCode\" style=\"color:$classColor;\">$cuCode</a>";
498 <tr
class=
'$tr_class'>
499 <td nowrap>{$lookupString}</td>
500 <td>{$dom_value[0]}</td>
501 <td>{$dom_value[1]}</td>
502 <td>{$dom_value[2]}</td>
503 <td>{$dom_value[3]}</td>
504 <td>{$dom_value[4]}</td>
505 <td>{$dom_value[5]}</td>
506 <td>{$dom_value[6]}</td>
507 <td>{$dom_value[7]}</td>
508 <td>{$dom_value[8]}</td>
509 <td align=
'right'>\${$dom_value[9]}</td>
510 <td align=
'right'>\${$dom_value[11]}</td>
511 <td align=
'right'>\${$dom_value[12]}</td>
519 <tr
class=
'hdr'><td colspan=
'13' align=
'center'>Total Client Information</td></tr>
522 <td>Total Clients: $TTL_Clients Total Clients Reported: {$TTL_Client_Info[0]}</td>
523 <td>{$TTL_Client_Info[1]}</td>
524 <td>{$TTL_Client_Info[2]}</td>
525 <td>{$TTL_Client_Info[3]}</td>
526 <td>{$TTL_Client_Info[4]}</td>
527 <td>{$TTL_Client_Info[5]}</td>
528 <td>{$TTL_Client_Info[6]}</td>
529 <td>{$TTL_Client_Info[7]}</td>
530 <td>{$TTL_Client_Info[8]}</td>
531 <td align=
'right'>\${$TTL_Client_Info[9]}</td>
532 <td align=
'right'>\${$TTL_Client_Info[11]}</td>
533 <td align=
'right'>\${$TTL_Client_Info[12]}</td>
540 if ( $lookupError > 0 ) {
541 print
"<tr><td style='text-align:center; color:red; font-size:larger; background-color:white;'>Domain lookup errors exist. Need to correct.</td></tr>";
546 print
"</body></html>";
552 if (!isset($enddate) || trim($enddate) ==
"")
554 $reportMonth = substr( $rdate, 0, 6 );
555 $file1_domain= getDataFromFile($reportMonth);
556 printCSVFromData($file1_domain, $link,
false);
560 $startDate= DateTime::createFromFormat(
"Ym", $rdate);
561 $endDate= intval(substr($enddate, 0, 6));
565 $month= intval($startDate->format(
"m"));
566 $year= intval($startDate->format(
"Y"));
567 $reportMonth= $month < 10 ? intval(
"{$year}0{$month}") : intval(
"{$year}{$month}");
568 if ($reportMonth > $endDate)
570 $data= getDataFromFile($reportMonth,
true);
572 foreach($data as $cuKey => $record)
574 $thisKey= trim(strtolower($cuKey));
575 if (!isset($realData[$cuKey]))
577 $realData[$thisKey]= $record;
582 foreach($record as $col)
585 $realData[$thisKey][$colIndex]+= $col;
590 $startDate->setDate($year, $month+1, 1);
593 printCSVFromData(array_values($realData), $link,
false);
598 $report_value =
"SELECT";
600 cu_header(
"Select Email Domain Result Files");
603 $print_msg =
"<tr><td colspan='2'>$retMsg</td></tr>";
606 <a href=
"$infourl/hcuadm/cuilist.prg" target=
"parent">Credit Union List</a><br />
607 <form name=
'domain_report' action=
"$self" method=
"post" enctype=
"multipart/form-data">
608 <input type=
"hidden" name=
"rv" value=
"$report_view">
609 <table cellpadding=
"3" cellspacing=
"0" border=
"0" width=
"300" class=
'dmsbg'><tr><td>
610 <table cellpadding=
"1" cellspacing=
"0" border=
"0" width=
"100%" bgcolor=
"white">
612 <td colspan=
"4" class=
"bar" align=
"center">
617 <td colspan=
"4" class=
"bar" align=
"center">
618 Upload Everyone.net Details File
622 <td nowrap align=
"right" class=
"hdr" valign=
'top'>
625 <td colspan=
"3" nowrap
class=
'dtl' valign=
'top'>
626 <input type=
'file' name=
'uplFileName' />
630 <td nowrap align=
"right" class=
"hdr" valign=
'top'>
633 <td colspan=
"3" nowrap
class=
'dtl' valign=
'top'>
634 <select name=
'uplMonth'>
635 <option value=
'01' {$month_select[
'Jan']}>Jan</option>
636 <option value=
'02' {$month_select[
'Feb']}>Feb</option>
637 <option value=
'03' {$month_select[
'Mar']}>Mar</option>
638 <option value=
'04' {$month_select[
'Apr']}>Apr</option>
639 <option value=
'05' {$month_select[
'May']}>May</option>
640 <option value=
'06' {$month_select[
'Jun']}>Jun</option>
641 <option value=
'07' {$month_select[
'Jul']}>Jul</option>
642 <option value=
'08' {$month_select[
'Aug']}>Aug</option>
643 <option value=
'09' {$month_select[
'Sep']}>Sep</option>
644 <option value=
'10' {$month_select[
'Oct']}>Oct</option>
645 <option value=
'11' {$month_select[
'Nov']}>Nov</option>
646 <option value=
'12' {$month_select[
'Dec']}>Dec</option>
648 <select name=
'uplYear'>
649 <option value=
'2014' {$year_select[
'2014']}>2014</option>
650 <option value=
'2015' {$year_select[
'2015']}>2015</option>
651 <option value=
'2016' {$year_select[
'2016']}>2016</option>
652 <option value=
'2017' {$year_select[
'2017']}>2017</option>
657 <td nowrap align=
"right" class=
"hdr" valign=
'top'>
660 <td colspan=
"3" nowrap
class=
'dtl' valign=
'top'>
661 <input type=
"submit" name=
"btnUpload" Value=
"Upload File">
666 <td colspan=
"4" class=
"bar" align=
"center">
671 <td nowrap align=
"right" class=
"hdr" valign=
'middle'>
674 <td nowrap
class=
'dtl' valign=
'top'>
675 <select size=6 name=
'selResults'>
678 foreach ($results_list as $value) {
680 $year = substr($value, 0, 4);
681 $mon = intval(substr($value, 4, 2));
682 $disp_value = $month[($mon - 1)] .
" " . $year;
683 print
"<option value='$value' " . ($cnt == 1 ?
"SELECTED" :
"") .
">$disp_value</option>\n";
688 <td nowrap align=
"right" class=
"hdr" valign=
'middle'>
691 <td nowrap
class=
'dtl' valign=
'top'>
692 <select size=6 name=
'selCompare'>
693 <option value=
'' SELECTED>None</option>
696 foreach ($results_list as $value) {
698 $year = substr($value, 0, 4);
699 $mon = intval(substr($value, 4, 2));
700 $disp_value = $month[($mon - 1)] .
" " . $year;
701 print
"<option value='$value'>$disp_value</option>\n";
708 <td
class=
'dtl'> </td>
709 <td colspan=
"3" nowrap
class=
'dtl'>
710 <input type=
"checkbox" name=
"chkShowZero" Value=
"1">Show Zero Values
714 <td
class=
'dtl'> </td>
715 <td colspan=
"3" nowrap
class=
'dtl'>
716 <input type=
"submit" name=
"btnCont" Value=
"View Report">
721 </form></body></html>
726 function getDataFromFile($reportMonth, $asMap=
false)
728 global $xrc_prefix, $results_dir;
731 $file1_domain = Array();
732 $result_file1 = $xrc_prefix . $reportMonth;
733 $rptShowZero =
false;
735 if (file_exists($results_dir . $result_file1))
737 $file1_results = file($results_dir . $result_file1);
738 foreach($file1_results as $key => $value)
740 $record= explode(
"\t", $value);
743 $file1_domain[trim(strtolower($record[0]))]= $record;
745 $file1_domain[] = $record;
749 if (count($file1_domain[0]) == 11)
751 for ( $idxAdjustRow = 0; $idxAdjustRow < count($file1_domain); $idxAdjustRow++)
754 $file1_domain[$idxAdjustRow][12] = $file1_domain[$idxAdjustRow][9];
755 $file1_domain[$idxAdjustRow][11] = $file1_domain[$idxAdjustRow][8];
756 $file1_domain[$idxAdjustRow][9] = $file1_domain[$idxAdjustRow][6];
758 $file1_domain[$idxAdjustRow][6] = 0;
759 $file1_domain[$idxAdjustRow][7] = 0;
760 $file1_domain[$idxAdjustRow][8] = 0;
764 return $file1_domain;
767 function printCSVFromData($file1_domain, $link, $showErrors)
770 $TTL_Client_Info = Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
773 $outString .=
"CU,Domain Name,TTL ACCT,REG,250M,1G,2G,100 3Yr,100 5Yr,100 7Yr,Cost,Prem,Total Bill\r\n";
776 foreach ($file1_domain as $key => $dom_value)
779 if (intval($dom_value[12]) > 0)
781 $TTL_Client_Info[0]++;
782 for ($idx=1; $idx <= 12; $idx++)
784 $TTL_Client_Info[$idx] += intval($dom_value[$idx]);
786 $cuCode = LookupCUCode( $link, $dom_value[0], $needsLookup );
788 if ($needsLookup && $showErrors)
790 $outString .=
"E,Error: Need Lookup for {$dom_value[0]},,,,,,,,,,,,\r\n";
793 $outString .=
"$cuCode,{$dom_value[0]},{$dom_value[1]},{$dom_value[2]},{$dom_value[3]}," .
794 "{$dom_value[4]},{$dom_value[5]},{$dom_value[6]},{$dom_value[7]},{$dom_value[8]}," .
795 "{$dom_value[9]},{$dom_value[11]},{$dom_value[12]}\r\n";
799 $outString .=
"T,Total Clients: $TTL_Clients Total Clients Reported: {$TTL_Client_Info[0]}," .
800 "{$TTL_Client_Info[1]},{$TTL_Client_Info[2]},{$TTL_Client_Info[3]},{$TTL_Client_Info[4]}," .
801 "{$TTL_Client_Info[5]},{$TTL_Client_Info[6]},{$TTL_Client_Info[7]},{$TTL_Client_Info[8]}," .
802 "{$TTL_Client_Info[9]},{$TTL_Client_Info[11]},{$TTL_Client_Info[12]}\r\n";
804 header(
"Content-length: " . strlen($outString) );
805 header(
"Content-type: application/octetstream" );
806 header(
"Content-disposition: inline; filename=\"download.csv\"" );
812 function ProcessFile($p_results_dir, $p_xrc_prefix, $p_upl_filename, $p_upl_month, $p_upl_year) {
816 $xrc_directory = $p_results_dir;
817 $xrc_prefix = $p_xrc_prefix;
819 $xrc_filename = $xrc_prefix . $p_upl_year . $p_upl_month;
821 if (is_dir($xrc_directory)) {
822 $rpt_fh = @fopen($xrc_directory . $xrc_filename,
"w");
826 return "PROBLEM OPENING FILE FOR REPORT! STOPPING";
830 $RemoveLogDate = date(
"Ym", mktime(0, 0, 0, date(
"m") - 15, date(
"d"), date(
"Y")));
831 if (is_dir($xrc_directory)) {
832 if ($dir_hndl = opendir($xrc_directory)) {
833 while (($file = readdir($dir_hndl)) !==
false) {
834 if (filetype($xrc_directory . $file) ==
"file" && (substr($file, 0, strlen($xrc_prefix)) == $xrc_prefix)) {
835 if (substr($file, strlen($xrc_prefix)) <= $RemoveLogDate) {
837 unlink($xrc_directory . $file);
847 $current_domain =
"";
849 $client_users = Array();
854 $mailsize_100_3yrArchive = 0;
855 $mailsize_100_5yrArchive = 0;
856 $mailsize_100_7yrArchive = 0;
858 if (($handle = fopen($_FILES[
'uplFileName'][
'tmp_name'],
"r")) !== FALSE) {
868 while (($data = fgetcsv($handle, 1000,
",")) !== FALSE) {
871 $row_domain = trim($data[0]);
872 $row_user = trim($data[1]);
873 $row_offer = trim($data[3]);
876 if (strpos($row_user,
"ALIAS ACCOUNT") ===
false && trim($data[2]) ==
'') {
879 if ($client_users[$row_domain][$row_user] !=
'') {
881 if (RetrieveOfferLevel($row_offer) > $client_users[$row_domain][$row_user]) {
883 $client_users[$row_domain][$row_user] = $row_offer;
887 $client_users[$row_domain][$row_user] = $row_offer;
896 foreach ($client_users as $current_domain => $domain_users) {
902 $mailsize_100_3yrArchive = 0;
903 $mailsize_100_5yrArchive = 0;
904 $mailsize_100_7yrArchive = 0;
908 foreach ($domain_users as $user_name => $user_offer) {
911 switch (trim($user_offer)) {
913 case "100MB Package (with AV+AS) + Stor 10MB + Arch 5d":
917 case "250MB Package (with AV+AS) + Stor 10MB + Arch 5d":
921 case "1000MB email + 500 MB storage + Arch 90d":
922 case "1000MB Package (with AV+AS) + Stor 10MB + Arch 5d":
926 case "2000MB Package (with AV+AS) + Stor 10MB + Arch 5d":
927 case "2GB Email + Stor 500MB + Arch 90d":
931 case "100MB Email + 10MB Stor + 3yr Arch":
932 $mailsize_100_3yrArchive++;
935 case "100MB Email + 10MB Stor + 5yr Arch":
936 $mailsize_100_5yrArchive++;
939 case "100MB Email + 10MB Stor + 7yr Arch":
940 $mailsize_100_7yrArchive++;
945 $domain_results[] = array($current_domain, $client_count, $mailsize_100, $mailsize_250, $mailsize_1000, $mailsize_2000, $mailsize_100_3yrArchive, $mailsize_100_5yrArchive, $mailsize_100_7yrArchive);
948 return "Unable to READ the file";
953 if (is_array($domain_results)) {
954 foreach ($domain_results as $dom_key=>$dom_value) {
959 $tr_class = ($tr_class ==
"odd_small" ?
"even_small" :
"odd_small");
961 $dom_accts = intval($dom_value[2]) + intval($dom_value[3]) + intval($dom_value[4]) + intval($dom_value[5]) + intval($dom_value[6]) + intval($dom_value[7]) + intval($dom_value[8]);
963 $dom_accts_prem = (intval($dom_value[3]) * 1) + (intval($dom_value[4]) * 2) + (intval($dom_value[5]) * 3) + (intval($dom_value[6]) * 3) + (intval($dom_value[7]) * 4) + (intval($dom_value[8]) * 5);
965 $dom_total_bill = intval($dom_accts) + intval($dom_accts_prem);
968 fwrite ($rpt_fh,
"{$dom_value[0]}\t{$dom_value[1]}\t{$dom_value[2]}\t{$dom_value[3]}\t{$dom_value[4]}\t{$dom_value[5]}\t{$dom_value[6]}\t{$dom_value[7]}\t{$dom_value[8]}\t{$dom_accts}\t{$dom_credit}\t{$dom_accts_prem}\t{$dom_total_bill}\t\n");
974 return "Report Uploaded for $p_upl_month $p_upl_year completed.";
978 function RetrieveOfferLevel($p_offer) {
984 switch ($row_offer) {
986 case "100MB Package (with AV+AS) + Stor 10MB + Arch 5d":
990 case "250MB Package (with AV+AS) + Stor 10MB + Arch 5d":
993 case "1000MB email + 500 MB storage + Arch 90d":
997 case "2000MB Package (with AV+AS) + Stor 10MB + Arch 5d":
1001 case "100MB Email + 10MB Stor + 3yr Arch":
1005 case "100MB Email + 10MB Stor + 5yr Arch":
1009 case "100MB Email + 10MB Stor + 7yr Arch":
1018 function LookupCUCode( $dbh, $domain, &$errorFlag ) {
1021 $parts = explode(
".", $domain );
1022 $searchDomain = $parts[0];
1024 $sql =
"SELECT cu_name FROM cubilldomainmap WHERE domain = '$domain'";
1026 $sth = db_query($sql, $dbh);
1030 $userList = array();
1031 while ( $userRow = db_fetch_assoc($sth, $iRow++) ) {
1032 $userList[] = trim($userRow[
"cu_name"]);
1035 if ( !count( $userList ) ) {
1037 $sql =
"SELECT user_name FROM cuinfo WHERE home_page_url like '%$searchDomain%'";
1038 $sth = db_query($sql, $dbh);
1042 $userList = array();
1043 while ( $userRow = db_fetch_assoc($sth, $iRow++) ) {
1044 $userList[] = trim($userRow[
"user_name"]);
1047 if ( count( $userList ) == 1 ) {
1049 $sql =
"INSERT INTO cubilldomainmap VALUES ( '$userList[0]', '$domain' )";
1050 $sth = db_query($sql, $dbh);
1056 if ( count( $userList ) > 1 ) {
1057 $retString = implode(
",", $userList );
1058 }
else if ( count( $userList ) > 0 ) {
1059 $retString = $userList[0];
1062 $retString =
"Not found";
1069 function GetCUCodeList( $dbh ) {
1070 global $SYS_TYPE_CLOSED;
1072 $sql =
"SELECT user_name, system_options FROM cuinfo ORDER BY user_name ";
1074 $sth = db_query($sql, $dbh);
1079 while ( $cuRow = db_fetch_assoc($sth, $iRow++) ) {
1080 if ( ($cuRow[
"system_options"] & $SYS_TYPE_CLOSED) == 0 ) {
1081 $cuList[] = trim($cuRow[
"user_name"]);