15 function TX_list($dbh, &$HB_ENV, $Acctid=
"", $showZeroBalance =
false, $pUserIdOverride=0) {
22 $live = $HB_ENV[
'live'];
23 $Fmsg_tx = $HB_ENV[
'Fmsg_tx'];
25 $Fset = $HB_ENV[
'Fset'];
26 $Fset2 = $HB_ENV[
'Fset2'];
27 $Fset3 = $HB_ENV[
"Fset3"];
28 $MC= HCU_array_key_value(
'MC', $HB_ENV) ? $HB_ENV[
"MC"] :
new hcu_talk_base(
"en_US" );
35 if ($pUserIdOverride == 0) {
37 $Uid = intval($HB_ENV[
"Uid"]);
39 $userEmail = $HB_ENV[
'Ml'];
40 $userFplog = $HB_ENV[
'Fplog'];
43 $Uid = intval($pUserIdOverride);
47 $userInfo = GetUserInfo($dbh, $HB_ENV, $MC, Array(
"user_id" => $Uid,
"cu" => $Cu));
48 if ($userInfo[
'status'][
'code'] ===
'000') {
49 $userEmail = HCU_array_key_value(
'cuusers_email', $userInfo[
'data']);
50 $userFplog = HCU_array_key_value(
'cuusers_lastlogin', $userInfo[
'data']);
54 $errors[] =
"User Not Found";
62 $cuTz = GetCreditUnionTimezone($dbh, $Cu);
65 $validationKey = GetValidationKey();
70 $txncodes = Get_HaveTrans($dbh,$HB_ENV);
79 $pending = Get_ReqTotals($dbh,$HB_ENV);
84 'email' => $userEmail,
85 'lastlogin' => $userFplog
91 $dataResp = LoadUserData($HB_ENV, $Uid, $userData);
92 $requestDate = HCU_array_key_value(
"requestDate", $dataResp[
'data']);
93 $requestDesc = HCU_array_key_value(
"requestDesc", $dataResp[
'data']);
94 if ($dataResp[
'code'] ==
'999') {
96 $balances[
'status'][
'code'] =
'999';
97 $balances[
'status'][
'severity'] =
'ERROR';
98 $balances[
'status'][
'errors'][] =
'System Unavailable';
102 $HB_ENV[
'lastupdate'] = $requestDate;
105 if ($dataResp[
'code'] !=
'900') {
107 $HB_ENV[
'packetStatus'] = Array(
108 'status' => $dataResp[
'code'],
109 'asofdate' => $requestDate,
110 'reason' => $requestDesc
121 if ((($HB_ENV[
'Fset3'] & GetFlagsetValue(
'CU3_API_XAC')) && ($HB_ENV[
'Fmsg_tx'] & GetMsgTxValue(
'MSGTX_TMP_XAX_LD')) == 0)) {
135 if (($Fmsg_tx & GetMsgTxValue(
'MSGTX_TMP_XAX_LD')) == 0) {
138 $userData = Array(
"email" => $HB_ENV[
'Ml']);
140 $xaResp = LoadCrossAcctData($HB_ENV, $Uid, $userData);
142 if ($xaResp[
'code'] ==
'000') {
144 $nflag = $Fmsg_tx | GetMsgTxValue(
'MSGTX_TMP_XAC_RQ') + GetMsgTxValue(
'MSGTX_TMP_XAX_LD');
147 $nflag = $Fmsg_tx | GetMsgTxValue(
'MSGTX_TMP_XAC_RQ');
156 if (($Fmsg_tx & GetMsgTxValue(
'MSGTX_TMP_XAX_LD')) == 0) {
157 # Didn't get a packet -- set an error 158 $errors[]=
"System Unavailable";
159 if ($xreason !=
'') {
160 $HB_ENV[
'packetStatus'][
'reason'] = $xreason;
162 $HB_ENV[
'packetStatus'][
'reason'] =
'System Temporarily Down - Unable to contact core system.';
165 $txreturn[
'status'][
'Fmsg_tx']=$Fmsg_tx;
169 if (count($errors) > 0) {
171 $txreturn[
'status'][
'code']=
'999';
172 $txreturn[
'status'][
'severity']=
'ERROR';
173 $txreturn[
'status'][
'errors']=$errors;
180 $bal_oid_select =
"";
182 if (($Fset2 & GetFlagsetValue(
"CU2_SORTORDER6")) == GetFlagsetValue(
"CU2_SORTORDER6")) {
183 $bal_oid_select =
", ab.oid ";
184 $xa_oid_select =
", ca.oid ";
188 $sqltx =
"SELECT trim(ua.display_name) as display_name, trim(ab.description) as description, 189 trim(ab.micraccount), 190 trim(ab.accounttype) as accounttype, ua.certnumber, ab.deposittype, ab.amount, 191 ab.available, trim(ua.accountnumber) as accountnumber, ua.view_balances, 192 ua.int_deposit, ua.int_withdraw, ua.ext_deposit, ua.ext_withdraw, may_deposit, may_withdraw, 193 coalesce(ab.balance_stamp, ma.balance_stamp) as balance_stamp, ma.balance_attempt, 194 ma.restrictions, ua.display_order, btrim(ab.accounttype, 'DIS'), 'balance' as tablesrc, null as permaccount {$bal_oid_select} 195 FROM {$Cu}useraccounts ua 197 INNER JOIN {$Cu}accountbalance ab ON ab.accountnumber = ua.accountnumber 198 AND ab.accounttype = ua.accounttype 199 AND ab.certnumber = ua.certnumber 200 AND ab.deposittype IN ('Y','S','N') 202 INNER JOIN {$Cu}memberacct as ma ON ma.accountnumber = ua.accountnumber 203 WHERE ua.user_id = {$Uid} 204 AND ua.recordtype = 'D' 205 AND (ua.int_deposit = 't' OR ua.int_withdraw = 't')";
215 if (HCU_array_key_value(
"XA", $txncodes) && ($Fset3 & GetFlagsetValue(
"CU3_API_XAC"))) {
219 SELECT trim(ua.display_name) as display_name, trim(ca.description) as description, 220 null, trim(ca.accounttype) as accounttype, ua.certnumber, ca.deposittype, 0 as amount, 221 0 as available, trim(ca.tomember) as accountnumber, ua.view_balances, 222 ua.int_deposit, ua.int_withdraw, ua.ext_deposit, ua.ext_withdraw, true as may_deposit, false as may_withdraw, 223 NULL as balance_stamp, NULL as balance_attempt, 224 ma.restrictions as restrictions, ua.display_order, btrim(ca.accounttype, 'DIS'), 'cross' as tablesrc, ca.accountnumber as permaccount {$xa_oid_select} 225 FROM {$Cu}useraccounts ua 227 INNER JOIN {$Cu}crossaccounts as ca ON ua.accountnumber = ca.accountnumber 228 AND trim(ca.accounttype) || '#' || trim(ca.tomember) = ua.accounttype 229 AND ca.deposittype IN ('Y','S','N') 230 INNER JOIN {$Cu}memberacct as ma ON ma.accountnumber = ua.accountnumber 232 WHERE ua.user_id = {$Uid} 233 AND ua.recordtype = 'T' 234 AND ua.int_deposit = 't'";
238 if (($Fset & GetFlagsetValue(
"CU_SORTORDER4")) == GetFlagsetValue(
"CU_SORTORDER4")) {
241 $sqltx .=
" ORDER BY 20, 21, 9, 4;";
242 } elseif (($Fset2 & GetFlagsetValue(
"CU2_SORTORDER6")) == GetFlagsetValue(
"CU2_SORTORDER6")) {
243 $sqltx .=
" order by 20, 22, 24";
247 $sqltx .=
" ORDER BY 20, 4, 5, 9";
250 $sthtx = db_query($sqltx,$dbh);
254 for ($trow=0; list($display,$desc,$micra,$type,$certnumber,$deposittype, $balance,$available, $acct,$view_b,$int_d,$int_w, $ext_d, $ext_w, $may_d, $may_w, $acct_balance_stamp,
255 $acct_balance_attempt, $restrictions, $dispOrder, $acctDIS, $tableSrc, $permAccount) = db_fetch_array($sthtx,$trow); $trow++) {
257 if ( !($txncodes[
"AT"] || $txncodes[
"XA"]) )
continue;
260 if ( $restrictions ==
"L" || $restrictions ==
"R" )
continue;
262 $acctGroup = $MC->msg(
"Deposit Accounts", HCU_DISPLAY_AS_RAW);
267 $addToXAList =
false;
269 if ($tableSrc ==
'cross') {
276 $permAccount = trim($permAccount);
294 $listAryKey =
"D|$jacct|$jtype|$certnumber";
295 if (HCU_array_key_exists($listAryKey, $txlist)) {
296 $addToTxList =
false;
300 if (strpos($type,
"@")) {
301 list($jtype,$jacct) = explode(
"@",$type);
308 $permAccount = $acct;
310 $tokn = sha1(
"{$jacct}{$jtype}D{$Cu}{$validationKey}");
313 $pend = sprintf(
"%.2f", HCU_array_key_value(
"D|$jacct|$jtype|$certnumber", $pending));
315 $available = sprintf(
"%.2f", ($available + $pend));
317 $balanceAmt = sprintf(
"%.2f", $balance);
318 $toFlag = ($int_d ==
"t" || $ext_d ==
"t") && $may_d ==
"t" ?
"Y" :
"N";
319 $fromFlag = ($int_w ==
"t" || $ext_w ==
"t") && $may_w ==
"t" ? ($available > 0 || $showZeroBalance ?
"Y" :
"N") :
"N";
321 $txlistRecord = array();
323 $txlistRecord[
'suffix'] = $type;
325 $txlistRecord[
'micraccount'] = $micra;
327 $txlistRecord[
'acctclass'] =
"D";
328 $txlistRecord[
'description'] = getAccountDescription($dbh, $HB_ENV[
"Cu"], $acct, $desc, $type, $display, $Fset3);
329 $txlistRecord[
'unitokn'] = $tokn;
330 $txlistRecord[
'deposittype'] = $deposittype;
331 if ($view_b ==
"t") {
332 $txlistRecord[
'available'] = $available;
333 $txlistRecord[
'balance'] = $balanceAmt;
334 $txlistRecord[
'pending'] = $pend;
336 $txlistRecord[
'available'] = 0;
337 $txlistRecord[
'balance'] = 0;
338 $txlistRecord[
'pending'] = 0;
340 $txlistRecord[
'from'] = $fromFlag;
341 $txlistRecord[
'from_int'] = ($int_w ==
"t" ?
"Y" :
"N");
342 $txlistRecord[
'from_ext'] = ($ext_w ==
"t" ?
"Y" :
"N");
343 $txlistRecord[
'to'] = $toFlag;
344 $txlistRecord[
'to_int'] = ($int_d ==
"t" ?
"Y" :
"N");
345 $txlistRecord[
'to_ext'] = ($ext_d ==
"t" ?
"Y" :
"N");
346 $txlistRecord[
'trust'] = $trust;
347 $txlistRecord[
'view_balances'] = ($view_b ==
"t" ?
"Y" :
"N");
350 $txlistRecord[
'member'] = $permAccount;
353 $txlistRecord[
'tomember'] =
'-1';
356 $txlistRecord[
'item-group'] =
"1 - $acctGroup";
359 $txlistRecord[
'as_of_date'] = GetDateFormatTimezone($acct_balance_stamp,
'm/d/Y h:i A', $cuTz);
360 $txlistRecord[
'out_of_sync'] = ($acct_balance_stamp < $acct_balance_attempt);
363 $txlistRecord[
'as_of_date'] =
"";
364 $txlistRecord[
'out_of_sync'] =
false;
369 $txlist[
"D|$jacct|$jtype|$certnumber"] = $txlistRecord;
373 if (!HCU_array_key_exists($permAccount, $xalist)) {
374 $xalist[$permAccount] = array();
376 $xalist[$permAccount][
"D|$jacct|$jtype|$certnumber"] = $txlistRecord;
395 if ($Cu ==
'FIRSTAM') {
396 $customWhere =
" AND substring(lb.loannumber, 1, 5) <> 'CRCD:' ";
398 $sqltx =
"SELECT trim(description) as description, trim(ua.display_name) as display_name, 399 trim(loannumber) as loannumber, trim(ua.accountnumber) as accountnumber, 400 int_deposit, int_withdraw, ext_deposit, ext_withdraw, view_balances, 401 currentbalance, paymentamount, creditlimit, 402 cbtype, misc1, payoff, may_addon, may_payment, 403 interestrate, unpaidinterest, 404 date_part('day',(now()-lastpaymentdate)) as unpaiddays, 405 coalesce(lb.balance_stamp, ma.balance_stamp) as balance_stamp, ma.balance_attempt, 406 ma.restrictions, ua.display_order, btrim(loannumber,'LC'), 407 'balance' as tablesrc, null as permaccount 408 FROM {$Cu}useraccounts ua 409 INNER JOIN {$Cu}loanbalance lb on lb.accountnumber = ua.accountnumber 410 and lb.loannumber = ua.accounttype 411 and (cbtype is null or cbtype <> 'X') 412 INNER JOIN {$Cu}memberacct as ma ON ma.accountnumber = ua.accountnumber 414 WHERE ua.user_id = {$Uid} 415 AND ua.recordtype = 'L' 417 AND (ua.int_deposit = 't' OR ua.int_withdraw = 't') 425 if (HCU_array_key_value(
"XP", $txncodes) && ($Fset3 & GetFlagsetValue(
"CU3_API_XAC"))) {
429 SELECT trim(ca.description) as description, trim(ua.display_name) as display_name, 430 trim(ca.accounttype) as loannumber, trim(ca.tomember) as accountnumber, 431 ua.int_deposit, ua.int_withdraw, ua.ext_deposit, ua.ext_withdraw, ua.view_balances, 432 0 as currentbalance, 0 as paymentamount, 0 as creditlimit, 433 '' as cbtype, ca.misc1 as misc1, 0 as payoff, false as may_addon, true as may_payment, 434 0 as interestrate, 0 as unpaidinterest, 436 0 as balance_stamp, 0 as balance_attempt, 437 ma.restrictions as restrictions, ua.display_order, btrim(ca.accounttype,'LC'), 438 'cross' as tablesrc, ca.accountnumber as permaccount 439 FROM {$Cu}useraccounts ua 441 INNER JOIN {$Cu}crossaccounts as ca ON ua.accountnumber = ca.accountnumber 442 AND trim(ca.accounttype) || '#' || trim(ca.tomember) = ua.accounttype 443 AND ca.deposittype IN ('L') 444 INNER JOIN {$Cu}memberacct as ma ON ma.accountnumber = ua.accountnumber 447 WHERE ua.user_id = {$Uid} 448 AND ua.recordtype = 'P' 449 AND ua.int_deposit = 't' 453 if ($Fset & GetFlagsetValue(
'CU_LNSORT2')) {
455 $loanOrderBy =
" ORDER BY 24, 25, 4";
458 $loanOrderBy =
" ORDER BY 24, 3, 4";
461 $sqltx .= $loanOrderBy;
463 $sthtx = db_query($sqltx,$dbh);
471 for ($row=0; $lnrow=db_fetch_array($sthtx,$row); $row++) {
473 if ( $lnrow[
"restrictions"] ==
"L" || $lnrow[
"restrictions"] ==
"R" )
continue;
476 $loanAcctNbr = trim($lnrow[
'accountnumber']);
477 $permacct = $loanAcctNbr;
479 if ( $lnrow[
"cbtype"] ==
"18" && ($Fset2 & GetFlagsetValue(
"CU2_SPEC18")) == GetFlagsetValue(
"CU2_SPEC18") ) {
481 $acctGroup =
"3 - " . $MC->msg(
"Credit Card Accounts", HCU_DISPLAY_AS_RAW);
484 $acctGroup =
"2 - " . $MC->msg(
"Loan Accounts", HCU_DISPLAY_AS_RAW);
488 if ( $cctype ==
"C" && !isset($txncodes[
"CC"]) && !isset($txncodes[
"CE"]) ) {
495 $addToXAList =
false;
497 $type = $lnrow[
'loannumber'];
499 $balance = $lnrow[
"view_balances"] ==
't' ? $lnrow[
'currentbalance'] : 0.00;
500 $payment = $lnrow[
'paymentamount'];
501 $creditlimit = sprintf(
"%.2f", $lnrow[
'creditlimit']);
502 $available = $lnrow[
"view_balances"] ==
't' ? ($creditlimit - $balance) : 0.00;
503 $available = sprintf(
"%.2f", ($available < 0 ? 0 : $available));
506 $cbtype = $lnrow[
'cbtype'];
508 $misc1 = $lnrow[
'misc1'];
509 $payoff = $lnrow[
'payoff'];
511 $rate = $lnrow[
'interestrate'];
512 $rate = (empty($rate) ? 0 : $rate);
513 $unpaid = $lnrow[
'unpaidinterest'];
514 $unpaid = (empty($unpaid) ? 0 : $unpaid);
515 $days = intval($lnrow[
'unpaiddays']);
516 $days = ($days < 0 ? 0 : $days);
519 $payoff = (((($rate / 100) * $balance) / 365) * $days) + $unpaid + $balance;
522 if(empty($payoff) || $payoff == 0) {
525 $payoff = sprintf(
"%.2f", $payoff);
528 $misc1 = (
"$misc1" ==
'' ?
'-' : $misc1);
529 if ($lnrow[
'tablesrc'] ==
'cross') {
535 $jacct = $loanAcctNbr;
536 $permacct = $lnrow[
"permaccount"];
555 $listAryKey =
"$cctype|$jacct|$jtype";
557 if ( $cctype ===
"C" ) {
558 if (HCU_array_key_exists($listAryKey, $ccList)) {
559 $addToTxList =
false;
563 if (HCU_array_key_exists($listAryKey, $loanList)) {
564 $addToTxList =
false;
569 if (strpos($type,
"@")) {
570 list($jtype,$jacct) = explode(
"@",$type);
575 $jacct = $loanAcctNbr;
576 $jacct = $lnrow[
'accountnumber'];
580 $pend = sprintf(
"%.2f", HCU_array_key_value(
"L|$jacct|$jtype", $pending));
584 if ( ($lnrow[
"int_withdraw"] ==
't' || $lnrow[
"ext_withdraw"] ==
't') &&
585 $lnrow[
"may_addon"] ==
't' &&
586 ((HCU_array_key_value(
'LA', $txncodes) && $cctype ==
"L") || (HCU_array_key_value(
'CA', $txncodes) && $cctype ==
"C")) ) {
588 $from = ($available > 0 || $showZeroBalance ?
"Y" :
"N");
591 if ( ($lnrow[
"int_deposit"] ==
't' || $lnrow[
"ext_deposit"] ==
't') &&
592 ($lnrow[
"may_payment"] ==
't' && HCU_array_key_value(
'LP', $txncodes)) ) {
593 if ( ($cctype ==
"C" &&
594 ($Fset2 & GetFlagsetValue(
"CU2_CC18SHOWZERO")) != GetFlagsetValue(
"CU2_CC18SHOWZERO") &&
598 || ($cctype ==
"L" && $balance == 0 && $lnrow[
"tablesrc"] !==
"cross")) {
606 $indexString =
"$cctype|$jacct|$jtype";
608 $tokn=sha1(
"{$jacct}{$jtype}L{$Cu}{$validationKey}");
609 $dataHolder = array();
611 $dataHolder[
'suffix'] = $type;
612 $dataHolder[
'micra'] = $micra;
613 $dataHolder[
'acctclass'] = $cctype;
614 $dataHolder[
'description'] = getAccountDescription($dbh, $HB_ENV[
"Cu"], $loanAcctNbr, $lnrow[
'description'], $type, $lnrow[
'display_name'], $Fset3);
615 $dataHolder[
'unitokn'] = $tokn;
616 $dataHolder[
'available'] = $available;
617 $dataHolder[
'pending'] = $pend;
618 $dataHolder[
'from'] = $from;
619 $dataHolder[
'from_int'] = ($lnrow[
"int_withdraw"] ==
"t" ?
"Y" :
"N");
620 $dataHolder[
'from_ext'] = ($lnrow[
"ext_withdraw"] ==
"t" ?
"Y" :
"N");
622 $dataHolder[
'to'] = $to;
625 $dataHolder[
'to_int'] = ($to ==
"Y" ? ($lnrow[
"int_deposit"] ==
"t" ?
"Y" :
"N") :
"N");
626 $dataHolder[
'to_ext'] = ($to ==
"Y" ? ($lnrow[
"ext_deposit"] ==
"t" ?
"Y" :
"N") :
"N");
628 $dataHolder[
'misc1'] = $misc1;
629 $dataHolder[
'trust'] = $trust;
630 $dataHolder[
'view_balances'] = ($lnrow[
"view_balances"] ==
"t" ?
"Y" :
"N");
631 $permacct = trim($permacct);
632 $dataHolder[
'member'] = $permacct;
635 $dataHolder[
'tomember'] =
'-1';
638 $dataHolder[
'item-group'] = $acctGroup;
641 $dataHolder[
'as_of_date'] = GetDateFormatTimezone($lnrow[
'balance_stamp'],
'm/d/Y h:i A', $cuTz);
642 $dataHolder[
'out_of_sync'] = ($lnrow[
'balance_stamp'] < $lnrow[
'balance_attempt']);
644 $dataHolder[
'as_of_date'] =
"";
645 $dataHolder[
'out_of_sync'] =
false;
650 if ( $cctype ==
"L" || ($cctype ==
"C" && ( $txncodes[
"CC"] || $txncodes[
"CE"] ) ) ) {
651 $dataHolder[
'payoff'] = $payoff;
652 $dataHolder[
'paymentdue'] = $payment;
653 $dataHolder[
'balance'] = sprintf(
"%.2f", $balance);
657 if ( $cctype ===
"C" ) {
658 $ccList[$indexString] = $dataHolder;
660 $loanList[$indexString] = $dataHolder;
666 if (!HCU_array_key_exists($permacct, $xalist)) {
667 $xalist[$permacct] = array();
669 $xalist[$permacct][$indexString] = $dataHolder;
675 $txlist = array_merge( $txlist, $loanList, $ccList );
683 foreach ($txncodes as $tcode => $value) {
685 $dataHolder = array();
686 $indexString =
"O|$Uid|$tcode";
687 $acctGroup = $MC->msg(
"Misc. Transfers", HCU_DISPLAY_AS_RAW);
692 if (in_array($value[1], Array(1, 2))) {
699 $desc = ($value[2] >
'' ? $value[2] : $value[0] );
700 $desc = htmlspecialchars($desc, ENT_QUOTES);
702 $tokn = sha1(
"{$Uid}{$tcode}O{$Cu}{$validationKey}");
705 $dataHolder[
'suffix'] =
"$tcode";
706 $dataHolder[
'micra'] =
"$micra";
707 $dataHolder[
'acctclass'] =
"O";
708 $dataHolder[
'description'] =
"$desc";
709 $dataHolder[
'unitokn'] =
"$tokn";
712 $dataHolder[
'to'] =
"Y";
713 $dataHolder[
'to_int'] =
"Y";
714 $dataHolder[
'to_ext'] =
"N";
715 $dataHolder[
'from'] =
"N";
716 $dataHolder[
'from_int'] =
"N";
717 $dataHolder[
'from_ext'] =
"N";
718 $dataHolder[
'view_balances'] =
"N";
721 $dataHolder[
'trust'] =
"primary";
722 $dataHolder[
'member'] = $othIdKey;
725 $dataHolder[
'tomember'] =
'-1';
726 $dataHolder[
'as_of_date'] =
"";
727 $dataHolder[
'out_of_sync'] =
false;
729 $dataHolder[
'item-group'] =
"4 - $acctGroup";
732 $othList[$indexString] = $dataHolder;
736 $txlist = array_merge($txlist, $othList);
744 $extAcctList = Get_ExternalAccounts( $dbh, $HB_ENV );
746 $acctGroup = $MC->msg(
"EXT External Accounts", HCU_DISPLAY_AS_RAW);
749 for ( $i = 0; $i < count( $extAcctList ); $i++ ) {
751 $dataHolder = Array();
753 $tokn = sha1(
"{$Uid}{$extAcctList[$i]["id"]}X{$Cu}{$validationKey}");
754 $desc = $extAcctList[$i][
"display_name"];
755 $desc = htmlspecialchars( $desc,ENT_QUOTES );
758 $available = $extAcctList[$i][
"max_amount"];
760 $indexString =
"X|{$Uid}|{$extAcctList[$i]["id"]}";
762 $dataHolder[
'acctclass'] =
"X";
763 $dataHolder[
'suffix'] =
"";
764 $dataHolder[
'micra'] = $micra;
765 $dataHolder[
'description'] = $desc;
766 $dataHolder[
'unitokn'] = $tokn;
767 $dataHolder[
'available'] = $available;
770 $dataHolder[
'to'] =
"Y";
771 $dataHolder[
'to_int'] =
"N";
772 $dataHolder[
'to_ext'] =
"Y";
773 $dataHolder[
'from'] =
"Y";
774 $dataHolder[
'from_int'] =
"N";
775 $dataHolder[
'from_ext'] =
"Y";
776 $dataHolder[
'trust'] =
"transfer";
777 $dataHolder[
'view_balances'] =
"N";
778 $dataHolder[
'member'] = $extIdKey;
779 $dataHolder[
'as_of_date'] =
"";
780 $dataHolder[
'out_of_sync'] =
false;
782 $dataHolder[
'item-group'] =
"5 - $acctGroup";
784 $extList[$indexString] = $dataHolder;
787 $txlist = array_merge( $txlist, $extList );
796 $acctList = Get_M2MAccounts( $dbh, $HB_ENV );
798 $acctGroup = $MC->msg(
"Other Member Accounts", HCU_DISPLAY_AS_RAW);
801 for ( $i = 0; $i < count( $acctList ); $i++ ) {
802 $dataHolder = Array();
804 $tokn = sha1(
"{$Uid}{$acctList[$i]["id"]}X{$Cu}{$validationKey}");
806 $desc = $acctList[$i][
"display_name"];
807 $desc = htmlspecialchars( $desc,ENT_QUOTES );
810 $available = sprintf(
"%.2f", $acctList[$i][
"max_amount"]);
812 $indexString =
"M|{$Uid}|{$acctList[$i]["id"]}";
814 $dataHolder[
'acctclass'] =
"M";
815 $dataHolder[
'suffix'] =
"";
816 $dataHolder[
'micra'] = $micra;
817 $dataHolder[
'description'] = $desc;
818 $dataHolder[
'unitokn'] = $tokn;
819 $dataHolder[
'available'] = $available;
820 $dataHolder[
'to'] =
"Y";
821 $dataHolder[
'to_int'] =
"Y";
822 $dataHolder[
'to_ext'] =
"N";
824 $dataHolder[
'from'] =
"N";
825 $dataHolder[
'from_int'] =
"N";
826 $dataHolder[
'from_ext'] =
"N";
827 $dataHolder[
'trust'] =
"transfer";
828 $dataHolder[
'view_balances'] =
"N";
830 $dataHolder[
'member'] = $extIdKey;
831 $dataHolder[
'as_of_date'] =
"";
832 $dataHolder[
'out_of_sync'] =
false;
834 $dataHolder[
'item-group'] =
"6 - $acctGroup";
836 $m2mList[$indexString] = $dataHolder;
839 $txlist = array_merge( $txlist, $m2mList );
841 if (!empty($Acctid)) {
842 # got an account identifier - return one only 844 $txreturn[
'acctlist'] = $txlist[$Acctid];
846 $txreturn[
'acctlist'] = $txlist;
850 $txreturn[
"xacctlist"] = $xalist;
852 $txreturn[
'status'][
'code']=
'0';
853 $txreturn[
'status'][
'severity']=
'INFO';
859 function Get_HaveTrans($dbh,$HB_ENV) {
860 # returns list of transaction types the cu supports 862 # fetch transactions types 864 $sqltx=
"select ht.trancode as txncode, 865 trim(t.trandesc) as txndesc, 866 t.specialproc as txnspec, 867 trim(ht.cudesc) as txncudesc 868 from cutrans t, cuhavetrans ht 870 and ht.trancode = t.trancode";
872 $txsth = db_query($sqltx,$dbh);
875 list($code, $desc, $spec, $cudesc) = db_fetch_array($txsth,$trow);
877 $txncodes[$code] =array($desc,$spec,$cudesc);
879 db_free_result($txsth);
881 # if type 18 loans are to be passed as CP transaction, make sure we have a 882 # description for that transaction code. 884 if ( HCU_array_key_exists(
"CC" , $txncodes) && !HCU_array_key_exists(
"CP" , $txncodes) ) {
885 $txncodes[
"CP"] =array(
'Credit Card Payment',0,
'');
890 function Get_ReqTotals($dbh,$HB_ENV) {
891 # returns array of BATCH pending transaction totals by dp account/loan 897 # consider any pending txns originated by this member 898 # or originated from this account by a joint owner. 899 # Do NOT consider the "to" portion for joint or cross, just the "from" 906 SELECT DISTINCT ON (ur.accountnumber) ur.accountnumber 907 FROM {$Cu}useraccounts ur 908 WHERE ur.user_id=$Uid";
909 $sth = db_query($sql, $dbh);
914 for ($row = 0; list($acct) = db_fetch_array($sth,$row); $row++) {
915 $sqlAcct = trim($acct);
917 SELECT TRIM(tr.accountnumber), TRIM(tr.transactioncode), TRIM(tr.reference1), TRIM(tr.memberto), TRIM(tr.reference2), tr.amount 918 FROM {$Cu}transaction tr 919 WHERE (tr.accountnumber = '{$sqlAcct}' OR TRIM(tr.reference1) LIKE '%@{$sqlAcct}') 922 FROM {$Cu}transaction 923 WHERE accountnumber='CHECKPOINT' 924 AND reference1='PHASE II' 927 $sth = db_query($sql,$dbh);
929 for ($row=0; list($memfrom,$tc,$ftype,$memto,$ttype,$amount) = db_fetch_array($sth,$row); $row++) {
931 if (strpos($ftype,
"@")) {
932 list($smplfacct,$smplfmem) = explode(
"@",$ftype);
933 $smplfmem = trim($smplfmem);
935 $smplfacct = trim($ftype);
936 $smplfmem = $memfrom;
938 if (strpos($ttype,
"@")) {
939 list($smpltacct,$smpltmem) = explode(
"@",$ttype);
940 $smpltmem = trim($smpltmem);
942 $smpltacct = trim($ttype);
943 $smpltmem = (
"$memto" ==
"" ? $memfrom : $memto);
946 $depositKeyF =
"D|$smplfmem|$smplfacct|0";
947 $depositKeyT =
"D|$smpltmem|$smpltacct|0";
948 $loanKeyT =
"L|$smpltmem|$smpltacct";
949 $loanKeyF =
"L|$smplfmem|$smplfacct";
951 !HCU_array_key_exists($depositKeyF, $pending) ? $pending[$depositKeyF] = 0 :
null;
952 $pending[$depositKeyF] -= $amount;
954 !HCU_array_key_exists($depositKeyT, $pending) ? $pending[$depositKeyT] = 0 :
null;
955 $pending[$depositKeyT] += $amount;
958 } elseif ($tc ==
'LA') {
960 !HCU_array_key_exists($loanKeyF, $pending) ? $pending[$loanKeyF] = 0 :
null;
961 $pending[$loanKeyF] -= $amount;
963 !HCU_array_key_exists($depositKeyT, $pending) ? $pending[$depositKeyT] = 0 :
null;
964 $pending[$depositKeyT] += $amount;
965 } elseif ($tc ==
'LP') {
966 !HCU_array_key_exists($loanKeyT, $pending) ? $pending[$loanKeyT] = 0 :
null;
967 $pending[$loanKeyT] += $amount;
974 function Get_ReqDetails($dbh,$HB_ENV,$Acctid=
"") {
975 # returns array of BATCH pending requested transactions by dp account/loan 978 $live=$HB_ENV[
'live'];
983 $txreturn[
'status'][
'code']=
'100';
984 $txreturn[
'status'][
'severity']=
'INFO';
985 $txreturn[
'status'][
'message']=
'Feature Not Activated';
988 $txncodes=Get_HaveTrans($dbh,$HB_ENV);
990 # override the default descriptions for AT, CW and LC transaction types 992 if ( HCU_array_key_exists(
"AT" , $txncodes) ) $txncodes[
'AT'][0]=
'Transfer';
993 if ( HCU_array_key_exists(
"CW" , $txncodes) ) $txncodes[
'CW'][0]=
'Check Withdrawal';
994 if ( HCU_array_key_exists(
"LC" , $txncodes) ) $txncodes[
'LC'][0]=
'Check Withdrawal from Loan Add-on';
996 # ea txncode is an array of desc, spec, cudesc where 997 # spec is the special processing flag and cudesc is the override description 998 # check ea entry and override description if special processing is set 1000 foreach ($txncodes as $tcode => $value) {
1001 if ($value[1] == 1) {
1002 $desc=($value[2] >
'' ? $value[2] : $value[0] );
1003 $txncodes[$tcode][0]=$desc;
1008 $tbl = substr( $Acctid, 0, 1 );
1009 if ( $tbl ==
'D' ) {
1010 list( $gettbl, $getacct, $gettype, $getcert) = explode(
"|", $Acctid );
1011 } elseif ( $tbl ==
'L' || $tbl ==
'C' ) {
1012 list( $gettbl, $getacct, $gettype) = explode(
"|",$Acctid );
1019 # consider any pending txns originated by this member 1020 # or originated from this account by a joint owner. 1021 # Do NOT consider the "to" portion for joint or cross, just the "from" 1024 $sql =
"select tr.id as id, 1025 trim(tr.accountnumber) as memfrom, 1026 trim(tr.reference1) as ftype, 1027 trim(f.description) as fdesc, 1028 trim(tr.reference2) as ttype, 1029 trim(t.description) as tdesc, 1030 tr.transactioncode as tc, 1031 tr.amount as amount, 1032 trim(tr.memberto) as memberto, 1033 to_char(tr.date,'YYYY-MM-DD') as date 1034 from {$Cu}transaction tr, 1035 {$Cu}accountbalance f, 1036 {$Cu}accountbalance t, 1038 where id > ALL (select MAX(id) 1039 from {$Cu}transaction tr2 1040 where tr2.accountnumber='CHECKPOINT' 1041 and reference1='PHASE II') 1042 and tr.accountnumber='$getacct' 1043 and tr.accountnumber = f.accountnumber 1044 and tr.reference1=f.accounttype 1045 and (tr.memberto = t.accountnumber or 1046 (tr.memberto is null and tr.accountnumber = t.accountnumber)) 1047 and tr.reference2=t.accounttype 1048 AND ma.accountnumber = tr.accountnumber 1049 AND coalesce(ma.restrictions, '') != 'L' 1050 and upper(f.deposittype) in ('Y','N','S') 1051 and upper(t.deposittype) in ('Y','N','S') 1052 and tr.transactioncode in ('AT') 1055 trim(tr.accountnumber) as memfrom, 1056 trim(tr.reference1) as ftype, 1057 trim(f.description) as fdesc, 1058 trim(tr.reference2) as ttype, 1059 trim(t.description) as tdesc, 1060 tr.transactioncode as tc, 1061 tr.amount as amount, 1062 trim(tr.memberto) as memberto, 1063 to_char(tr.date,'YYYY-MM-DD') as date 1064 from {$Cu}transaction tr, 1065 {$Cu}accountbalance f, 1068 where id > ALL (select MAX(id) 1069 from {$Cu}transaction tr2 1070 where tr2.accountnumber='CHECKPOINT' 1071 and reference1='PHASE II') 1072 and tr.accountnumber='$getacct' 1073 and tr.accountnumber = f.accountnumber 1074 and tr.reference1=f.accounttype 1075 and (tr.memberto = t.accountnumber or 1076 (tr.memberto is null and tr.accountnumber = t.accountnumber)) 1077 and tr.reference2=t.loannumber 1078 AND ma.accountnumber = tr.accountnumber 1079 AND coalesce(ma.restrictions, '') != 'L' 1080 and upper(f.deposittype) in ('Y','N','S') 1081 and tr.transactioncode in ('LP') 1084 trim(tr.accountnumber) as memfrom, 1085 trim(tr.reference1) as ftype, 1086 trim(f.description) as fdesc, 1087 trim(tr.reference2) as ttype, 1088 trim(t.description) as tdesc, 1089 tr.transactioncode as tc, 1090 tr.amount as amount, 1091 trim(tr.memberto) as memberto, 1092 to_char(tr.date,'YYYY-MM-DD') as date 1093 from {$Cu}transaction tr, 1095 {$Cu}accountbalance t, 1097 where id > ALL (select MAX(id) 1098 from {$Cu}transaction tr2 1099 where tr2.accountnumber='CHECKPOINT' 1100 and reference1='PHASE II') 1101 and tr.accountnumber='$getacct' 1102 and tr.accountnumber=f.accountnumber 1103 and tr.reference1=f.loannumber 1104 and (tr.memberto = t.accountnumber or 1105 (tr.memberto is null and tr.accountnumber = t.accountnumber)) 1106 and tr.reference2=t.accounttype 1107 AND ma.accountnumber = tr.accountnumber 1108 AND coalesce(ma.restrictions, '') != 'L' 1109 and upper(t.deposittype) in ('Y','N','S') 1110 and tr.transactioncode in ('LA') 1113 trim(tr.accountnumber) as memfrom, 1114 trim(tr.reference1) as ftype, 1115 trim(f.description) as fdesc, 1116 trim(tr.reference2) as ttype, 1118 tr.transactioncode as tc, 1119 tr.amount as amount, 1120 trim(tr.memberto) as memberto, 1121 to_char(tr.date,'YYYY-MM-DD') as date 1122 from {$Cu}transaction tr, {$Cu}accountbalance f, 1124 where id > ALL (select MAX(id) 1125 from {$Cu}transaction tr2 1126 where tr2.accountnumber='CHECKPOINT' 1127 and reference1='PHASE II') 1128 and tr.accountnumber='{$getacct}' 1129 and tr.accountnumber=f.accountnumber 1130 and tr.reference1=f.accounttype 1131 AND ma.accountnumber = tr.accountnumber 1132 AND coalesce(ma.restrictions, '') != 'L' 1133 and upper(f.deposittype) in ('Y','N','S') 1134 and tr.transactioncode in ('CW','CP','VP','VC','VG','MP','GM') 1137 trim(tr.accountnumber) as memfrom, 1138 trim(tr.reference1) as ftype, 1139 trim(f.description) as fdesc, 1140 trim(tr.reference2) as ttype, 1142 tr.transactioncode as tc, 1143 tr.amount as amount, 1144 trim(tr.memberto) as memberto, 1145 to_char(tr.date,'YYYY-MM-DD') as date 1146 from {$Cu}transaction tr, {$Cu}loanbalance f, 1148 where id > ALL (select MAX(id) 1149 from {$Cu}transaction tr2 1150 where tr2.accountnumber='CHECKPOINT' 1151 and reference1='PHASE II') 1152 and tr.accountnumber='{$getacct}' 1153 and tr.accountnumber=f.accountnumber 1154 and tr.reference1=f.loannumber 1155 and tr.transactioncode = 'LC' 1156 AND ma.accountnumber = tr.accountnumber 1157 AND coalesce(ma.restrictions, '') != 'L'";
1159 $sth = db_query($sql,$dbh);
1161 for ($row=0; $drow = db_fetch_array($sth,$row); $row++) {
1165 $drow[
'fdesc'] = utf8_encode($drow[
'fdesc']);
1166 $drow[
'tdesc'] = utf8_encode($drow[
'tdesc']);
1168 if (strpos($drow[
'ftype'],
"@")) {
1169 list($smplfacct,$smplfmem) = explode(
"@",$drow[
'ftype']);
1170 $smplfmem = trim($smplfmem);
1172 $smplfacct = trim($drow[
'ftype']);
1173 $smplfmem = $drow[
'memfrom'];
1175 if (strpos($drow[
'ttype'],
"@")) {
1176 list($smpltacct,$smpltmem) = explode(
"@",$drow[
'ttype']);
1177 $smpltmem = trim($smpltmem);
1179 $smpltacct = trim($drow[
'ttype']);
1180 $smpltmem = (
"${drow['memberto']}" ==
"" ? $drow[
'memfrom'] : $drow[
'memberto']);
1196 default: # CW CP VP VC VG MP GM etc.
1200 $txdesc=$txncodes[$tc][0];
1201 $ftxdesc =
"$txdesc from $smplfacct ${drow['fdesc']}";
1202 $ttxdesc =
"$txdesc to" . ($smpltmem == $smplfmem ?
"" :
" $smpltmem") .
" $smpltacct ${drow['tdesc']}";
1204 if (substr($fromto,0,1) ==
'L') {
1206 $pending[
"L|$smplfmem|$smplfacct"][$id][
'id'] = $drow[
'id'];
1207 $pending[
"L|$smplfmem|$smplfacct"][$id][
'tc'] = $drow[
'tc'];
1208 $pending[
"L|$smplfmem|$smplfacct"][$id][
'memfrom'] = $smplfmem;
1209 $pending[
"L|$smplfmem|$smplfacct"][$id][
'facct'] = $smplfacct;
1210 $pending[
"L|$smplfmem|$smplfacct"][$id][
'memberto'] = $smpltmem;
1211 $pending[
"L|$smplfmem|$smplfacct"][$id][
'tacct'] = $smpltacct;
1212 $pending[
"L|$smplfmem|$smplfacct"][$id][
'amount'] = sprintf(
"%.2f",(-1 * $drow[
'amount']));
1213 $pending[
"L|$smplfmem|$smplfacct"][$id][
'postdate'] = $drow[
'date'];
1214 $pending[
"L|$smplfmem|$smplfacct"][$id][
'txdesc'] = $ttxdesc;
1217 $pending[
"D|$smplfmem|$smplfacct|0"][$id][
'id'] = $drow[
'id'];
1218 $pending[
"D|$smplfmem|$smplfacct|0"][$id][
'tc'] = $drow[
'tc'];
1219 $pending[
"D|$smplfmem|$smplfacct|0"][$id][
'memfrom'] = $smplfmem;
1220 $pending[
"D|$smplfmem|$smplfacct|0"][$id][
'facct'] = $smplfacct;
1221 $pending[
"D|$smplfmem|$smplfacct|0"][$id][
'memberto'] = $smpltmem;
1222 $pending[
"D|$smplfmem|$smplfacct|0"][$id][
'tacct'] = $smpltacct;
1223 $pending[
"D|$smplfmem|$smplfacct|0"][$id][
'amount'] = sprintf(
"%.2f",(-1 * $drow[
'amount']));
1224 $pending[
"D|$smplfmem|$smplfacct|0"][$id][
'postdate'] = $drow[
'date'];
1225 $pending[
"D|$smplfmem|$smplfacct|0"][$id][
'txdesc'] = $ttxdesc;
1227 if (substr($fromto,2,1) ==
'L') {
1229 $pending[
"L|$smpltmem|$smpltacct"][$id][
'id'] = $drow[
'id'];
1230 $pending[
"L|$smpltmem|$smpltacct"][$id][
'tc'] = $drow[
'tc'];
1231 $pending[
"L|$smpltmem|$smpltacct"][$id][
'memfrom'] = $smplfmem;
1232 $pending[
"L|$smpltmem|$smpltacct"][$id][
'facct'] = $smplfacct;
1233 $pending[
"L|$smpltmem|$smpltacct"][$id][
'memberto'] = $smpltmem;
1234 $pending[
"L|$smpltmem|$smpltacct"][$id][
'tacct'] = $smpltacct;
1235 $pending[
"L|$smpltmem|$smpltacct"][$id][
'amount'] = $drow[
'amount'];
1236 $pending[
"L|$smpltmem|$smpltacct"][$id][
'amount'] = sprintf(
"%.2f",$drow[
'amount']);
1237 $pending[
"L|$smpltmem|$smpltacct"][$id][
'postdate'] = $drow[
'date'];
1238 $pending[
"L|$smpltmem|$smpltacct"][$id][
'txdesc'] = $ftxdesc;
1240 } elseif (substr($fromto,2,1) ==
'D') {
1243 $pending[
"D|$smpltmem|$smpltacct|0"][$id][
'id'] = $drow[
'id'];
1244 $pending[
"D|$smpltmem|$smpltacct|0"][$id][
'tc'] = $drow[
'tc'];
1245 $pending[
"D|$smpltmem|$smpltacct|0"][$id][
'memfrom'] = $smplfmem;
1246 $pending[
"D|$smpltmem|$smpltacct|0"][$id][
'facct'] = $smplfacct;
1247 $pending[
"D|$smpltmem|$smpltacct|0"][$id][
'memberto'] = $smpltmem;
1248 $pending[
"D|$smpltmem|$smpltacct|0"][$id][
'tacct'] = $smpltacct;
1249 $pending[
"D|$smpltmem|$smpltacct|0"][$id][
'amount'] = sprintf(
"%.2f",$drow[
'amount']);
1250 $pending[
"D|$smpltmem|$smpltacct|0"][$id][
'postdate'] = $drow[
'date'];
1251 $pending[
"D|$smpltmem|$smpltacct|0"][$id][
'txdesc'] = $ftxdesc;
1255 if (!empty($Acctid)) {
1256 # got an account identifier - return one only 1257 if (HCU_array_key_value( $Acctid , $pending ) > 0) {
1258 $txreturn[
'acctlist'][$Acctid] = HCU_array_key_value( $Acctid , $pending );
1261 $txreturn[
'acctlist']=$pending;
1264 $txreturn[
'status'][
'code']=
'0';
1265 $txreturn[
'status'][
'severity']=
'INFO';
1274 function Get_ExternalAccounts( $pDbh, $pHBEnv ) {
1279 $permissionInputs = array(
"feature" => FEATURE_EXTERNAL_TRANSFERS );
1280 $accessRights = Perm_AccessRights( $pDbh, $pHBEnv, $permissionInputs );
1282 if ( !$accessRights[
"create"] ) {
1284 throw new Exception( json_encode( $pHBEnv[
"MC"]->msg(
'Rights not set', HCU_DISPLAY_AS_HTML) ), 915 );
1289 $limits = Perm_GetValidationLimits( $pDbh, $pHBEnv, $permissionInputs );
1290 $maxLimit = ( $limits !==
false ? $limits[
"amount_per_transaction"] : 0 );
1293 $SQL =
"SELECT id, display_name 1294 FROM {$pHBEnv["Cu
"]}extaccount ea 1295 WHERE ea.user_id = {$pHBEnv["Uid
"]} 1298 ORDER BY display_name, id 1300 $rs = db_query( $SQL, $pDbh );
1305 while ( $extRow = db_fetch_array( $rs, $row++ ) ) {
1306 $displayName = trim( $extRow[
"display_name"] );
1308 $retList[] = array(
"id" => $extRow[
"id"],
1309 "display_name" => $displayName,
1310 "max_amount" => $maxLimit );
1313 }
catch (Exception $ex) {
1325 function Get_M2MAccounts( $pDbh, $pHBEnv ) {
1330 $permissionInputs = array(
"feature" => FEATURE_M2M_TRANSFERS );
1331 $accessRights = Perm_AccessRights( $pDbh, $pHBEnv, $permissionInputs );
1333 if ( !$accessRights[
"create"] ) {
1335 throw new Exception( json_encode( $pHBEnv[
"MC"]->msg(
'Rights not set', HCU_DISPLAY_AS_HTML) ), 915 );
1340 $limits = Perm_GetValidationLimits( $pDbh, $pHBEnv, $permissionInputs );
1341 $maxLimit = ( $limits !==
false ? $limits[
"amount_per_transaction"] : 0 );
1344 $SQL =
"SELECT id, display_name 1345 FROM {$pHBEnv["Cu
"]}extaccount ea 1346 WHERE ea.user_id = {$pHBEnv["Uid
"]} 1349 ORDER BY display_name, id 1351 $rs = db_query( $SQL, $pDbh );
1356 while ( $extRow = db_fetch_array( $rs, $row++ ) ) {
1357 $displayName = trim( $extRow[
"display_name"] );
1359 $retList[] = array(
"id" => $extRow[
"id"],
1360 "display_name" => $displayName,
1361 "max_amount" => $maxLimit );
1364 }
catch (Exception $ex) {
1388 function Get_Balances($dbh,&$HB_ENV, $callerContext=
"") {
1390 $Cu = HCU_array_key_exists(
"Cu", $HB_ENV) ? trim($HB_ENV[
"Cu"]) :
"";
1391 $Cn = HCU_array_key_exists(
"Cn", $HB_ENV) ? trim($HB_ENV[
"Cn"]) :
"";
1393 $Uid = HCU_array_key_exists(
"Uid", $HB_ENV) ? trim($HB_ENV[
"Uid"]) :
"";
1394 $live = HCU_array_key_exists(
"live", $HB_ENV) ? trim($HB_ENV[
"live"]) :
"";
1395 $Fset = HCU_array_key_exists(
"Fset", $HB_ENV) ? intval($HB_ENV[
"Fset"]) : 0;
1396 $Fset2 = HCU_array_key_exists(
"Fset2", $HB_ENV) ? intval($HB_ENV[
"Fset2"]) : 0;
1397 $Fset3 = HCU_array_key_exists(
"Fset3", $HB_ENV) ? intval($HB_ENV[
"Fset3"]) : 0;
1399 $Clw = HCU_array_key_exists(
"Clw", $HB_ENV) ? intval($HB_ENV[
"Clw"]) : 300;
1401 $balances = array(
'status' => Array(
'code' =>
'000',
'severity' =>
'',
'errors' => Array()));
1403 $doEncrypt = HCU_array_key_exists(
"doEncrypt", $HB_ENV) ? $HB_ENV[
"doEncrypt"] :
false;
1405 $cuTz = GetCreditUnionTimezone($dbh, $Cu);
1408 $txncodes = Get_HaveTrans($dbh, $HB_ENV);
1413 'email' => $HB_ENV[
'Ml'],
1414 'lastlogin' => $HB_ENV[
'Fplog']
1417 $dataResp = LoadUserData($HB_ENV, $Uid, $userData);
1419 $requestDate = HCU_array_key_value(
"requestDate", $dataResp[
'data']);
1420 $requestDesc = HCU_array_key_value(
"requestDesc", $dataResp[
'data']);
1421 if ($dataResp[
'code'] ==
'999') {
1423 $balances[
'status'][
'code'] =
'999';
1424 $balances[
'status'][
'severity'] =
'ERROR';
1425 $balances[
'status'][
'errors'][] =
'System Unavailable';
1426 $HB_ENV[
'stale'] = 1;
1430 $HB_ENV[
'lastupdate'] = $requestDate;
1432 if ($dataResp[
'code'] !=
'900') {
1434 $HB_ENV[
'packetStatus'] = Array(
1435 'status' => $dataResp[
'code'],
1436 'asofdate' => $requestDate,
1437 'reason' => $requestDesc
1450 $hissql=
"select ccinfourl from cuadmin 1453 $sth = db_query($hissql,$dbh);
1456 list($hisinfo) = db_fetch_array($sth,0);
1459 db_free_result($sth);
1460 if (!empty($hisinfo)) {
1462 if (strtolower($hisinfo) ===
'homecu' || substr(strtolower($hisinfo), 0, 4) ===
'http') {
1463 $hinfo = array(
'18' => $hisinfo);
1466 $hinfo = HCU_JsonDecode($hisinfo);
1472 $orderby =
"ORDER BY 11, 2, 1, 3";
1476 if ($Fset & GetFlagsetValue(
'CU_SORTORDER4') ) {
1478 $orderby =
"ORDER BY 11, 23, 1, 3 ";
1481 $bal_oid_select =
"";
1482 $xa_oid_select =
"";
1483 if ($Fset2 & GetFlagsetValue(
'CU2_SORTORDER6')) {
1484 $orderby =
"order by 11, 24, 25 ";
1485 $bal_oid_select =
", ab.oid ";
1486 $xa_oid_select =
", ca.oid ";
1489 $appendCrossAccounts =
false;
1492 if (HCU_array_key_value(
"XA", $txncodes) && ($Fset3 & GetFlagsetValue(
"CU3_API_XAC"))) {
1493 if ($callerContext ==
"acct_desc_read") {
1496 if (!($Fset3 & GetFlagsetValue(
"CU3_EXCLUDE_XAC_FROM_PROFILE_DESCRIPTIONS"))) {
1497 $appendCrossAccounts =
true;
1502 $appendCrossAccounts =
true;
1506 $sql =
"select trim(ua.accountnumber) as accountnumber, 1507 trim(ua.accounttype) as accounttype, 1509 upper(deposittype) as deposittype, 1510 trim(description) as description, 1515 trim(micraccount) as micraccount, 1516 display_order as displayorder, 1517 display_name as displayname, 1525 coalesce(ab.balance_stamp, ma.balance_stamp) as balance_stamp, 1528 btrim(ab.accounttype, 'DIS'), 1529 'balance' as tablesrc {$bal_oid_select} 1531 FROM {$Cu}useraccounts ua 1532 INNER JOIN {$Cu}accountbalance as ab ON ab.accountnumber = ua.accountnumber 1533 AND ab.accounttype = ua.accounttype 1534 AND ab.certnumber = ua.certnumber 1535 INNER JOIN {$Cu}memberacct as ma ON ma.accountnumber = ua.accountnumber 1536 WHERE ua.user_id = $Uid 1537 AND ua.recordtype = 'D' 1540 if($appendCrossAccounts) {
1545 trim(ua.accountnumber) as accountnumber, 1546 trim(ua.accounttype) as accounttype, 1548 upper(ca.deposittype) as deposittype, 1549 trim(ca.description) as description, 1552 0 as lastyrinterest, 1555 ua.display_order as displayorder, 1556 ua.display_name as displayname, 1559 ua.view_transactions, 1567 btrim(ca.accounttype, 'DIS'), 1568 'cross' as tablesrc {$xa_oid_select} 1569 FROM {$Cu}useraccounts ua 1571 INNER JOIN {$Cu}crossaccounts as ca ON ca.accountnumber = ca.accountnumber 1572 AND trim(ca.accounttype) || '#' || trim(ca.tomember) = ua.accounttype 1573 AND ca.deposittype IN ('Y','S','N') 1574 INNER JOIN {$Cu}memberacct as ma ON ma.accountnumber = ua.accountnumber 1576 WHERE ua.user_id = {$Uid} 1577 AND ua.recordtype = 'T' 1578 AND ua.int_deposit = 't' 1585 $whcc = ($Fset2 & GetFlagsetValue(
'CU2_SPEC18') ?
" and (cbtype <> '18' or cbtype is null) " :
"");
1589 $lorderby =
" ORDER BY 15, 2, 1";
1593 if ($Fset & GetFlagsetValue(
'CU_LNSORT2')) {
1595 $lorderby =
" ORDER BY 11, 29, 1 ";
1600 trim(ua.accountnumber) as accountnumber, 1601 trim(loannumber) as loannumber, 1602 coalesce(currentbalance,0) as currentbalance, 1603 coalesce(payoff,0) as payoff, 1604 coalesce(unpaidinterest,0) as unpaidinterest, 1605 date_part('day',(now()-lastpaymentdate)) as unpaiddays, 1607 to_char(nextduedate,'YYYY-MM-DD') as nextduedate, 1608 trim(description) as description, 1609 coalesce(interestrate,0) as interestrate, 1614 display_order as displayorder, 1615 display_name as displayname, 1617 case when nextduedate < CURRENT_DATE 1618 and currentbalance > 0 1619 and paymentamount > 0 1620 then 1 else 0 end as pastdue, 1621 to_char(lastpaymentdate,'YYYY-MM-DD') as lastpaymentdate, 1628 coalesce(lb.balance_stamp, ma.balance_stamp) as balance_stamp, 1631 btrim(loannumber,'LC'), 1632 'balance' as tablesrc 1633 FROM {$Cu}useraccounts ua 1634 INNER JOIN {$Cu}loanbalance lb ON lb.accountnumber = ua.accountnumber 1635 AND lb.loannumber = ua.accounttype 1636 INNER JOIN {$Cu}memberacct as ma ON ma.accountnumber = ua.accountnumber 1638 WHERE ua.user_id = $Uid 1639 AND ua.recordtype = 'L' 1645 if($appendCrossAccounts) {
1650 trim(ua.accountnumber) as accountnumber, 1651 trim(ua.accounttype) as loannumber, 1652 0 as currentbalance, 1654 0 as unpaidinterest, 1658 trim(ca.description) as description, 1662 0 as lastyrinterest, 1664 ua.display_order as displayorder, 1665 ua.display_name as displayname, 1668 '' as lastpaymentdate, 1670 ua.view_transactions, 1678 btrim(ca.accounttype,'LC'), 1680 FROM {$Cu}useraccounts ua 1682 INNER JOIN {$Cu}crossaccounts as ca ON ca.accountnumber = ca.accountnumber 1683 AND trim(ca.accounttype) || '#' || trim(ca.tomember) = ua.accounttype 1684 AND ca.deposittype IN ('L') 1685 INNER JOIN {$Cu}memberacct as ma ON ma.accountnumber = ua.accountnumber 1687 WHERE ua.user_id = {$Uid} 1688 AND ua.recordtype = 'P' 1689 AND ua.int_deposit = 't' 1693 $loan_sql .= $lorderby;
1698 trim(loannumber) as loannumber, 1702 to_char(nextduedate,'YYYY-MM-DD') as nextduedate, 1709 display_order as displayorder, 1710 display_name as displayname, 1712 case when nextduedate < CURRENT_DATE 1713 and currentbalance > 0 1714 and paymentamount > 0 1715 then 1 else 0 end as pastdue, 1716 to_char(lastpaymentdate,'YYYY-MM-DD') as lastpaymentdate, 1723 coalesce(lb.balance_stamp, ma.balance_stamp) as balance_stamp, 1726 btrim(loannumber,'LC'), 1727 'balance' as tablesrc 1728 FROM {$Cu}useraccounts ua 1729 INNER JOIN {$Cu}loanbalance lb ON lb.accountnumber = ua.accountnumber 1730 AND lb.loannumber = ua.accounttype 1731 INNER JOIN {$Cu}memberacct as ma ON ma.accountnumber = ua.accountnumber 1732 WHERE user_id = $Uid 1739 $sthdp = db_query($sql,$dbh);
1740 $sthln = db_query($loan_sql,$dbh);
1741 $sthcc = db_query($cc_sql,$dbh);
1743 if (!(db_num_rows($sthdp)) && !(db_num_rows($sthcc)) && !(db_num_rows($sthln))) {
1745 $balances[
'status'][
'code']=
'999';
1746 $balances[
'status'][
'severity']=
'ERROR';
1747 $balances[
'status'][
'errors'][]=
'No Accounts Available';
1749 $balances[
'status'][
'code']=
'000';
1750 $balances[
'status'][
'severity']=
'SUCCESS';
1751 for ($row=0;$drow=db_fetch_array($sthdp,$row);$row++) {
1752 $accounttype=$drow[
'accounttype'];
1754 $cert=$drow[
'certnumber'];
1756 if ($drow[
'tablesrc'] ==
'cross') {
1757 $trust =
"transfer";
1759 if (strpos($accounttype,
"@")) {
1766 $key=
"D|" . trim($drow[
"accountnumber"]) .
"|$accounttype|$cert";
1769 $displayname= trim($drow[
'displayname']);
1770 $description= trim($drow[
"description"]);
1771 $accountnumber= trim($drow[
'accountnumber']);
1773 $balances[
'dp'][$key][
'displayname'] = $displayname;
1775 $displayAcctNbr =
'';
1776 $displayAcctType =
'';
1777 if (strpos($accounttype,
"#")) {
1778 list($displayAcctType, $displayAcctNbr) = explode(
"#",$accounttype);
1780 $displayAcctNbr = $accountnumber;
1781 $displayAcctType = $accounttype;
1783 $balances[
'dp'][$key][
'description'] = getAccountDescription($dbh, $HB_ENV[
"Cu"], $displayAcctNbr, $description, $displayAcctType,
"", $Fset3, $cert);
1784 $balances[
'dp'][$key][
'displaydesc'] = getAccountDescription($dbh, $HB_ENV[
"Cu"], $displayAcctNbr, $description, $displayAcctType, $displayname, $Fset3, $cert);
1786 $balances[
'dp'][$key][
'displayorder'] = $drow[
'displayorder'];
1787 $balances[
'dp'][$key][
'recordtype'] = $drow[
'recordtype'];
1788 $balances[
'dp'][$key][
'accountnumber'] = $accountnumber;
1790 $balances[
'dp'][$key][
'view_balances'] = ($drow[
'view_balances'] ==
't');
1791 $balances[
'dp'][$key][
'view_transactions'] = $drow[
'restrictions'] ==
"L" ? false : ($drow[
'view_transactions'] ==
't');
1792 $balances[
'dp'][$key][
'int_deposit'] = $drow[
'restrictions'] ==
"L" ? false : ($drow[
'int_deposit'] ==
't');
1793 $balances[
'dp'][$key][
'int_withdraw'] = $drow[
'restrictions'] ==
"L" ? false : ($drow[
'int_withdraw'] ==
't');
1794 $balances[
'dp'][$key][
'ext_deposit'] = $drow[
'restrictions'] ==
"L" ? false : ($drow[
'ext_deposit'] ==
't');
1795 $balances[
'dp'][$key][
'ext_withdraw'] = $drow[
'restrictions'] ==
"L" ? false : ($drow[
'ext_withdraw'] ==
't');
1798 $balances[
'dp'][$key][
'encryption']= $doEncrypt ? HCU_PayloadEncode($Cu, explode(
"|", $key)) : null;
1802 $balances[
'dp'][$key][
'restrictions'] = $drow[
'restrictions'];
1803 $balances[
'dp'][$key][
'trust'] =
"$trust";
1804 if ( $drow[
'restrictions'] ==
"L" || $drow[
'view_balances'] !=
't') {
1806 $balances[
'dp'][$key][
'currentbal'] = 0;
1807 if ($Fset & GetFlagsetValue(
'CU_SHOWAVAILABLE'))
1808 $balances[
'dp'][$key][
'availablebal'] = 0;
1814 $balances[
'dp'][$key][
'accounttype']=$drow[
'accounttype'];
1815 $balances[
'dp'][$key][
'certnumber']=$drow[
'certnumber'];
1816 $balances[
'dp'][$key][
'deposittype']=$drow[
'deposittype'];
1817 $balances[
'dp'][$key][
'currentbal']=$drow[
'amount'];
1818 if ($Fset & GetFlagsetValue(
'CU_SHOWAVAILABLE'))
1819 $balances[
'dp'][$key][
'availablebal']=$drow[
'available'];
1820 if ($Fset & GetFlagsetValue(
'CU_SHOWDEPDIVIDEND')) {
1821 $balances[
'dp'][$key][
'ytdinterest']=$drow[
'ytdinterest'];
1822 if (!($Fset & GetFlagsetValue(
'CU_HIDE_PYR')))
1823 $balances[
'dp'][$key][
'lastyrinterest']=$drow[
'lastyrinterest'];
1825 $balances[
'dp'][$key][
'micraccount']=$drow[
'micraccount'];
1827 if ($Fset2 & GetFlagsetValue(
'CU2_SHOWHOLD')) {
1828 $pending=Get_HoldTotal($dbh,$HB_ENV,$key);
1829 if (empty($pending[$key])) {
1830 $holdtotal =
'0.00';
1832 $holdtotal=sprintf(
"%.2f",$pending[$key][
'total']);
1834 $balances[
'dp'][$key][
'holdtotal']=
"$holdtotal";
1836 if ($Fset2 & GetFlagsetValue(
'CU2_SHOWPEND')) {
1837 $pending=Get_PendTotal($dbh,$HB_ENV,$key);
1838 if (empty($pending[$key])) {
1839 $pendtotal =
'0.00';
1841 $pendtotal=sprintf(
"%.2f",$pending[$key][
'total']);
1843 $balances[
'dp'][$key][
'pendtotal']=
"$pendtotal";
1847 $balances[
'dp'][$key][
'as_of_date'] = GetDateFormatTimezone($drow[
'balance_stamp'],
'm/d/Y h:i A', $cuTz);
1849 $balances[
'dp'][$key][
'out_of_sync'] = ($drow[
'balance_stamp'] < $drow[
'balance_attempt']);
1852 $balances[
'dp'][$key][
'as_of_date'] =
"";
1853 $balances[
'dp'][$key][
'out_of_sync'] =
false;
1857 for ($row=0;$drow=db_fetch_array($sthln,$row);$row++) {
1858 $loan=$drow[
'loannumber'];
1860 if ($drow[
'tablesrc'] ==
'cross') {
1861 $trust =
"transfer";
1863 if (strpos($loan,
"@")) {
1873 $payoff=$drow[
'payoff'];
1875 $rate = $drow[
'interestrate'];
1876 $rate = (empty($rate) ? 0 : $rate);
1877 $unpaid = $drow[
'unpaidinterest'];
1878 $unpaid = (empty($unpaid) ? 0 : $unpaid);
1879 $days = $drow[
'unpaiddays'];
1880 $days = (empty($days) ? 0 : $days);
1884 $payoff = (((($rate/100)*$drow[
'currentbalance'])/365)*$days)+$unpaid+$drow[
'currentbalance'];
1886 $tenday = (((($drow[
'interestrate']/100)*$drow[
'currentbalance'])/365)*10) + (empty($payoff) ? 0 : $payoff );
1888 if (empty($payoff) || $payoff == 0) {
1891 $payoff=sprintf(
"%.2f",$payoff);
1893 if ($drow[
'currentbalance'] <= 0 ) {
1896 $tenday = ((empty($tenday) || $tenday==0 || $drow[
'cbtype']==
'18') ?
'#Call Us#' : sprintf(
"%.2f",$tenday));
1899 if ($Fset2 & GetFlagsetValue(
'CU2_CALL_PAYOFF')) {
1900 $payoff=
'#Call Us#';
1903 $limit = $drow[
'creditlimit'];
1904 $balance = $drow[
'currentbalance'];
1905 $available = ($limit - $balance < 0 ? 0 : $limit - $balance);
1907 $key=
"L|" . trim($drow[
"accountnumber"]) .
"|$loan";
1908 $keyEncrypt = HCU_PayloadEncode($Cu, explode(
"|",$key));
1914 $displayname = trim($drow[
'displayname']);
1915 $description = trim($drow[
"description"]);
1916 $accountnumber = trim($drow[
'accountnumber']);
1918 $balances[
'ln'][$key][
'displayname'] = $displayname;
1920 $displayAcctNbr =
'';
1921 $displayAcctType =
'';
1922 if (strpos($loan,
"#")) {
1923 list($displayAcctType, $displayAcctNbr) = explode(
"#",$loan);
1925 $displayAcctNbr = $accountnumber;
1926 $displayAcctType = $loan;
1928 $balances[
'ln'][$key][
'description'] = getAccountDescription($dbh, $HB_ENV[
"Cu"], $displayAcctNbr, $description, $displayAcctType,
"", $Fset3);
1929 $balances[
'ln'][$key][
'displaydesc'] = getAccountDescription($dbh, $HB_ENV[
"Cu"], $displayAcctNbr, $description, $displayAcctType, $displayname, $Fset3);
1948 $balances[
'ln'][$key][
'displayorder'] = $drow[
'displayorder'];
1949 $balances[
'ln'][$key][
'recordtype'] = $drow[
'recordtype'];
1950 $balances[
'ln'][$key][
'accountnumber'] = trim($drow[
'accountnumber']);
1952 $balances[
'ln'][$key][
'view_balances'] = ($drow[
'view_balances'] ==
't');
1953 $balances[
'ln'][$key][
'view_transactions'] = $drow[
'restrictions'] ==
"L" ? false : ($drow[
'view_transactions'] ==
't');
1954 $balances[
'ln'][$key][
'int_deposit'] = $drow[
'restrictions'] ==
"L" ? false : ($drow[
'int_deposit'] ==
't');
1955 $balances[
'ln'][$key][
'int_withdraw'] = $drow[
'restrictions'] ==
"L" ? false : ($drow[
'int_withdraw'] ==
't');
1956 $balances[
'ln'][$key][
'ext_deposit'] = $drow[
'restrictions'] ==
"L" ? false : ($drow[
'ext_deposit'] ==
't');
1957 $balances[
'ln'][$key][
'ext_withdraw'] = $drow[
'restrictions'] ==
"L" ? false : ($drow[
'ext_withdraw'] ==
't');
1960 $balances[
'ln'][$key][
'restrictions'] = $drow[
'restrictions'];
1961 if ( $drow[
'restrictions'] ==
"L" ) {
1963 $balances[
'ln'][$key][
'currentbal'] = 0;
1965 $balances[
'ln'][$key][
'paymentamount'] = 0;
1970 $balances[
'ln'][$key][
'encryption']= $doEncrypt ? $keyEncrypt :
null;
1972 $balances[
'ln'][$key][
'loan']=$drow[
'loannumber'];
1973 $balances[
'ln'][$key][
'currentbal']=$drow[
'currentbalance'];
1974 if (!($Fset2 & GetFlagsetValue(
'CU2_HIDE_PAYOFF')))
1975 $balances[
'ln'][$key][
'payoff']=$payoff;
1977 if ($Fset2 & GetFlagsetValue(
'CU2_10DAYPAY'))
1978 $balances[
'ln'][$key][
'tenday'] = $tenday;
1980 $balances[
'ln'][$key][
'paymentamount'] = $drow[
'paymentamount'];
1982 if (!($Fset & GetFlagsetValue(
'CU_HIDELOANDATE'))) {
1983 if (trim($drow[
'nextduedate']) ==
'' || $payoff ==
'N/A') {
1984 $drow[
'nextduedate'] =
'N/A';
1986 $balances[
'ln'][$key][
'nextduedate'] = $drow[
'nextduedate'];
1987 if (($drow[
'pastdue']) && !($Fset2 & GetFlagsetValue(
'CU2_HIDE_PASTDUE'))) {
1988 $balances[
'ln'][$key][
'pastdue'] = $drow[
'pastdue'];
1992 $balances[
'ln'][$key][
'trust']=
"$trust";
1993 if ($Fset & GetFlagsetValue(
'CU_SHOWLNRATE'))
1994 $balances[
'ln'][$key][
'interestrate']=$drow[
'interestrate'];
1996 $balances[
'ln'][$key][
'creditlimit']=$drow[
'creditlimit'];
1999 if ($Fset & GetFlagsetValue(
'CU_SHOWAVAILABLE') && floatval($drow[
'creditlimit']) > 0)
2000 $balances[
'ln'][$key][
'availablebal']=$available;
2002 if ($Fset & GetFlagsetValue(
'CU_SHOWLNINTEREST')) {
2003 $balances[
'ln'][$key][
'ytdinterest']=$drow[
'ytdinterest'];
2005 if (!($Fset & GetFlagsetValue(
'CU_HIDE_PYR')))
2006 $balances[
'ln'][$key][
'lastyrinterest']=$drow[
'lastyrinterest'];
2008 $balances[
'ln'][$key][
'type']=$drow[
'cbtype'];
2009 $balances[
'ln'][$key][
'cbtype']=$drow[
'cbtype'];
2011 if (HCU_array_key_exists(
'cbtype', $drow) && HCU_array_key_exists($drow[
'cbtype'], $hinfo)) {
2013 $hisLink = str_replace(
"#acctid#", urlencode($keyEncrypt), $hinfo[$drow[
'cbtype']]);
2014 $balances[
'ln'][$key][
'hisinfo'] = $hisLink;
2016 $balances[
'ln'][$key][
'hisinfo']=
"";
2018 $balances[
'ln'][$key][
'lastpaymentdate']=$drow[
'lastpaymentdate'];
2022 if ($Fset2 & GetFlagsetValue(
'CU2_SHOWHOLD')) {
2023 $pending=Get_HoldTotal($dbh,$HB_ENV,$key);
2024 if (empty($pending[$key])) {
2025 $holdtotal =
'0.00';
2027 $holdtotal=sprintf(
"%.2f",$pending[$key][
'total']);
2029 $balances[
'ln'][$key][
'holdtotal']=
"$holdtotal";
2031 $balances[
'ln'][$key][
'restrictions'] = $drow[
'restrictions'];
2034 $balances[
'ln'][$key][
'as_of_date'] = GetDateFormatTimezone($drow[
'balance_stamp'],
'm/d/Y h:i A', $cuTz);
2035 $balances[
'ln'][$key][
'out_of_sync'] = ($drow[
'balance_stamp'] < $drow[
'balance_attempt']);
2038 $balances[
'ln'][$key][
'as_of_date'] =
"";
2039 $balances[
'ln'][$key][
'out_of_sync'] =
false;
2042 if ($Fset2 & GetFlagsetValue(
'CU2_SPEC18')) {
2043 for ($row = 0; $drow = db_fetch_array($sthcc, $row); $row++) {
2044 $loan = $drow[
'loannumber'];
2046 if (strpos($loan,
"@")) {
2051 $limit = $drow[
'creditlimit'];
2052 $balance = $drow[
'currentbalance'];
2053 $available = ($limit - $balance < 0 ? 0 : $limit - $balance);
2054 $available = (($Fset2 & GetFlagsetValue(
'CU2_CALL_CCAVAIL')) ?
"#Call Us#" : sprintf(
"%.2f", $available));
2056 $key =
"C|" . trim($drow[
"accountnumber"]) .
"|$loan";
2057 $keyEncrypt = HCU_PayloadEncode($Cu, explode(
"|",$key));
2060 $displayname= trim($drow[
'displayname']);
2061 $description= trim($drow[
'description']);
2062 $accountnumber= trim($drow[
'accountnumber']);
2064 $balances[
'cc'][$key][
'displayname'] = $displayname;
2065 $balances[
'cc'][$key][
'description'] = getAccountDescription($dbh, $HB_ENV[
"Cu"], $accountnumber, $description, $loan,
"", $Fset3);
2066 $balances[
'cc'][$key][
'displaydesc'] = getAccountDescription($dbh, $HB_ENV[
"Cu"], $accountnumber, $description, $loan, $displayname, $Fset3);
2068 $balances[
'cc'][$key][
'displayorder'] = $drow[
'displayorder'];
2069 $balances[
'cc'][$key][
'recordtype'] = $drow[
'recordtype'];
2070 $balances[
'cc'][$key][
'accountnumber'] = trim($drow[
'accountnumber']);
2072 $balances[
'cc'][$key][
'view_balances'] = ($drow[
'view_balances'] ==
't');
2073 $balances[
'cc'][$key][
'view_transactions'] = $drow[
'restrictions'] ==
"L" ? false : ($drow[
'view_transactions'] ==
't');
2074 $balances[
'cc'][$key][
'int_deposit'] = $drow[
'restrictions'] ==
"L" ? false : ($drow[
'int_deposit'] ==
't');
2075 $balances[
'cc'][$key][
'int_withdraw'] = $drow[
'restrictions'] ==
"L" ? false : ($drow[
'int_withdraw'] ==
't');
2076 $balances[
'cc'][$key][
'ext_deposit'] = $drow[
'restrictions'] ==
"L" ? false : ($drow[
'ext_deposit'] ==
't');
2077 $balances[
'cc'][$key][
'ext_withdraw'] = $drow[
'restrictions'] ==
"L" ? false : ($drow[
'ext_withdraw'] ==
't');
2080 $balances[
'cc'][$key][
'restrictions'] = $drow[
'restrictions'];
2081 if ( $drow[
'restrictions'] ==
"L" ) {
2083 $balances[
'cc'][$key][
'currentbal'] = 0;
2084 $balances[
'cc'][$key][
'paymentamount'] = 0;
2089 $balances[
'cc'][$key][
'encryption'] = $doEncrypt ? $keyEncrypt :
null;
2091 $balances[
'cc'][$key][
'loan'] = $drow[
'loannumber'];
2093 $balances[
'cc'][$key][
'trust'] =
"$trust";
2094 $balances[
'cc'][$key][
'type'] = $drow[
'cbtype'];
2095 $balances[
'cc'][$key][
'cbtype']=$drow[
'cbtype'];
2097 if (HCU_array_key_exists(
'cbtype', $drow) && HCU_array_key_exists($drow[
'cbtype'], $hinfo)) {
2099 $hisLink = str_replace(
"#acctid#", urlencode($keyEncrypt), $hinfo[$drow[
'cbtype']]);
2100 $balances[
'cc'][$key][
'hisinfo'] = $hisLink;
2102 $balances[
'cc'][$key][
'hisinfo']=
"";
2104 if (($Fset2 & GetFlagsetValue(
'CU2_CC18NOINFO')) != GetFlagsetValue(
'CU2_CC18NOINFO')) {
2105 $balances[
'cc'][$key][
'currentbal'] = $drow[
'currentbalance'];
2106 if ($live && ($Fset2 & $GLOBALS[
'CU2_SHOWCCSB']) == $GLOBALS[
'CU2_SHOWCCSB']) {
2107 $balances[
'cc'][$key][
'stmntbal'] = $drow[
'payoff'];
2109 if (($Fset2 & $GLOBALS[
'CU2_HIDE_CCAVAIL']) != $GLOBALS[
'CU2_HIDE_CCAVAIL']) {
2110 $balances[
'cc'][$key][
'available'] = $available;
2112 $balances[
'cc'][$key][
'availablebal'] = $available;
2115 $balances[
'cc'][$key][
'paymentamount'] = $drow[
'paymentamount'];
2116 if (!($Fset & GetFlagsetValue(
'CU_HIDELOANDATE'))) {
2123 if (trim($drow[
'nextduedate']) ==
'' || $drow[
'currentbalance'] == 0) {
2124 $drow[
'nextduedate'] =
'N/A';
2126 $balances[
'cc'][$key][
'nextduedate'] = $drow[
'nextduedate'];
2127 if (($drow[
'pastdue']) && !($Fset2 & GetFlagsetValue(
'CU2_HIDE_PASTDUE'))) {
2128 $balances[
'cc'][$key][
'pastdue'] = $drow[
'pastdue'];
2131 if ($Fset2 & GetFlagsetValue(
'CU2_SHOWCCRATE')) {
2132 $balances[
'cc'][$key][
'interestrate'] = $drow[
'interestrate'];
2134 $balances[
'cc'][$key][
'creditlimit'] = $drow[
'creditlimit'];
2135 if ($Fset & GetFlagsetValue(
'CU_SHOWLNINTEREST')) {
2136 $balances[
'cc'][$key][
'ytdinterest'] = $drow[
'ytdinterest'];
2137 if (!($Fset & GetFlagsetValue(
'CU_HIDE_PYR')))
2138 $balances[
'cc'][$key][
'lastyrinterest'] = $drow[
'lastyrinterest'];
2140 if ($Fset2 & GetFlagsetValue(
'CU2_SHOWCCLPAY')) {
2141 $balances[
'cc'][$key][
'lastpaymentdate'] = $drow[
'lastpaymentdate'];
2146 if ($Fset2 & GetFlagsetValue(
'CU2_SHOWHOLD')) {
2147 $pending = Get_HoldTotal($dbh, $HB_ENV, $key);
2148 if (empty($pending[$key])) {
2149 $holdtotal =
'0.00';
2151 $holdtotal = sprintf(
"%.2f", $pending[$key][
'total']);
2153 $balances[
'cc'][$key][
'holdtotal'] =
"$holdtotal";
2156 $balances[
'cc'][$key][
'as_of_date'] = GetDateFormatTimezone($drow[
'balance_stamp'],
'm/d/Y h:i A', $cuTz);
2157 $balances[
'cc'][$key][
'out_of_sync'] = ($drow[
'balance_stamp'] < $drow[
'balance_attempt']);
2160 $balances[
'cc'][$key][
'as_of_date'] =
"";
2161 $balances[
'cc'][$key][
'out_of_sync'] =
false;
2181 function Get_History($dbh,&$HB_ENV,$Acctid,$DTSTART=
"",$DTEND=
"",$pAdvSearch=[]) {
2183 $Cu = $HB_ENV[
'Cu'];
2184 $Uid = $HB_ENV[
"Uid"];
2185 $live = $HB_ENV[
'live'];
2186 $Fset = $HB_ENV[
'Fset'];
2187 $Fset2 = $HB_ENV[
'Fset2'];
2195 'email' => $HB_ENV[
'Ml'],
2196 'lastlogin' => $HB_ENV[
'Fplog']
2199 $dataResp = LoadUserData($HB_ENV, $Uid, $userData);
2200 $requestDate = HCU_array_key_value(
"requestDate", $dataResp[
'data']);
2201 $requestDesc = HCU_array_key_value(
"requestDesc", $dataResp[
'data']);
2203 if ($dataResp[
'code'] ==
'999') {
2205 $balances[
'status'][
'code'] =
'999';
2206 $balances[
'status'][
'severity'] =
'ERROR';
2207 $balances[
'status'][
'errors'][] =
'System Unavailable';
2208 $HB_ENV[
'stale'] = 1;
2212 $HB_ENV[
'lastupdate'] = $requestDate;
2215 if ($dataResp[
'code'] !=
'900') {
2217 $HB_ENV[
'packetStatus'] = [
2218 'status' => $dataResp[
'code'],
2219 'asofdate' => $requestDate,
2220 'reason' => $requestDesc
2225 date_default_timezone_set(
'UTC');
2226 if (empty($DTSTART) || !strtotime($DTSTART)) {
2227 $errors[]=
"Invalid Start Date";
2229 if (empty($DTEND) || !strtotime($DTEND)) {
2230 $errors[]=
"Invalid End Date";
2232 if ( strtotime($DTSTART) > strtotime($DTEND)) {
2233 $errors[]=
"Invalid Date Range";
2235 if (count($errors) > 0) {
2236 $history[
'status'][
'code'] =
'999';
2237 $history[
'status'][
'severity'] =
'ERROR';
2238 $history[
'status'][
'errors'] = $errors;
2241 $sqlstart = (date(
'Y-m-d',strtotime($DTSTART)));
2242 $sqlend = (date(
'Y-m-d',strtotime($DTEND)));
2243 $currentdate = date(
'Y-m-d');
2245 $date_clause=
" and date >= '$sqlstart 00:00:00' ";
2246 if ($sqlend < $currentdate) {
2247 $date_clause .=
"and date <= '$sqlend 23:59:59' ";
2250 $tbl=substr($Acctid,0,1);
2255 list($gettbl,$getacct,$gettype,$getcert) = explode(
"|",$Acctid);
2258 # set the default dp sort order 2259 $orderby =
"order by date desc, tracenumber desc";
2261 # then override it if a flag is set 2262 if (($Fset & $GLOBALS[
'CU_SORTORDER1']) == $GLOBALS[
'CU_SORTORDER1']) {
2263 $orderby =
"order by tracenumber desc";
2266 # only SORTORDER2 and SORTORDER5 change the dp history sort order 2267 if (($Fset & $GLOBALS[
'CU_SORTORDER2']) == $GLOBALS[
'CU_SORTORDER2']) {
2268 $orderby =
"order by date desc, sortkey desc";
2271 if (($Fset & $GLOBALS[
'CU_SORTORDER5']) == $GLOBALS[
'CU_SORTORDER5']) {
2272 $orderby =
"order by date desc, oid desc";
2275 # running balance calc if $CU_CALCRUNBAL 2276 # need deposittype from accountbalance table to determine checking? 2277 # micr overrides? alternate rt will be handled in ImageSRC 2279 $dp_bal =
"select deposittype,amount, 2280 (select sum(amount) from {$Cu}accounthistory 2281 where accountnumber='" . prep_save($getacct) .
"' and accounttype='" . prep_save($gettype) .
"' 2282 and date >'" . prep_save($sqlend) .
" 23:59:59' and certnumber=" . prep_save(intval($getcert)) .
" 2284 from {$Cu}accountbalance 2285 where accountnumber='" . prep_save($getacct) .
"' 2286 and accounttype='" . prep_save($gettype) .
"' 2287 and certnumber=" . prep_save(intval($getcert)) .
" ";
2289 $sthbal = db_query($dp_bal,$dbh);
2292 # error, query failed 2293 $history[
'status'][
'code'] =
'999';
2294 $history[
'status'][
'severity'] =
'ERROR';
2295 $history[
'status'][
'errors'][] = db_last_error();
2296 $history[
'status'][
'errors'][] =
"$dp_bal";
2299 $drow = db_fetch_array($sthbal,0);
2300 $deptype = $drow[
'deposittype'];
2301 $seedbal = ($currentdate == $sqlend ? $drow[
'amount'] : $drow[
'amount'] - $drow[
'txnsum']);
2305 if ( count( $pAdvSearch ) > 0 ) {
2309 if ( HCU_array_key_exists(
"fdesc", $pAdvSearch) && strlen( $pAdvSearch[
"fdesc"] ) > 0 ) {
2310 $advSql .=
" and description ~* '{$pAdvSearch["fdesc
"]}'";
2312 if ( HCU_array_key_exists(
"findamt", $pAdvSearch) && strlen( $pAdvSearch[
"findamt"] ) > 0 ) {
2313 $advSql .=
" and abs(amount)=cast('{$pAdvSearch["findamt
"]}' as numeric)";
2315 if ( HCU_array_key_exists(
"check", $pAdvSearch) && strlen( $pAdvSearch[
"check"] ) > 0 && $deptype ==
"Y" ) {
2316 $advSql .=
" and trim(checknumber)='{$pAdvSearch["check
"]}'";
2323 $dp_sql =
"select trim(accounttype) as accounttype, 2325 trim(checknumber) as checknumber, 2326 to_char(date,'YYYY-MM-DD') as ymddate, 2328 trim(description) as description, 2329 trim(sortkey) as sortkey, 2331 trim(tracenumber) as tracenumber 2332 from {$Cu}accounthistory 2333 where accountnumber='" . prep_save($getacct) .
"' 2334 and certnumber=" . prep_save(intval($getcert)) .
" 2335 and accounttype='" . prep_save($gettype) .
"' 2339 $dp_sql .= $orderby;
2340 $sthdp = db_query($dp_sql,$dbh);
2343 # error, query failed 2344 $history[
'status'][
'code'] =
'999';
2345 $history[
'status'][
'severity'] =
'ERROR';
2346 $history[
'status'][
'errors'][] = db_last_error();
2347 $history[
'status'][
'errors'][] =
"$dp_sql";
2350 $history[
'status'][
'code'] =
'000';
2351 $history[
'status'][
'severity'] =
'SUCCESS';
2352 $history[
'status'][
'startdate'] = $sqlstart;
2353 $history[
'status'][
'stopdate'] = $sqlend;
2354 $history[
'status'][
'txnsum'] = $drow[
'txnsum'];
2355 $history[
'status'][
'startbal'] = $drow[
'amount'];
2356 $history[
'status'][
'seedbal'] = $seedbal;
2359 if (($Fset & $GLOBALS[
'CU_CALCRUNBAL']) == $GLOBALS[
'CU_CALCRUNBAL'] )
2362 for ($row=0;$drow = db_fetch_array($sthdp,$row);$row++) {
2365 $drow[
'description'] = utf8_encode($drow[
'description']);
2366 $accounttype = $drow[
'accounttype'];
2367 $cert = $drow[
'certnumber'];
2369 if (strpos($accounttype,
"@")) {
2375 $trace =
"T" . $drow[
'tracenumber'];
2376 $amount = $drow[
'amount'];
2377 $amount = str_replace(
",",
"",str_replace(
"$",
"",$amount));
2378 $amount = sprintf(
"%.2f",$amount);
2380 if (($Fset & $GLOBALS[
'CU_CALCRUNBAL']) == $GLOBALS[
'CU_CALCRUNBAL'] ) {
2382 $runbal -= $drow[
'amount'];
2384 $balance = $drow[
'balance'];
2387 $history[$Acctid][$trace][
'accounttype'] = $drow[
'accounttype'];
2388 $history[$Acctid][$trace][
'certnumber'] = $drow[
'certnumber'];
2389 $history[$Acctid][$trace][
'amount'] = $amount;
2390 $history[$Acctid][$trace][
'balance'] = sprintf(
"%.2f",$balance);
2392 $history[$Acctid][$trace][
'date'] = $drow[
'ymddate'];
2394 if ($deptype ==
"Y") {
2396 $history[$Acctid][$trace][
'checkno']=$drow[
'checknumber'];
2398 if (((($Fset & $GLOBALS[
'CU_SHOWIMAGES']) == $GLOBALS[
'CU_SHOWIMAGES'])) &&
2399 $drow[
'checknumber'] > 0) {
2400 $history[$Acctid][$trace][
'ckitem'] =
2401 hcu_encrypturl(
"{$Cu}|{$getacct}|${accounttype}|${cert}|${drow['tracenumber']}",$chk_key);
2402 $history[$Acctid][$trace][
'ckhash'] =
2403 sha1(
"{$Cu}{$getacct}{$accounttype}{$cert}{$drow['tracenumber']}cierto");
2407 $history[$Acctid][$trace][
'description'] = $drow[
'description'];
2408 $history[$Acctid][$trace][
'traceno'] = $drow[
'tracenumber'];
2417 list($gettbl,$getacct,$getloan) = explode(
"|",$Acctid);
2419 # set the default loan sort order 2420 $lorderby =
" order by date desc, tracenumber desc";
2422 # none of the loan sort order flags change the ln history sort 2423 $ln_bal =
"select currentbalance, 2424 (select sum(principleamount) from {$Cu}loanhistory 2425 where accountnumber='" . prep_save($getacct) .
"' and loannumber='" . prep_save($getloan) .
"' 2426 and date >'" . prep_save($sqlend) .
" 23:59:59' 2428 from {$Cu}loanbalance 2429 where accountnumber='" . prep_save($getacct) .
"' 2430 and loannumber='" . prep_save($getloan) .
"' ";
2432 $sthbal = db_query($ln_bal,$dbh);
2435 # error, query failed 2436 $history[
'status'][
'code'] =
'999';
2437 $history[
'status'][
'severity'] =
'ERROR';
2438 $history[
'status'][
'errors'][] = db_last_error();
2439 $history[
'status'][
'errors'][] =
"$ln_bal";
2442 $drow = db_fetch_array($sthbal,0);
2443 $seedbal = ($currentdate == $sqlend ? $drow[
'currentbalance'] : $drow[
'currentbalance'] - $drow[
'txnsum']);
2448 $ln_sql =
"select trim(loannumber) as loannumber, 2449 to_char(date,'YYYY-MM-DD') as ymddate, 2450 principleamount as principle, 2451 interestamount as interest, 2453 trim(description) as description, 2454 trim(tracenumber) as tracenumber ";
2456 if (($Fset2 & $GLOBALS[
'CU2_ESCHEMA']) == $GLOBALS[
'CU2_ESCHEMA'] )
2457 $ln_sql .=
",fee as fee, escrow as escrow";
2459 $ln_sql .=
" from {$Cu}loanhistory 2460 where accountnumber='" . prep_save($getacct) .
"' 2461 and loannumber='" . prep_save($getloan) .
"'";
2463 $ln_sql .= $date_clause;
2464 $ln_sql .= $lorderby;
2466 $sthln = db_query($ln_sql,$dbh);
2469 # error, query failed 2470 $history[
'status'][
'code'] =
'999';
2471 $history[
'status'][
'severity'] =
'ERROR';
2472 $history[
'status'][
'errors'][] = db_last_error();
2473 $history[
'status'][
'errors'][] = $ln_sql;
2476 $history[
'status'][
'code'] =
'000';
2477 $history[
'status'][
'severity'] =
'SUCCESS';
2478 $history[
'status'][
'startdate'] = $sqlstart;
2479 $history[
'status'][
'stopdate'] = $sqlend;
2480 $history[
'status'][
'txnsum'] = $drow[
'txnsum'];
2481 $history[
'status'][
'startbal'] = $drow[
'currentbalance'];
2482 $history[
'status'][
'seedbal'] = $seedbal;
2484 if (($Fset & $GLOBALS[
'CU_CALCRUNBAL']) == $GLOBALS[
'CU_CALCRUNBAL'] )
2487 for ($row=0;$drow = db_fetch_array($sthln,$row);$row++) {
2491 $drow[
'description'] = utf8_encode($drow[
'description']);
2492 $loan = $drow[
'loannumber'];
2493 $trace =
"T" . $drow[
'tracenumber'];
2495 if (strpos($loan,
"@")) {
2504 if (($Fset2 & $GLOBALS[
'CU2_ESCHEMA']) == $GLOBALS[
'CU2_ESCHEMA'] ) {
2505 if (($Fset2 & $GLOBALS[
'CU2_SHOW_LN_ESCROW']) == $GLOBALS[
'CU2_SHOW_LN_ESCROW'])
2506 $escrow=$drow[
'escrow'];
2508 if (($Fset2 & $GLOBALS[
'CU2_SHOW_LN_FEE']) == $GLOBALS[
'CU2_SHOW_LN_FEE'])
2512 $principle = $drow[
'principle'];
2513 $principle = str_replace(
",",
"",str_replace(
"$",
"",$principle));
2514 $interest = $drow[
'interest'];
2515 $interest = str_replace(
",",
"",str_replace(
"$",
"",$interest));
2516 $escrow = str_replace(
",",
"",str_replace(
"$",
"",$escrow));
2517 $fee = str_replace(
",",
"",str_replace(
"$",
"",$fee));
2519 if (($Fset & $GLOBALS[
'CU_CALCRUNBAL']) == $GLOBALS[
'CU_CALCRUNBAL'] ) {
2521 $runbal -= $drow[
'principle'];
2523 $balance = $drow[
'balance'];
2526 $balance = str_replace(
",",
"",str_replace(
"$",
"",$balance));
2527 $totalpay = sprintf(
"%.2f",(abs($principle) + abs($interest) + abs($escrow) + abs($fee)));
2528 $principle = sprintf(
"%.2f",$principle);
2529 $interest = sprintf(
"%.2f",$interest);
2530 $escrow = sprintf(
"%.2f",$escrow);
2531 $fee = sprintf(
"%.2f",$fee);
2533 $history[$Acctid][$trace][
'loan'] = $drow[
'loannumber'];
2534 $history[$Acctid][$trace][
'traceno'] = $drow[
'tracenumber'];
2536 if (($Fset & $GLOBALS[
'CU_SHOWLNTXNDESC']) == $GLOBALS[
'CU_SHOWLNTXNDESC'])
2537 $history[$Acctid][$trace][
'description'] = $drow[
'description'];
2540 $history[$Acctid][$trace][
'date'] = $drow[
'ymddate'];
2542 if (($Fset2 & $GLOBALS[
'CU2_ESCHEMA']) == $GLOBALS[
'CU2_ESCHEMA']
2543 && ($Fset2 & $GLOBALS[
'CU2_SHOW_LN_ESCROW']) == $GLOBALS[
'CU2_SHOW_LN_ESCROW'])
2544 $history[$Acctid][$trace][
'escrow'] = $escrow;
2546 if (($Fset2 & $GLOBALS[
'CU2_ESCHEMA']) == $GLOBALS[
'CU2_ESCHEMA']
2547 && ($Fset2 & $GLOBALS[
'CU2_SHOW_LN_FEE']) == $GLOBALS[
'CU2_SHOW_LN_FEE'])
2548 $history[$Acctid][$trace][
'fee'] = $fee;
2550 if (($Fset & $GLOBALS[
'CU_SHOWLNTXNSPLIT'])==$GLOBALS[
'CU_SHOWLNTXNSPLIT']) {
2551 $history[$Acctid][$trace][
'principal'] = $principle;
2552 $history[$Acctid][$trace][
'interest'] = $interest;
2555 $history[$Acctid][$trace][
'totalpay'] = $totalpay;
2557 if (($Fset & $GLOBALS[
'CU_LNBALUNUSABLE'])!=$GLOBALS[
'CU_LNBALUNUSABLE']) {
2558 $history[$Acctid][$trace][
'balance'] = $balance;
2566 # loans shown as credit cards 2567 list($gettbl,$getacct,$getloan) = explode(
"|",$Acctid);
2569 # set the default loan sort order 2570 $lorderby =
" order by date desc, tracenumber desc";
2572 # none of the loan sort order flags change the ln history sort 2573 $cc_bal=
"select currentbalance, 2574 (select sum(principleamount) from {$Cu}loanhistory 2575 where accountnumber='" . prep_save($getacct) .
"' and loannumber='" . prep_save($getloan) .
"' 2576 and date >'" . prep_save($sqlend) .
" 23:59:59' 2578 from {$Cu}loanbalance 2579 where accountnumber='" . prep_save($getacct) .
"' 2580 and loannumber='" . prep_save($getloan) .
"' ";
2582 $sthbal = db_query($cc_bal,$dbh);
2585 # error, query failed 2586 $history[
'status'][
'code'] =
'999';
2587 $history[
'status'][
'severity'] =
'ERROR';
2588 $history[
'status'][
'errors'][] = db_last_error();
2589 $history[
'status'][
'errors'][] =
"$cc_bal";
2592 $drow = db_fetch_array($sthbal,0);
2593 $seedbal = ($currentdate == $sqlend ? $drow[
'currentbalance'] : $drow[
'currentbalance'] - $drow[
'txnsum']);
2598 $cc_sql=
"select trim(loannumber) as loannumber, 2599 to_char(date,'YYYY-MM-DD') as ymddate, 2600 principleamount as principle, 2601 interestamount as interest, 2602 trim(tracenumber) as tracenumber, 2604 trim(description) as description ";
2606 if (($Fset2 & $GLOBALS[
'CU2_ESCHEMA']) == $GLOBALS[
'CU2_ESCHEMA'])
2607 $cc_sql .=
",fee as fee";
2609 $cc_sql .=
" from {$Cu}loanhistory 2610 where accountnumber='" . prep_save($getacct) .
"' and loannumber = '" . prep_save($getloan) .
"' ";
2611 $cc_sql .= $date_clause;
2612 $cc_sql .= $lorderby;
2614 $sthcc = db_query($cc_sql,$dbh);
2617 # error, query failed 2618 $history[
'status'][
'code'] =
'999';
2619 $history[
'status'][
'severity'] =
'ERROR';
2620 $history[
'status'][
'errors'][] = db_last_error();
2621 $history[
'status'][
'errors'][] = $cc_sql;
2624 $history[
'status'][
'code'] =
'000';
2625 $history[
'status'][
'severity'] =
'SUCCESS';
2626 $history[
'status'][
'startdate'] = $sqlstart;
2627 $history[
'status'][
'stopdate'] = $sqlend;
2628 $history[
'status'][
'txnsum'] = $drow[
'txnsum'];
2629 $history[
'status'][
'startbal'] = $drow[
'currentbalance'];
2630 $history[
'status'][
'seedbal'] = $seedbal;
2632 if (($Fset & $GLOBALS[
'CU_CALCRUNBAL']) == $GLOBALS[
'CU_CALCRUNBAL'] )
2635 for ($row=0;$drow = db_fetch_array($sthcc,$row);$row++) {
2639 $drow[
'description'] = utf8_encode($drow[
'description']);
2640 $loan = $drow[
'loannumber'];
2641 $trace =
"T" . $drow[
'tracenumber'];
2643 $history[$Acctid][$trace][
'loan'] = $drow[
'loannumber'];
2644 $history[$Acctid][$trace][
'traceno'] = $drow[
'tracenumber'];
2646 if (($Fset & $GLOBALS[
'CU_SHOWLNTXNDESC'])==$GLOBALS[
'CU_SHOWLNTXNDESC'])
2647 $history[$Acctid][$trace][
'description']=$drow[
'description'];
2650 $history[$Acctid][$trace][
'date']=$drow[
'ymddate'];
2652 if (($Fset & $GLOBALS[
'CU_CALCRUNBAL']) == $GLOBALS[
'CU_CALCRUNBAL'] ) {
2654 $runbal -= $drow[
'principle'];
2657 $balance = $drow[
'balance'];
2660 $principle = $drow[
'principle'];
2661 $interest = $drow[
'interest'];
2662 $description = $drow[
'description'];
2665 if (($Fset2 & $GLOBALS[
'CU2_ESCHEMA']) == $GLOBALS[
'CU2_ESCHEMA']) {
2666 if (($Fset2 & $GLOBALS[
'CU2_SHOW_LN_FEE']) == $GLOBALS[
'CU2_SHOW_LN_FEE'])
2670 $principle = str_replace(
",",
"",str_replace(
"$",
"",$principle));
2671 $interest = str_replace(
",",
"",str_replace(
"$",
"",$interest));
2672 $fee = str_replace(
",",
"",str_replace(
"$",
"",$fee));
2673 $totalpay = sprintf(
"%.2f",(abs($principle) + abs($interest) + abs($fee)));
2674 $principle = sprintf(
"%.2f",$principle);
2675 $interest = sprintf(
"%.2f",$interest);
2676 $fee = sprintf(
"%.2f",$fee);
2678 if (($Fset2 & $GLOBALS[
'CU2_ESCHEMA']) == $GLOBALS[
'CU2_ESCHEMA'] && ($Fset2 & $GLOBALS[
'CU2_SHOW_LN_FEE']) == $GLOBALS[
'CU2_SHOW_LN_FEE'])
2679 $history[$Acctid][$trace][
'fee'] = $fee;
2681 if (($Fset & $GLOBALS[
'CU_SHOWLNTXNSPLIT'])==$GLOBALS[
'CU_SHOWLNTXNSPLIT']) {
2682 $history[$Acctid][$trace][
'principal'] = $principle;
2683 $history[$Acctid][$trace][
'interest'] = $interest;
2686 $history[$Acctid][$trace][
'totalpay'] = $totalpay;
2687 if (($Fset & $GLOBALS[
'CU_LNBALUNUSABLE'])!=$GLOBALS[
'CU_LNBALUNUSABLE']) {
2688 $history[$Acctid][$trace][
'balance']=$balance;
2696 # unknown account requested, set error 2710 function Get_PendTotal($dbh,$HB_ENV,$Acctid) {
2712 $Cu = $HB_ENV[
'Cu'];
2713 $Fset2 = $HB_ENV[
'Fset2'];
2716 if (($Fset2 & $GLOBALS[
'CU2_SHOWPEND']) != $GLOBALS[
'CU2_SHOWPEND']) {
2717 $pending[
'status'][
'code'] =
'100';
2718 $pending[
'status'][
'severity'] =
'INFO';
2719 $pending[
'status'][
'message'] =
'Feature Not Activated';
2723 $tbl=substr($Acctid,0,1);
2731 list($gettbl,$getacct,$gettype,$getcert) = explode(
"|",$Acctid);
2732 $getcert =
" and certnumber=" . prep_save(intval($getcert)) .
" ";
2733 $gethold =
" and holdtype = 'd' ";
2735 } elseif ($tbl ==
'L' || $tbl ==
'C') {
2736 list($gettbl,$getacct,$gettype) = explode(
"|",$Acctid);
2738 $gethold =
" and holdtype = 'l' ";
2741 $dp_sql=
"select sum(amount) as total 2743 where accountnumber='" . prep_save($getacct) .
"' 2744 and accounttype='" . prep_save($gettype) .
"' $gethold $getcert";
2746 $sthdp = db_query($dp_sql,$dbh);
2749 # error, query failed 2750 $pending[
'status'][
'code'] =
'999';
2751 $pending[
'status'][
'severity'] =
'ERROR';
2752 $pending[
'status'][
'errors'][] = db_last_error();
2755 $pending[
'status'][
'code'] =
'000';
2756 $pending[
'status'][
'severity'] =
'SUCCESS';
2758 for ($row=0;$drow = db_fetch_array($sthdp,$row);$row++) {
2759 $total = $drow[
'total'];
2760 $total = sprintf(
"%.2f",$total);
2761 $pending[
"$Acctid"][
'total'] = $total;
2767 # unknown account requested, set error 2768 $pending[
'status'][
'code'] =
'999';
2769 $pending[
'status'][
'severity'] =
'ERROR';
2770 $pending[
'status'][
'errors'][] =
'Unknown Account Requested';
2785 function Get_PendDetails($dbh,$HB_ENV,$Acctid) {
2787 $Cu = $HB_ENV[
'Cu'];
2788 $Fset2 = $HB_ENV[
'Fset2'];
2791 if (($Fset2 & $GLOBALS[
'CU2_SHOWPEND']) != $GLOBALS[
'CU2_SHOWPEND']) {
2792 $history[
'status'][
'code'] =
'100';
2793 $history[
'status'][
'severity'] =
'INFO';
2794 $history[
'status'][
'message'] =
'Feature Not Activated';
2797 $tbl=substr($Acctid,0,1);
2805 list($gettbl,$getacct,$gettype,$getcert) = explode(
"|",$Acctid);
2806 $getcert =
" and certnumber=" . prep_save(intval($getcert)) .
" ";
2807 $gethold =
" and holdtype = 'd' ";
2809 } elseif ($tbl ==
'L' || $tbl ==
'C') {
2810 list($gettbl,$getacct,$gettype) = explode(
"|",$Acctid);
2812 $gethold=
" and holdtype = 'l' ";
2815 # accounttype,certnumber,date desc, tracenumber desc 2816 #$orderby = "order by accounttype, certnumber, date desc, tracenumber desc"; 2826 $orderby =
"order by expiredate desc, tracenumber desc";
2828 $dp_sql=
"select trim(h.accounttype) as accounttype, 2829 h.certnumber, trim(h.accountnumber) as accountnumber, 2830 to_char(h.expiredate,'YYYY-MM-DD') as expiredate, 2832 trim(h.description) as description, 2833 trim(h.tracenumber) as tracenumber 2835 INNER JOIN {$Cu}memberacct ma ON ma.accountnumber = h.accountnumber 2836 AND coalesce(ma.restrictions, '') != 'L' 2837 where h.accountnumber='" . prep_save($getacct) .
"' 2838 and h.accounttype='" . prep_save($gettype) .
"' ";
2839 $dp_sql .=
"$getcert $gethold $orderby";
2841 $sthdp = db_query($dp_sql,$dbh);
2844 # error, query failed 2845 $history[
'status'][
'code'] =
'999';
2846 $history[
'status'][
'severity'] =
'ERROR';
2847 $history[
'status'][
'errors'][] = db_last_error();
2850 $history[
'status'][
'code'] =
'000';
2851 $history[
'status'][
'severity'] =
'SUCCESS';
2853 for ($row=0;$drow = db_fetch_array($sthdp,$row);$row++) {
2855 $accounttype = $drow[
'accounttype'];
2856 $acct = $drow[
'accountnumber'];
2857 $trace =
"T" . $drow[
'tracenumber'];
2858 $amount = $drow[
'amount'];
2859 $amount = sprintf(
"%.2f",$amount);
2862 $cert = $drow[
'certnumber'];
2863 $tblkey =
"$tbl|$acct|$accounttype|$cert";
2865 $tblkey =
"$tbl|$acct|$accounttype";
2868 $history[
"$tblkey"][$trace][
'accounttype'] = $drow[
'accounttype'];
2871 $history[
"$tblkey"][$trace][
'certnumber'] = $drow[
'certnumber'];
2874 $history[
"$tblkey"][$trace][
'amount'] = $amount;
2879 $history[
"$tblkey"][$trace][
'postdate'] = $drow[
'expiredate'];
2880 $history[
"$tblkey"][$trace][
'description'] = $drow[
'description'];
2881 $history[
"$tblkey"][$trace][
'traceno'] = $drow[
'tracenumber'];
2888 # unknown account requested, set error 2889 $history[
'status'][
'code'] =
'999';
2890 $history[
'status'][
'severity'] =
'ERROR';
2891 $history[
'status'][
'errors'][] =
'Unknown Account Requested';
2905 function Get_HoldTotal($dbh,$HB_ENV,$Acctid) {
2907 $Cu = $HB_ENV[
'Cu'];
2908 $Fset2 = $HB_ENV[
'Fset2'];
2911 if (($Fset2 & $GLOBALS[
'CU2_SHOWHOLD']) != $GLOBALS[
'CU2_SHOWHOLD'] ) {
2912 $pending[
'status'][
'code'] =
'100';
2913 $pending[
'status'][
'severity'] =
'INFO';
2914 $pending[
'status'][
'message'] =
'Feature Not Activated';
2918 $tbl=substr($Acctid,0,1);
2926 list($gettbl,$getacct,$gettype,$getcert) = explode(
"|",$Acctid);
2927 $getcert=
" and certnumber=" . prep_save(intval($getcert)) .
" ";
2928 $gethold=
" and holdtype = 'D' ";
2930 } elseif ($tbl ==
'L' || $tbl ==
'C') {
2931 list($gettbl,$getacct,$gettype) = explode(
"|",$Acctid);
2933 $gethold=
" and holdtype = 'L' ";
2936 $dp_sql=
"select sum(amount) as total 2938 where accountnumber='" . prep_save($getacct) .
"' 2939 and accounttype='" . prep_save($gettype) .
"' $gethold $getcert";
2941 $sthdp = db_query($dp_sql,$dbh);
2944 # error, query failed 2945 $pending[
'status'][
'code'] =
'999';
2946 $pending[
'status'][
'severity'] =
'ERROR';
2947 $pending[
'status'][
'errors'][] = db_last_error();
2950 $pending[
'status'][
'code'] =
'000';
2951 $pending[
'status'][
'severity'] =
'SUCCESS';
2953 for ($row=0;$drow=db_fetch_array($sthdp,$row);$row++) {
2955 $total = $drow[
'total'];
2956 $total = sprintf(
"%.2f",$total);
2957 $pending[
"$Acctid"][
'total'] = $total;
2963 # unknown account requested, set error 2964 $pending[
'status'][
'code'] =
'999';
2965 $pending[
'status'][
'severity'] =
'ERROR';
2966 $pending[
'status'][
'errors'][] =
'Unknown Account Requested';
2981 function Get_HoldDetails($dbh,$HB_ENV,$Acctid) {
2983 $Cu = $HB_ENV[
'Cu'];
2984 $Fset2 = $HB_ENV[
'Fset2'];
2987 if (($Fset2 & $GLOBALS[
'CU2_SHOWHOLD']) != $GLOBALS[
'CU2_SHOWHOLD']) {
2988 $history[
'status'][
'code'] =
'100';
2989 $history[
'status'][
'severity'] =
'INFO';
2990 $history[
'status'][
'message'] =
'Feature Not Activated';
2994 $tbl=substr($Acctid,0,1);
3002 list($gettbl,$getacct,$gettype,$getcert) = explode(
"|",$Acctid);
3003 $getcert=
" and certnumber=" . prep_save(intval($getcert)) .
" ";
3004 $gethold=
" and holdtype = 'D' ";
3006 } elseif ($tbl ==
'L' || $tbl ==
'C') {
3007 list($gettbl,$getacct,$gettype) = explode(
"|",$Acctid);
3009 $gethold=
" and holdtype = 'L' ";
3012 # accounttype,certnumber,date desc, tracenumber desc 3013 $orderby =
"order by postdate desc, tracenumber desc";
3015 $dp_sql=
"select trim(h.accounttype) as accounttype, 3017 to_char(h.postdate,'YYYY-MM-DD') as postdate, 3019 trim(h.description) as description, 3020 trim(h.tracenumber) as tracenumber 3022 INNER JOIN {$Cu}memberacct ma ON ma.accountnumber = h.accountnumber 3023 AND coalesce(ma.restrictions, '') != 'L' 3024 where h.accountnumber='" . prep_save($getacct) .
"' 3025 and h.accounttype='" . prep_save($gettype) .
"' ";
3027 $dp_sql .=
"$getcert $gethold $orderby";
3028 $sthdp = db_query($dp_sql,$dbh);
3031 # error, query failed 3032 $history[
'status'][
'code'] =
'999';
3033 $history[
'status'][
'severity'] =
'ERROR';
3034 $history[
'status'][
'errors'][] = db_last_error();
3037 $history[
'status'][
'code'] =
'000';
3038 $history[
'status'][
'severity'] =
'SUCCESS';
3040 for ($row=0;$drow = db_fetch_array($sthdp,$row);$row++) {
3042 $accounttype = $drow[
'accounttype'];
3043 $trace =
"T" . $drow[
'tracenumber'];
3044 $amount = $drow[
'amount'];
3045 $amount = sprintf(
"%.2f",$amount);
3048 $cert = $drow[
'certnumber'];
3049 $tblkey =
"$tbl|$getacct|$accounttype|$cert";
3051 $tblkey =
"$tbl|$getacct|$accounttype";
3054 $history[
"$tblkey"][$trace][
'accounttype'] = $drow[
'accounttype'];
3057 $history[
"$tblkey"][$trace][
'certnumber']=$drow[
'certnumber'];
3060 $history[
"$tblkey"][$trace][
'amount'] = $amount;
3061 $history[
"$tblkey"][$trace][
'postdate'] = $drow[
'postdate'];
3062 $history[
"$tblkey"][$trace][
'description'] = $drow[
'description'];
3063 $history[
"$tblkey"][$trace][
'traceno'] = $drow[
'tracenumber'];
3069 # unknown account requested, set error 3070 $history[
'status'][
'code'] =
'999';
3071 $history[
'status'][
'severity'] =
'ERROR';
3072 $history[
'status'][
'errors'][] =
'Unknown Account Requested';
3079 function Get_OverMicr($dbh,$HB_ENV,$Acctid) {
3080 # returns array of micr settings and overrides for member 3083 $Fset=$HB_ENV[
'Fset'];
3084 $Fset2=$HB_ENV[
'Fset2'];
3087 list($gettbl,$getacct,$gettype,$getcert) = explode(
"|",$Acctid);
3093 if (($Fset & $GLOBALS[
'CU_SHOWIMAGES']) != $GLOBALS[
'CU_SHOWIMAGES']) {
3094 # return error -- cu not set for images 3095 $micrs[
'status'][
'code']=
'999';
3096 $micrs[
'status'][
'severity']=
'ERROR';
3097 $micrs[
'status'][
'errors'][]=
"CU not set up for image retrieval";
3099 # adjust this to send back the default settings as well as overrides 3100 #$sql = "select trim(rt), trim(img) from cuadmin where cu='$Cu'"; 3102 $sql =
"select trim(accounttype), trim(rt), trim(micraccount) 3103 from {$Cu}accountbalance, cuadmin 3104 where cu='$Cu' and deposittype='Y' and accountnumber='$getacct' 3105 and accounttype='$gettype' and certnumber=$getcert";
3107 $sth = db_query($sql,$dbh);
3108 if (db_num_rows($sth) == 0 ) {
3109 # return error -- account not found 3110 $micrs[
'status'][
'code']=
'999';
3111 $micrs[
'status'][
'severity']=
'ERROR';
3112 $micrs[
'status'][
'errors'][]=
"Account not found";
3114 list($osfx, $ort, $omicr) = db_fetch_array($sth,0);
3116 $micrs[
'prime'][
'accounttype'] =
"$osfx";
3117 $micrs[
'prime'][
'rt'] =
"$ort";
3118 $micrs[
'prime'][
'micr'] =
"$omicr";
3120 $sql =
"select trim(accounttype), trim(rt), 3121 trim(micraccount), startcheck 3122 from cuovermicr where cu='$Cu' and accountnumber='$getacct' 3123 and accounttype='$gettype' 3124 order by startcheck desc";
3125 $sth = db_query($sql,$dbh);
3127 for ($row=0;list($osfx, $ort, $omicr, $ostart) =
3128 db_fetch_array($sth,$row); $row++) {
3129 $micrs[
'oride'][$row][
'accounttype'] =
"$osfx";
3130 $micrs[
'oride'][$row][
'rt'] =
"$ort";
3131 $micrs[
'oride'][$row][
'micr'] =
"$omicr";
3132 $micrs[
'oride'][$row][
'startcheck'] = $ostart;
3139 function Get_PrimaryChecking($dbh, $HB_ENV) {
3140 # returns list of checking accounts w/ non-blank micrs 3144 # includes primary accounts only (accounttype not containing '@') 3146 $Cu = $HB_ENV[
'Cu'];
3147 $Cn = $HB_ENV[
'Cn'];
3150 $sql =
"select trim(accountnumber) as accountnumber, 3151 trim(accounttype) as accounttype, 3153 trim(description) as description, 3154 trim(micraccount) as micraccount 3155 from ${Cu}accountbalance 3156 where accountnumber='$Cn' and deposittype='Y' 3157 and accounttype not like '%@%' 3160 # Run the sql and see if we got anything 3162 $sthdp = db_query($sql, $dbh);
3164 if (db_num_rows($sthdp)) {
3165 for ($row = 0; $drow = db_fetch_array($sthdp, $row); $row++) {
3168 $drow[
'description'] = utf8_encode($drow[
'description']);
3170 $accounttype = $drow[
'accounttype'];
3171 $cert = $drow[
'certnumber'];
3172 $micraccount = $drow[
'micraccount'];
3173 if (strpos($accounttype,
"@")) {
3178 if (trim($micraccount) ==
'') {
3179 $sqlmicr =
"select trim(o.micraccount) as omicr 3180 from cuovermicr o join cuadmin a on o.cu = a.cu 3181 where o.cu='$Cu' and o.accountnumber='$Cn' 3182 and o.accounttype='$accounttype' and o.rt=a.rt 3183 order by o.startcheck desc limit 1";
3184 $sthmicr = db_query($sqlmicr, $dbh);
3185 if (db_num_rows($sthmicr) == 1) {
3186 list ($micraccount) = db_fetch_row($sthmicr, 0);
3187 $drow[
'micraccount'] = $micraccount;
3190 if (trim($micraccount) !=
'') {
3191 $accts[
'dp'][
"D|$Cn|$accounttype|$cert"][
'accounttype'] = $drow[
'accounttype'];
3192 $accts[
'dp'][
"D|$Cn|$accounttype|$cert"][
'certnumber'] = $drow[
'certnumber'];
3193 $accts[
'dp'][
"D|$Cn|$accounttype|$cert"][
'description'] = $drow[
'description'];
3194 $accts[
'dp'][
"D|$Cn|$accounttype|$cert"][
'micraccount'] = $drow[
'micraccount'];
3195 $accts[
'dp'][
"D|$Cn|$accounttype|$cert"][
'trust'] =
"$trust";
3196 $accts[
'dp'][
"D|$Cn|$accounttype|$cert"][
'displaydesc'] =
3197 ($cert == 0 ?
"{$drow['description']} - $accounttype" :
"{$drow['description']} # $cert - $accounttype");
3201 if (
sizeof($accts[
'dp'])) {
3202 $accts[
'status'][
'code'] =
'000';
3203 $accts[
'status'][
'severity'] =
'SUCCESS';
3206 $accts[
'status'][
'code'] =
'999';
3207 $accts[
'status'][
'severity'] =
'ERROR';
3208 $accts[
'status'][
'errors'][] =
'No Accounts Available';
3215 function CheckIfAccountLocked( $dbh, $currCU, $accountNumber ) {
3219 $accountSQL =
"SELECT restrictions 3220 FROM {$currCU}memberacct 3221 WHERE accountnumber = '$accountNumber'";
3223 $rs = db_query( $accountSQL, $dbh );
3225 dmserror( $DMSMAIL,
"WARN",
"Unable to read {$currCU}memberacct for account $accountNumber. \n" . db_last_error() );
3227 $accountRow = db_fetch_assoc( $rs );
3229 $lockStatus = trim( $accountRow[
"restrictions"] );
3238 function SortEstmt( $a, $b ) {
3239 $result = strcmp( $b[
"PerEnd"], $a[
"PerEnd"] );
3240 if ( $result == 0 ) {
3241 $result = strcmp( $a[
"PerDesc"], $b[
"PerDesc"] );
3282 function Get_Estmt($dbh, $HB_ENV, $MC, $pAcct) {
3283 # not finished with this, but moving on... 3284 # needs to check cuthird for field list override, 3285 # populate 'Wait' message (estmt_flag=Y but no statement file) 3286 # use mobile fragments instead of desktop 3287 $Cu = $HB_ENV[
'Cu'];
3288 $Cn = $HB_ENV[
'Cn'];
3289 $Flang = $HB_ENV[
'Flang'];
3290 $chome = $HB_ENV[
'chome'];
3291 $email = $HB_ENV[
'Ml'];
3292 $live = $HB_ENV[
'live'];
3295 $stmt = Get_EstmtEnrollStatus($dbh, $HB_ENV, $MC, $pAcct);
3296 if ($stmt[
'status'][
'code'] ===
'000') {
3301 # populate list of PDF links to be offered 3302 $pdfnews =
"/home/$chome/public_html/pdf/newsletter.pdf";
3303 $pdfkids =
"/home/$chome/public_html/pdf/kidsnews.pdf";
3304 $pdfprime =
"/home/$chome/public_html/pdf/primenews.pdf";
3305 $pdfsenior =
"/home/$chome/public_html/pdf/seniornews.pdf";
3306 $pdfteen =
"/home/$chome/public_html/pdf/teennews.pdf";
3307 $pdfins =
"/home/$chome/public_html/pdf/insert.pdf";
3308 $pdffee =
"/home/$chome/public_html/pdf/fees.pdf";
3309 $pdfprivacy =
"/home/$chome/public_html/pdf/privacy.pdf";
3310 $pdfpath = $HB_ENV[
"fi_path"] .
"pdf";
3312 $pdflinks = array();
3313 if (is_readable(
"$pdfnews")) {
3314 $title = $MC->msg(
'Newsletter');
3315 $pdflinks[] = array(
'pdftitle' => $title,
'pdfpath' =>
"$pdfpath/newsletter.pdf");
3318 if (is_readable(
"$pdfkids")) {
3319 $title = $MC->msg(
'Youth Newsletter');
3320 $pdflinks[] = array(
'pdftitle' => $title,
'pdfpath' =>
"$pdfpath/kidsnews.pdf");
3323 if (is_readable(
"$pdfteen")) {
3324 $title = $MC->msg(
'Teen Newsletter');
3325 $pdflinks[] = array(
'pdftitle' => $title,
'pdfpath' =>
"$pdfpath/teennews.pdf");
3328 if (is_readable(
"$pdfprime")) {
3329 $title = $MC->msg(
'Prime Newsletter');
3330 $pdflinks[] = array(
'pdftitle' => $title,
'pdfpath' =>
"$pdfpath/primenews.pdf");
3333 if (is_readable(
"$pdfsenior")) {
3334 $title = $MC->msg(
'Senior Newsletter');
3335 $pdflinks[] = array(
'pdftitle' => $title,
'pdfpath' =>
"$pdfpath/seniornews.pdf");
3339 if (is_readable(
"$pdfins")) {
3340 $title = $MC->msg(
'Statement Insert');
3341 $pdflinks[] = array(
'pdftitle' => $title,
'pdfpath' =>
"$pdfpath/insert.pdf");
3345 if (is_readable(
"$pdffee")) {
3346 $title = $MC->msg(
'Fee Schedule');
3347 $pdflinks[] = array(
'pdftitle' => $title,
'pdfpath' =>
"$pdfpath/fees.pdf");
3351 if (is_readable(
"$pdfprivacy")) {
3352 $title = $MC->msg(
'Privacy Policy');
3353 $pdflinks[] = array(
'pdftitle' => $title,
'pdfpath' =>
"$pdfpath/privacy.pdf");
3357 $estmt = $stmt[
'status'][
'estmt'];
3361 if ( $HB_ENV[
"Fset3"] & GetFlagsetValue(
"CU3_ESTMNT_CORE") ) {
3364 'member' =>
"$pAcct" 3367 $getEsResp = GetMemberES($HB_ENV, $mbrData);
3369 if ($getEsResp[
'code'] !=
'000') {
3370 $reason = $getEsResp[
'error'];
3371 $errorMsg = $MC->msg(
'Unable retrieve estatement') .
" $reason";
3372 throw new Exception( $errorMsg );
3374 $TOC = HCU_array_key_value(
"TOC", $getEsResp[
"data"]);
3376 for ( $i = 0; $i < count( $TOC ); $i++ ) {
3377 $PerDesc = $TOC[$i][
"Description"];
3378 $PerId = $TOC[$i][
"ID"];
3379 $PerTokn = sha1(
"{$Cn}{$PerDesc}{$Cu}");
3380 $PerEnd = $TOC[$i][
"PeriodEnd"];
3381 $PerType = $TOC[$i][
"Type"];
3386 $PeriodType =
'Monthly';
3390 $PeriodType =
'Quarterly';
3394 $PeriodType =
'Semi-Annual';
3397 $PeriodType =
'Tax Form';
3400 $PeriodType =
'Unknown';
3405 $PeriodEnd = str_replace(array(
'/',
'-'),
'', $PerEnd);
3406 $PeriodEnd = substr( $PeriodEnd, 0, 6 );
3407 $toclinks[] = array(
"PerDesc" =>
"$PerDesc",
"PerType" =>
"$PeriodType",
"PerTypeText" => $MC->msg($PeriodType, HCU_DISPLAY_AS_RAW),
3408 "PerEnd" =>
"$PeriodEnd",
"PerKey" =>
"$PerId",
"PerTokn" => $PerTokn);
3411 $stmntdir =
"/home/$chome/stmnt/history/";
3412 $stmntdir .= substr($pAcct, 0, 1);
3413 $stmntfile =
"$stmntdir/$pAcct";
3415 if (is_readable($stmntfile)) {
3416 $toclinks = array();
3419 $zp = gzopen($stmntfile,
"r");
3422 $TOCmark = gzgets($zp, 4096);
3425 while ($buf = gzgets($zp, 4096)) {
3426 $buf = preg_replace(
"/^> /",
"", $buf);
3427 if (trim($buf) ==
"") {
continue; }
3428 if ($buf == $TOCmark) {
3431 list($bd, $ldTime, $ldProc, $PerEnd, $PerType, $PerDesc) = explode(
"\t", $buf);
3432 if (
"$ldTime" !=
"") {
3433 $tokn = sha1(
"${Cn}${PerDesc}${Cu}");
3434 $perid = urlencode(rtrim($buf));
3436 $perdesc =
"$PerDesc";
3440 $pertype =
'Monthly';
3444 $pertype =
'Quarterly';
3448 $pertype =
'Semi-Annual';
3451 $pertype =
'Tax Form';
3454 $toclinks[] = array(
"PerDesc" =>
"$perdesc",
"PerType" =>
"$pertype",
"PerTypeText" => $MC->msg($pertype, HCU_DISPLAY_AS_RAW),
3455 "PerEnd" =>
"$PerEnd",
"PerKey" =>
"$perid",
"PerTokn" => $pertokn);
3464 # populate 'Click Here to enroll' msg noestmntfrag.html 3467 $stmt[
'status'][
'code'] =
'000';
3468 $stmt[
'status'][
'severity'] =
'INFO';
3469 $stmt[
'estmt'][
'enrolled'] = $estmt;
3473 $stmt[
'status'][
'estmt'] = $estmt;
3475 $stmt[
'estmt'][
'pdflinks'] = $pdflinks;
3476 if ($estmt ==
'Y') {
3477 if (is_array($toclinks)) {
3478 usort( $toclinks,
"SortEstmt" );
3480 $stmt[
'estmt'][
'toclinks'] = $toclinks;
3482 }
catch (Exception $e) {
3483 $stmt[
'status'][
'code'] =
'999';
3484 $stmt[
'status'][
'severity'] =
'ERROR';
3485 $stmt[
'status'][
'errors'][] = $e->getMessage();
3486 $stmt[
'estmt'] = array();
3526 function Get_EstmtEnrollStatus($dbh, $HB_ENV, $MC, $pAcct) {
3527 # not finished with this, but moving on... 3528 # needs to check cuthird for field list override, 3529 # populate 'Wait' message (estmt_flag=Y but no statement file) 3530 # use mobile fragments instead of desktop 3531 $Cu = $HB_ENV[
'Cu'];
3532 $Cn = $HB_ENV[
'Cn'];
3533 $Flang = $HB_ENV[
'Flang'];
3534 $chome = $HB_ENV[
'chome'];
3535 $email = $HB_ENV[
'Ml'];
3536 $live = $HB_ENV[
'live'];
3541 $sql =
"SELECT email 3543 WHERE cu = '{$HB_ENV['Cu']}' 3544 AND role = 'agree'";
3545 $emRs = db_query($sql, $dbh);
3546 list($notifyEmail) = db_fetch_array($emRs);
3547 db_free_result($emRs);
3551 $sslFormsDir =
"/home/{$HB_ENV['chome']}/sslforms/";
3554 if (trim($notifyEmail) ==
'' || !(is_writable($sslFormsDir))) {
3555 throw new Exception($MC->msg(
'Feature Not Set') .
'. ' . $MC->msg(
'Contact CU'), 1);
3558 if ( ($HB_ENV[
"Fset3"] & GetFlagsetValue(
"CU3_ESTMNT_CORE")) == 0 ) {
3563 $sslStmntDir =
"/home/{$HB_ENV['chome']}/stmnt/";
3564 if (!(is_writable($sslStmntDir))) {
3565 throw new Exception($MC->msg(
'Feature Not Set') .
'. ' . $MC->msg(
'Contact CU'), 2);
3570 $stmt[
'estmt'][
'notifyemail'] = trim($notifyEmail);
3571 $stmt[
'estmt'][
'sslformsdir'] = $sslFormsDir;
3573 $sql =
"select coalesce(estmnt_flag, 'N') 3574 from {$HB_ENV["Cu
"]}memberacct 3575 where accountnumber = '$pAcct'";
3577 $sth = db_query($sql, $dbh);
3579 throw new Exception($MC->msg(
'Unable retrieve estatement') .
': ' . db_last_error(), 3);
3581 list($estmt) = db_fetch_array($sth, 0);
3582 $estmt = (strtoupper($estmt) ==
'Y' ?
'Y' :
'N');
3583 $stmt[
'status'][
'estmt'] = $estmt;
3585 if ($estmt ==
"Y" && !($HB_ENV[
"Fset3"] & GetFlagsetValue(
"CU3_ESTMNT_CORE"))) {
3586 $stmntdir =
"/home/$chome/stmnt/history/";
3587 $stmntdir .= substr($pAcct, 0, 1);
3588 $stmntfile =
"$stmntdir/$pAcct";
3589 if (!is_readable($stmntfile)) {
3594 $stmt[
'status'][
'code'] =
'000';
3595 $stmt[
'status'][
'severity'] =
'INFO';
3596 $stmt[
'estmt'][
'enrolled'] = $estmt;
3600 $stmt[
'status'][
'estmt'] = $estmt;
3602 }
catch (Exception $e) {
3603 $stmt[
'status'][
'code'] =
'999';
3604 $stmt[
'status'][
'severity'] =
'ERROR';
3605 $stmt[
'status'][
'errors'][] = $e->getMessage();
3606 $stmt[
'estmt'] = array();
3612 function Create_PDF_Statement($stId, $pHB_ENV, $pMC, $pAcct) {
3614 $CHome = $pHB_ENV[
"chome"];
3615 $Cu = $pHB_ENV[
"Cu"];
3616 $Cn = $pHB_ENV[
"Cn"];
3627 $pythonUserWarningFlag =
false;
3629 if ($pHB_ENV[
"Fset3"] & GetFlagsetValue(
"CU3_ESTMNT_CORE")) {
3632 'member' =>
"$pAcct",
3633 'statement-id' =>
"$stId" 3636 $getEsResp = GetMemberES($pHB_ENV, $mbrData);
3638 if ($getEsResp[
'code'] ==
'000') {
3639 $fileContents = base64_decode(HCU_array_key_value(
"statement", $getEsResp[
"data"]));
3641 if ($fileContents ==
"") {
3642 $errors[] = $pMC->msg(
'Statement Not Found');
3644 header(
"Content-type: application/pdf");
3645 header(
"Content-Disposition: inline; filename=\"statement.pdf\"");
3646 header(
'Content-Transfer-Encoding: binary');
3648 print $fileContents;
3652 $reason = $getEsResp[
"error"];
3653 $errorMsg = $pMC->msg(
'Unable retrieve estatement') .
" $reason";
3654 $errors[] = $errorMsg;
3658 $stIdParts = explode(
"/", $stId);
3659 $stId = trim($stIdParts[0]);
3660 $stId = urldecode($stId);
3663 $stmntTmp =
"/home/$CHome/tmp";
3664 $stmntDir =
"/home/$CHome/stmnt/history/";
3665 $stmntBaseDir =
"/home/{$CHome}/stmnt/";
3666 $stmntDir .= substr($pAcct, 0, 1);
3667 $fileName =
"{$stmntDir}/{$pAcct}";
3668 $pdfDefsFile =
"/home/$CHome/bin/pdfdefs";
3669 $stPerArray = explode(
"\t", $stId);
3670 $stPerType = $stPerArray[4];
3672 if (substr($stPerType, 0, 1) ==
'C') {
3673 # if credit card statement type, use ccdisclaimer 3674 $disclaimerFile =
"/home/$CHome/bin/disclaimerCC";
3675 }
else if (substr($stPerType, 0, 1) ==
'T') {
3677 $disclaimerFile =
"";
3679 $disclaimerFile =
"/home/$CHome/bin/disclaimer";
3683 $errors[] = $pMC->msg(
'Statement Not Found');
3685 $stmnterrmsg =
"Bad cookie data, empty value for: st_id";
3686 $stmnterrlog = fopen(
"$stmntTmp/statement_retrieve_failure.log",
"a");
3687 chmod(
"$stmntTmp/statement_retrieve_failure.log", 0666);
3688 $stmnterrtime = time();
3689 $stmntexternalref =
"";
3690 fwrite($stmnterrlog, implode(
"\t", array($stmnterrtime, date(
'Y-m-d_H:i:s', $stmnterrtime), getmypid(),
"cu_data.i:Create_PDF_Statement", $CHome, $Cn, $stmntexternalref, $stId, $stmnterrmsg)) .
"\n");
3691 fclose($stmnterrlog);
3692 } elseif (count(explode(
"\t", $stId)) < 6) {
3693 $errors[] = $pMC->msg(
'Statement Not Found');
3695 $stmnterrmsg =
"Bad cookie data, missing TAB delimiters in value for: st_id";
3696 $stmnterrlog = fopen(
"$stmntTmp/statement_retrieve_failure.log",
"a");
3697 chmod(
"$stmntTmp/statement_retrieve_failure.log", 0666);
3698 $stmnterrtime = time();
3699 $stmntexternalref =
"";
3700 fwrite($stmnterrlog, implode(
"\t", array($stmnterrtime, date(
'Y-m-d_H:i:s', $stmnterrtime), getmypid(),
"cu_data.i:Create_PDF_Statement", $CHome, $Cn, $stmntexternalref, $stId, $stmnterrmsg)) .
"\n");
3701 fclose($stmnterrlog);
3702 } elseif (is_readable($fileName)) {
3704 # find the desired statement info (also checks to see if PDF already generated) 3706 $zp = gzopen($fileName,
"rb");
3710 while ($buf = gzgets($zp, 4096)) {
3712 if (trim($buf) == $stId) {
3717 if ($found ==
false) {
3718 $stmnterrmsg =
"Bad cookie data, no matching period found using value for: st_id";
3719 $stmnterrlog = fopen(
"$stmntTmp/statement_retrieve_failure.log",
"a");
3720 chmod(
"$stmntTmp/statement_retrieve_failure.log", 0666);
3721 $stmnterrtime = time();
3722 $stmntexternalref =
"";
3723 fwrite($stmnterrlog, implode(
"\t", array($stmnterrtime, date(
'Y-m-d_H:i:s', $stmnterrtime), getmypid(),
"cu_data.i:Create_PDF_Statement", $CHome, $Cn, $stmntexternalref, $stId, $stmnterrmsg)) .
"\n");
3724 fclose($stmnterrlog);
3733 $myPID = getmypid();
3734 $fpCommandFile = fopen(
"$stmntTmp/t$myPID",
"wb");
3736 if ($fpCommandFile) {
3738 $statementCore =
"";
3741 while ($buf = gzgets($zp, 4096)) {
3742 if (trim($buf) == $stId) {
3747 if (preg_match(
"/^DMS PDF:/", $buf)) {
3748 $pdfExternal =
true;
3754 if (preg_match(
"/^DMS TXT:/", $buf)) {
3755 $txtExternal =
true;
3760 if (preg_match(
"/^DMS~FBG:/", $buf)) {
3763 preg_match(
"/^DMS~FBG:(.+)$/", $buf, $matches);
3764 # discard the marker line - the generation scripts trip on it 3765 $buf = substr($buf,strlen($matches[0])+1);
3766 $fbgPDFScript = trim($matches[1]);
3767 # drop the ending backtic 3768 $fbgPDFScript = substr($fbgPDFScript,0,strlen($fbgPDFScript)-1);
3769 # if script isn't specified, set a default 3770 if (empty($fbgPDFScript)) {
3771 $fbgPDFScript =
"/home/$CHome/bin/pdfFBG.pl";
3775 if (preg_match(
"/^DMS~XML:/", $buf)) {
3777 $pythonUserWarningFlag =
true;
3779 preg_match(
"/^DMS~XML:(.+)$/", $buf, $matches);
3780 # discard the marker line - the generation scripts trip on it 3781 $buf = substr($buf,strlen($matches[0])+1);
3782 $fbgPDFScript = trim($matches[1]);
3783 # drop the ending backtic 3784 $fbgPDFScript = substr($fbgPDFScript,0,strlen($fbgPDFScript)-1);
3785 # if script isn't specified, set a default 3786 if (empty($fbgPDFScript)) {
3787 $fbgPDFScript =
"/usr/local/bin/xmlestatement_generate_otf -dl -b /home/" . strtolower($Cu) .
" OnTheFly " . strtoupper($Cu) .
" pb";
3791 $statementCore .= $buf;
3792 $txtInternal =
true;
3800 preg_match(
"/^DMS PDF:(.+)$/", $buf, $matches);
3801 $retrieveFromS3 =
false;
3805 $externalPDFRef = trim($matches[1]);
3806 $externalPDFFileName = $stmntBaseDir . trim($matches[1]);
3808 if (is_readable($externalPDFFileName)) {
3809 $fileContents = file_get_contents($externalPDFFileName);
3810 if ($fileContents ==
"") {
3811 $retrieveFromS3 =
true;
3812 $fileContents = data_from_EStateGet($externalPDFFileName, $presignurl=$s3Presign);
3815 $retrieveFromS3 =
true;
3816 $fileContents = data_from_EStateGet($externalPDFFileName, $presignurl=$s3Presign);
3818 if ($fileContents ==
"") {
3819 $errors[] = $pMC->msg(
'Statement Not Found');
3821 $stmnterrmsg =
"Failed reading (local and S3) file: $externalPDFFileName";
3822 $stmnterrlog = fopen(
"$stmntTmp/statement_retrieve_failure.log",
"a");
3823 chmod(
"$stmntTmp/statement_retrieve_failure.log", 0666);
3824 $stmnterrtime = time();
3825 $stmntexternalref = $externalPDFRef;
3826 fwrite($stmnterrlog, implode(
"\t", array($stmnterrtime, date(
'Y-m-d_H:i:s', $stmnterrtime), getmypid(),
"cu_data.i:Create_PDF_Statement", $CHome, $Cn, $stmntexternalref, $stId, $stmnterrmsg)) .
"\n");
3827 fclose($stmnterrlog);
3829 if ($s3Presign && $retrieveFromS3) {
3830 header(
"Location: " . $fileContents);
3832 header(
"Content-type: application/pdf");
3833 header(
"Content-Disposition: inline; filename=\"statement.pdf\"");
3834 header(
'Content-Transfer-Encoding: binary');
3835 print $fileContents;
3843 preg_match(
"/^DMS TXT:(.+)$/", $buf, $matches);
3845 $externalTXTRef = trim($matches[1]);
3846 $externalTXTFileName = $stmntBaseDir . trim($matches[1]);
3848 if (is_readable($externalTXTFileName)) {
3849 $statementCore = file_get_contents($externalTXTFileName);
3850 if ($statementCore ==
"") {
3851 $statementCore = data_from_EStateGet($externalTXTFileName);
3854 $statementCore = data_from_EStateGet($externalTXTFileName);
3856 if ($statementCore ==
"") {
3857 $errors[] = $pMC->msg(
'Statement Not Found');
3859 $stmnterrmsg =
"Failed reading (local and S3) file: $externalTXTFileName";
3860 $stmnterrlog = fopen(
"$stmntTmp/statement_retrieve_failure.log",
"a");
3861 chmod(
"$stmntTmp/statement_retrieve_failure.log", 0666);
3862 $stmnterrtime = time();
3863 $stmntexternalref = $externalTXTRef;
3864 fwrite($stmnterrlog, implode(
"\t", array($stmnterrtime, date(
'Y-m-d_H:i:s', $stmnterrtime), getmypid(),
"cu_data.i:Create_PDF_Statement", $CHome, $Cn, $stmntexternalref, $stId, $stmnterrmsg)) .
"\n");
3865 fclose($stmnterrlog);
3869 if ($txtInternal ==
true || ( $txtExternal ==
true && $txtMissing !=
true )) {
3878 if (is_readable($pdfDefsFile) && $txtFBG !=
true) {
3879 $defsFile = file_get_contents($pdfDefsFile);
3883 if ($defsFile !==
false) {
3884 fwrite($fpCommandFile, $defsFile);
3888 fwrite($fpCommandFile, $statementCore);
3890 if (strlen($disclaimerFile) > 0 && is_readable($disclaimerFile) && $txtFBG !=
true) {
3891 $disclaimerFileContents = file_get_contents($disclaimerFile);
3893 if ($defsFile !==
false)
3894 fwrite($fpCommandFile, $disclaimerFileContents);
3896 fclose($fpCommandFile);
3898 if ($txtFBG ==
true) {
3899 list($Tscript,$Topts) = explode(
' ', $fbgPDFScript, 2);
3900 if (!is_executable(
"$Tscript")) {
3901 $errors[] = $pMC->msg(
'Feature Not Set') .
' (missing script)';
3904 if (count($errors) == 0) {
3907 header(
"Content-type: application/pdf");
3908 header(
"Content-Disposition: inline; filename=\"statement.pdf\"");
3909 header(
'Content-Transfer-Encoding: binary');
3911 if ($txtFBG ==
true) {
3912 if ($pythonUserWarningFlag) {
3913 passthru(
"python3 -W ignore::UserWarning $fbgPDFScript $stmntTmp/t$myPID -");
3915 passthru(
"$fbgPDFScript $stmntTmp/t$myPID");
3918 passthru(
"/opt/odyssey/tools/bin/pdffile.cgi $stmntTmp/t$myPID -");
3923 unlink(
"$stmntTmp/t$myPID");
3926 $errors[] = $pMC->msg(
'Statement Not Found');
3930 $errors[] = $pMC->msg(
'Statement Missing');
3934 if (count($errors)) {
3935 $stmt[
"status"][
"code"] =
'999';
3936 $stmt[
"status"][
"severity"] =
'Error';
3937 $stmt[
"estmt"][
"stId"] =
"$stId";
3938 $stmt[
"errors"] = $errors;
3939 $stmt[
"estmt"][
"contents"] =
"";
3941 $stmt[
"status"][
"code"] =
'0';
3942 $stmt[
"status"][
"severity"] =
'INFO';
3948 function data_from_EStateGet( $EStateGet_file, $presignurl=
false ) {
3950 $EStateGet_data =
"";
3952 $cmd =
"/opt/odyssey/tools/bin/EStateGetFromS3.py -f " . $EStateGet_file;
3957 $EStateGet_fd = popen($cmd,
'r');
3958 while ($EStateGet_buf = fread($EStateGet_fd,2096)){
3959 $EStateGet_data .= $EStateGet_buf;
3961 pclose($EStateGet_fd);
3962 return $EStateGet_data;
4076 function Get_NoticeInfo($p_dbh, $p_hb_env, $p_mc, $p_device, $p_noticefor, $p_fulldetail = 1, $p_noticeid = -1) {
4078 $retStatus_ary = Array(
'status' => Array(
'code'=>
'000',
'severity'=>
'SUCCESS',
'errors' => Array()),
'notice' => Array());
4080 switch ($p_noticefor) {
4084 if (!array_key_exists(
'messageSuppressPromo', $p_hb_env) || !$p_hb_env[
'messageSuppressPromo']) {
4085 $HBPromoMsg_ary = Get_CMSFragFile($p_dbh, $p_hb_env, $p_mc, $p_device, $p_noticefor, $p_fulldetail, $p_noticeid);
4086 if ($HBPromoMsg_ary[
'status'][
'code'] ==
'000') {
4088 if (count($HBPromoMsg_ary[
'notice']) > 0) {
4090 $retStatus_ary[
'notice'] = array_merge($retStatus_ary[
'notice'], $HBPromoMsg_ary[
'notice']);
4094 if ($p_noticefor ==
'PROMO') {
4103 $HBSurveyMsg_ary = Get_HBSurveyMsg($p_dbh, $p_hb_env, $p_mc, $p_device, $p_noticefor, $p_fulldetail, $p_noticeid);
4104 if ($HBSurveyMsg_ary[
'status'][
'code'] ==
'000') {
4106 if (count($HBSurveyMsg_ary[
'notice']) > 0) {
4108 $retStatus_ary[
'notice'] = array_merge($retStatus_ary[
'notice'], $HBSurveyMsg_ary[
'notice']);
4117 if ($p_noticefor !=
'' && $p_noticeid == -1) {
4118 $NoticeStatus_ary = Get_HBNoticeFile($p_hb_env, $p_mc, $p_device, $p_noticefor, $p_fulldetail);
4120 if ($NoticeStatus_ary[
'status'][
'code'] ==
'000') {
4122 if (count($NoticeStatus_ary[
'notice']) > 0) {
4125 $retStatus_ary[
'notice'] = array_merge($retStatus_ary[
'notice'], $NoticeStatus_ary[
'notice']);
4137 if ($p_noticefor !=
'') {
4138 $NoticeStatus_ary = Get_CMSFragFile($p_dbh, $p_hb_env, $p_mc, $p_device, $p_noticefor, $p_fulldetail, $p_noticeid);
4139 if ($NoticeStatus_ary[
'status'][
'code'] ==
'000') {
4141 if (count($NoticeStatus_ary[
'notice']) > 0) {
4143 $retStatus_ary[
'notice'] = array_merge($retStatus_ary[
'notice'], $NoticeStatus_ary[
'notice']);
4149 return $retStatus_ary;
4196 function Get_CMSFragFile($p_dbh, $p_hb_env, $p_mc, $p_device, $p_noticefor, $p_inctext, $p_noticeid = -1) {
4197 $retStatus_ary = Array(
'status' => Array(
'code'=>
'000',
'errors' => Array()),
'notice' => Array());
4199 $tmp_Notices_tmpl = Array(
4201 "notice_subtype" =>
"",
4203 "notice_text" =>
"",
4204 "notice_linktarget" =>
"",
4205 "notice_linkdisplay" =>
"",
4206 "notice_posttarget" =>
"",
4207 "notice_intro" =>
"",
4208 "notice_title" =>
"",
4209 "notice_msg_tx" =>
"",
4210 "notice_donotshowtext" =>
"",
4211 "notice_msg_tx_show" =>
"",
4212 "notice_msg_tx_perm" =>
"",
4213 "notice_popup" => 0,
4214 "notice_answertype" =>
"",
4215 "notice_positive_caption" =>
"",
4216 "notice_negative_caption" =>
"",
4217 "notice_answers" => Array()
4219 $tmp_Notices = Array();
4220 $tmp_Answers_tmpl = Array (
4225 $tmp_Answer = Array();
4227 $tmp_ViewNotice = Array(
4241 $defaultStrReplace = Array(
"CULOGIN" => strtolower($p_hb_env[
'Cu']),
4242 "CUNAME" => HCU_array_key_exists(
"orgname", $p_hb_env) ? trim($p_hb_env[
'orgname']) :
"",
4243 "CUSERVER" => HCU_array_key_exists(
"cuhost", $p_hb_env) ? $p_hb_env[
'cuhost'] :
"",
4244 "DBPREFIX" => $p_hb_env[
'Cu'],
4245 "HCUDIR" =>
'banking' 4248 if ( !is_array( HCU_array_key_value(
"noticeStrReplace", $p_hb_env ) ) ) {
4250 $p_hb_env[
'noticeStrReplace'] = $defaultStrReplace;
4254 $p_hb_env[
'noticeStrReplace'] = array_merge($defaultStrReplace, $p_hb_env[
'noticeStrReplace']);
4260 if ($p_noticefor ===
'updatecms') {
4261 $accountnumber = HCU_array_key_value(
"notice_accountnumber", $p_hb_env[
"HCUPOST"]);
4262 $sql =
"SELECT cucmsdocs.docsid, cucmsdocs.docsname, cucmsdocs.docsdesc, 4263 cucmsdocs.docsdefaultavail, cucmsdocs.docsresponsetype, 4264 cucmsdocs.docsdisplaytext, cucmsdocs.docsdisplaylink, 4265 cucmsfrags.cu, cucmsfrags.fragusedefault, cucmsfrags.fraguselink, 4266 cucmsfrags.fragclearresponse, coalesce((SELECT 'Y' 4268 WHERE cu = '" . prep_save($p_hb_env[
'Cu'], 10) .
"' AND user_id = {$p_hb_env['Uid']} 4269 " . ($accountnumber ===
false ?
"" :
"AND trim(accountnumber) = '" . prep_save(trim($accountnumber), 12) .
"'") .
" 4270 AND cucmsresponse.docsid = cucmsdocs.docsid)::text, 'N') as responseexists 4272 JOIN cucmsdocs on cucmsdocs.docsid = cucmsfrags.docsid 4273 WHERE cucmsdocs.docsid = '" . intval($p_noticeid) .
"' 4274 AND cucmsfrags.cu = '" . prep_save($p_hb_env[
'Cu'], 10) .
"' 4275 AND (docsresponsetype = 'N' 4276 OR (fraguselink = 'Y' 4277 OR (docsresponsetype in ('D', 'T', 'F', 'A', 'E', 'P')) 4280 } elseif ($p_noticefor ===
'viewcms' || $p_noticefor ===
'loadcms') {
4281 $sql =
"SELECT cucmsdocs.docsid, cucmsdocs.docsname, cucmsdocs.docsdesc, 4282 cucmsdocs.docsdefaultavail, cucmsdocs.docsresponsetype, 4283 cucmsdocs.docsdisplaytext, cucmsdocs.docsdisplaylink, 4284 cucmsfrags.cu, cucmsfrags.fragusedefault, cucmsfrags.fraguselink, 4285 cucmsfrags.fragclearresponse 4287 JOIN cucmsdocs on cucmsdocs.docsid = cucmsfrags.docsid 4288 WHERE cucmsdocs.docsid = '" . intval($p_noticeid) .
"' 4289 AND cucmsfrags.cu = '" . prep_save($p_hb_env[
'Cu'], 10) .
"' ";
4291 } elseif ($p_noticefor ==
'ALL' || $p_noticefor ==
'PROMO') {
4299 $permissionInputs = array(
"feature" => FEATURE_ESTATEMENTS );
4300 $permissionEstmt = Perm_AccessRights( $p_dbh, $p_hb_env, $permissionInputs );
4303 $Uid = (int) $p_hb_env[
'Uid'];
4308 d.docsid, d.docsname, d.docsdesc, d.docsdefaultavail, d.docsresponsetype, d.docsdisplaytext, d.docsdisplaylink, f.cu, f.fragusedefault, f.fraguselink, f.fragclearresponse, r.responseon 4310 INNER JOIN cucmsdocs d 4311 ON f.docsid = d.docsid 4312 LEFT JOIN cucmsresponse r 4313 ON f.docsid = r.docsid 4315 AND r.user_id = $Uid 4316 WHERE d.docsresponsetype IN ('A', 'E', 'P') 4318 (f.fragstartdate IS null AND f.fragenddate IS NULL) 4320 (f.fragstartdate > now() AND f.fragenddate <= now()) 4322 AND f.cu = '{$p_hb_env['Cu']}' 4323 AND r.responseon IS NULL 4326 $sql .=
"SELECT * FROM base b WHERE b.docsresponsetype <> 'E'";
4328 if ($permissionEstmt[
'access']) {
4331 SELECT b.* FROM base b 4333 SELECT bool_and(COALESCE(estmnt_flag, 'N') <> 'Y') AS estmt_unset 4334 FROM {$p_hb_env['Cu']}memberacct ma 4337 FROM {$p_hb_env['Cu']}useraccounts ua 4338 WHERE ma.accountnumber = ua.accountnumber 4339 AND ua.user_id = $Uid) 4341 ON b.docsresponsetype = 'E' 4350 $Uid = (int) HCU_array_key_value(
"Uid", $p_hb_env );
4351 $sql =
"SELECT cucmsdocs.docsid, cucmsdocs.docsname, cucmsdocs.docsdesc, 4352 cucmsdocs.docsdefaultavail, cucmsdocs.docsresponsetype, 4353 cucmsdocs.docsdisplaytext, cucmsdocs.docsdisplaylink, 4354 cucmsfrags.cu, cucmsfrags.fragusedefault, cucmsfrags.fraguselink, 4355 cucmsfrags.fragclearresponse, cucmsresponse.responseon 4357 JOIN cucmsdocs on cucmsdocs.docsid = cucmsfrags.docsid 4358 LEFT JOIN cucmsresponse on cucmsresponse.docsid = cucmsfrags.docsid 4359 AND cucmsresponse.cu = cucmsfrags.cu 4360 AND cucmsresponse.user_id = $Uid 4361 WHERE cucmsdocs.docsname = '" . prep_save($p_noticefor) .
"' 4362 AND cucmsfrags.cu = '" . prep_save($p_hb_env[
'Cu'], 10) .
"'; ";
4366 $fragRs = db_query($sql, $p_dbh);
4368 if (db_num_rows($fragRs) > 0) {
4374 while ($fragRow = db_fetch_assoc($fragRs, $fragIdx)) {
4376 $tmp_Notices = $tmp_Notices_tmpl;
4377 $tmp_Notices[
'notice_type'] =
'C';
4382 if ($p_inctext == 1) {
4385 if ($fragRow[
'fragusedefault'] ==
'Y') {
4386 $fragFileDir=
"/home/homecu/public_html/bankingIncludes";
4387 $fragFileName =
"skel_" . trim($fragRow[
'docsname']);
4389 $fragFileDir =
"/home/{$p_hb_env['chome']}/public_html/bankingIncludes";
4390 $fragFileName = trim($fragRow[
'docsname']) .
".html";
4395 if (is_readable($fragFileDir .
"/" . $p_hb_env[
'Flang'] .
"/" . $fragFileName)) {
4396 $fragFilePath = $fragFileDir .
"/" . $p_hb_env[
'Flang'] .
"/" . $fragFileName;
4397 }
else if (is_readable($fragFileDir .
"/en_US/" . $fragFileName)) {
4398 $fragFilePath = $fragFileDir .
"/en_US/" . $fragFileName;
4409 if ($fragFilePath !=
'' && is_readable($fragFilePath)) {
4411 $tmp_Notices[
'notice_text'] = file_get_contents($fragFilePath);
4414 $substList = HCU_array_key_exists(
"noticeStrReplace", $p_hb_env) ? $p_hb_env[
"noticeStrReplace"] :
null;
4417 if (isset($substList) && is_array($substList))
4419 $tmp_Notices[
"notice_text"]= strtr($tmp_Notices[
"notice_text"], $substList);
4424 $tmp_Notices[
'notice_subtype'] = $fragRow[
'docsresponsetype'];
4425 $tmp_Notices[
'notice_id'] = $fragRow[
'docsid'];
4427 if ($p_noticefor !=
'viewcms') {
4434 $tmp_ViewNotice[
'docsid'] = $fragRow[
'docsid'];
4435 $tmp_ViewNotice[
'Cu'] = $p_hb_env[
'Cu'];
4436 $tmp_ViewNotice[
'device'] = $p_device;
4437 $tmp_ViewNotice[
'chome'] = $p_hb_env[
'chome'];
4438 $tmp_ViewNotice[
'Flang'] = $p_hb_env[
'Flang'];
4440 $encryptedDocDetails= HCU_PayloadEncode($p_hb_env[
'Cu'], $tmp_ViewNotice);
4443 $tmp_Notices[
'notice_linktarget'] = $p_hb_env[
'homebankingpath'] .
'/hcuWebView.prg?x=' . urlencode($encryptedDocDetails) .
'&cu=' . $p_hb_env[
'Cu'];
4445 $tmp_Notices[
"notice_responseexists"] = HCU_array_key_value(
"responseexists", $fragRow);
4447 if ($fragRow[
'fraguselink'] ==
'Y') {
4448 $tmp_Notices[
'notice_linkdisplay'] = ($fragRow[
'docsdisplaylink'] ==
'Y' ? $p_mc->msg($fragRow[
'docsdisplaytext']) :
'');
4455 if ($fragRow[
'docsresponsetype'] !==
'N') {
4460 switch ($p_device) {
4463 $tmp_Notices[
'notice_posttarget'] = $p_hb_env[
'loginpath'] .
"/hcuViewNotice.prg?cu={$p_hb_env['Cu']}";
4468 $tmp_Notices[
'notice_posttarget'] = $p_hb_env[
'loginpath'] .
"/notices?cu={$p_hb_env['Cu']}";
4472 $tmp_Notices[
'notice_posttarget'] = $p_hb_env[
'loginpath'] .
"/notices?cu={$p_hb_env['Cu']}";
4476 $tmp_Notices[
'notice_posttarget'] = $p_hb_env[
'loginpath'] .
"/hcuViewNotice.prg?cu={$p_hb_env['Cu']}";
4482 $tmp_Notices[
'notice_intro'] =
'';
4483 $tmp_Notices[
'notice_title'] =
'';
4486 if (in_array($fragRow[
'docsresponsetype'], Array(
'A',
'E',
'P'))) {
4487 $tmp_Notices[
'notice_msg_tx'] = 16384;
4489 $tmp_Notices[
'notice_msg_tx'] =
'';
4491 $tmp_Notices[
'notice_msg_tx_show'] =
'';
4492 $tmp_Notices[
'notice_donotshowtext'] =
'';
4496 if (HCU_array_key_value(
'responseon', $fragRow) ==
'' && in_array($fragRow[
'docsresponsetype'], Array(
'D',
'T',
'A',
'E',
'P'))) {
4499 if (HCU_array_key_exists(
"Fmsg_tx", $p_hb_env) && (($p_hb_env[
'Fmsg_tx'] & $tmp_Notices[
'notice_msg_tx']) == 0 )) {
4501 $tmp_Notices[
'notice_popup'] = 1;
4504 $tmp_Notices[
'notice_answertype'] =
'M';
4505 $tmp_Notices[
'notice_suppressresponse'] =
'Y';
4508 if ($fragRow[
'docsresponsetype'] ==
'T') {
4509 $tmp_Answer = $tmp_Answers_tmpl;
4511 $tmp_Answer[
'answer_id'] = $fragRow[
'docsid'];
4512 $tmp_Answer[
'answer_text'] = $p_mc->msg(
'I Accept the Terms');
4514 $tmp_Notices[
'notice_answers'][] = $tmp_Answer;
4517 $tmp_Notices[
'notice_positive_caption'] = $p_mc->msg(
'Accept');
4518 $tmp_Notices[
'notice_negative_caption'] = $p_mc->msg(
'Cancel');
4520 $tmp_Notices[
'notice_neutral_caption'] = $p_mc->msg(
'Close');
4521 }
else if (in_array($fragRow[
'docsresponsetype'], Array(
'D',
'A',
'E',
'P'))) {
4522 $tmp_Answer = $tmp_Answers_tmpl;
4524 $tmp_Answer[
'answer_id'] = $fragRow[
'docsid'];
4525 $tmp_Answer[
'answer_text'] = $p_mc->msg(
'Dont Tell Me Again');
4527 $tmp_Notices[
'notice_answers'][] = $tmp_Answer;
4531 $tmp_Notices[
'notice_positive_caption'] = $fragRow[
'docsresponsetype'] ==
"E" ? $p_mc->msg(
'Close') : $p_mc->msg(
'Continue');
4533 $tmp_Notices[
'notice_neutral_caption'] = $p_mc->msg(
'Close');
4537 $tmp_Notices[
'notice_neutral_caption'] = $p_mc->msg(
'Close');
4543 $retStatus_ary[
'notice'][$fragIdx] = $tmp_Notices;
4552 return $retStatus_ary;
4578 function Get_HBNoticeFile($p_hb_env, $p_mc, $p_device, $p_noticefor, $p_inctext) {
4582 $retStatus_ary = Array(
'status' => Array(
'code'=>
'000',
'severity'=>
'SUCCESS',
'errors' => Array()),
'notice' => Array());
4584 $tmp_Notices = Array(
4587 "notice_text" =>
"",
4588 "notice_linktarget" =>
"",
4589 "notice_linkdisplay" =>
"",
4590 "notice_posttarget" =>
"",
4591 "notice_intro" =>
"",
4592 "notice_title" =>
"",
4593 "notice_msg_tx" =>
"",
4594 "notice_donotshowtext" =>
"",
4595 "notice_msg_tx_show" =>
"",
4596 "notice_msg_tx_perm" =>
"",
4597 "notice_popup" => 0,
4598 "notice_answertype" =>
"",
4599 "notice_answers" => Array()
4603 $tmp_Notices[
'notice_type'] =
'N';
4604 $tmp_Notices[
'notice_id'] = $p_noticefor;
4607 if ($p_noticefor !=
'') {
4608 $notice_filename =
"";
4610 switch ($p_noticefor) {
4612 switch ($p_device) {
4616 $notice_filename =
"mblTransfer";
4619 $notice_filename =
"Transfer";
4622 $tmp_Notices[
'notice_msg_tx'] = 1;
4623 $tmp_Notices[
'notice_msg_tx_show'] = 1;
4624 $tmp_Notices[
'notice_msg_tx_perm'] = 1;
4625 $tmp_Notices[
'notice_linkdisplay'] = $p_mc->msg(
'Transfer Notices');
4626 $tmp_Notices[
'notice_donotshowtext'] = $p_mc->msg(
'Dont Tell Me Again');
4627 $tmp_Notices[
'notice_title'] = $p_mc->msg(
'Transfer Notices');
4630 switch ($p_device) {
4634 $notice_filename =
"mblEStatement";
4637 $notice_filename =
"EStatement";
4640 $tmp_Notices[
'notice_msg_tx'] = 2;
4641 $tmp_Notices[
'notice_msg_tx_show'] = 1;
4642 $tmp_Notices[
'notice_msg_tx_perm'] = 1;
4643 $tmp_Notices[
'notice_donotshowtext'] = $p_mc->msg(
'Dont Tell Me Again');
4644 $tmp_Notices[
'notice_linkdisplay'] = $p_mc->msg(
'E-Statement Message');
4645 $tmp_Notices[
'notice_title'] = $p_mc->msg(
'Message');
4648 $retStatus_ary[
'status'][
'code'] =
'999';
4649 $retStatus_ary[
'status'][
'severity'] =
'ERROR';
4650 $retStatus_ary[
'status'][
'errors'][] =
'Unknown notice parameter';
4653 return $retStatus_ary;
4657 $fragdir =
"/home/{$p_hb_env['chome']}/public_html/";
4658 $fragfile = $notice_filename;
4660 $fragext = (trim($p_hb_env[
'Flang']) ==
"en_US" ?
"" :
"_" . substr($p_hb_env[
'Flang'], 0,strpos($p_hb_env[
'Flang'],
"_")) );
4661 $fragfilename = ($fragext >
"" && is_readable(
"{$fragdir}{$fragfile}{$fragext}.html") ?
"{$fragfile}{$fragext}.html" :
"{$fragfile}.html");
4664 $fragfile = $fragdir . $fragfilename;
4666 if (is_readable($fragfile)) {
4667 $notice_link = $p_hb_env[
'loginpath'] .
"/notices?cu={$p_hb_env['Cu']}&Flang={$p_hb_env['Flang']}";
4669 if ($p_inctext == 1) {
4670 $tmp_Notices[
'notice_text'] = file_get_contents($fragfile);
4674 $retStatus_ary[
'status'][
'code'] =
'999';
4675 $retStatus_ary[
'status'][
'severity'] =
'ERROR';
4676 $retStatus_ary[
'status'][
'errors'][] =
'Unable to read notice file.';
4680 if ($notice_link !=
'') {
4683 $notice_param =
"¬ice_type=N¬ice_id={$p_noticefor}¬ice_device={$p_device}";
4686 $tmp_Notices[
'notice_linktarget'] = $p_hb_env[
'cupublic'] .
"/" . $fragfilename;
4688 $tmp_Notices[
'notice_posttarget'] = $notice_link;
4691 if (($p_hb_env[
'Fmsg_tx'] & $tmp_Notices[
'notice_msg_tx']) == 0 ) {
4693 $tmp_Notices[
'notice_popup'] = 1;
4699 $retStatus_ary[
'notice'][] = $tmp_Notices;
4701 return $retStatus_ary;
4738 function Get_HBSurveyMsg($p_dbh, $p_hb_env, $p_mc, $p_device, $p_noticefor, $p_fulldetail = 1, $p_noticeid = -1, $p_action =
"SHOW") {
4739 $retStatus_ary = Array(
'status' => Array(
'code'=>
'000',
'severity'=>
'SUCCESS',
'errors' => Array()),
'notice' => Array());
4741 $messageSuppressSurvey = (key_exists(
'messageSuppressSurvey', $p_hb_env) ? $p_hb_env[
'messageSuppressSurvey'] :
false);
4742 $messageSuppressMsg = (key_exists(
'messageSuppressMsg', $p_hb_env) ? $p_hb_env[
'messageSuppressMsg'] :
false);
4744 $tmp_Notices = Array();
4745 $tmp_Notices_tmpl = Array(
4748 "notice_text" =>
"",
4749 "notice_linktarget" =>
"",
4750 "notice_linkdisplay" =>
"",
4751 "notice_posttarget" =>
"",
4752 "notice_intro" =>
"",
4753 "notice_title" =>
"",
4754 "notice_msg_tx" =>
"",
4755 "notice_donotshowtext" =>
"",
4756 "notice_msg_tx_show" =>
"",
4757 "notice_msg_tx_perm" =>
"",
4758 "notice_popup" => 0,
4759 "notice_positive_caption" =>
"",
4760 "notice_negative_caption" =>
"",
4761 "notice_answertype" =>
"",
4762 "notice_answers" => Array()
4765 $tmp_Answers_tmpl = Array (
4769 $tmp_Answer = Array();
4772 if ($p_action ==
"RESULTS") {
4773 $tmp_Notices_tmpl = array_merge($tmp_Notices_tmpl, Array(
"notice_suppressresponse" =>
"",
"notice_answervotes_ttl" =>
"",
"notice_answervotes_ttldisplay" =>
""));
4774 $tmp_Answers_tmpl = array_merge($tmp_Answers_tmpl, Array(
"answer_votes" =>
"",
"answer_pct" =>
""));
4785 if (HCU_array_key_value(
'employee', $p_hb_env) ==
'Y') {
4787 $sql_employee =
" AND m.employee = 'Y' ";
4792 if ($p_noticefor !=
'' && $p_device ==
'C') {
4796 if ($p_noticefor ==
'Balances') {
4797 $sql_embed =
" AND inc_balances = 'Y' ";
4799 } elseif($p_device ==
'C') {
4801 $sql_embed =
" AND (inc_balances is null or inc_balances <> 'Y') ";
4807 if ($p_noticefor ==
'S' && !$messageSuppressSurvey) {
4809 $sql_criteria .=
" AND (surveytype is null or surveytype < 1) ";
4810 } elseif ($p_noticefor ==
'M') {
4813 if ($messageSuppressMsg) {
4815 $sql_criteria .=
" AND (surveytype = 1 AND inc_balances = 'Y') ";
4817 $sql_criteria .=
" AND surveytype = 1 ";
4822 if ($messageSuppressMsg && $messageSuppressSurvey) {
4824 $sql_criteria .=
" AND (surveytype = 1 AND inc_balances = 'Y') ";
4826 if ($messageSuppressSurvey) {
4828 $sql_criteria .=
" AND (surveytype is not null and surveytype > 0) ";
4829 } elseif ($messageSuppressMsg) {
4831 $sql_criteria .=
" AND ((surveytype is null or surveytype < 1) OR (surveytype = 1 AND inc_balances = 'Y')) ";
4844 if ($p_noticeid > 0){
4846 $sql_criteria .=
" AND m.surveyid = " . intval($p_noticeid) .
" ";
4850 AND (startdate <= CURRENT_DATE and stopdate >= CURRENT_DATE) 4854 WHERE s.surveyid = m.surveyid 4855 AND s.user_id = '{$p_hb_env['Uid']}') ";
4869 if (HCU_array_key_exists(
'tz', $p_hb_env) && trim($p_hb_env[
'tz']) !=
'') {
4870 $tzOffset =
"SET LOCAL TIME ZONE '" . trim($p_hb_env[
'tz']) .
"'; ";
4875 SELECT m.surveyid, m.qstyle, q.question, m.inc_balances, i.surveyintro , m.surveytype, 4876 m.dontshow, m.surveytitle 4877 FROM cusurveymaster as m 4878 JOIN cusurveyquest as q ON m.surveyid = q.surveyid AND m.cu = q.cu AND q.language = '{$p_hb_env['Flang']}' 4879 LEFT JOIN cusurveyintro as i on i.cu = m.cu AND i.language = '{$p_hb_env['Flang']}' 4883 AND m.cu='{$p_hb_env['Cu']}' 4888 switch ($p_device) {
4894 ORDER BY random(), m.surveyid 4924 $notice_rs = db_query(($sql), $p_dbh);
4928 while ($notice_row = db_fetch_assoc($notice_rs, $notice_idx)) {
4929 $tmp_Notices[$notice_idx] = $tmp_Notices_tmpl;
4934 $tmp_Notices[$notice_idx][
'notice_type'] = (intval($notice_row[
'surveytype']) == 1 ?
'M' :
'S');
4936 $tmp_Notices[$notice_idx][
'notice_id'] = $notice_row[
'surveyid'];
4938 $tmp_Notices[$notice_idx][
'notice_text'] = $notice_row[
'question'];
4940 $tmp_Notices[$notice_idx][
'notice_linktarget'] =
"";
4941 $tmp_Notices[$notice_idx][
'notice_linkdisplay'] =
"";
4944 if ($p_device ==
'D') {
4945 $tmp_Notices[$notice_idx][
'notice_posttarget'] = $notice_link = $p_hb_env[
'loginpath'] .
"/hcuViewNotice.prg?cu={$p_hb_env['Cu']}";
4947 $tmp_Notices[$notice_idx][
'notice_posttarget'] = $notice_link = $p_hb_env[
'loginpath'] .
"/notices?cu={$p_hb_env['Cu']}&Flang={$p_hb_env['Flang']}";
4951 $tmp_Notices[$notice_idx][
'notice_intro'] = $notice_row[
'surveyintro'];
4955 if (intval($notice_row[
'surveytype']) == 1) {
4957 $tmp_Notices[$notice_idx][
'notice_title'] = ($notice_row[
'surveytitle'] ==
'' ? $p_mc->msg(
'Message') : $notice_row[
'surveytitle']);
4959 $tmp_Notices[$notice_idx][
'notice_msg_tx'] = 256;
4962 $tmp_Notices[$notice_idx][
'notice_answertype'] =
"M";
4963 $tmp_Notices[$notice_idx][
"notice_suppressresponse"] =
"Y";
4966 $tmp_Notices[$notice_idx][
'notice_title'] = $p_mc->msg(
'Survey');
4967 $tmp_Notices[$notice_idx][
'notice_msg_tx'] = 8;
4969 $tmp_Notices[$notice_idx][
'notice_answertype'] =
"O";
4970 $tmp_Notices[$notice_idx][
"notice_suppressresponse"] = $notice_row[
'dontshow'];
4972 $tmp_Notices[$notice_idx][
'notice_msg_tx_perm'] = 0;
4973 $tmp_Notices[$notice_idx][
'notice_msg_tx_show'] = 2;
4976 $tmp_Notices[$notice_idx][
'notice_donotshowtext'] =
"";
4978 if (($p_hb_env[
'Fmsg_tx'] & $tmp_Notices[$notice_idx][
'notice_msg_tx']) == 0 ) {
4979 if ($p_device ==
'M' && intval($notice_row[
'surveytype']) != 1) {
4981 $tmp_Notices[$notice_idx][
'notice_popup'] = 1;
4982 } elseif (($p_device ==
'D' || $p_device =
'R') && intval($notice_row[
'surveytype']) != 1) {
4984 $tmp_Notices[$notice_idx][
'notice_popup'] = 1;
4988 $tmp_Notices[$notice_idx][
'notice_popup'] = ($notice_row[
'inc_balances'] ==
'Y' ? 0 : 1);
4995 if (intval($notice_row[
'surveytype']) == 1 && $notice_row[
'inc_balances'] ==
'Y') {
4996 $tmp_Notices[$notice_idx][
'notice_popup'] = 0;
4998 $tmp_Notices[$notice_idx][
'notice_popup'] = 1;
5002 if (intval($notice_row[
'surveytype']) == 1) {
5005 $tmp_Answer = $tmp_Answers_tmpl;
5007 $tmp_Answer[
'answer_id'] = $tmp_Notices[$notice_idx][
'notice_id'];
5008 $tmp_Answer[
'answer_text'] = $p_mc->msg(
'Dont Tell Me Again');
5010 $tmp_Notices[$notice_idx][
'notice_answers'][] = $tmp_Answer;
5012 $tmp_Notices[$notice_idx][
"notice_positive_caption"] = $p_mc->msg(
'Close');
5013 $tmp_Notices[$notice_idx][
"notice_negative_caption"] = $p_mc->msg(
'Dont show me again');
5016 $tmp_Notices[$notice_idx][
"notice_positive_caption"] = $p_mc->msg(
'Cast my Vote');
5017 $tmp_Notices[$notice_idx][
"notice_negative_caption"] =
'Vote Later';
5019 if ($p_action ==
"SHOW") {
5023 WHERE cu = '{$p_hb_env['Cu']}' 5024 AND surveyid = {$notice_row['surveyid']} 5025 AND language = '{$p_hb_env['Flang']}' 5029 $answer_rs = db_query($sql, $p_dbh);
5031 while ($answer_row = db_fetch_assoc($answer_rs, $answer_idx)) {
5032 $tmp_Answer = $tmp_Answers_tmpl;
5034 $tmp_Answer[
'answer_id'] = $answer_row[
'answerid'];
5035 if (function_exists(
'hcu_displayHtml')) {
5036 $tmp_Answer[
'answer_text'] = hcu_displayHtml($answer_row[
'answertext']);
5038 $tmp_Answer[
'answer_text'] = dms_disphtml($answer_row[
'answertext']);
5041 $tmp_Notices[$notice_idx][
'notice_answers'][] = $tmp_Answer;
5045 db_free_result($answer_rs);
5046 } elseif ($p_action ==
"RESULTS") {
5047 $answervotes_ttl = 0;
5050 SELECT answerid, answertext, 5053 WHERE cusurveysays.cu = cusurveydetail.cu 5054 AND cusurveysays.surveyid = cusurveydetail.surveyid 5055 AND cusurveysays.answerid = cusurveydetail.answerid) as answervotes 5057 WHERE cu = '{$p_hb_env['Cu']}' 5058 AND surveyid = {$notice_row['surveyid']} 5059 AND language = '{$p_hb_env['Flang']}' 5062 $answer_rs = db_query($sql, $p_dbh);
5064 while ($answer_row = db_fetch_assoc($answer_rs, $answer_idx)) {
5065 $tmp_Answer = $tmp_Answers_tmpl;
5067 $tmp_Answer[
'answer_id'] = $answer_row[
'answerid'];
5068 if (function_exists(
'hcu_displayHtml')) {
5069 $tmp_Answer[
'answer_text'] = hcu_displayHtml($answer_row[
'answertext']);
5071 $tmp_Answer[
'answer_text'] = dms_disphtml($answer_row[
'answertext']);
5073 $tmp_Answer[
'answer_votes'] = intval($answer_row[
'answervotes']);
5074 $answervotes_ttl += intval($answer_row[
'answervotes']);
5076 $tmp_Notices[$notice_idx][
'notice_answers'][] = $tmp_Answer;
5080 db_free_result($answer_rs);
5086 $tmp_Notices[$notice_idx][
'notice_answervotes_ttl'] = $answervotes_ttl;
5087 $tmp_Notices[$notice_idx][
'notice_answervotes_ttldisplay'] = $p_mc->msg(
'total votes');
5088 if (count($tmp_Notices[$notice_idx][
'notice_answers']) > 0) {
5089 foreach ($tmp_Notices[$notice_idx][
'notice_answers'] as $answer_key => $answer_row) {
5090 if ($answervotes_ttl == 0) {
5092 $tmp_Notices[$notice_idx][
'notice_answers'][$answer_key][
'answer_pct'] = 0;
5094 $tmp_Notices[$notice_idx][
'notice_answers'][$answer_key][
'answer_pct'] =
5095 number_format(floatval($answer_row[
'answer_votes'] / $answervotes_ttl) * 100, 1);
5108 $retStatus_ary[
'notice'] = $tmp_Notices;
5109 return $retStatus_ary;
5172 Function Update_NoticeInfo($p_dbh, $p_hb_env, $p_mc ) {
5173 $retStatus_ary = Array(
'status' => Array(
'code'=>
'000',
'severity'=>
'SUCCESS',
'errors' => Array()));
5175 $retResp_ary = Array(
'notice_action' =>
'',
'notice_results' => Array());
5183 switch ($p_hb_env[
'HCUPOST'][
'notice_type']) {
5187 $HB_Notices_ary = Get_NoticeInfo($p_dbh, $p_hb_env, $p_mc, $p_hb_env[
'HCUPOST'][
'notice_device'], $p_hb_env[
'HCUPOST'][
'notice_id'], 0);
5190 if ($HB_Notices_ary[
'status'][
'code'] ==
'000' && count($HB_Notices_ary[
'notice']) > 0) {
5197 if (intval($HB_Notices_ary[
'notice'][0][
'notice_msg_tx_show']) > 0 && intval($p_hb_env[
'HCUPOST'][
'notice_msg_show']) == 1) {
5201 $nflag = intval($HB_Notices_ary[
'notice'][0][
'notice_msg_tx']);
5203 $oflag = intval($p_hb_env[
'Fmsg_tx']);
5205 $nflag = $oflag | $nflag;
5208 $dflag = ~(~$nflag | $tempflags);
5211 if (intval($HB_Notices_ary[
'notice'][0][
'notice_msg_tx_perm']) > 0) {
5212 if (hcu_checkOffline($p_dbh, $p_hb_env)) {
5214 $upd_list_array = Array(
"msg_tx" =>
"$dflag");
5215 $UpdTable_ary = Update_MemberInfo($p_dbh, $p_hb_env, $p_mc, serialize($upd_list_array), serialize(Array()));
5217 if ($UpdTable_ary[
'status'][
'code'] !=
'000') {
5219 $retStatus_ary[
'status'][
'code'] =
'999';
5220 $retStatus_ary[
'status'][
'severity'] =
'ERROR';
5221 $retStatus_ary[
'status'][
'errors'] = array_merge($retStatus_ary[
'status'][
'errors'], $UpdTable_ary[
'status'][
'errors']);
5228 if ($p_hb_env[
'HCUPOST'][
'notice_device'] ==
'M' ||
5229 $p_hb_env[
'HCUPOST'][
'notice_device'] ==
'R' ||
5230 $p_hb_env[
'HCUPOST'][
'notice_device'] ==
'C') {
5231 SetTicket($p_hb_env, $_COOKIE[
'Ticket'],
"Fmsg_tx=$nflag");
5243 $HB_Notices_ary = Get_NoticeInfo($p_dbh, $p_hb_env, $p_mc, $p_hb_env[
'HCUPOST'][
'notice_device'],
'B', 0, $p_hb_env[
'HCUPOST'][
'notice_id']);
5245 if ($HB_Notices_ary[
'status'][
'code'] ==
'000' && count($HB_Notices_ary[
'notice']) > 0) {
5251 $noticeRespCount = (HCU_array_key_exists(
'notice_response', $p_hb_env[
'HCUPOST']) ? count($p_hb_env[
'HCUPOST'][
'notice_response']) : 0);
5253 if ($noticeRespCount > 0 && $p_hb_env[
'HCUPOST'][
'notice_cancel'] != 1) {
5255 foreach ($p_hb_env[
'HCUPOST'][
'notice_response'] as $response_key => $response_value) {
5257 $upd_sql .=
" INSERT INTO cusurveysays (cu, surveyid, user_id, accountnumber, language, answerid) 5259 (SELECT '" . prep_save($p_hb_env[
'Cu']) .
"', " . intval($p_hb_env[
'HCUPOST'][
'notice_id']) .
", 5260 " . prep_save($p_hb_env[
'Uid']) .
", '', 5261 '" . prep_save($p_hb_env[
'Flang']) .
"', " . intval($response_value) .
" 5262 WHERE NOT EXISTS (SELECT (cu, surveyid, accountnumber) 5263 FROM cusurveysays as cus 5264 WHERE cus.cu = '" . prep_save($p_hb_env[
'Cu']) .
"' 5265 AND cus.surveyid = " . intval($p_hb_env[
'HCUPOST'][
'notice_id']) .
" 5266 AND cus.user_id = '" . prep_save($p_hb_env[
'Uid']) .
"') 5270 if ($upd_sql !=
'') {
5271 if (!$upd_rs = db_query ($upd_sql, $p_dbh)) {
5273 $retStatus_ary[
'status'][
'errors'][] = $p_mc->msg(
'Error udpating');
5281 if (in_array($p_hb_env[
'HCUPOST'][
'notice_device'], array(
'M',
'R',
'C',
'D')) && intval($HB_Notices_ary[
'notice'][0][
'notice_msg_tx']) > 0) {
5282 $oflag = $p_hb_env[
'Fmsg_tx'];
5283 $nflag = $p_hb_env[
'Fmsg_tx'] | intval($HB_Notices_ary[
'notice'][0][
'notice_msg_tx']);
5284 SetTicket($p_hb_env,$_COOKIE[
'Ticket'],
"Fmsg_tx=$nflag");
5287 if ($p_hb_env[
'HCUPOST'][
'notice_type'] ==
'S' && count($p_hb_env[
'HCUPOST'][
'notice_response']) > 0 && $p_hb_env[
'HCUPOST'][
'notice_cancel'] != 1) {
5291 $HB_Results_ary = Get_HBSurveyMsg($p_dbh, $p_hb_env, $p_mc, $p_hb_env[
'HCUPOST'][
'notice_device'],
'', 1, $p_hb_env[
'HCUPOST'][
'notice_id'],
"RESULTS");
5292 if ($HB_Results_ary[
'status'][
'code'] ==
'000') {
5295 if ($HB_Results_ary[
'notice'][0][
'notice_suppressresponse'] !=
'Y') {
5297 $retResp_ary[
'notice_action'] =
'DISPLAY';
5298 $retResp_ary[
'notice_results'] = $HB_Results_ary[
'notice'];
5301 $retResp_ary[
'notice_action'] =
'CLOSE';
5306 $retResp_ary[
'notice_action'] =
'CLOSE';
5319 $HB_Notices_ary = Get_NoticeInfo($p_dbh, $p_hb_env, $p_mc, $p_hb_env[
'HCUPOST'][
'notice_device'],
'updatecms', 0, $p_hb_env[
'HCUPOST'][
'notice_id']);
5322 if ($HB_Notices_ary[
'status'][
'code'] ==
'000' && count($HB_Notices_ary[
'notice']) > 0) {
5328 $noticeRespCount = (HCU_array_key_exists(
'notice_response', $p_hb_env[
'HCUPOST']) ? count($p_hb_env[
'HCUPOST'][
'notice_response']) : 0);
5330 $responseexists = HCU_array_key_value(
"notice_responseexists", $p_hb_env[
"HCUPOST"]);
5331 $accountnumber = HCU_array_key_value(
"notice_accountnumber", $p_hb_env[
"HCUPOST"]);
5332 $accountnumber = $accountnumber ===
false ?
"" : trim($accountnumber);
5333 if ($noticeRespCount > 0) {
5339 foreach ($p_hb_env[
'HCUPOST'][
'notice_response'] as $response_key => $response_value) {
5340 if (intval($response_value) > 0) {
5343 if ($responseexists !=
"Y") {
5345 $upd_sql =
"INSERT INTO cucmsresponse (docsid, cu, accountnumber, user_id, responseon) 5346 (SELECT " . intval($p_hb_env[
'HCUPOST'][
'notice_id']) .
", '" . prep_save($p_hb_env[
'Cu']) .
"', 5347 '$accountnumber', {$p_hb_env['Uid']}, current_date 5348 WHERE NOT EXISTS (SELECT 'FOUND' 5349 FROM cucmsresponse as cur 5350 WHERE cur.docsid = " . intval($p_hb_env[
'HCUPOST'][
'notice_id']) .
" 5351 AND cur.cu = '" . prep_save($p_hb_env[
'Cu']) .
"' 5352 AND cur.user_id = {$p_hb_env['Uid']} 5353 " . ($accountnumber ==
"" ?
"" :
"AND cur.accountnumber = '$accountnumber'") .
" 5357 $updateRs = db_query($upd_sql, $p_dbh);
5360 if ($responseexists ==
"Y" || ($updateRs && db_affected_rows($updateRs) === 0)) {
5364 $upd_sql =
"UPDATE cucmsresponse 5365 SET responseon = current_date 5366 WHERE docsid = " . intval($p_hb_env[
'HCUPOST'][
'notice_id']) .
" 5367 AND cu = '" . prep_save($p_hb_env[
'Cu']) .
"' 5368 AND user_id = {$p_hb_env['Uid']} 5369 " . ($accountnumber ==
"" ?
"" :
"AND accountnumber = '$accountnumber'") .
" 5372 $updateRs = db_query($upd_sql, $p_dbh);
5376 $retStatus_ary[
'status'][
'errors'][] = $p_mc->msg(
'Error udpating');
5384 if (in_array($p_hb_env[
'HCUPOST'][
'notice_device'], array(
'M',
'R',
'C',
'D')) && intval($HB_Notices_ary[
'notice'][0][
'notice_msg_tx']) > 0) {
5385 $oflag = $p_hb_env[
'Fmsg_tx'];
5386 $nflag = $p_hb_env[
'Fmsg_tx'] | intval($HB_Notices_ary[
'notice'][0][
'notice_msg_tx']);
5387 SetTicket($p_hb_env,$_COOKIE[
'Ticket'],
"Fmsg_tx=$nflag");
5399 $retStatus_ary[
'status'][
'errors'][] = $p_mc->msg(
'Error') .
" (Invalid notice_type)";
5403 if (count($retStatus_ary[
'status'][
'errors']) > 0) {
5404 $retStatus_ary[
'status'][
'code'] =
'999';
5405 $retStatus_ary[
'status'][
'severity'] =
'ERROR';
5408 $retStatus_ary[
'response'] = $retResp_ary;
5410 return $retStatus_ary;
5428 Function Update_MemberInfo($p_dbh, $p_hb_env, $p_mc, $p_values, $p_primaryKeys, $p_BuildOnly =
false) {
5429 $retStatus_ary = Array(
'status' => Array(
'code'=>
'000',
'severity'=>
'',
'errors' => Array()));
5440 $HB_CUUSERS_FIELDS_ary = Array(
"passwd" =>
"C34",
5442 "confidence" =>
"C20",
5443 "user_name" =>
"S50",
5444 "estmt_flag" =>
"C1",
5445 "egenl_flag" =>
"C1",
5446 "failedremain" =>
"I",
5454 $HB_CUUSERS_PRIMARY_KEYS_ary = Array(
"user_name" =>
'S50');
5458 $requested_fields_ary = unserialize($p_values);
5459 if (is_array($requested_fields_ary)) {
5462 $sql_field_update = PrepareExpressionList($HB_CUUSERS_FIELDS_ary, $requested_fields_ary);
5464 $requested_keys_ary = unserialize($p_primaryKeys);
5465 $sql_keys_list = PrepareExpressionList($HB_CUUSERS_PRIMARY_KEYS_ary, $requested_keys_ary,
true);
5467 if ($sql_field_update !=
'' && $sql_keys_list !=
'') {
5469 $sql =
"UPDATE {$p_hb_env['Cu']}user 5472 WHERE {$sql_keys_list}; 5475 if (!$p_BuildOnly) {
5477 if (!$trans_rs = db_query($sql, $p_dbh)) {
5479 throw new exception ($p_mc->msg(
'Error udpating'),
'999');
5483 $retStatus_ary[
'data'][
'sql'] = $sql;
5486 throw new exception ($p_mc->msg(
'Error'),
'999');
5492 throw new exception ($p_mc->msg(
'Error'),
'999');
5494 }
catch (exception $e) {
5496 $retStatus_ary[
'status'][
'code']=
'999';
5497 $retStatus_ary[
'status'][
'severity'] =
'ERROR';
5498 $retStatus_ary[
'status'][
'errors'][] = $e->getMessage();
5501 return $retStatus_ary;
5513 function Get_TxCodes($p_dbh, $p_hb_env, $p_mc) {
5514 $retStatus_ary = Array(
'status' => Array(
'code'=>
'000',
'severity'=>
'SUCCESS',
'errors' => Array()),
'data' => Array());
5516 $codelist = Array();
5517 $sql=
"SELECT t.trancode, trim(t.trandesc) as trandesc, 5518 trim(ht.cudesc) as cudesc, t.specialproc 5520 LEFT JOIN cuhavetrans as ht on ht.trancode = t.trancode AND ht.cu = '{$p_hb_env['Cu']}' ";
5523 $sth = db_query($sql, $p_dbh);
5528 while (list($code, $desc, $cudesc, $spec) = db_fetch_array($sth,$row)) {
5530 $desc = ($code ==
'AT' ?
"Transfer" : $desc );
5531 $desc = ($code ==
'CW' ?
"Check Withdrawal" : $desc );
5534 $desc = ($cudesc >
'' ? $cudesc : $p_mc->msg($desc) );
5537 $codelist[$code] = $desc;
5541 $retStatus_ary[
'data'] = $codelist;
5543 return $retStatus_ary;
5558 function Get_MemberChallengeResponses($p_dbh, $p_hb_env, $p_user, $p_questid = -1) {
5559 $retVal_ary = Array();
5595 function GetUserInfo($p_dbh, $p_hb_env, $p_mc, $p_values) {
5596 $retStatus_ary = Array(
'status' => Array(
'code'=>
'',
'errors' => Array()));
5598 $sql =
"SELECT passwd, email, confidence, egenl_flag, user_name, 5599 failedremain, userflags & " . intval(GetUserFlagsValue(
'MEM_FORCE_RESET')) .
"::int4 as forcereset, 5600 employee, userflags, mfaquest, priorlogin, lastlogin 5601 FROM {$p_values['cu']}user 5602 WHERE user_id = '{$p_values['user_id']}' ";
5604 $mbr_rs = db_query($sql, $p_dbh);
5606 if ($mbr_row = db_fetch_assoc($mbr_rs)) {
5608 $retStatus_ary[
'status'][
'code']=
'000';
5609 $retStatus_ary[
'data'][
'cuusers_name'] = trim($mbr_row[
'user_name']);
5610 $retStatus_ary[
'data'][
'cuusers_passwd'] = trim($mbr_row[
'passwd']);
5611 $retStatus_ary[
'data'][
'cuusers_email'] = trim($mbr_row[
'email']);
5612 $retStatus_ary[
'data'][
'cuusers_confidence'] = trim($mbr_row[
'confidence']);
5613 $retStatus_ary[
'data'][
'cuusers_egenl_flag'] = trim($mbr_row[
'egenl_flag']);
5614 $retStatus_ary[
'data'][
'cuusers_user_name'] = trim($mbr_row[
'user_name']);
5615 $retStatus_ary[
'data'][
'cuusers_failedremain'] = trim($mbr_row[
'failedremain']);
5616 $retStatus_ary[
'data'][
'cuusers_forcereset'] = trim($mbr_row[
'forcereset']);
5617 $retStatus_ary[
'data'][
'cuusers_employee'] = trim($mbr_row[
'employee']);
5618 $retStatus_ary[
'data'][
'cuusers_userflags'] = trim($mbr_row[
'userflags']);
5619 $retStatus_ary[
'data'][
'cuusers_lastlogin'] = trim($mbr_row[
'lastlogin']);
5620 $retStatus_ary[
'data'][
'cuusers_priorlogin'] = trim($mbr_row[
'priorlogin']);
5622 $mbrMfaQuest = HCU_MFADecode(HCU_JsonDecode($mbr_row[
'mfaquest']));
5623 $retStatus_ary[
'data'][
'savecqid'] = $mbrMfaQuest[
'challenge'];
5624 $retStatus_ary[
'data'][
'chcount'] = $mbrMfaQuest[
'mfacount'];
5625 $retStatus_ary[
'data'][
'authcode'] = $mbrMfaQuest[
'authcode'];
5626 $retStatus_ary[
'data'][
'authexpires'] = $mbrMfaQuest[
'authexpires'];
5627 $retStatus_ary[
'data'][
'mfadate'] = $mbrMfaQuest[
'mfadate'];
5632 $retStatus_ary[
'status'][
'code']=
'999';
5633 $retStatus_ary[
'status'][
'errors'][] = $p_mc->msg(
'Not Found');
5635 $retStatus_ary[
'data'] = Array();
5637 return $retStatus_ary;
5664 function GetChallengeQuestions($p_mode, $p_dbh, &$p_hb_env, $p_mc, $p_username =
'') {
5668 $mfaKeyAnswers =
"answers";
5669 $mfaKeyChallenge =
"challenge";
5670 $mfaKeyCount =
"mfacount";
5681 $sql =
"SELECT mfaquest 5682 FROM {$p_hb_env['cu']}user as cuuser 5683 WHERE lower(cuuser.user_name) = '" . strtolower(prep_save($p_username)) .
"' ";
5685 $rsMfa = db_query($sql, $p_dbh);
5687 if (db_num_rows($rsMfa) > 0) {
5689 $recMfa = db_fetch_assoc($rsMfa);
5690 $mfaquest = $recMfa[
'mfaquest'];
5695 $retVal = HCU_MFADecode(HCU_JsonDecode($mfaquest));
5703 $sql =
"SELECT mfaquest 5704 FROM {$p_hb_env['cu']}user as cuuser 5705 WHERE lower(cuuser.user_name) = '" . strtolower(prep_save($p_username)) .
"' ";
5707 $rsMfa = db_query($sql, $p_dbh);
5708 if (db_num_rows($rsMfa) > 0) {
5710 $recMfa = db_fetch_assoc($rsMfa);
5714 $mbrMfaQuest = HCU_MFADecode(HCU_JsonDecode($recMfa[
'mfaquest']));
5716 $countMbrMfa = $mbrMfaQuest[$mfaKeyCount];
5717 if ($countMbrMfa > 0) {
5723 $sql =
"SELECT quest_id, quest_text, example_text 5724 FROM cuquestmaster as m 5725 WHERE quest_lang = '{$p_mc->get_lang()}' 5726 ORDER BY quest_id, quest_lang ";
5731 $rsQstMaster = db_query($sql, $p_dbh);
5732 $recQstMaster = db_fetch_all($rsQstMaster);
5739 if (($p_hb_env[
'flagset2'] & $GLOBALS[
'CU2_RANDOM_CHAL']) == $GLOBALS[
'CU2_RANDOM_CHAL']) {
5740 if (intval($mbrMfaQuest[$mfaKeyChallenge]) == 0 ) {
5747 $mbrMfaQuest[$mfaKeyChallenge] = array_rand($mbrMfaQuest[$mfaKeyAnswers]);
5753 $mbrSaveMfaQuest = PrepareMfaQuestString($mbrMfaQuest);
5755 $upd_list_array = serialize(Array(
"mfaquest" => $mbrSaveMfaQuest));
5756 $upd_keys_array = serialize(Array(
"user_name" => $p_username));
5757 $updateResponse = Update_MemberInfo($p_dbh, $p_hb_env, $p_mc, $upd_list_array, $upd_keys_array);
5759 if ($updateResponse[
'status'][
'code'] !=
'000') {
5762 throw new Exception(
'User Record Not Updated',
'905');
5777 if ($mbrMfaQuest[$mfaKeyChallenge] > 0) {
5779 $masterQstIdx = array_search($mbrMfaQuest[$mfaKeyChallenge], array_column($recQstMaster,
'quest_id'));
5780 if ($masterQstIdx !==
false) {
5782 $retVal[] = Array(
"display" => $recQstMaster[$masterQstIdx][
'quest_text'],
"cqid" => $mbrMfaQuest[$mfaKeyChallenge],
"cqanswer" => $mbrMfaQuest[$mfaKeyAnswers][$mbrMfaQuest[$mfaKeyChallenge]]);
5792 if ($mbrMfaQuest[$mfaKeyCount] > 0 and is_array($mbrMfaQuest[$mfaKeyAnswers])) {
5794 foreach ($mbrMfaQuest[$mfaKeyAnswers] as $questIdx => $questAnswer) {
5795 $masterQstIdx = array_search($questIdx, array_column($recQstMaster,
'quest_id'));
5796 if ($masterQstIdx !==
false) {
5797 $retVal[] = Array(
"display" => $recQstMaster[$masterQstIdx][
'quest_text'],
"cqid" => $questIdx,
"cqanswer" => $questAnswer);
5809 $sql =
"SELECT quest_id as \"cqid\", trim(quest_text) as \"display\" 5811 WHERE quest_lang='{$p_mc->get_lang()}' 5812 ORDER BY quest_text ";
5813 $rsQstMaster = db_query($sql, $p_dbh);
5814 $retVal = db_fetch_all($rsQstMaster);
5815 if ($retVal == FALSE) {
5816 throw new Exception(
'No Master Records',
'910');
5821 throw new Exception(
'Invalid Option',
'999');
5823 }
catch (Exception $e) {
5847 function Update_AuditMember($p_dbh, $p_hb_env, $p_action, $p_time =
"", $p_post_build, &$p_build_sql) {
5849 $retFuncFailed =
false;
5851 if ($p_hb_env[
'live']) {
5853 $showtx =
", show_livetx('{$p_hb_env['Cu']}','{$p_hb_env['Cn']}') ";
5855 $cutx =
"cubatchtx";
5856 $showtx =
", show_txacct('{$p_hb_env['Cu']}','{$p_hb_env['Cn']}') ";
5860 $p_time = ($p_time ==
'' ?
" now()" : $p_time);
5861 switch ($p_action) {
5863 $audit_action =
"UPD_T";
5866 $audit_action =
"RESET";
5869 $audit_action =
"UPD_F";
5872 $sql =
"insert into cuauditusers 5873 (chdate, admuser, action, 5874 cu, user_name, user_alias, passwd, pktdate, pktstamp, email, 5875 estmt_flag, egenl_flag, failedremain, forcechange, 5876 forceremain, lastlogin, priorlogin, failedlogin, 5877 pwchange, msg_tx, billpayid, employee, txlist, 5878 depositlimit,userflags) 5879 select '{$p_time}', 'HomeCU_Member', '{$audit_action}', 5880 cuusers.cu, cuusers.user_name, cuusers.user_alias, 5881 cuusers.passwd, cuusers.pktdate, cuusers.pktstamp, 5882 cuusers.email, cuusers.estmt_flag, cuusers.egenl_flag, 5883 cuusers.failedremain, cuusers.forcechange, 5884 cuusers.forceremain, cuusers.lastlogin, 5885 cuusers.priorlogin, cuusers.failedlogin, 5886 cuusers.pwchange, cuusers.msg_tx, cuusers.billpayid, 5887 cuusers.employee $showtx, 5888 cuusers.depositlimit,userflags 5889 from cuusers where cu='{$p_hb_env['Cu']}' and user_name = '{$p_hb_env['Cn']}'; ";
5892 if ($p_post_build) {
5894 if (!$trans_rs = db_query($sql, $p_dbh)) {
5895 $retFuncFailed =
true;
5898 $p_build_sql .= $sql;
5921 function Update_ResetPassword($p_dbh, $p_hb_env, $p_values) {
5923 $retAry = Array(
"status" => Array (
"code" =>
"",
"severity" =>
"",
"errors" => Array()));
5925 $trans_failed =
false;
5926 $retFuncFailed =
false;
5930 if ($time_rs = db_query(
"select now();", $p_dbh)) {
5931 list($chnow) = db_fetch_array($time_rs, 0);
5934 $trans_failed =
true;
5937 $p_values[
'forceremain'] = intval($p_values[
'forceremain']);
5938 $p_values[
'failedremain'] = intval($p_values[
'failedremain']);
5942 if (array_key_exists(
'newpasswd_hash', $p_values)) {
5944 $hash = crypt($p_values[
'newpasswd']);
5946 $sBuildSql =
"UPDATE cuusers 5947 SET passwd = '{$p_values['newpasswd_hash']}', 5950 failedremain = '{$p_values['failedremain']}', 5951 forceremain = '{$p_values['forceremain']}' 5952 WHERE lower(user_name) = '" . strtolower($p_hb_env[
'Cn']) .
"' and cu = '{$p_hb_env['Cu']}'; ";
5955 $trans_failed = Update_AuditMember($p_dbh, $p_hb_env, 2, $chnow,
false, $sBuildSql);
5959 if ($upd_rs = db_query($sBuildSql, $p_dbh)) {
5960 $retAry[
'status'][
'code'] =
'000';
5961 $retAry[
'status'][
'severity'] =
"SUCCESS";
5964 $retAry[
'status'][
'code'] =
'999';
5965 $retAry[
'status'][
'severity'] =
'ERROR';
5966 $retAry[
'status'][
'errors'][] = $p_mc->msg(
"Error Occurred updating settings");
5970 $retAry[
'status'][
'code'] =
'999';
5971 $retAry[
'status'][
'severity'] =
'ERROR';
5972 $retAry[
'status'][
'errors'][] = $p_mc->msg(
"Error Occurred updating settings");
5979 function Get_Billpayid($dbh, $HB_ENV, $TrustID=
'billpay', $pAcct) {
5980 # returns array of bill pay override settings for member for specified Trustid vendor 5981 $Cu = $HB_ENV[
'Cu'];
5982 $Cn = $HB_ENV[
'Cn'];
5985 $sql =
"select trim(billpayid) from {$Cu}memberacct 5986 where accountnumber = '{$pAcct}'";
5988 $sth = db_query($sql, $dbh);
5989 if (db_num_rows($sth) == 0) {
5990 # return error -- account not found 5991 $billpay[
'status'][
'code'] =
'999';
5992 $billpay[
'status'][
'severity'] =
'ERROR';
5993 $billpay[
'status'][
'errors'][] =
"Account not found";
5994 $billpay[
'billpayid'] =
"";
5997 list($billpayid) = db_fetch_array($sth, 0);
5999 # GECU converted from Midatlantic to Ipay -- ignore stale billpayid settings 6000 if (trim($billpayid) ==
'' ||
"$Cu" ==
'GECU') {
6001 $billpayid = $pAcct;
6014 if (strlen($billpayid) < 2) {
6015 $billpayid=substr(
"00$billpayid",-2,2);
6021 $billpay[
'status'][
'code']=
'000';
6022 $billpay[
'status'][
'severity']=
'SUCCESS';
6023 $billpay[
'billpayid'] =
"$billpayid";
6042 function Read_AllAlerts( $pDbh, $pCu, $pUid ) {
6045 $retAlert = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
6048 $alertTypes= array(
"B" => array(
"type" =>
"bal",
"name" =>
"Balance"),
6049 "T" => array(
"type" =>
"trans",
"name" =>
"Transaction"),
6050 "C" => array(
"type" =>
"check",
"name" =>
"Check"),
6051 "L" => array(
"type" =>
"loan",
"name" =>
"Loan"));
6054 $sql =
"SELECT alerttype, id, alert.accountnumber, emailtype, description, 6055 notifymsg, inctransdesc, notifydesc, lastalert, alert.accounttype, 6057 FROM cu_alerts alert 6058 INNER JOIN {$pCu}loanbalance lb ON lb.accountnumber = alert.accountnumber 6059 AND lb.loannumber = alert.accounttype 6060 WHERE alert.cu = '{$pCu}' 6061 AND alert.user_id = '{$pUid}' ";
6068 $sql .=
"SELECT alerttype, id, alert.accountnumber, emailtype, description, 6069 notifymsg, inctransdesc, notifydesc, lastalert, alert.accounttype, 6071 FROM cu_alerts alert 6072 INNER JOIN {$pCu}accountbalance ab ON ab.accountnumber = alert.accountnumber 6073 AND ab.accounttype = alert.accounttype 6074 AND ab.certnumber = alert.certnumber 6075 WHERE alert.cu = '{$pCu}' 6076 AND alert.user_id = '{$pUid}' ";
6079 $sql .=
" ORDER BY accountnumber, alerttype, description, id";
6081 $alertRS = db_query($sql, $pDbh);
6083 while ( $alertRow = db_fetch_assoc($alertRS, $iRow++) ) {
6086 foreach( $alertRow as $key => $value ) {
6087 $alertRow[$key] = trim($value);
6091 $typeRecord= $alertTypes[$alertRow[
"alerttype"]];
6093 $alertRow[
"type"] = $typeRecord[
"type"];
6094 $alertRow[
"type_name"] = $typeRecord[
"name"];
6097 $lastAlert = trim( $alertRow[
"lastalert"] );
6098 if ( $lastAlert ==
"01/01/2000" ) {
6099 $alertRow[
"lastalert"] =
"";
6100 }
else if ( strlen( $lastAlert ) ) {
6101 $lastAlertTime = strtotime($lastAlert);
6102 if ( date(
"m/d/Y", $lastAlertTime ) ==
"01/01/2000" ) {
6103 $alertRow[
"lastalert"] =
"";
6105 $alertRow[
"lastalert"] = $lastAlert;
6108 $alertRow[
"lastalert"] =
"";
6111 $alertRow[
"description"] = trim( $alertRow[
"description"] ) .
" - " . trim( $alertRow[
"accounttype"] );
6122 if ($alertRow[
"alerttype"] ==
'trans') {
6123 $alertRow[
"notifymsg"] = (intval($alertRow[
'inctransdesc']) == 1 ?
6124 'Description Contains' .
' "' . $alertRow[
'notifydesc'] .
'" ' :
6125 $alertRow[
'notifymsg']);
6128 $retAlert[
"data"][] = $alertRow;
6131 db_free_result($alertRS);
6153 function Read_OneAlert( $dbh, $pHBEnv ) {
6155 $retAlert = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
6157 $alertId = $pHBEnv[
"HCUPOST"][
"id"];
6158 $Cu = $pHBEnv[
"Cu"];
6160 $Uid = $pHBEnv[
"Uid"];
6165 WHERE id = '{$alertId}' 6167 AND user_id = '{$Uid}' ";
6168 $alertRS = db_query( $sql, $dbh );
6169 $alertRow = db_fetch_assoc( $alertRS, 0 );
6172 if ( isset( $alertRow[
"id"] ) && $alertRow[
"id"] > 0 ) {
6173 foreach( $alertRow as $key => $value ) {
6174 $alertRow[$key] = trim($value);
6179 if ( $alertRow[
"type"] ==
"l" ) {
6180 $selAcct = trim( $alertRow[
"loannumber"] );
6182 $selAcct = trim( $alertRow[
"accounttype"] ) .
"_" . trim( $alertRow[
"certnumber"] );
6185 $alertRow[
"selacct"] = trim( $alertRow[
"accountnumber"] ) .
"_" . $selAcct;
6187 $retAlert[
"data"] = $alertRow;
6209 function Delete_Alert( $dbh, $pHBEnv, $MC ) {
6211 $retAlert = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
6213 $alertId = $pHBEnv[
"HCUPOST"][
"id"];
6214 $Cu = $pHBEnv[
"Cu"];
6216 $Uid = $pHBEnv[
"Uid"];
6220 WHERE id = {$alertId} 6222 AND user_id = '{$Uid}'";
6223 $delRS = db_query( $sql, $dbh );
6225 $aryReturnErrors = array();
6227 $aryReturnErrors[] = $MC->msg(
'Alert Delete Fail');
6229 $affectedRows = db_affected_rows( $delRS );
6231 if ( $affectedRows != 1 ) {
6232 $aryReturnErrors[] = $MC->msg(
'Alert Delete Fail');
6236 if ( count( $aryReturnErrors ) > 0 ) {
6238 $retAlert[
'code'] =
'999';
6239 $retAlert[
"errors"] = $aryReturnErrors;
6276 function Validate_Alert( $dbh, $pHBEnv, $MC ) {
6282 $retAlert = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
6284 $alertType = $pHBEnv[
"HCUPOST"][
"type"];
6286 $aryReturnErrors = array();
6288 if ( trim( $pHBEnv[
"HCUPOST"][
"mbr_account"] ) ==
"" ) {
6289 $aryReturnErrors[] = $MC->msg(
'Account Number Missing');
6294 switch ( $alertType ) {
6298 if (trim($pHBEnv[
"HCUPOST"][
"notifyamt"]) ==
"" || !is_numeric($pHBEnv[
"HCUPOST"][
"notifyamt"])) {
6299 $aryReturnErrors[] = $MC->msg(
'Amount Missing');
6305 if ( $pHBEnv[
"HCUPOST"][
"userange"] ==
"1" ) {
6307 if ( trim($pHBEnv[
"HCUPOST"][
"desc_amtmin"]) ==
"" || !is_numeric($pHBEnv[
"HCUPOST"][
"desc_amtmin"]) ) {
6308 $aryReturnErrors[] = $MC->msg(
'Amount Minimum');
6310 if ( trim($pHBEnv[
"HCUPOST"][
"desc_amtmax"]) ==
"" || !is_numeric($pHBEnv[
"HCUPOST"][
"desc_amtmax"]) ) {
6311 $aryReturnErrors[] = $MC->msg(
'Amount Maximum');
6314 if ( strlen(trim($pHBEnv[
"HCUPOST"][
"notifydesc"])) == 0 ) {
6315 $aryReturnErrors[] = $MC->msg(
'Description Missing');
6316 } elseif ( strlen(trim($pHBEnv[
"HCUPOST"][
"notifydesc"])) < 3 ) {
6317 $aryReturnErrors[] = $MC->msg(
'Description Short');
6320 $inctransdesc = intval($pHBEnv[
'HCUPOST'][
'inctransdesc']);
6324 if ( strlen(trim($pHBEnv[
"HCUPOST"][
"chknum"])) == 0 ) {
6325 $aryReturnErrors[] = $MC->msg(
'Check Number Missing');
6332 $aryReturnErrors[] = $MC->msg(
'Invalid Alert Type');
6336 $notifyMsg = isset( $pHBEnv[
"HCUPOST"][
"notifymsg"] ) && strlen( trim($pHBEnv[
"HCUPOST"][
"notifymsg"]) ) > 0 ? trim($pHBEnv[
"HCUPOST"][
"notifymsg"]) :
"";
6337 if ( $notifyMsg ==
"" && (($alertType !=
'trans') || ($alertType ==
'trans' && $inctransdesc == 0))) {
6338 $aryReturnErrors[] = $MC->msg(
'Message Missing');
6342 $weType = isset( $pHBEnv[
"HCUPOST"][
"emailtype"] ) && strlen( $pHBEnv[
"HCUPOST"][
"emailtype"] ) ? $pHBEnv[
"HCUPOST"][
"emailtype"] :
"";
6343 $weType = substr(strtoupper($weType), 0, 1);
6344 $cellProvider = isset( $pHBEnv[
"HCUPOST"][
"provider_id"] ) && strlen( $pHBEnv[
"HCUPOST"][
"provider_id"] ) ? $pHBEnv[
"HCUPOST"][
"provider_id"] :
"";
6345 $notifyTo = isset( $pHBEnv[
"HCUPOST"][
"notifyto"] ) && strlen( $pHBEnv[
"HCUPOST"][
"notifyto"] ) ? trim( $pHBEnv[
"HCUPOST"][
"notifyto"] ) :
"";
6346 if ($weType ==
"E") {
6348 if ( strlen( $notifyTo ) == 0 ) {
6349 $aryReturnErrors[] = $MC->msg(
'EMail Missing');
6351 if ( !validateEmail( $notifyTo ) ) {
6352 $aryReturnErrors[] = $MC->msg(
'Email appears invalid');
6355 }
else if ( $weType ==
"W" ) {
6357 if (strlen( $notifyTo ) == 0) {
6358 $aryReturnErrors[] = $MC->msg(
'Cell Number Missing');
6359 } elseif (strlen( $notifyTo ) != 10) {
6361 $aryReturnErrors[] = $MC->msg(
'Cell Number Length');
6362 } elseif (!is_numeric( $notifyTo ) ) {
6364 $aryReturn[
'status'][
'errors'][] = $MC->msg(
'Cell Number Digits');
6366 if (strlen( $cellProvider ) ==
'') {
6367 $aryReturn[
'status'][
'errors'][] = $MC->msg(
'Provider Missing');
6370 $aryReturn[
'status'][
'errors'][] = $MC->msg(
'Send Option Missing');
6373 if ( count( $aryReturnErrors ) > 0 ) {
6375 $retAlert[
'code'] =
'999';
6376 $retAlert[
"errors"] = $aryReturnErrors;
6426 function Update_Alert( $dbh, $pHBEnv, $MC ) {
6429 $retAlert = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
6431 $Cu = $pHBEnv[
"Cu"];
6432 $alertType = $pHBEnv[
"HCUPOST"][
"type"];
6433 $alertId = $pHBEnv[
"HCUPOST"][
"id"];
6438 if (isset($pHBEnv[
"HCUPOST"][
"selacct"])) {
6439 if ( $alertType ==
"loan" ) {
6440 list( $mbrAccount, $loanNumber) = explode(
"_", $pHBEnv[
"HCUPOST"][
"selacct"] );
6442 list( $mbrAccount, $acctType, $certNumber) = explode(
"_", $pHBEnv[
"HCUPOST"][
"selacct"] );
6443 $certNumber = intval($certNumber);
6446 $mbrAccount = isset( $pHBEnv[
"HCUPOST"][
"mbr_account"] ) && strlen( trim($pHBEnv[
"HCUPOST"][
"mbr_account"]) ) > 0 ? trim($pHBEnv[
"HCUPOST"][
"mbr_account"]) :
'';
6451 $notifyMsg = isset( $pHBEnv[
"HCUPOST"][
"notifymsg"] ) && strlen( trim($pHBEnv[
"HCUPOST"][
"notifymsg"]) ) > 0 ? trim($pHBEnv[
"HCUPOST"][
"notifymsg"]) :
"";
6454 $weType = isset( $pHBEnv[
"HCUPOST"][
"emailtype"] ) && strlen( $pHBEnv[
"HCUPOST"][
"emailtype"] ) ? $pHBEnv[
"HCUPOST"][
"emailtype"] :
"";
6455 $weType = substr(strtoupper($weType), 0, 1);
6456 $cellProvider = isset( $pHBEnv[
"HCUPOST"][
"provider_id"] ) && strlen( $pHBEnv[
"HCUPOST"][
"provider_id"] ) ? $pHBEnv[
"HCUPOST"][
"provider_id"] :
"";
6457 $notifyTo = isset( $pHBEnv[
"HCUPOST"][
"notifyto"] ) && strlen( $pHBEnv[
"HCUPOST"][
"notifyto"] ) ? trim( $pHBEnv[
"HCUPOST"][
"notifyto"] ) :
"";
6460 $save_n_desc =
"NULL";
6461 $save_n_chk =
"NULL";
6463 $save_wire_emailtype = $weType;
6464 $save_notifyto = prep_save( $notifyTo, 50 );
6465 $save_msg = prep_save( str_replace(
"\\",
"", $notifyMsg), 255 );
6468 $save_n_min =
"NULL";
6469 $save_n_max =
"NULL";
6471 $save_loannumber = prep_save($loanNumber);
6472 $acctType = prep_save($acctType);
6473 $certNumber = prep_save($certNumber);
6474 $incBal = isset( $pHBEnv[
"HCUPOST"][
"incbal"] ) && $pHBEnv[
"HCUPOST"][
"incbal"] == 1 ? 1 : 0;
6475 $incAmt = isset( $pHBEnv[
"HCUPOST"][
"incamt"] ) && $pHBEnv[
"HCUPOST"][
"incamt"] == 1 ? 1 : 0;
6476 $incTransDesc = isset( $pHBEnv[
"HCUPOST"][
"inctransdesc"] ) && $pHBEnv[
"HCUPOST"][
"inctransdesc"] == 1 ? 1 : 0;
6477 $useAvailBal = isset( $pHBEnv[
"HCUPOST"][
"useavailbal"] ) && $pHBEnv[
"HCUPOST"][
"useavailbal"] == 1 ? 1 : 0;
6478 switch ( $alertType ) {
6481 $save_n_max = $pHBEnv[
"HCUPOST"][
"notifyamt"];
6484 $save_n_desc = prep_save($pHBEnv[
"HCUPOST"][
"notifydesc"], 90);
6485 $save_n_trans = prep_save($pHBEnv[
"HCUPOST"][
"transtype"]);
6486 if ($pHBEnv[
"HCUPOST"][
"userange"] ==
"1") {
6487 $save_n_min = $pHBEnv[
"HCUPOST"][
"desc_amtmin"];
6488 $save_n_max = $pHBEnv[
"HCUPOST"][
"desc_amtmax"];
6490 $save_notifyrange = prep_save($pHBEnv[
"HCUPOST"][
"userange"]);
6493 $save_n_chk =
"'" . prep_save($pHBEnv[
"HCUPOST"][
"chknum"], 8) .
"'";
6496 switch (intval($pHBEnv[
"HCUPOST"][
"days_prior"])) {
6499 $save_days_prior = intval($pHBEnv[
"HCUPOST"][
"days_prior"]);
6502 $save_days_prior = 0;
6508 if ( $alertId > 0 ) {
6510 switch ( $alertType ) {
6512 $field_value =
"accounttype = '$acctType', 6513 certnumber = '$certNumber', 6515 useavailbal = '$useAvailBal', 6516 notifyamt = $save_n_max, ";
6520 $field_value =
"accounttype = '$acctType', 6521 certnumber = '$certNumber', 6523 incamt = '" . intval($incAmt) .
"', 6524 inctransdesc = '$incTransDesc', 6525 notifyamtmin = $save_n_min, 6526 notifyamtmax = $save_n_max, 6527 notifyrange = '" . intval($save_notifyrange) .
"', 6528 notifydesc = '$save_n_desc', 6529 notifytranstype = '$save_n_trans', ";
6532 $field_value =
"accounttype = '$acctType', 6533 certnumber = '$certNumber', 6534 incamt = '" . intval($incAmt) .
"', 6535 notifychknum = $save_n_chk, ";
6538 $field_value =
"accounttype = '$save_loannumber', 6539 notifyloandaysprior = $save_days_prior, ";
6544 $sql =
"UPDATE cu_alerts 6546 accountnumber = '$mbrAccount', 6548 emailtype = '$save_wire_emailtype', 6549 notifyto = '$save_notifyto', 6550 provider_id = '" . prep_save($cellProvider, 35) .
"', 6551 notifymsg = '$save_msg' 6552 WHERE id = {$alertId} ";
6556 switch ( $alertType ) {
6559 $field_list =
"alerttype, accounttype, certnumber, 6560 incbal, useavailbal, notifyamt, lastalert ";
6561 $value_list =
"'B', '$acctType', '$certNumber', 6562 $incBal, $useAvailBal, $save_n_max, NULL ";
6566 $sql =
"SELECT max(tracenumber) as maxtrace 6567 FROM {$Cu}accounthistory 6568 WHERE accountnumber = '$mbrAccount' 6569 AND accounttype = '$acctType' 6570 AND certnumber = '$certNumber' 6571 AND tracenumber is not null ";
6572 $traceRS = db_query( $sql, $dbh );
6573 $traceRow = db_fetch_array($traceRS, 0);
6575 db_free_result($traceRS);
6577 $field_list =
"alerttype, accounttype, certnumber, 6578 incbal, incamt, inctransdesc, notifyrange, notifyamtmin, 6579 notifyamtmax, notifydesc, notifytranstype, lasttrace, lastalert ";
6580 $value_list =
"'T', '$acctType', '$certNumber', 6582 '" . intval($incAmt) .
"', $incTransDesc, 6583 '" . intval($save_notifyrange) .
"', $save_n_min, 6584 $save_n_max, '$save_n_desc', '$save_n_trans', '{$traceRow['maxtrace']}', NULL ";
6587 $field_list =
"alerttype, accounttype, certnumber, 6588 incamt, notifychknum, lastalert ";
6589 $value_list =
"'C', '$acctType', '$certNumber', 6590 '" . intval($incAmt) .
"', 6591 $save_n_chk, NULL ";
6595 $field_list =
"alerttype, accounttype, lastalert, notifyloandaysprior ";
6596 $value_list =
"'L', '$save_loannumber', NULL, $save_days_prior ";
6600 $userId = $pHBEnv[
"Uid"];
6603 $sql =
"SELECT nextval('cualerts_id_seq'::text) as alertid";
6604 $alertRS = db_query( $sql, $dbh );
6605 $alertRow = db_fetch_assoc( $alertRS );
6606 $alertId = $alertRow[
"alertid"];
6609 $sql =
"INSERT INTO cu_alerts 6610 (id, cu, accountnumber, user_id, emailtype, 6611 notifyto, provider_id, notifymsg, alertstatus, $field_list ) 6613 ($alertId, '{$Cu}', '$mbrAccount', $userId, '$save_wire_emailtype', 6614 '$save_notifyto', '" . prep_save($cellProvider, 35) .
"', 6615 '$save_msg', 1, $value_list 6620 if ((!$save_rs = db_query($sql, $dbh))) {
6622 $retAlert[
'errors'][] = $MC->msg(
'Error Saving Alert');
6625 if ( count( $retAlert[
'errors'] ) > 0 ) {
6627 $retAlert[
'code'] =
'999';
6648 function Check_AlertsEnabled( $dbh, $pHBEnv ) {
6650 $retAlert = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
6653 $sql =
"SELECT email FROM cuadmnotify 6654 WHERE cu = '{$pHBEnv["Cu
"]}' AND role = 'alert'";
6655 $emRS = db_query($sql, $dbh);
6656 $emRow = db_fetch_array($emRS, 0);
6657 $notifyEmail = $emRow[
"email"];
6658 db_free_result($emRS);
6660 if ( !strlen( trim( $notifyEmail ) ) ) {
6676 function Get_AlertLimits( ) {
6678 $retAlert = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
6681 define(
"TRANS_LIMIT", 20 );
6684 define(
"CHECK_LIMIT", 4 );
6687 $alertLimits = array();
6688 $alertLimits[
"bal"] = array(
"total_limit" => 0,
"acct_type" => 2 );
6689 $alertLimits[
"trans"] = array(
"total_limit" => TRANS_LIMIT,
"acct_type" => 0 );
6690 $alertLimits[
"check"] = array(
"total_limit" => CHECK_LIMIT,
"acct_type" => 0 );
6691 $alertLimits[
"loan"] = array(
"total_limit" => 0,
"acct_type" => 1 );
6693 $retAlert[
"data"] = $alertLimits;
6709 function Get_AlertTypes( $pMC ) {
6711 $retAlert = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
6714 $alertTypes = array();
6715 $alertTypes[] = array(
"name" => $pMC->msg(
'Balance'),
"value" =>
"bal" );
6716 $alertTypes[] = array(
"name" => $pMC->msg(
'Transaction'),
"value" =>
"trans" );
6717 $alertTypes[] = array(
"name" => $pMC->msg(
'Check Number'),
"value" =>
"check" );
6718 $alertTypes[] = array(
"name" => $pMC->msg(
'Missed Payment Date'),
"value" =>
"loan" );
6720 $retAlert[
"data"] = $alertTypes;
6739 function Get_AlertProviders( $dbh, $showSQL=
false) {
6741 $retAlert = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
6743 $providers = array();
6746 FROM cualertproviders 6747 ORDER BY provider_name ";
6748 $provRS = db_query($sql, $dbh);
6750 while ($provRow = db_fetch_assoc($provRS, $dbRow++)) {
6751 $provRow[
"provider_id"] = trim( $provRow[
"provider_id"] );
6752 $provRow[
"provider_name"] = trim( $provRow[
"provider_name"] );
6753 $providers[] = $provRow;
6756 $retAlert[
"data"] = $providers;
6758 $retAlert[
"sqls"]= array($sql);
6778 function Get_AlertDesc( $alertType, $pMC ) {
6780 $retAlert = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
6783 switch ($alertType) {
6785 $alertName = $pMC->msg(
'Balance');
6788 $alertName = $pMC->msg(
'Transaction');
6791 $alertName = $pMC->msg(
'Check Number');
6794 $alertName = $pMC->msg(
'Missed Payment Date');
6798 $retAlert[
"data"] = $alertName;
6821 function Get_AlertAccounts( $pDbh, $pHBEnv ) {
6823 $retAlert = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
6825 $cu = $pHBEnv[
"Cu"];
6826 $uId = $pHBEnv[
"Uid"];
6827 $Fset = $pHBEnv[
"Fset"];
6828 $Fset2 = $pHBEnv[
"Fset2"];
6829 $Fset3 = $pHBEnv[
"Fset3"];
6839 $orderBy .=
"display_order,";
6840 $orderBy .=
" CASE recordtype";
6842 if (($Fset & GetFlagsetValue(
"CU_SORTORDER4")) == GetFlagsetValue(
"CU_SORTORDER4")) {
6844 $orderBy .=
" WHEN 'D' THEN btrim(accounttype,'DIS')";
6845 }
else if (($Fset2 & GetFlagsetValue(
"CU2_SORTORDER6")) == GetFlagsetValue(
"CU2_SORTORDER6")) {
6846 $orderBy .=
" WHEN 'D' THEN acctoid";
6858 $tempOid =
"acct.oid";
6860 $orderBy .=
" WHEN 'D' THEN btrim(accounttype, 'DIS')";
6864 if ($Fset & GetFlagsetValue(
'CU_LNSORT2')) {
6865 $orderBy .=
" WHEN 'L' THEN btrim(accounttype,'LC')";
6868 $orderBy .=
" WHEN 'L' THEN accounttype";
6872 $orderBy .=
" END,";
6873 $orderBy .=
" accountnumber, certnumber";
6878 SELECT acct.accountnumber, useracct.display_name, useracct.display_order, description, useracct.accounttype, useracct.certnumber, 6879 useracct.recordtype, useracct.view_balances, useracct.view_transactions, acct.deposittype, ma.restrictions, 1 as alertgroup, lpad({$tempOid}::varchar, 10, '0') as acctoid 6880 FROM {$cu}useraccounts as useracct 6881 INNER JOIN {$cu}accountbalance as acct ON acct.accountnumber = useracct.accountnumber 6882 AND acct.accounttype = useracct.accounttype 6883 AND acct.certnumber = useracct.certnumber 6884 INNER JOIN {$cu}memberacct ma ON ma.accountnumber = useracct.accountnumber 6885 WHERE useracct.user_id = $uId 6886 AND useracct.recordtype = 'D' 6890 SELECT acct.accountnumber, useracct.display_name, useracct.display_order, description, useracct.accounttype, useracct.certnumber, 6891 useracct.recordtype, useracct.view_balances, useracct.view_transactions, 'N' as deposittype, ma.restrictions, 2 as alertgroup, lpad({$tempOid}::varchar, 10, '0') as acctoid 6892 FROM {$cu}useraccounts as useracct 6893 INNER JOIN {$cu}loanbalance as acct ON acct.accountnumber = useracct.accountnumber 6894 AND acct.loannumber = useracct.accounttype 6895 INNER JOIN {$cu}memberacct ma ON ma.accountnumber = useracct.accountnumber 6896 WHERE useracct.user_id ='$uId' 6897 AND useracct.recordtype = 'L' 6898 ) accts ORDER BY $orderBy";
6900 $acctRS = db_query( $sql, $pDbh );
6902 $acctListHolder = array();
6903 while ($acctRow = db_fetch_array( $acctRS, $rowCnt++ )) {
6905 if ( $acctRow[
"restrictions"] ==
"L" ) {
6909 $recordType = $acctRow[
"recordtype"];
6910 if ( $recordType ==
"L" ) {
6911 $ident = trim( $acctRow[
"accounttype"] );
6913 $ident = trim( $acctRow[
"accounttype"] ) .
"_" . trim( $acctRow[
"certnumber"] );
6916 $account= trim($acctRow[
"accountnumber"]);
6919 $ident = $account .
"_" . $ident;
6921 $acctListHolder[] = array(
"type" => $recordType,
6922 "account" => $account,
6923 "description" => getAccountDescription($pDbh, $cu, $account, $acctRow[
'description'], $acctRow[
"accounttype"], $acctRow[
'display_name'], $Fset3,
6924 $acctRow[
"certnumber"],
false),
6925 "deposit_acct" => strtoupper($acctRow[
"deposittype"]),
6926 "view_balances" => $acctRow[
'view_balances'],
6927 "view_transactions" => $acctRow[
'view_transactions'],
6928 "identifier" => $ident );
6931 $retAlert[
"data"] = $acctListHolder;
6949 function Get_AlertAccountList( $pDbh, $pHbEnv ) {
6951 $retAlert = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
6953 $accountList = array();
6955 $return = Get_AlertAccounts( $pDbh, $pHbEnv );
6956 $alertAccounts = $return[
"data"];
6958 for ( $t = 0; $t < count( $alertAccounts ); $t++ ) {
6961 for ( $i = 0; $i < count( $accountList ); $i++ ) {
6962 if ( ($alertAccounts[$t][
"account"] == $accountList[$i][
"accountnumber"]) &&
6963 ($alertAccounts[$t][
"identifier"] == $accountList[$i][
"acct_ident"]) ) {
6971 $accountList[] = array (
6972 "acct_ident" => $alertAccounts[$t][
"identifier"],
6973 "accountnumber" => $alertAccounts[$t][
"account"],
6974 "description" => $alertAccounts[$t][
"description"],
6975 "bal_allowed" =>
false,
6976 "trans_allowed" =>
false,
6977 "check_allowed" =>
false,
6978 "loan_allowed" =>
false );
6983 if ( $alertAccounts[$t][
"type"] ==
"D" ) {
6984 if ( $alertAccounts[$t][
"view_balances"] ==
"t" ) {
6985 $accountList[$i][
"bal_allowed"] =
true;
6987 if ( $alertAccounts[$t][
"view_transactions"] ==
"t" ) {
6988 $accountList[$i][
"trans_allowed"] =
true;
6990 if ( $alertAccounts[$t][
"deposit_acct"] ==
"Y" ) {
6991 $accountList[$i][
"check_allowed"] =
true;
6994 }
else if ( $alertAccounts[$t][
"type"] ==
"L" ) {
6995 if ( $alertAccounts[$t][
"view_balances"] ==
"t" ) {
6996 $accountList[$i][
"loan_allowed"] =
true;
7004 $retAlert[
"data"] = $accountList;
7027 function Get_AlertsDetailed( $pDbh, $pCu, $pUid, $Fset3, $MC=
null)
7030 $retAlert = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
7033 $currAlerts = array();
7037 $alertTypes= array(
"B" => array(
"type" =>
"bal",
"name" => isset($MC) ? $MC->msg(
"Balance", HCU_DISPLAY_AS_JS) :
"Balance"),
7038 "T" => array(
"type" =>
"trans",
"name" => isset($MC) ? $MC->msg(
"Transaction", HCU_DISPLAY_AS_JS) :
"Transaction"),
7039 "C" => array(
"type" =>
"check",
"name" => isset($MC) ? $MC->msg(
"Check", HCU_DISPLAY_AS_JS) :
"Check"),
7040 "L" => array(
"type" =>
"loan",
"name" => isset($MC) ? $MC->msg(
"Loan", HCU_DISPLAY_AS_JS) :
"Loan"));
7043 $sql =
"SELECT alert.alerttype, alert.accountnumber, coalesce(nullif(trim(ua.display_name), ''), description) as descSort, ua.certnumber, ua.accounttype, alert.*, description, 7044 ua.display_name, ma.restrictions 7045 FROM cu_alerts alert 7046 INNER JOIN {$pCu}loanbalance lb ON lb.accountnumber = alert.accountnumber 7047 AND lb.loannumber = alert.accounttype 7048 INNER JOIN {$pCu}useraccounts ua ON ua.accountnumber = alert.accountnumber 7049 AND ua.accounttype = alert.accounttype 7050 AND ua.user_id = alert.user_id 7051 INNER JOIN {$pCu}memberacct ma ON ma.accountnumber = alert.accountnumber 7052 WHERE alert.cu = '{$pCu}' 7053 AND alert.alerttype = 'L' 7054 AND alert.user_id = '{$pUid}' ";
7060 $sql .=
"SELECT alert.alerttype, alert.accountnumber, coalesce(nullif(trim(ua.display_name), ''), description) as descSort, ua.certnumber, ua.accounttype, alert.*, description, 7061 ua.display_name, ma.restrictions 7062 FROM cu_alerts alert 7063 INNER JOIN {$pCu}accountbalance ab ON ab.accountnumber = alert.accountnumber 7064 AND ab.accounttype = alert.accounttype 7065 AND ab.certnumber = alert.certnumber 7066 INNER JOIN {$pCu}useraccounts ua ON ua.accountnumber = alert.accountnumber 7067 AND ua.accounttype = alert.accounttype 7068 AND ua.certnumber = alert.certnumber 7069 AND ua.user_id = alert.user_id 7070 INNER JOIN {$pCu}memberacct ma ON ma.accountnumber = alert.accountnumber 7071 WHERE alert.cu = '{$pCu}' 7072 AND alert.alerttype IN ('B', 'T', 'C') 7073 AND alert.user_id = '{$pUid}' ";
7076 $sql .=
"ORDER BY 1, 2, 3";
7080 $alertRS = db_query($sql, $pDbh);
7082 while ( $alertRow = db_fetch_assoc($alertRS, $iRow++) ) {
7085 foreach( $alertRow as $key => $value ) {
7086 $alertRow[$key] = trim($value);
7090 $lastAlert= trim($alertRow[
"lastalert"]);
7091 if ( $lastAlert ==
"01/01/2000" ) {
7092 $alertRow[
"lastalert"] =
"";
7093 }
else if ( strlen( $lastAlert ) ) {
7094 $lastAlertTime = strtotime($lastAlert);
7095 if ( date(
"m/d/Y", $lastAlertTime ) ==
"01/01/2000" ) {
7096 $alertRow[
"lastalert"] =
"";
7098 $alertRow[
"lastalert"] = $lastAlert;
7101 $alertRow[
"lastalert"] =
"";
7112 $lNotifyMsg = (intval($alertRow[
'inctransdesc']) == 1 ?
7113 'Description Contains' .
' ' . $alertRow[
'notifydesc'] :
7114 $alertRow[
'notifymsg']);
7117 $type= $alertRow[
"alerttype"];
7118 $typeRecord= $alertTypes[$type];
7120 $accountnumber= trim($alertRow[
"accountnumber"]);
7123 $selAcct = $type ==
"L" ? trim( $alertRow[
"accounttype"] ) : trim( $alertRow[
"accounttype"] ) .
"_" . trim( $alertRow[
"certnumber"] );
7124 $selAcct = trim( $alertRow[
"accountnumber"] ) .
"_" . $selAcct;
7127 $currAlerts[] = array(
7128 "type" => $typeRecord[
"type"],
7129 "type_name" => $typeRecord[
"name"],
7130 "id" => $alertRow[
"id"],
7131 "description" => getAccountDescription($pDbh, $pCu, $accountnumber, $alertRow[
"description"], $alertRow[
"accounttype"], $alertRow[
'display_name'], $Fset3, $alertRow[
"certnumber"]),
7132 "accountnumber" => $accountnumber,
7133 "emailtype" => $alertRow[
"emailtype"],
7134 "notifyto" => $alertRow[
"notifyto"],
7135 "provider_id" => $alertRow[
"provider_id"],
7136 "provider_name" => isset( $alertRow[
"provider_name"] ) ? $alertRow[
"provider_name"] :
"",
7137 "notifymsg" => $alertRow[
"notifymsg"],
7138 "notifydisplaymsg" => $lNotifyMsg,
7139 "lastalert" => $alertRow[
"lastalert"],
7140 "alertstatus" => $alertRow[
"alertstatus"],
7141 "restrictions" => $alertRow[
"restrictions"],
7142 "selacct" => $selAcct,
7143 "incbal" => $type ==
"B" || $type ==
"T" ? $alertRow[
"incbal"] :
"",
7144 "inctransdesc" => $type ==
"T" ? $alertRow[
"inctransdesc"] :
"0",
7145 "notifyamt" => $type ==
"B" ? $alertRow[
"notifyamt"] :
"",
7146 "useavailbal" => $type ==
"B" ? $alertRow[
"useavailbal"] :
"",
7147 "incamt" => $type ==
"T" || $type ==
"C" ? $alertRow[
"incamt"] :
"",
7148 "notifychknum" => $type ==
"C" ? $alertRow[
"notifychknum"] :
"",
7149 "alert_days_prior" => $type ==
"L" ? $alertRow[
"notifyloandaysprior"] :
"",
7150 "notifyrange" => $type ==
"T" ? $alertRow[
"notifyrange"] :
"",
7151 "notifyamtmin" => $type ==
"T" ? $alertRow[
"notifyamtmin"] :
"",
7152 "notifyamtmax" => $type ==
"T" ? $alertRow[
"notifyamtmax"] :
"",
7153 "notifydesc" => $type ==
"T" ? $alertRow[
"notifydesc"] :
"",
7154 "notifytranstype" => $type ==
"T" ? $alertRow[
"notifytranstype"] :
"" 7158 db_free_result($alertRS);
7160 $retAlert[
"data"] = $currAlerts;
7178 function Get_UserAccounts( $pDbh, $pCu, $pUid ) {
7180 $retAlert = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
7182 $cu = strtolower( $pCu );
7184 $sql =
"SELECT DISTINCT accountnumber 7185 FROM {$cu}useraccounts 7186 WHERE user_id = $pUid ";
7187 $accountRS = db_query( $sql, $pDbh );
7189 $accountList = array();
7191 while ( $alertRow = db_fetch_assoc($accountRS, $iRow++) ) {
7192 $accountList[] = trim( $alertRow[
"accountnumber"] );
7195 db_free_result( $accountRS );
7197 $retAlert[
"data"] = $accountList;
7198 $retAlert[
"sql"] = $sql;
7220 function Get_AlertDefaultEmail( $dbh, $pHBEnv ) {
7222 $retAlert = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
7224 $Cu = $pHBEnv[
"Cu"];
7225 $Uid = $pHBEnv[
"Uid"];
7227 $cu = strtolower( $Cu );
7228 $sql =
"SELECT email 7230 WHERE user_id = $Uid ";
7231 $emailRS = db_query( $sql, $dbh );
7232 $emailRow = db_fetch_array( $emailRS, 0 );
7233 db_free_result( $emailRS );
7236 if ( strlen( trim( $emailRow[
'email'] ) ) ) {
7237 if (function_exists(
'hcu_displayHtml')) {
7238 $defaultEmail = hcu_displayHtml( $emailRow[
'email'], ENT_QUOTES,
true );
7240 $defaultEmail = disp_i18n( $emailRow[
'email'], ENT_QUOTES );
7244 $retAlert[
"data"] = $defaultEmail;
7268 function Get_AlertDefaultCell( $dbh, $pHBEnv ) {
7270 $retAlert = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
7272 $Cu = $pHBEnv[
"Cu"];
7274 $Uid = $pHBEnv[
"Uid"];
7277 SELECT notifyto, provider_id 7280 AND user_id = '{$Uid}' 7282 GROUP BY notifyto, provider_id 7283 ORDER BY notifyto, provider_id 7286 $cellRS = db_query( $sql, $dbh );
7287 $cellRow = db_fetch_array( $cellRS, 0 );
7288 db_free_result($cellRS);
7291 if (function_exists(
'hcu_displayHtml')) {
7292 $cellProvider[
"cell_number"] = hcu_displayHtml( $cellRow[
'notifyto'], ENT_QUOTES,
true );
7294 $cellProvider[
"cell_number"] = disp_i18n( $cellRow[
'notifyto'], ENT_QUOTES );
7296 $cellProvider[
"provider_id"] = trim( $cellRow[
'provider_id'] );
7298 $cellProvider[
"cell_number"] =
"";
7299 $cellProvider[
"provider_id"] =
"";
7302 $retAlert[
"data"] = $cellProvider;
7320 function Update_AlertStatuses($dbh, $cuCode, $userId, $alerts, $loggedInUser) {
7325 if (trim($alerts) !=
"") {
7326 $alerts = HCU_JsonDecode($alerts,
false);
7327 if (!is_array($alerts)) {
7328 throw new Exception(
"Alerts are not encoded correctly.", 2);
7334 $updateArray = array();
7335 foreach($alerts as $alert) {
7336 if (!(isset($alert[
"id"]) && isset($alert[
"alertstatus"]))) {
7337 throw new Exception(
"Alert is not formatted correctly.", 3);
7339 $updateArray[] = array(
"_action" =>
"update",
"id" => $alert[
"id"],
"alertstatus" => $alert[
"alertstatus"]);
7342 $updateArray= array(
"alert" => $updateArray);
7346 $script =
"userSupport.prg";
7349 $sql =
"select email from cuadminusers where user_name = '$loggedInUser' and cu= '$cuCode'";
7350 if (($sth = db_query($sql, $dbh)) !==
false) {
7351 $email = db_fetch_row($sth)[0];
7353 throw new Exception(
"Email query failed.", 7);
7356 if (count($updateArray[
"alert"]) > 0 && DataUserTableUpdate($dbh, array(
"cu" => $cuCode),
null, $updateArray, $userId,
"ALT_STATUS", $context, $script,
"A",
"Alert Status Update",
7357 $loggedInUser, $email, trim($_SERVER[
"REMOTE_ADDR"])) ===
false) {
7358 throw new Exception(
"Alert status update failed.", 6);
7360 }
catch(Exception $e) {
7361 $errors = array($e->getMessage());
7362 $code = $e->getCode();
7365 $returnArray = array(
"code" => $code,
"errors" => $errors);
7366 return $returnArray;
7396 function Get_BannerText($dbh, $HB_ENV, $MC, $device) {
7397 # look for embedded banner info 7398 $aryReturn = Array(
"status" => Array(
"code",
"errors" => Array()));
7411 $Cu = $HB_ENV[
'Cu'];
7414 $bnrSql =
"select trim(question) as question, 7415 to_char(startdate,'YYYY-MM-DD') as startdate, 7416 to_char(stopdate,'YYYY-MM-DD') as stopdate 7418 where cu = '$Cu' and surveytype = $stype 7419 and startdate <= CURRENT_DATE 7420 and stopdate >= CURRENT_DATE";
7422 if (!$sbh = db_query($bnrSql, $dbh)) {
7423 $aryReturn[
'status'][
'errors'][] = $MC->msg(
'Error Finding Form');
7425 $bnrRow = db_fetch_array( $sbh, 0 );
7426 $bannertext=stripslashes($bnrRow[
'question']);
7429 if ( count( $aryReturn[
'status'][
'errors'] ) > 0 ) {
7431 $aryReturn[
'status'][
'code'] =
'999';
7432 $aryReturn[
'banner']=array();
7435 $aryReturn[
'status'][
'code'] =
'000';
7436 $aryReturn[
'banner'][
'bannertext'] = $bannertext;
7437 $aryReturn[
'banner'][
'startdate'] = $bnrRow[
'startdate'];
7438 $aryReturn[
'banner'][
'stopdate'] = $bnrRow[
'startdate'];
7439 $aryReturn[
'banner'][
'bnrRow'] = $bnrRow;
7440 $aryReturn[
'banner'][
'bnrSql'] = $bnrSql;
7447 function Translate_BannerText($HB_ENV, $btext) {
7448 $Cu = $HB_ENV[
'Cu'];
7449 $Cn = $HB_ENV[
'Cn'];
7451 $aryfind = array(
'$Cn',
'$Cu');
7452 $aryreplace = array(
"$Cn",
"$Cu");
7454 $bannertext = str_replace($aryfind, $aryreplace,$btext);
7456 if ( empty($bannertext) ) {
7457 $aryReturn[
'status'][
'code'] =
'999';
7458 $aryReturn[
'banner'][
'bannertext'] =
'';
7461 $aryReturn[
'status'][
'code'] =
'000';
7462 $aryReturn[
'banner'][
'bannertext'] = $bannertext;
7495 function Post_CUEStmt($pDbh, $pHBEnv, $pMC, $pAcct) {
7497 $retStatus_ary = Array(
'status' => Array(
'code'=>
'000',
'errors' => Array()));
7513 $retCUStatus = Get_EstmtEnrollStatus($pDbh, $pHBEnv, $pMC, $pAcct);
7514 if ($retCUStatus[
'status'][
'code'] ==
'999') {
7515 if ($retCUStatus[
'status'][
'errors'][0] !=
'') {
7516 $errMsg = $retCUStatus[
'status'][
'errors'][0];
7518 $errMsg = $pMC->msg(
'Contact CU');
7520 throw new Exception($errMsg);
7526 $esFormNotes = Array();
7527 if (strtoupper($pHBEnv[
'esProcessMode']) ==
'STOP') {
7530 $esFormNotes[] =
'This is a STOP request.';
7535 if ($pHBEnv[
'Ml'] ==
'') {
7537 $esFormNotes[] =
'No valid email set.';
7541 if ($esFormMode ==
'N') {
7542 if (trim($pHBEnv[
'HCUPOST'][
'stop_reason']) ==
'') {
7543 $errMsg =
'Please provide the reason for stopping e-statements.';
7544 throw new Exception($errMsg);
7548 $secureFormTitle = $pMC->msg(
'E-STATEMENT ' . strtoupper($pHBEnv[
'esProcessMode']) .
' REQUEST');
7559 $trans_array = Get_HaveTrans($pDbh, $pHBEnv);
7562 if (isset($pHBEnv[
'live']) && array_key_exists(
'ES', $trans_array)) {
7564 $packetValues = Array(
7568 'R3' => $pHBEnv[
'Ml'],
7570 'R5' => $esFormMode,
7571 "selectedAccount" => $pAcct
7573 $postEntryPacketAry = Post_CUESPacket($pHBEnv, $pMC, $packetValues);
7575 if ($postEntryPacketAry[
'status'][
'error'] !=
'') {
7576 if ($postEntryPacketAry[
'status'][
'code'] ==
'000') {
7578 $esFormNotes[] =
'This request was processed as an online transaction';
7580 throw new Exception($postEntryPacketAry[
'status'][
'error']);
7588 $entryFields = Array (
7589 "Cn" => Array(
'required' =>
false,
'dataKey' =>
'',
'dataLabel' =>
'CU Account Number'),
7590 "Ml" => Array(
'required' =>
true,
'dataKey' =>
'',
'dataLabel' =>
'E-mail Address')
7592 if ($esFormMode ==
'N') {
7593 $entryFields[
"stop_reason"] = Array(
'required' =>
true,
'dataKey' =>
'HCUPOST',
'dataLabel' => $pMC->msg(
'Why Stop'));
7595 foreach ($entryFields as $fieldKey => $fieldAttr) {
7597 $secureFormDataAry[] = Array(
'type' =>
'field',
7598 'label' => $fieldAttr[
'dataLabel'],
7599 'value' => ($fieldAttr[
'dataKey'] !=
'' ? $pHBEnv[$fieldAttr[
'dataKey']][$fieldKey] : $pHBEnv[$fieldKey]));
7602 $secureFormData = <<< printblock
7603 <?xml version=
"1.0"?><!doctype html>
7604 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:lang=
"en" lang=
"en">
7606 <title>$secureFormTitle</title>
7607 <link href=
"https://{$pHBEnv['cloudfrontDomainName']}/homecu/css/KendoUI/{$pHBEnv['homecuKendoVersion']}/kendo.common.min.css" rel=
"stylesheet">
7608 <link href=
"https://{$pHBEnv['cloudfrontDomainName']}/homecu/css/KendoUI/{$pHBEnv['homecuKendoVersion']}/kendo.default.min.css" rel=
"stylesheet">
7610 <script type=
"text/javascript" src=
"https://{$pHBEnv['cloudfrontDomainName']}/jquery/js/jquery-1.9.1.min.js.gz"></script>
7611 <script src=
"https://{$pHBEnv['cloudfrontDomainName']}/homecu/js/KendoUI/{$pHBEnv['homecuKendoVersion']}/kendo.web.min.js"></script>
7614 .k-block {width: 500px}
7615 .field-label-wrapper { margin: 0px 5px 5px 5px; padding: 0px 5px 5px 20px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; }
7616 .field-label-wrapper label { display: block; padding: 10px 0 6px 4px; color: #333333; font-size:1.2em; margin-left: -10px; width: 100%; }
7617 .field-label-wrapper label.note {color: red;font-weight: bold;}
7618 .field-label-wrapper label.note:before {content:
"NOTE: "}
7619 .field-label-wrapper label.field:after {content:
":"}
7620 .field-label-wrapper label hr { z-index: 0; display:
inline-block; width: 100%; position:relative; top:-24px;background-color:#000000; }
7623 <div
class=
'k-content'>
7624 <div
class=
"k-block"><div
class=
"k-header k-shadow">$secureFormTitle</div>
7628 foreach ($esFormNotes as $printNote) {
7629 $printLabel =
"<label class='note'>{$printNote}</label>";
7630 $secureFormData .= <<< printblock
7631 <div
class=
'field-label-wrapper'>
7637 foreach ($secureFormDataAry as $dataIdx => $dataAttr) {
7639 $printLabel = ($dataAttr[
'label'] !=
'' ?
"<label class='{$dataAttr['type']}'>{$dataAttr['label']}</label>" :
'');
7640 $secureFormData .= <<< printblock
7641 <div
class=
'field-label-wrapper'>
7643 <div
class=
'field-value'>{$dataAttr[
'value']}</div>
7648 $secureFormData .= <<< printblock
7659 $sslFormsFileName =
'estmt' . date(
'YmdHis') . posix_getpid() .
'.html';
7664 $secureFormFileHdl = fopen($retCUStatus[
'estmt'][
'sslformsdir'] . $sslFormsFileName,
'w');
7665 if ($secureFormFileHdl) {
7666 fwrite($secureFormFileHdl, $secureFormData);
7667 fclose($secureFormFileHdl);
7670 throw new Exception($pMC->msg(
'Errors found'));
7676 $validateEntryAry[
'estmnt'] = $esFormMode;
7677 $updateMbrAry = Update_CUMbrEs($pDbh, $pHBEnv, $pMC, $validateEntryAry, $pAcct);
7679 if ($updateMbrAry[
'status'][
'code'] ==
'999') {
7680 $retStatus_ary[
'homecuErrors'] = $updateMbrAry[
'status'][
'errors'];
7681 throw new Exception($pMC->msg(
'Errors found'));
7687 $notify->mailto = $retCUStatus[
'estmt'][
'notifyemail'];
7688 $notify->replyto = ($pHBEnv[
'Ml'] !=
'' ? $pHBEnv[
'Ml'] : $retCUStatus[
'estmt'][
'notifyemail']);
7689 $notify->subject =
"SECURE FORM NOTIFICATION (estmt)";
7690 $notify->msgbody =
"\tSECURE FORM NOTIFICATION (estmt)\n\n";
7691 $notify->msgbody .=
"{$pHBEnv['Cn']} has left a secure document at your site. ";
7692 $notify->msgbody .=
"\nYou can retrieve it in the password protected ";
7693 $notify->msgbody .=
"admin directory.\n\n";
7695 $notify->msgbody .=
"Member Email: " . ($pHBEnv[
'Ml'] !=
'' ? $pHBEnv[
'Ml'] :
'Member needs to validate e-mail') .
"\n";
7696 $notify->callingfunction = __FUNCTION__;
7697 $notify->file = __FILE__;
7698 $notify->cu = $pHbEnv[
'Cu'];
7704 $retStatus_ary[
'homecuInfo'] = $pMC->msg(
'Thank you your request will be sent');
7707 }
catch (Exception $ex) {
7709 $retStatus_ary[
'status'][
'errors'][] = $ex->getMessage();
7710 $retStatus_ary[
'status'][
'code'] =
'999';
7714 return $retStatus_ary;
7744 function Post_CUESPacket($pHbEnv, $pMC, $pValues) {
7746 $retStatus_ary = Array(
7747 'status' => Array(
'code'=>
'000',
'error' =>
''),
7758 $stopRequest = (HCU_array_key_value(
"R5", $pValues) ==
"N");
7762 "member" => $pValues[
'selectedAccount'],
7764 "tran_code" => $pValues[
'Tc'],
7765 "ref1" => $pValues[
'R1'],
7766 "ref2" => $pValues[
'R2'],
7767 "ref3" => $pValues[
'R3'],
7768 "ref4" => $pValues[
'R4'],
7769 "ref5" => $pValues[
'R5']
7772 $esAction = $stopRequest ?
'ESTMTSTOP' :
'ESTMTACTIVATE';
7773 $sendResp = SendTransaction( $pHbEnv, $esAction, $txnValues );
7775 $statcode = $sendResp[
'status'][
'code'];
7776 if ($statcode ==
'000') {
7778 $retDataMsg = $pMC->msg(
'E-Statement Request OK', HCU_DISPLAY_AS_RAW);
7781 $statreason = HCU_array_key_value(
"desc", $sendResp[
'data']);
7782 $retStatus_ary[
'status'][
'code'] =
'999';
7783 $retStatus_ary[
'status'][
'error'] = $pMC->msg(
'E-Statement Request Error', HCU_DISPLAY_AS_RAW)
7784 . $pMC->msg(
'Contact CU', HCU_DISPLAY_AS_RAW);
7792 $retDataMsg = $pMC->msg(
'E-Statement Request Error', HCU_DISPLAY_AS_RAW)
7793 .
" [{$pHbEnv['Cn']} {$pValues['R3']} {$pValues['R5']}] $statcode $statreason";
7796 $retStatus_ary[
'data'] = $retDataMsg;
7798 return $retStatus_ary;
7822 function Update_CUMbrEs($pDbh, $pHbEnv, $pMC, $pValues, $pSelectedAccount) {
7824 $retStatus_ary = Array(
7825 'status' => Array(
'code'=>
'000',
'errors' => Array()),
7830 $updateTrans =
false;
7835 if ($time_rs = db_query(
"select now();", $pDbh)) {
7836 list($chnow) = db_fetch_array($time_rs, 0);
7839 throw new Exception($pMC->msg(
"Error Occurred updating settings"));
7842 # update the usermember entry 7843 $updateTableArray = array(
7844 'memberacct' => array(
7846 '_action' =>
'update',
7847 'accountnumber' => $pSelectedAccount,
7848 'estmnt_flag' => $pValues[
'estmnt'])
7851 # SEND DATA TO UPDATE USER 7852 $result = DataUserTableUpdate($pDbh, $pHbEnv, $pMC, $updateTableArray, $pHbEnv[
"Uid"],
'U_UPD', $pHbEnv[
'platform'], $pHbEnv[
'currentscript'],
'U',
'E-Statement Update',
7853 $pHbEnv[
'Cn'], $pHbEnv[
'Ml'], $pHbEnv[
'remoteIp'],
false, $pSelectedAccount);
7854 if ( $result ===
false ) {
7855 $retStatus_ary[
'status'][
'errors'][] = $pMC->msg(
"Error Occurred updating settings");
7858 }
catch (Exception $ex) {
7859 $retStatus_ary[
'status'][
'errors'][] = $ex->getMessage();
7862 if (count($retStatus_ary[
'status'][
'errors']) > 0) {
7863 $retStatus_ary[
'status'][
'code'] =
'999';
7866 return $retStatus_ary;
7882 function GetMask($dbh, $Cu, $showSQL=
false)
7921 $returnArray= array(
"error" => array(),
"code" => 0,
"data" => array(
"start" => -2));
7922 return $returnArray;
7931 function ApplyMask($stringInput, $maskArray)
7933 $stringInput= trim($stringInput);
7934 $mask= preg_replace(
"/\S/",
"*", $stringInput);
7935 $start= HCU_array_key_exists(
"start", $maskArray) ? intval($maskArray[
"start"]) : 0;
7936 $stringLength= strlen($stringInput);
7937 $maskLength= HCU_array_key_exists(
"length", $maskArray) ? intval($maskArray[
"length"]) : null;
7939 $returnString= $start > 0 ? substr($mask, 0, $start) : ($start < 0 ? substr($mask, 0, $stringLength+$start) :
"");
7940 $returnString.= isset($maskLength) ? substr($stringInput, $start, $maskLength) : substr($stringInput, $start);
7941 $returnString.= substr($mask, strlen($returnString));
7943 if (strpos($returnString,
"*") ===
false)
7944 $returnString=
"****" . $returnString;
7946 return $returnString;
7965 function getAccountDescription($dbh, $Cu, $acct, $desc, $type, $display, $Fset3, $cert=0, $doEncode=
true, $isM2M=
false) {
7967 $display= trim($display);
7980 $desc = utf8_encode($desc);
7981 $desc = htmlspecialchars($desc, ENT_QUOTES);
7986 $doPrepend= $isM2M || ($Fset3 & GetFlagsetValue(
'CU3_PREPEND_MBR_DESC')) != 0;
7987 $doMask= $isM2M || ($Fset3 & GetFlagsetValue(
'CU3_MASK_MBR_DESC')) != 0;
7989 $acct= $doPrepend ? $acct :
"";
7990 if ($doPrepend && $doMask)
7992 $mask= GetMask($dbh, $Cu);
7993 $mask= $mask[
"code"] != 0 ? array(
"start" => -2) : $mask[
"data"];
7994 $acct= ApplyMask($acct, $mask);
7998 $desc=
"$acct / $type";
8001 $desc= $acct ==
"" ? $desc :
"$acct / $desc";
8002 $desc= $cert == 0 ?
"$desc - $type" :
"$desc # $cert - $type";
8020 function Get_FeatureAccounts( $pHBEnv, $pFeature, $pPlatform ) {
8021 $resultAccounts = array();
8025 if ( !( $pPlatform ==
"D" ||
8026 $pPlatform ==
"A" ) ) {
8027 throw new Exception(
"Get_FeatureAccounts: Invalid platform parameter" );
8030 $restrictedList = array(
"L",
"R" );
8031 switch ( $pFeature ) {
8034 $restrictedList = array(
"L",
"R" );
8038 $restrictedList = array(
"L" );
8042 $restrictedList = array(
"L",
"R" );
8046 $restrictedList = array(
"L",
"R" );
8052 throw new Exception(
"Get_FeatureAccounts: Invalid feature parameter" );
8057 $Cu = $pHBEnv[
"Cu"];
8058 $Uid = $pHBEnv[
"Uid"];
8059 $dbh = $pHBEnv[
"dbh"];
8062 $sql =
"SELECT DISTINCT mar.accountnumber, mar.platform, ma.restrictions 8063 FROM {$Cu}memberacctrights mar 8064 INNER JOIN {$Cu}memberacct ma ON ma.accountnumber = mar.accountnumber 8065 WHERE mar.user_id = {$Uid} 8066 AND mar.whichright = '{$pFeature}' 8067 AND mar.allowed = TRUE";
8068 $rs = db_query( $sql, $dbh );
8071 while ( $aRow = db_fetch_array( $rs, $row++ ) ) {
8072 if ( in_array( $aRow[
"restrictions"], $restrictedList )) {
8075 $platforms = HCU_JsonDecode( $aRow[
"platform"] );
8076 if ( in_array( $pPlatform, $platforms )) {
8078 $resultAccounts[] = trim( $aRow[
"accountnumber"] );
8083 }
catch (Exception $e) {
8085 $pHBEnv[
"SYSENV"][
"logger"]->error( $e->getMessage() );
8087 $resultAccounts = array();
8090 return $resultAccounts;
8119 function GetMemberDescription ($pDbh, $pCu, $pUid, $pAcctKey) {
8120 $retDesc = Array(
"description" =>
'',
"display_name" =>
"");
8124 $acctTypeorLoan = (in_array(HCU_array_key_value(
'recordtype', $pAcctKey), array(
"L",
"C")) ?
"loannumber" :
"accounttype");
8125 $isCrossAccount = strpos(HCU_array_key_value($acctTypeorLoan, $pAcctKey),
'#');
8127 switch ($pAcctKey[
'recordtype']) {
8129 if ($isCrossAccount) {
8134 list ($localXASfx, $localXAMbr) = explode(
'#', $pAcctKey[
'accounttype']);
8135 $sql =
"SELECT trim(description) as description, useraccount.display_name 8136 FROM " . prep_save($pCu, 10) .
"crossaccounts as crossaccounts 8137 LEFT JOIN " . prep_save($pCu, 10) .
"useraccounts as useraccount ON 8138 useraccount.accountnumber = crossaccounts.accountnumber 8139 AND useraccount.recordtype = 'T' 8140 AND useraccount.accounttype = trim(crossaccounts.accounttype) || '#' || trim(crossaccounts.tomember) 8141 AND useraccount.certnumber = 0 8142 AND useraccount.user_id = " . intval($pUid) .
" 8143 WHERE crossaccounts.accountnumber = '" . prep_save($pAcctKey[
'accountnumber'], 12) .
"' 8144 AND crossaccounts.tomember = '" . prep_save($localXAMbr, 12) .
"' 8145 AND crossaccounts.accounttype = '" . prep_save($localXASfx, 12) .
"' 8146 AND crossaccounts.deposittype in ('Y', 'N'); ";
8150 $sql =
"SELECT trim(description) as description, 8151 useraccount.display_name 8152 FROM " . prep_save($pCu, 10) .
"accountbalance as accountbalance 8153 LEFT JOIN " . prep_save($pCu, 10) .
"useraccounts as useraccount ON 8154 useraccount.accountnumber = accountbalance.accountnumber 8155 AND useraccount.recordtype = 'D' 8156 AND useraccount.accounttype = accountbalance.accounttype 8157 AND useraccount.certnumber = accountbalance.certnumber 8158 AND useraccount.user_id = " . intval($pUid) .
" 8159 WHERE accountbalance.accountnumber = '" . prep_save($pAcctKey[
'accountnumber'], 12) .
"' 8160 AND accountbalance.accounttype = '" . prep_save($pAcctKey[
'accounttype'], 25) .
"' 8161 AND accountbalance.certnumber = " . intval($pAcctKey[
'certnumber']) .
"; ";
8166 if ($isCrossAccount) {
8171 list ($localXASfx, $localXAMbr) = explode(
'#', $pAcctKey[
'loannumber']);
8172 $sql =
"SELECT trim(description) as description, useraccount.display_name 8173 FROM " . prep_save($pCu, 10) .
"crossaccounts as crossaccounts 8174 LEFT JOIN " . prep_save($pCu, 10) .
"useraccounts as useraccount ON 8175 useraccount.accountnumber = crossaccounts.accountnumber 8176 AND useraccount.recordtype = 'P' 8177 AND useraccount.accounttype = trim(crossaccounts.accounttype) || '#' || trim(crossaccounts.tomember) 8178 AND useraccount.certnumber = 0 8179 AND useraccount.user_id = " . intval($pUid) .
" 8180 WHERE crossaccounts.accountnumber = '" . prep_save($pAcctKey[
'accountnumber'], 12) .
"' 8181 AND crossaccounts.tomember = '" . prep_save($localXAMbr, 12) .
"' 8182 AND crossaccounts.accounttype = '" . prep_save($localXASfx, 12) .
"' 8183 AND crossaccounts.deposittype = 'L'; ";
8188 $sql =
"SELECT trim(description) as description, 8189 useraccount.display_name 8190 FROM " . prep_save($pCu, 10) .
"loanbalance as loanbalance 8191 LEFT JOIN " . prep_save($pCu, 10) .
"useraccounts as useraccount ON 8192 useraccount.accountnumber = loanbalance.accountnumber 8193 AND useraccount.recordtype = 'L' 8194 AND useraccount.accounttype = loanbalance.loannumber 8195 AND useraccount.user_id = " . intval($pUid) .
" 8196 WHERE loanbalance.accountnumber = '" . prep_save($pAcctKey[
'accountnumber'], 12) .
"' 8197 AND loanbalance.loannumber = '" . prep_save($pAcctKey[
'loannumber'], 25) .
"'; ";
8203 if ($sql !=
'' && db_connection_status($pDbh) === PGSQL_CONNECTION_OK) {
8205 $descRs = db_query($sql, $pDbh);
8206 $descRow = db_fetch_assoc($descRs);
8209 $retDesc[
'description'] = trim($descRow[
'description']);
8210 $retDesc[
'display_name'] = trim($descRow[
'display_name']);
8237 function FindUserAccountExists ($pDbh, $pCu, $pUid, $pAcctType, $pAcctNbr, $pAcctSfx, $pCertNo=
'') {
8241 switch ($pAcctType) {
8245 $sql =
"SELECT useraccount.* 8246 FROM " . prep_save($pCu, 10) .
"useraccounts as useraccount 8248 useraccount.recordtype = '" . prep_save($pAcctType, 1) .
"' 8249 AND useraccount.accountnumber = '" . prep_save($pAcctNbr, 12) .
"' 8250 AND useraccount.accounttype = '" . prep_save($pAcctSfx, 25) .
"' 8251 AND useraccount.certnumber = " . intval($pCertNo) .
" 8252 AND useraccount.user_id = " . intval($pUid) .
"; ";
8258 $sql =
"SELECT useraccount.* 8259 FROM " . prep_save($pCu, 10) .
"useraccounts as useraccount 8261 useraccount.recordtype = '" . prep_save($pAcctType, 1) .
"' 8262 AND useraccount.accountnumber = '" . prep_save($pAcctNbr, 12) .
"' 8263 AND useraccount.accounttype = '" . prep_save($pAcctSfx, 25) .
"' 8264 AND useraccount.user_id = " . intval($pUid) .
"; ";
8269 if ($sql !=
'' && db_connection_status($pDbh) === PGSQL_CONNECTION_OK) {
8271 $descRs = db_query($sql, $pDbh);
8272 $descRow = db_fetch_assoc($descRs);
8274 $retVal = Array(
"data" => $descRow);
8295 function FindMemberAccountExists ($pDbh, $pCu, $pAcctNbr) {
8300 FROM " . prep_save($pCu, 10) .
"memberacct as memberacct 8302 accountnumber = '" . prep_save($pAcctNbr, 12) .
"'; ";
8304 if ($sql !=
'' && db_connection_status($pDbh) === PGSQL_CONNECTION_OK) {
8306 $descRs = db_query($sql, $pDbh);
8307 $descRow = db_fetch_assoc($descRs);
8309 $retVal = Array(
"data" => $descRow);
8327 function GetMemberAccessList($pDbh, $pHBEnv, $pMbrAcct) {
8331 $sql =
"SELECT user_id, allowed 8332 FROM " . prep_save($pHBEnv[
'Cu'], 10) .
"memberacctrights as mar 8333 WHERE accountnumber = '" . prep_save($pMbrAcct, 12) .
"' 8334 AND whichright = 'ACCESS' 8335 AND allowed = true";
8337 $accessRS = db_query($sql, $pDbh);
8338 $accessRows = db_fetch_all( $accessRS);
8340 if (is_array($accessRows)) {
8342 for ($idx = 0; $idx < count($accessRows); $idx++) {
8343 $retList[] = intval($accessRows[$idx][
'user_id']);
8346 }
catch (Exception $ex) {
8364 function CanActivateUser($pHBEnv, $pMbrAcct) {
8366 $Cu = $pHBEnv[
"Cu"];
8367 $dbh = $pHBEnv[
"dbh"];
8369 $returnArray = array(
"memberExists" =>
false,
"userExists" =>
false,
"isNullPassword" =>
false,
"isFailed" =>
false,
"allowEnroll" =>
false);
8372 $sql =
"select ma.accountnumber, ma.allowenroll from ${Cu}memberacct ma where ma.accountnumber = '$pMbrAcct'";
8374 $sth = db_query ($sql, $dbh);
8376 throw new exception(
"Member query failed.", 4);
8379 if (db_num_rows($sth) > 0) {
8380 $row = db_fetch_assoc($sth, 0);
8381 $returnArray [
"memberExists"] =
true;
8382 $returnArray [
"allowEnroll"] = isset($row[
"allowenroll"]) && trim($row[
"allowenroll"]) ==
"t";
8385 $sql =
"select u.user_id, u.passwd, u.failedremain from ${Cu}user u 8386 left join ${Cu}memberacct ma on u.user_id = ma.primary_user and u.user_name = '$pMbrAcct' 8387 where u.user_name = '$pMbrAcct' or ma.primary_user is not null";
8389 $sth = db_query ($sql, $dbh);
8391 throw new exception(
"User account query failed.", 3);
8394 if (db_num_rows($sth) > 0) {
8395 $row = db_fetch_assoc($sth, 0);
8396 $returnArray [
"userExists"] =
true;
8397 $returnArray [
"isNullPassword"] = trim($row[
"passwd"]) ==
'NULL PASSWORD';
8398 $returnArray [
"isFailed"] = $row[
"failedremain"] <= 0;
8401 }
catch (exception $e) {
8402 $pHBEnv[
"SYSENV"][
"logger"]->error($e->getMessage());
8405 return $returnArray;
8408 function FindAccountDisplay($pEnv, $pDbh, $pCu, $pMember, $pSuffix, $pType, $pCert = 0) {
8411 "accountnumber" => $pMember,
8412 "recordtype" => $pType
8415 if ($acctKey[
'recordtype'] ==
"D" ) {
8416 $acctKey[
'accounttype'] = $pSuffix;
8417 $acctKey[
'certnumber'] = $pCert;
8418 }
else if ($acctKey[
'recordtype'] ==
"L" || $acctKey[
'recordtype'] ==
"C") {
8419 $acctKey[
'loannumber'] = $pSuffix;
8422 $acctDisp = GetMemberDescription($pDbh, $pCu, $pEnv[
'Uid'], $acctKey);
8423 if ($acctKey[
'recordtype'] ==
"D") {
8424 $acctDesc = getAccountDescription($pDbh, $pCu, $acctKey[
'accountnumber'], $acctDisp[
'description'], $acctKey[
'accounttype'], $acctDisp[
'display_name'], $pEnv[
"Fset3"], $acctKey[
'certnumber'],
false);
8425 }
else if ($acctKey[
'recordtype'] ==
"L" || $acctKey[
'recordtype'] ==
"C") {
8426 $acctDesc = getAccountDescription($pDbh, $pCu, $acctKey[
'accountnumber'], $acctDisp[
'description'], $acctKey[
'loannumber'], $acctDisp[
'display_name'], $pEnv[
"Fset3"], 0,
false);
8428 $acctDesc = $pEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );