11 require_once (
"$admLibrary/ck_aticket.i");
18 return "main.prg?ft=86";
21 $string= array(
"filter" => FILTER_DEFAULT);
22 $parameters = array(
"a" => array());
23 HCU_ImportVars($parameters,
"a", array(
"action" => $string,
"period" => $string));
24 extract($parameters[
"a"]);
26 $action = isset($action) ? trim($action) :
"";
27 $period = isset($period) ? trim($period) :
"";
29 $ccname =
'CREDIT CARD';
30 if (preg_match(
"/^$ccname/",$period)) {
31 $saved_file =
"$home_path/tmp/{$chome}ccard.daz";
33 $saved_file =
"$home_path/tmp/{$chome}stmnt.daz";
38 if (!$period || $period ==
'Select') {
39 $msg =
"You must select a Statement Period.";
45 $fileArray = $_FILES[
"files"];
47 if (!is_uploaded_file($fileArray[
'tmp_name']) || ($fileArray[
'size'] < 1)) {
50 switch ($fileArray[
'error']) {
52 $up_err =
"0: No error, the file was uploaded successfully";
55 $up_err =
"1: The upload is larger than the amount allowable by the upload_max_filesize directive in the php.ini";
58 $up_err =
"2: The upload is larger than the MAX_FILE_SIZE directive that was specified via html";
61 $up_err =
"3: The file was only partially uploaded";
64 $up_err =
"4: no file was uploaded";
69 $up_fe = (!file_exists(
"{$fileArray['tmp_name']}") ?
"True" :
"False");
71 Upload File Error --\n 73 Client Filename: {$fileArray['name']}\n 74 Client Filesize: {$fileArray['size']}\n 75 Client Filetype: {$fileArray['type']}\n\n 76 Client IP: {$_SERVER['REMOTE_ADDR']}\n\n 77 Web Server Information \n 78 Temp File Name - {$fileArray['tmp_name']} 79 Temp File exist - $up_fe\n 80 Error Reported - $up_err\n\n 84 $notify->line = __LINE__;
85 $notify->file = __FILE__;
86 $notify->callingfunction = __FUNCTION__;
90 $notify->mailto =
"mark@homecu.net";
95 header(
'Content-type: text/plain');
96 print HCU_JsonEncode(array(
"error" => array(
"File could not be uploaded. Please retry.",
"If the problem persists call HomeCU and report the problem."),
"code" => 1));
99 $find_ary = array(
"\\",
"/",
" ",
";");
100 $rpl_ary = array(
"",
"",
"",
"");
102 $real_name = str_replace($find_ary, $rpl_ary, $fileArray[
'name']);
105 if (!move_uploaded_file($fileArray[
'tmp_name'], $saved_file)) {
106 unlink ($fileArray[
'tmp_name']);
109 $rc = @chmod($saved_file, 0644);
114 $sql =
"SELECT email FROM cuadmnotify 115 WHERE cu = '$Cu' AND role = 'esload'";
116 $em_rs = db_query($sql, $dbh);
117 list($esload) = db_fetch_array($em_rs, 0);
118 db_free_result($em_rs);
120 $sql =
"SELECT email FROM cuadminusers 121 WHERE cu = '$Cu' AND user_name = '$Cn' ";
122 $em_rs = db_query($sql, $dbh);
123 list($email) = db_fetch_array($em_rs, 0);
124 db_free_result($em_rs);
125 if (trim($email) !=
'') { $esload = no_dupes(
"$email;$esload"); }
126 putenv(
"ADMMAIL=$esload");
133 $scriptDir = GetScriptDir();
135 if (preg_match(
"/^$ccname/",$period)) {
136 $command =
"/usr/bin/nice -19 /usr/bin/env perl $scriptDir/ccardload.pl " . escapeshellcmd($home_path) .
" \"{$period}\" >/dev/null &";
138 $command =
"/usr/bin/nice -19 /usr/bin/env perl $scriptDir/stmntload.pl " . escapeshellcmd($home_path) .
" \"{$period}\" >/dev/null &";
141 $rc = exec ($command);
144 HCU_setcookie_env($SYSENV,
"LastStmtName", $fileArray[
'name'], time()+60*60*24*30);
147 header(
'Content-type: text/plain');
148 print HCU_JsonEncode(array(
"error" => array(),
"code" => 0,
"data" => array(
"name" => $fileArray[
"name"],
"size" => $fileArray[
"size"])));
155 # first, make sure the configuration file and the stmnt director exist 156 if (!(is_readable(
"$home_path/bin/stmntload.cfg")
157 && is_dir(
"$home_path/stmnt"))) {
159 PrintFirstUploaded();
162 $lastUploadedFile = HCU_array_key_value(
'LastStmtName', $_COOKIE);
163 $lastUploadedFile = $lastUploadedFile ? trim($lastUploadedFile) :
"";
165 $scriptDir = GetScriptDir();
166 $command =
"/usr/bin/nice -19 /usr/bin/env perl $scriptDir/stmntload_running_status.pl " . strtolower($Cu);
167 $commandRs = exec($command);
168 $commandStatusAry = explode(
"\t", $commandRs);
169 $commandStatus = trim($commandStatusAry[0]);
171 $lastUploadedStatus = 0;
172 switch ($commandStatus) {
175 $lastUploadedStatus = 1;
178 $lastUploadedStatus = 2;
183 $lastUploadedStatus = 0;
191 $cuLower = strtolower($Cu);
192 if (is_dir(
"$home_path/tmp") && file_exists(
"$home_path/tmp/{$cuLower}stmnt.daz")) {
193 $lastUploadedStatus = 2;
196 PrintSelectUpload($lastUploadedFile, $lastUploadedStatus, GetPeriodData($home_path));
208 function no_dupes($estring) {
210 foreach (explode(
";",$estring) as $x => $ema) {
212 if ($ema !=
"" && (strpos(
"$return",
"$ema") ===
false)) {
226 function return_bytes($val) {
228 $last = strtolower($val[strlen($val)-1]);
248 function GetPeriodData($home_path) {
249 $periodData = array();
250 $ccname = GetCCName();
252 $date =
new DateTime();
253 $thisyr = intval($date->format(
"Y"));
254 $thisday = intval($date->format(
"d"));
255 $thisMonthAbbrev = $date->format(
"M");
256 $thismo = intval($date->format(
"n")) - 1;
258 $date->modify(
"first day of last month");
259 $lastmo = intval($date->format(
"n")) - 1;
260 $lastMonthAbbrev = $date->format(
"M");
261 $lastyr = intval($date->format(
"Y"));
263 # Dec & after 24th, or Jan-May, or June & before 25th set 2nd half 264 if (($thismo == 11 && $thisday > 24) || $thismo < 5 || ($thismo == 5 && $thisday < 25)) {
266 $halfyr = ($thismo == 11 ? $thisyr : $thisyr - 1);
272 $periods = array(
"Select");
275 # if past mid month, show the current month 277 $periods[] =
"$thisMonthAbbrev $thisyr";
278 $carpers[] =
"$ccname $thisMonthAbbrev $thisyr";
281 $periods[] =
"$lastMonthAbbrev $lastyr";
282 $carpers[] =
"$ccname $lastMonthAbbrev $lastyr";
284 $quarter = intval($thismo / 3);
286 # if past mid month and current month ends a qtr, show the current quarter 288 if ($thisday > 15 && $thismo % 3 == 2) {
289 $periods[] =
"Quarter " . ($quarter + 1) .
" $thisyr";
290 $carpers[] =
"$ccname Quarter " . ($quarter + 1) .
" $thisyr";
295 $periods[] =
"Quarter 4 ". ($thisyr - 1);
296 $periods[] =
"Quarter 3 ". ($thisyr - 1);
297 $carpers[] =
"$ccname Quarter 4 ". ($thisyr - 1);
298 $carpers[] =
"$ccname Quarter 3 ". ($thisyr - 1);
301 $periods[] =
"Quarter 1 $thisyr";
302 $periods[] =
"Quarter 4 ". ($thisyr - 1);
303 $carpers[] =
"$ccname Quarter 1 $thisyr";
304 $carpers[] =
"$ccname Quarter 4 ". ($thisyr - 1);
307 $periods[] =
"Quarter $quarter $thisyr";
308 $periods[] =
"Quarter " . ($quarter - 1) .
" $thisyr";
309 $carpers[] =
"$ccname Quarter $quarter $thisyr";
310 $carpers[] =
"$ccname Quarter " . ($quarter - 1) .
" $thisyr";
313 $periods[] =
"$half Half $halfyr";
314 $carpers[] =
"$ccname $half Half $halfyr";
316 # and now append so all Credit Card options are at the end of the list but only show if the credit card config is done 317 if (is_readable(GetCCConfig($home_path))) {
318 $periods = array_merge($periods, $carpers);
332 function PrintSelectUpload($lastUploadedFile, $lastUploadedStatus, $periodData) { ?>
333 <script type=
"text/javascript">
334 <?php getShowWaitFunctions(); ?>
335 var maxSize = <?php echo return_bytes(ini_get(
"upload_max_filesize")); ?>;
345 function OpenConfirmDialog(fileData) {
346 var dialog = $(
"#confirmDialog").data(
"kendoDialog");
347 if (dialog ==
null) {
348 dialog = $(
"<div id='confirmDialog'></div>").appendTo(
"body").kendoDialog({
351 text:
"Okay", primary:
true,
358 title:
"File Successfully Uploaded" 359 }).data(
"kendoDialog");
362 var
template = kendo.template($(
"#confirmationTemplate").html());
363 dialog.content(
template(fileData)).open();
373 $.homecuValidator.setup({formValidate:
'statementUploadDiv', formStatusField:
'formValidateDiv'});
381 var uploader = $(
"#uploader").kendoUpload({
383 saveUrl:
"<?php echo GetSelf(); ?>&action=uploadFile",
384 withCredentials:
true,
392 var response = e.XMLHttpRequest.responseText;
393 $.homecuValidator.displayMessage(
"File upload failed.", $.homecuValidator.settings.statusError );
398 if (e.response.code != 0) {
399 $.homecuValidator.displayMessage(e.response.error, $.homecuValidator.settings.statusError );
403 OpenConfirmDialog(e.response.data);
407 select:
function(e) <?php
412 var file = e.files[0];
414 if (file.size > maxSize) {
415 throw "File exceeds the max size.";
421 if (error.length !=
"")
423 $.homecuValidator.displayMessage(error, $.homecuValidator.settings.statusError );
428 upload:
function(e) {
431 if (periodDDL.value() ==
null || periodDDL.value() ==
"Select") {
432 throw "Period must be selected.";
434 var file = e.files[0];
436 if (file.size > maxSize) {
437 throw "File exceeds the max size.";
443 if (error.length !=
"") {
444 $.homecuValidator.displayMessage(error, $.homecuValidator.settings.statusError );
448 e.data = {period: periodDDL.value()};
453 select:
"Select File" 455 }).data(
"kendoUpload");
463 var periodDDL = $(
"#periodDDL").kendoDropDownList({
465 data: <?php echo HCU_JsonEncode($periodData); ?>
468 }).data(
"kendoDropDownList");
476 $(
".clearBtn").click(
function() {
477 uploader.clearAllFiles();
478 periodDDL.value(
"Select");
479 $.homecuValidator.validate(); <?php
488 $(
".uploadBtn").click(
function() {
490 if (uploader.getFiles().length == 0) {
491 errors.push(
"File must be selected.");
493 if (periodDDL.value() ==
null || periodDDL.value() ==
"Select") {
494 errors.push(
"Period must be selected.");
497 if (errors.length > 0) {
498 $.homecuValidator.displayMessage(errors, $.homecuValidator.settings.statusError );
500 $.homecuValidator.validate();
506 $(document).ready(
function() {
511 #statementUploadDiv { 513 margin-right: initial;
514 margin-left: initial;
517 .k-clear-selected, .k-upload-selected, .k-upload-status {
518 display: none !important;
528 <script type=
"text/x-kendo-template" id=
"confirmationTemplate">
529 <div
class=
"container-fluid">
530 <div
class=
"row hcuSpacer">
531 <div
class=
"col-xs-12">
532 Thank you
for the upload.
535 <div
class=
"row hcuSpacer">
536 <div
class=
"col-xs-12">
537 The file <b>#: name #</b> with a size of <b>#: size #</b> bytes was successfully uploaded. It is now being processed.
540 <div
class=
"row hcuSpacer">
541 <div
class=
"col-xs-12">
542 An email status will be sent to the Credit Union.
545 <div
class=
"row hcuSpacer">
546 <div
class=
"col-xs-12">
547 If there are any errors, please
do not resend your file. Contact <b>HomeCU</b>
for support.
552 <div
class=
"container-fluid vsgPrimary hcu-template" id=
"statementUploadDiv">
554 <div
id=
"formValidateDiv" class=
"k-block k-error-colored formValidateDiv" style=
"display:none;"></div>
556 <div
class=
"row hcuSpacer">
557 <h3
class=
"col-xs-12">Statement File Upload</h3>
559 <div
class=
"well well-sm">
560 <?php
if ($lastUploadedFile !=
"") { ?>
561 <div
class=
"row hcuSpacer">
562 <label
class=
"col-xs-12 col-sm-3">Last File Uploaded</label>
563 <div
class=
"col-xs-12 col-sm-9">
564 <?php echo $lastUploadedFile; ?>
566 <?php
if ($lastUploadedStatus == 2) { ?>
567 <label> Processing...</label>
568 <?php }
else if ($lastUploadedStatus == 1) { ?>
569 <label style=
"color: red;"> Failed</label>
573 <?php
if ($lastUploadedStatus == 2) { ?>
574 <div
class=
"row hcuSpacer hcu-secondary">
575 <div
class=
"col-xs-12 vsgSecondary hcu-note">Refresh the page to view the current processing status</div>
580 <?php
if ($lastUploadedStatus < 2) { ?>
581 <div
class=
"row hcuSpacer">
582 <label
class=
"col-xs-12 col-sm-3">File Uploader</label>
583 <div
class=
"col-xs-12 col-sm-9">
584 <input type=
"file" name=
"files" id=
"uploader" />
587 <div
class=
"row hcuSpacer">
588 <label
class=
"col-xs-12 col-sm-3">
591 <div
class=
"col-xs-12 col-sm-9">
592 <div
id=
"periodDDL"></div>
597 <div
class=
"row hcu-secondary hcuSpacer">
598 <div
class=
"col-xs-12 vsgSecondary hcu-note">
599 The file you upload must include complete account numbers. If you have changed your settings to mask all or part of the account number,
600 your file will not load correctly and may result in presenting eStatement information to the WRONG member!
603 <?php
if ($lastUploadedStatus < 2) { ?>
604 <div
class=
"hcu-edit-buttons k-state-default tabFooter">
605 <a
class=
"clearBtn" href=
"#">Clear</a>
607 <a
class=
"uploadBtn k-button k-primary" href=
"#">Upload</a>
617 function PrintFirstUploaded() { ?>
618 <div
class=
"container-fluid vsgPrimary hcu-template" id=
"statementUploadDiv">
619 <div
class=
"row hcuSpacer">
620 <h3
class=
"col-xs-12">Statement File Upload</h3>
622 <div
class=
"row hcuSpacer">
623 <div
class=
"col-xs-12">It looks like
this is the first time you
've uploaded eStatements. The configuration files and directories could not be found.</div> 625 <div class="row hcuSpacer"> 626 <div class="col-xs-12">Please check with HomeCU first to get things set up right.</div>