18 function getActiveStatuses($MC) {
19 return array(array(
"value" =>
"",
"text" => $MC->msg(
"Any", HCU_DISPLAY_AS_HTML)),
20 array(
"value" =>
"A",
"text" => $MC->msg(
"Active", HCU_DISPLAY_AS_HTML)),
21 array(
"value" =>
"I",
"text" => $MC->msg(
"Inactive", HCU_DISPLAY_AS_HTML)));
31 function getApprovalStatuses($MC)
33 return array(array(
"value" =>
"",
"text" => $MC->msg(
"Any", HCU_DISPLAY_AS_HTML)),
34 array(
"value" => 10,
"text" => $MC->msg(
"Approved", HCU_DISPLAY_AS_HTML)),
35 array(
"value" => 99,
"text" => $MC->msg(
"Cancelled", HCU_DISPLAY_AS_HTML)),
36 array(
"value" => 90,
"text" => $MC->msg(
"Declined", HCU_DISPLAY_AS_HTML)));
46 function getActions($MC) {
48 array(
"value" =>
"action",
"text" => $MC->msg(
"Action", HCU_DISPLAY_AS_HTML)),
49 array(
"value" =>
"viewDetails",
"text" => $MC->msg(
"View Details", HCU_DISPLAY_AS_HTML)),
50 array(
"value" =>
"approve",
"text" => $MC->msg(
"Approve", HCU_DISPLAY_AS_HTML),
"grids" => array(
"pendingApprovalGrid"),
"uid" => array(
"without")),
51 array(
"value" =>
"decline",
"text" => $MC->msg(
"Decline", HCU_DISPLAY_AS_HTML),
"grids" => array(
"pendingApprovalGrid"),
"uid" => array(
"without")),
52 array(
"value" =>
"cancel",
"text" => $MC->msg(
"Cancel", HCU_DISPLAY_AS_HTML),
"grids" => array(
"pendingApprovalGrid",
"scheduledTransactionsGrid"),
"uid" => array(
"with")),
53 array(
"value" =>
"skip",
"text" => $MC->msg(
"Skip", HCU_DISPLAY_AS_HTML),
"grids" => array(
"scheduledTransactionsGrid"),
"uid" => array(
"with")));
62 function getApprovalList() {
63 return array(
"TRN",
"ACHPMT",
"ACHCOL",
"TRNEXT",
"TRNM2M");
77 function parseWhere($where, $whereBase) {
78 foreach($where as $whereCode => $whereRecord) {
79 $where[$whereCode] = implode(
" and ", $whereRecord);
82 $where = (count($where) > 0 ?
"((" . implode(
") or (", $where) .
")) " :
"");
83 $whereBase = (count($whereBase) > 0 ? implode(
" and ", $whereBase) :
"");
84 $whereAll = $where !=
"" ? ($whereBase !=
"" ?
"$where and $whereBase" : $where) : ($whereBase !=
"" ? $whereBase :
"");
95 function addCustomData($key, &$row) {
96 if ($row[$key] ==
null) {
97 $customData = array(
"string" =>
"");
99 $customData = HCU_JsonDecode($row[$key]);
100 if (!is_array($customData)) {
101 $customData = array(
"string" => trim($row[$key]));
102 }
else if (count($customData) == 0) {
103 $customData = array(
"string" =>
"");
117 function gridModify(&$grid) {
118 for($i = 0, $count = count($grid); $i != $count; $i++) {
119 unset($grid[$i][
"dateSortObj"]);
120 unset($grid[$i][
"isscheduled"]);
122 foreach($grid[$i] as $key => $value) {
123 $grid[$i][$key] = isset($value) ? (!is_array($value) ? trim($value) : $value) :
"";
126 $grid[$i][
"kendoId"] = $i + 1;
127 $grid[$i][
"amount"] = isset($grid[$i][
"amount"]) ? floatval($grid[$i][
"amount"]) : 0;
138 function getIntervalLookup($MC) {
139 $intervalList = TxIntervalList($MC);
140 foreach($intervalList as $interval) {
141 $value = trim($interval[
"value"]);
142 $intervalLookup[$value] = trim($interval[
"text"]);
144 return $intervalLookup;
159 function getFeatures($dbh, $Cu, &$sqls, $MC, $Uid) {
162 SELECT DISTINCT f.feature_code AS value, f.description AS text 164 RIGHT JOIN cu_featuremenu fm ON f.feature_code = fm.feature_code 165 INNER JOIN cu_profilerights pr ON fm.feature_code = pr.feature_code 166 INNER JOIN {$Cu}group g ON pr.profile_id = g.profile_id 167 INNER JOIN {$Cu}user u ON g.group_id = u.group_id 168 WHERE u.user_id = $Uid 169 AND fm.feature_code IN ('TRN', 'TRNEXT', 'TRNM2M', 'ACHPMT', 'ACHCOL', 'TRNWIRE') 170 ORDER BY f.description";
172 $sth = db_query($sql, $dbh);
174 throw new exception(
"feature query failed.", 504);
176 $featureDDL = array(array(
"value" =>
"",
"text" => $MC->msg(
"All", HCU_DISPLAY_AS_HTML)));
177 for($i = 0; $row = db_fetch_assoc($sth, $i); $i++) {
179 $feature = $MC->msg(
"CU feature " . $row[
"value"], HCU_DISPLAY_AS_RAW);
180 $row[
"text"] = isset($feature) ? $feature : $row[
"text"];
182 $featureDDL[] = $row;
198 function getValidUserIds($dbh, $Cu, $Cn, &$sqls) {
200 $sql =
"select b.user_id from ${Cu}user a inner join ${Cu}user b on a.user_name = '" . prep_save($Cn, 50) .
"' and a.group_id = b.group_id";
202 $sth = db_query($sql, $dbh);
204 throw new exception(
"group query failed.", 602);
206 $validUserIds = array();
208 for($i = 0; $row = db_fetch_row($sth, $i); $i++) {
209 $validUserIds[] = intval($row[0]);
211 $showPendingApprovalGrid = count($validUserIds) > 1;
212 return array(
"showPendingApprovalGrid" => $showPendingApprovalGrid,
"validUserIds" =>
"(" . implode(
",", $validUserIds) .
")");
222 function getDateTime($datestring) {
224 $dateTime = DateTime::createFromFormat(
"Y-m-d h:i:s.u+", $datestring);
225 $dateTime = !$dateTime ? DateTime::createFromFormat(
"Y-m-d h:i:s+", $datestring) : $dateTime;
226 $dateTime = !$dateTime ? DateTime::createFromFormat(
"Y-m-d+", $datestring) : $dateTime;
229 $dateTime = !$dateTime ?
new DateTime(
"@1") : $dateTime;
233 function getValidDate($datestring, $tz, $setTimezone =
true) {
234 $dateTime = isset($datestring) && trim($datestring) !=
"" ?
new DateTime($datestring) : null;
237 if ($setTimezone && isset($dateTime)) {
238 $dateTime->setTimezone($tz);
253 function cmp($a, $b) {
254 $aCmp = $a[
"dateSortObj"];
255 $bCmp = $b[
"dateSortObj"];
257 return $aCmp > $bCmp ? 1 : ($aCmp < $bCmp ? -1 : 0);
267 function revCmp($a, $b) {
268 $aCmp = $a[
"dateSortObj"];
269 $bCmp = $b[
"dateSortObj"];
271 return $aCmp > $bCmp ? -1 : ($aCmp < $bCmp ? 1 : 0);
281 function getGFormat() {
282 return "n/j/Y g:i A";
292 function getDFormat() {
314 function GetUserActivity( $pHBEnv, $pWhichActivity, $pParams ) {
315 $returnData = array(
"code" =>
"000",
"error" =>
"",
"data" => array() );
320 $confirmPermissions = array();
321 $results = Perm_FeatureAccessList( $pHBEnv[
"dbh"], $pHBEnv );
322 if ( !intval($results[
"status"][
"code"] ) == 0) {
323 throw new exception($results[
"status"][
"error"] .
" 1404");
327 $permissions = $results[
"data"][$pHBEnv[
"Uid"]];
330 $approvalFeatureList = getApprovalList();
331 $confirmFound =
false;
332 foreach( $permissions as $featureCode => $featureRecord ) {
333 if ( !in_array( $featureCode, $approvalFeatureList ) ) {
337 $confirmFound = $confirmFound || $featureRecord[
"confirm"];
338 $confirmPermissions[$featureCode] = $featureRecord[
"confirm"];
341 if ( !$confirmFound )
343 $sql=
"SELECT 'FOUND' FROM {$pHBEnv["Cu
"]}user a 344 INNER JOIN {$pHBEnv["Cu
"]}user b ON a.user_id = {$pHBEnv["Uid
"]} 345 AND a.group_id = b.group_id 346 AND a.user_id <> b.user_id";
347 $sth = db_query($sql, $pHBEnv[
"dbh"]);
349 throw new exception(
"Error checking if multiple users found" .
" 1403");
351 if (db_num_rows($sth) > 0) {
353 throw new exception(
"No approval permissions found" .
" 1402");
358 if ( $pWhichActivity ==
"prior" ) {
359 $result = _GetUserActivityPrior( $pHBEnv, $pParams );
360 }
else if ( $pWhichActivity ==
"scheduled" ) {
361 $result = _GetUserActivityScheduled( $pHBEnv, $pParams );
362 }
else if ( $pWhichActivity ==
"pending" ) {
363 $result = _GetUserActivityPending( $pHBEnv, $pParams, $confirmPermissions );
366 throw new exception( $pHBEnv[
"MC"]->msg(
"Feature Unavailable", HCU_DISPLAY_AS_RAW ) .
" 1401");
369 if ( $result[
"code"] !=
"000" ) {
370 throw new exception( $result[
"error"] );
373 $returnData[
"data"] = $result[
"data"];
375 }
catch (Exception $e) {
377 $message = $e->getMessage();
379 $returnData[
"code"] =
"999";
380 $returnData[
"error"] = $message;
396 function GetActivityDetail( $pHBEnv, $pTxnId, $pIsScheduled ) {
397 if ( $pIsScheduled ) {
398 $returnInfo = _GetActivityDetailScheduled( $pHBEnv, $pTxnId );
400 $returnInfo = _GetActivityDetailRegular( $pHBEnv, $pTxnId );
415 function _GetActivityDetailRegular( $pHBEnv, $pTxnId ) {
416 $returnData = array(
"code" =>
"000",
"error" =>
"",
"data" => array() );
420 $accountMask = GetMask( $pHBEnv[
"dbh"], $pHBEnv[
"Cu"] );
423 $sql =
"SELECT h.*, u.user_name, a.user_name as approve_name, u.group_id as user_group, t.group_id as test_group 424 FROM {$pHBEnv["Cu
"]}transhdr h 425 INNER JOIN {$pHBEnv["Cu
"]}user u ON u.user_id = h.posted_by 426 INNER JOIN {$pHBEnv["Cu
"]}user t ON t.user_id = {$pHBEnv["Uid
"]} 427 LEFT JOIN {$pHBEnv["Cu
"]}user a ON a.user_id = h.approved_by 428 WHERE h.id = $pTxnId";
430 $sth = db_query( $sql, $pHBEnv[
"dbh"] );
432 throw new exception($pHBEnv[
"MC"]->msg(
"ACH Query Error", HCU_DISPLAY_AS_RAW ) .
" 1412");
435 $headerRow = db_fetch_assoc($sth, 0);
437 if ( $headerRow[
"user_group"] != $headerRow[
"test_group"] ) {
438 throw new exception($pHBEnv[
"MC"]->msg(
"Invalid account access", HCU_DISPLAY_AS_RAW ) .
" 1413");
441 $approvedStatus = intval( $headerRow[
"approved_status"] );
445 FROM {$pHBEnv["Cu
"]}transdtl d 446 WHERE transhdr_id = $pTxnId";
448 $sth = db_query( $sql, $pHBEnv[
"dbh"] );
450 throw new exception($pHBEnv[
"MC"]->msg(
"ACH Query Error", HCU_DISPLAY_AS_RAW ) .
" 1414");
453 $detailRows = db_fetch_all($sth);
456 $transDetail = array();
458 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Created On", HCU_DISPLAY_AS_RAW ),
459 "value" => date(
"m/d/Y g:ia", strtotime( $headerRow[
"posted_date"] ) ) );
460 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Created By", HCU_DISPLAY_AS_RAW ),
461 "value" => $headerRow[
"user_name"] );
462 if ( $approvedStatus == 90 ) {
463 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Declined on", HCU_DISPLAY_AS_RAW ),
464 "value" => date(
"m/d/Y g:ia", strtotime( $headerRow[
"approved_date"] ) ) );
465 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Declined by", HCU_DISPLAY_AS_RAW ),
466 "value" => $headerRow[
"approve_name"] );
468 }
else if ( $approvedStatus == 99 ) {
469 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Cancelled on", HCU_DISPLAY_AS_RAW ),
470 "value" => date(
"m/d/Y g:ia", strtotime( $headerRow[
"approved_date"] ) ) );
471 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Cancelled by", HCU_DISPLAY_AS_RAW ),
472 "value" => $headerRow[
"approve_name"] );
473 }
else if ( $approvedStatus > 0 ) {
475 if ( $headerRow[
"approved_by"] != $headerRow[
"posted_by"] ) {
476 $approveTime = strtotime( $headerRow[
"approved_date"] );
477 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Approved on", HCU_DISPLAY_AS_RAW ),
478 "value" => date(
"m/d/Y", $approveTime ) );
480 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Approved by", HCU_DISPLAY_AS_RAW ),
481 "value" => $headerRow[
"approve_name"] );
484 $processTime = strtotime( $headerRow[
"processed_date"] );
485 if ( $processTime == 0 ) {
486 $dateString = $pHBEnv[
"MC"]->msg(
"Not processed", HCU_DISPLAY_AS_RAW );
488 $dateString = date(
"m/d/Y", $processTime );
490 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Processed Date", HCU_DISPLAY_AS_RAW ),
491 "value" => $dateString );
492 }
else if ( $approvedStatus == 0 ) {
493 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Approved by", HCU_DISPLAY_AS_RAW ),
494 "value" => $pHBEnv[
"MC"]->msg(
"Pending Approval", HCU_DISPLAY_AS_RAW ) );
500 $transactionCode = $headerRow[
"transactioncode"];
503 $txnInfo = HCU_JsonDecode( $detailRows[0][
"transdata"] );
506 if ( in_array( $transactionCode, array(
"2W",
"2P") ) ) {
508 $fromDesc = $txnInfo[
"acct_source"][
"remote_entity"][
"name"];
510 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"From", HCU_DISPLAY_AS_RAW ),
511 "value" => $fromDesc );
514 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"ACH Routing Number", HCU_DISPLAY_AS_RAW ),
515 "value" => $txnInfo[
"acct_source"][
"rdfi"][
"rdfi_routing"] );
517 $fromAcct = ApplyMask( $txnInfo[
"acct_source"][
"rdfi"][
"rdfi_account"], $accountMask[
"data"] );
519 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Account", HCU_DISPLAY_AS_RAW ),
520 "value" => $fromAcct );
523 $acctParts = explode(
"|", $txnInfo[
"acct_source"] );
524 $certNumber = isset( $acctParts[3] ) && $acctParts[3] > 0 ? $acctParts[3] : 0;
525 $accountType = $txnInfo[
'source_key'][
'recordtype'] ==
"L" ? $txnInfo[
'source_key'][
'loannumber'] : $txnInfo[
'source_key'][
'accounttype'];
527 $fromDesc = FindAccountDisplay( $pHBEnv, $pHBEnv[
"dbh"], $pHBEnv[
'Cu'], $txnInfo[
'source_key'][
'accountnumber'], $accountType, $txnInfo[
'source_key'][
'recordtype'], $certNumber );
529 if ( $fromDesc ==
"" ) {
530 $fromDesc = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
533 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"From", HCU_DISPLAY_AS_RAW ),
534 "value" => $fromDesc );
537 if ( in_array( $transactionCode, array(
"1W",
"1P") ) ) {
539 $toDesc = $txnInfo[
"acct_dest"][
"remote_entity"][
"name"];
541 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"To", HCU_DISPLAY_AS_RAW ),
542 "value" => $toDesc );
545 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"ACH Routing Number", HCU_DISPLAY_AS_RAW ),
546 "value" => $txnInfo[
"acct_dest"][
"rdfi"][
"rdfi_routing"] );
548 $toAcct = ApplyMask( $txnInfo[
"acct_dest"][
"rdfi"][
"rdfi_account"], $accountMask[
"data"] );
550 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Account", HCU_DISPLAY_AS_RAW ),
551 "value" => $toAcct );
552 }
else if ( $transactionCode ==
"MM" ) {
555 $toAcct = ApplyMask( $txnInfo[
"dest_key"][
"accountnumber"], $accountMask[
"data"] );
558 $toName = $txnInfo[
"dest_key"][
"name"];
560 $toDesc =
"$toAcct ($toName)";
562 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"To", HCU_DISPLAY_AS_RAW ),
563 "value" => $toDesc );
565 }
else if ( in_array( $transactionCode, array(
"OT",
"CW") ) ) {
567 $acctParts = explode(
"|", $txnInfo[
"acct_dest"] );
568 if ( $acctParts[0] ==
"O" ) {
569 if ( $trans ==
null ) {
570 $trans = Get_HaveTrans( $pHBEnv[
"dbh"], $pHBEnv );
573 $otherDesc = HCU_array_key_value($acctParts[2], $trans);
575 $cuDesc = isset($otherDesc[2]) ? trim($otherDesc[2]) :
"";
576 $nonCUDesc = isset($otherDesc[0]) ? trim($otherDesc[0]) :
"";
578 $toDesc = $cuDesc !=
"" ? $cuDesc : $nonCUDesc;
581 if ( $toDesc ==
"" ) {
582 $toDesc = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
585 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"To", HCU_DISPLAY_AS_RAW ),
586 "value" => $toDesc );
589 $acctParts = explode(
"|", $txnInfo[
"acct_dest"] );
590 $certNumber = isset( $acctParts[3] ) && $acctParts[3] > 0 ? $acctParts[3] : 0;
591 $accountType = $txnInfo[
'dest_key'][
'recordtype'] ==
"L" ? $txnInfo[
'dest_key'][
'loannumber'] : $txnInfo[
'dest_key'][
'accounttype'];
593 $toDesc = FindAccountDisplay( $pHBEnv, $pHBEnv[
"dbh"], $pHBEnv[
'Cu'], $txnInfo[
'dest_key'][
'accountnumber'], $accountType, $txnInfo[
'dest_key'][
'recordtype'], $certNumber );
595 if ( $toDesc ==
"" ) {
596 $toDesc = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
599 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"To", HCU_DISPLAY_AS_RAW ),
600 "value" => $toDesc );
604 switch( $headerRow[
"feature_code"] ) {
616 throw new exception($pHBEnv[
"MC"]->msg(
"Unknown feature type", HCU_DISPLAY_AS_RAW ) .
" 1415");
620 $amount = number_format( $detailRows[0][
"amount"], 2 );
621 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Amount", HCU_DISPLAY_AS_RAW ),
622 "value" =>
"$" . $amount,
"type" =>
"currency" );
624 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Comment", HCU_DISPLAY_AS_RAW ),
625 "value" => $headerRow[
"memo"] );
629 $confCodeBuilder[
"id"] = $headerRow[
"id"];
630 if ( $headerRow[
"processed_by"] !=
"" ) {
632 $confCodeBuilder[
"processed_by"] =
"*immed*";
633 $confCodeBuilder[
"posted_by"] = $headerRow[
"posted_by"];
634 $confCodeBuilder[
"processed_date"] = $headerRow[
"processed_date"];
635 $confirmationCode = GetTransferConfirmCode( $pHBEnv,
"process", $confCodeBuilder );
636 }
else if ( $headerRow[
"approved_by"] !=
"" ) {
638 $confCodeBuilder[
"approved_by"] = $headerRow[
"approved_by"];
639 $confCodeBuilder[
"approved_date"] = $headerRow[
"approved_date"];
640 $confirmationCode = GetTransferConfirmCode( $pHBEnv,
"approve", $confCodeBuilder );
641 }
else if ( $headerRow[
"posted_by"] !=
"" ) {
643 $confCodeBuilder[
"posted_by"] = $headerRow[
"posted_by"];
644 $confCodeBuilder[
"posted_date"] = $headerRow[
"posted_date"];
645 $confirmationCode = GetTransferConfirmCode( $pHBEnv,
"post", $confCodeBuilder );
647 $confirmationCode =
"";
650 if ( $confirmationCode !=
"" ) {
651 $transDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Confirmation", HCU_DISPLAY_AS_RAW ),
652 "value" => $confirmationCode );
656 for ( $i = 0; $i < count( $transDetail ); $i++ ) {
657 $returnData[
"data"][][
"detail"] = $transDetail[$i];
660 }
catch (Exception $e) {
662 $message = $e->getMessage();
664 $returnData[
"code"] =
"999";
665 $returnData[
"error"] = $message;
680 function _GetActivityDetailScheduled( $pHBEnv, $pTxnId ) {
681 $returnData = array(
"code" =>
"000",
"error" =>
"",
"data" => array() );
685 $accountMask = GetMask( $pHBEnv[
"dbh"], $pHBEnv[
"Cu"] );
688 $transferFeatureList = GetTransferFeatureList( $pHBEnv );
691 $transferFeatures = ConvertToLookupArray( $transferFeatureList );
694 $recurringIntervals = getIntervalLookup( $pHBEnv[
"MC"] );
697 $sql =
"SELECT s.*, c.user_name as created, a.user_name as approved, 698 c.group_id as user_group, t.group_id as test_group 699 FROM cu_scheduledtxn s 700 INNER JOIN {$pHBEnv["Cu
"]}user c ON c.user_id = s.user_id 701 INNER JOIN {$pHBEnv["Cu
"]}user t ON t.user_id = {$pHBEnv["Uid
"]} 702 LEFT JOIN {$pHBEnv["Cu
"]}user a ON a.user_id = s.approved_by 703 WHERE s.id = $pTxnId";
705 $sth = db_query( $sql, $pHBEnv[
"dbh"] );
707 throw new exception($pHBEnv[
"MC"]->msg(
"ACH Query Error", HCU_DISPLAY_AS_RAW ) .
" 1416");
710 $schedRow = db_fetch_assoc( $sth, 0 );
712 if ( $schedRow[
"user_group"] != $schedRow[
"test_group"] ) {
713 throw new exception($pHBEnv[
"MC"]->msg(
"Invalid account access", HCU_DISPLAY_AS_RAW ) .
" 1417");
722 $txnInfo = HCU_JsonDecode( $schedRow[
"txn_data"] );
725 $schedDetail = array();
728 if ( $schedRow[
"status"] ==
"I" ) {
729 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Status", HCU_DISPLAY_AS_RAW ),
730 "value" => $pHBEnv[
"MC"]->msg(
"Inactive", HCU_DISPLAY_AS_RAW ) );
734 $featureName = $transferFeatures[$schedRow[
"feature_code"]];
735 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Transfer", HCU_DISPLAY_AS_RAW ),
736 "value" => $featureName );
738 $createTime = date(
"m/d/Y g:ia", strtotime( $schedRow[
"create_date"] ) );
739 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Created On", HCU_DISPLAY_AS_RAW ),
740 "value" => $createTime );
742 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Created By", HCU_DISPLAY_AS_RAW ),
743 "value" => $schedRow[
"created"] );
745 $status = $schedRow[
"approved_status"];
747 if ( strlen( trim( $schedRow[
"approved"] ) ) > 0 ) {
750 if ( $schedRow[
"user_id"] != $schedRow[
"approved_by"] ) {
751 $approveTime = date(
"m/d/Y g:ia", strtotime( $schedRow[
"approved_date"] ) );
752 if ( $status == 90 ) {
753 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Declined on", HCU_DISPLAY_AS_RAW ),
754 "value" => $approveTime );
756 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Declined by", HCU_DISPLAY_AS_RAW ),
757 "value" => $schedRow[
"approved"] );
759 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Approved on", HCU_DISPLAY_AS_RAW ),
760 "value" => $approveTime );
762 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Approved by", HCU_DISPLAY_AS_RAW ),
763 "value" => $schedRow[
"approved"] );
768 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Approved by", HCU_DISPLAY_AS_RAW ),
769 "value" => $pHBEnv[
"MC"]->msg(
"Pending Approval", HCU_DISPLAY_AS_RAW ) );
772 $startDate = date(
"m/d/Y", strtotime( $schedRow[
"start_date"] ) );
773 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Start Date", HCU_DISPLAY_AS_RAW ),
774 "value" => $startDate );
776 $endDate = empty( trim( $schedRow[
"end_date"] ) ) ? $pHBEnv[
"MC"]->msg(
"Transfer does not stop", HCU_DISPLAY_AS_RAW) : date(
"m/d/Y", strtotime( $schedRow[
"end_date"] ) );
777 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"End Date", HCU_DISPLAY_AS_RAW ),
778 "value" => $endDate );
780 $nextTriggerDate = date(
"m/d/Y", strtotime( $schedRow[
"next_trigger_date"] ) );
781 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Next Date", HCU_DISPLAY_AS_RAW ),
782 "value" => $nextTriggerDate );
786 if ( $status == 10 ) {
787 $statusString = $pHBEnv[
"MC"]->msg( $schedRow[
"status"] ==
"A" ?
"Active" :
"Inactive", HCU_DISPLAY_AS_RAW );
789 $allowedStatuses = _GetAllowedStatuses( $pHBEnv[
"MC"] );
791 $statusString = $allowedStatuses[$schedRow[
"approved_status"]];
794 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Status", HCU_DISPLAY_AS_RAW),
795 "value" => $statusString );
798 $repeatingParams = HCU_JsonDecode( $schedRow[
"repeating_parameters"],
false,
true );
799 $intervalName = $recurringIntervals[$repeatingParams[
"interval"]];
800 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Interval", HCU_DISPLAY_AS_RAW),
801 "value" => $intervalName );
804 $transactionCode = $txnInfo[
"txn"][
"transactioncode"];
806 if ( in_array( $transactionCode, array(
"2W",
"2P") ) ) {
808 $extId = $txnInfo[
"txn"][
"from"];
809 $fromInfo = _GetExternalAccount( $pHBEnv, $extId );
811 $fromDesc = $fromInfo[
"display"];
813 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"From Account", HCU_DISPLAY_AS_RAW ),
814 "value" => $fromDesc );
817 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"ACH Routing Number", HCU_DISPLAY_AS_RAW ),
818 "value" => $fromInfo[
"routing"] );
820 $fromAcct = ApplyMask( $fromInfo[
"account"], $accountMask[
"data"] );
822 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Account", HCU_DISPLAY_AS_RAW ),
823 "value" => $fromAcct );
826 $acctParts = explode(
"|", $txnInfo[
"txn"][
"from"] );
827 $certNumber = isset( $acctParts[3] ) && $acctParts[3] > 0 ? $acctParts[3] : 0;
828 $fromDesc = FindAccountDisplay( $pHBEnv, $pHBEnv[
"dbh"], $pHBEnv[
'Cu'], $txnInfo[
'txn'][
'frommember'], $txnInfo[
'txn'][
'fromsuffix'], $txnInfo[
'txn'][
'fromtype'], $certNumber );
830 if ( $fromDesc ==
"" ) {
831 $fromDesc = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
834 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"From Account", HCU_DISPLAY_AS_RAW ),
835 "value" => $fromDesc );
838 if ( in_array( $transactionCode, array(
"1W",
"1P") ) ) {
840 $extId = $txnInfo[
"txn"][
"to"];
841 $toInfo = _GetExternalAccount( $pHBEnv, $extId );
843 $toDesc = $toInfo[
"display"];
844 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"To Account", HCU_DISPLAY_AS_RAW ),
845 "value" => $toDesc );
848 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"ACH Routing Number", HCU_DISPLAY_AS_RAW ),
849 "value" => $toInfo[
"routing"] );
852 $toAcct = ApplyMask( $toInfo[
"account"], $accountMask[
"data"] );
854 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Account", HCU_DISPLAY_AS_RAW ),
855 "value" => $toAcct );
856 }
else if ( $transactionCode ==
"MM" ) {
858 $extId = $txnInfo[
"txn"][
"to"];
859 $toInfo = _GetExternalAccount( $pHBEnv, $extId );
862 $toAcct = ApplyMask( $toInfo[
"account"], $accountMask[
"data"] );
865 $toName = $toInfo[
"name"];
867 $toDesc =
"$toAcct ($toName)";
869 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"To Account", HCU_DISPLAY_AS_RAW ),
870 "value" => $toDesc );
873 $acctParts = explode(
"|", $txnInfo[
"txn"][
"to"] );
874 $certNumber = isset( $acctParts[3] ) && $acctParts[3] > 0 ? $acctParts[3] : 0;
875 $toDesc = FindAccountDisplay( $pHBEnv, $pHBEnv[
"dbh"], $pHBEnv[
'Cu'], $txnInfo[
'txn'][
'tomember'], $txnInfo[
'txn'][
'tosuffix'], $txnInfo[
'txn'][
'totype'], $certNumber );
877 if ( $toDesc ==
"" ) {
878 $toDesc = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
881 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"To Account", HCU_DISPLAY_AS_RAW ),
882 "value" => $toDesc );
885 $amount = number_format( $txnInfo[
"txn"][
"amount"], 2 );
886 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Amount", HCU_DISPLAY_AS_RAW ),
887 "value" =>
"$" . $amount,
"type" =>
"currency" );
889 $memo = trim( $txnInfo[
"txn"][
"memo"] );
890 $schedDetail[] = array(
"name" => $pHBEnv[
"MC"]->msg(
"Comment", HCU_DISPLAY_AS_RAW ),
894 for ( $i = 0; $i < count( $schedDetail ); $i++ ) {
895 $returnData[
"data"][][
"detail"] = $schedDetail[$i];
898 }
catch (Exception $e) {
900 $message = $e->getMessage();
902 $returnData[
"code"] =
"999";
903 $returnData[
"error"] = $message;
912 function GetTransferFeatureList( $pHBEnv ) {
914 $allowedTranfers = getApprovalList();
915 $transLimitStr =
"'" . implode(
"','", $allowedTranfers ) .
"'";
918 $sql =
"SELECT distinct f.feature_code AS name, f.description AS value 920 INNER JOIN cu_profilerights pr ON f.feature_code = pr.feature_code 922 INNER JOIN cu_profile p ON pr.profile_id = p.profile_id 923 AND p.cu='{$pHBEnv["Cu
"]}' 924 INNER JOIN {$pHBEnv["Cu
"]}group g ON p.profile_id = g.profile_id 925 WHERE f.feature_code IN ($transLimitStr) 926 ORDER BY f.description";
927 $sth = db_query($sql, $pHBEnv[
"dbh"]);
929 throw new exception($pHBEnv[
"MC"]->msg(
"ACH Query Error", HCU_DISPLAY_AS_RAW ) .
" 1405" );
932 $featureList = array();
934 while ( $featureRow = db_fetch_assoc( $sth, $row++ ) ) {
935 $featureList[] = array(
"name" => $featureRow[
"name"],
"value" => $featureRow[
"value"] );
946 function ConvertToLookupArray( $inputArray ) {
947 $outputArray = array();
950 $keys = array_keys( $inputArray[0] );
952 for ( $i = 0; $i < count( $inputArray ); $i++ ) {
953 $newKey = $inputArray[$i][$keys[0]];
954 $newValue = $inputArray[$i][$keys[1]];
956 $outputArray[$newKey] = $newValue;
966 function ShowPendingApproval( $pHBEnv ) {
967 $showPending =
false;
970 $sql =
"SELECT b.user_id, b.group_id 971 FROM {$pHBEnv["Cu
"]}user a 972 INNER JOIN {$pHBEnv["Cu
"]}user b ON b.group_id = a.group_id 973 WHERE a.user_id = {$pHBEnv["Uid
"]}";
974 $sth = db_query( $sql, $pHBEnv[
"dbh"] );
976 throw new exception($pHBEnv[
"MC"]->msg(
"ACH Query Error", HCU_DISPLAY_AS_RAW ) .
" 1407");
980 $groupUserIds = array();
981 for( $i = 0; $row = db_fetch_row($sth, $i); $i++ ) {
983 $groupId = intval( $row[1] );
985 $groupUserIds[] = intval( $row[0] );
989 if ( count( $groupUserIds ) > 1 ) {
992 FROM {$pHBEnv["Cu
"]}group g 993 INNER JOIN cu_profilerights p ON p.profile_id = g.profile_id 994 AND p.confirm_required 995 WHERE g.group_id = $groupId 998 $sth = db_query( $sql, $pHBEnv[
"dbh"] );
1000 throw new exception($pHBEnv[
"MC"]->msg(
"ACH Query Error", HCU_DISPLAY_AS_RAW ) .
" 1409");
1003 $row = db_fetch_row($sth, 0);
1004 $showPending = $row[0] > 0;
1006 if ( !$showPending ) {
1009 FROM {$pHBEnv["Cu
"]}grouprights g 1010 WHERE g.group_id = $groupId 1011 AND g.confirm_required 1014 $sth = db_query( $sql, $pHBEnv[
"dbh"] );
1016 throw new exception($pHBEnv[
"MC"]->msg(
"ACH Query Error", HCU_DISPLAY_AS_RAW ) .
" 1410");
1019 $row = db_fetch_row($sth, 0);
1020 $showPending = $row[0] > 0;
1023 if ( !$showPending ) {
1025 $userIdList =
"'" . implode(
"','", $groupUserIds ) .
"'";
1027 FROM {$pHBEnv["Cu
"]}userrights u 1028 WHERE u.user_id IN ($userIdList) 1029 AND u.confirm_required 1032 $sth = db_query( $sql, $pHBEnv[
"dbh"] );
1034 throw new exception($pHBEnv[
"MC"]->msg(
"ACH Query Error", HCU_DISPLAY_AS_RAW ) .
" 1411");
1037 $row = db_fetch_row($sth, 0);
1038 $showPending = $row[0] > 0;
1042 return $showPending;
1057 function GetUserActivityMetaData( $pHBEnv ) {
1058 $returnData = array(
"code" =>
"000",
"error" =>
"",
"data" => array() );
1062 $actionList = array();
1063 $actionList[] = array(
"name" =>
"details",
"value" => $pHBEnv[
"MC"]->msg(
"View Details", HCU_DISPLAY_AS_RAW));
1064 $actionList[] = array(
"name" =>
"approve",
"value" => $pHBEnv[
"MC"]->msg(
"Approve", HCU_DISPLAY_AS_RAW));
1065 $actionList[] = array(
"name" =>
"decline",
"value" => $pHBEnv[
"MC"]->msg(
"Decline", HCU_DISPLAY_AS_RAW));
1066 $actionList[] = array(
"name" =>
"cancel",
"value" => $pHBEnv[
"MC"]->msg(
"Cancel", HCU_DISPLAY_AS_RAW));
1069 for ( $i = 0; $i < count( $actionList ); $i++ ) {
1070 $actions[] = array(
"action" => $actionList[$i] );
1073 $returnData[
"data"][
"actions"] = $actions;
1075 $transferFeatures = GetTransferFeatureList( $pHBEnv );
1078 $featureList = array();
1079 $featureList[] = array(
"feature" => array(
"name" =>
"",
"value" => $pHBEnv[
"MC"]->msg(
"All", HCU_DISPLAY_AS_RAW)) );
1080 for ( $i = 0; $i < count( $transferFeatures ); $i++ ) {
1081 $featureList[] = array(
"feature" => $transferFeatures[$i] );
1084 $returnData[
"data"][
"features"] = $featureList;
1087 $statuses = _GetAllowedStatuses( $pHBEnv[
"MC"] );
1089 $statusList = array();
1090 $keys = array_keys( $statuses );
1091 foreach( $keys as $key ) {
1092 $statusList[] = array(
"status" => array(
"name" => $key,
"value" => $statuses[$key] ) );
1095 $returnData[
"data"][
"statuses"] = $statusList;
1098 $settingsList = array();
1099 $showPending = ShowPendingApproval( $pHBEnv ) ? 1 : 0;
1100 $settingsList[] = array(
"setting" => array(
"name" =>
"showpending",
"value" => $showPending ) );
1102 $returnData[
"data"][
"settings"] = $settingsList;
1104 }
catch( Exception $e ) {
1106 $message = $e->getMessage();
1108 $returnData[
"code"] =
"999";
1109 $returnData[
"error"] = $message;
1118 function _GetAllowedStatuses( $MC ) {
1120 $statusList = array( 0 => $MC->msg(
"Any", HCU_DISPLAY_AS_RAW),
1121 10 => $MC->msg(
"Approved", HCU_DISPLAY_AS_RAW),
1122 90 => $MC->msg(
"Declined", HCU_DISPLAY_AS_RAW),
1123 99 => $MC->msg(
"Cancelled", HCU_DISPLAY_AS_RAW) );
1131 function _GetUserActivityScheduled( $pHBEnv, $pParams ) {
1132 $returnData = array(
"code" =>
"000",
"error" =>
"",
"data" => array() );
1136 $transferFeatureList = GetTransferFeatureList( $pHBEnv );
1139 $transferFeatures = ConvertToLookupArray( $transferFeatureList );
1142 $recurringIntervals = getIntervalLookup( $pHBEnv[
"MC"] );
1145 $allowedTypes = getApprovalList();
1148 $filterTransferType = isset( $pParams[
"filter"][
"type"] ) && in_array( $pParams[
"filter"][
"type"], $allowedTypes ) ? $pParams[
"filter"][
"type"] :
"";
1151 $filterStartDate = isset( $pParams[
"filter"][
"start"] ) ? $pParams[
"filter"][
"start"] :
"";
1152 $filterEndDate = isset( $pParams[
"filter"][
"end"] ) ? $pParams[
"filter"][
"end"] :
"";
1155 $getAllScheduled = ( isset( $pParams[
"filter"][
"scheduled"] ) && $pParams[
"filter"][
"scheduled"] ==
"all" );
1158 if ( $getAllScheduled ) {
1159 $filterStartDate =
"";
1160 $filterEndDate =
"";
1164 $allowedStatuses = _GetAllowedStatuses( $pHBEnv[
"MC"] );
1166 $filterStatus = isset( $pParams[
"filter"][
"status"] ) && in_array( $pParams[
"filter"][
"status"], $allowedStatuses ) ? $pParams[
"filter"][
"status"] : 0;
1169 if ( $filterStartDate !=
"" ) {
1170 $filterStartDate = date(
"Y-m-d", strtotime( $filterStartDate ) );
1173 if ( $filterEndDate !=
"" ) {
1174 $filterEndDate = date(
"Y-m-d", strtotime( $filterEndDate ) );
1178 $sql =
"SELECT id, user_id, feature_code, next_trigger_date as date, repeating_parameters, 1179 txn_data, approved_status 1180 FROM cu_scheduledtxn sched 1181 WHERE cu = '{$pHBEnv["Cu
"]}' 1182 AND user_id = {$pHBEnv["Uid
"]} ";
1185 if ( $getAllScheduled ) {
1187 $sql .=
" AND approved_status != 0";
1190 $sql .=
" AND (end_date is NULL OR current_date <= end_date OR next_trigger_date < end_date)";
1191 $sql .=
" AND approved_status = 10";
1195 if ( $filterTransferType !=
"" ) {
1196 $sql .=
" AND feature_code = '$filterTransferType'";
1198 $sql .=
" AND feature_code IN ('" . implode(
"','", $allowedTypes) .
"')";
1201 if ( $filterStartDate !=
"" ) {
1202 $sql .=
" AND next_trigger_date >= '$filterStartDate'";
1208 if ( $filterEndDate !=
"" ) {
1209 $sql .=
" AND next_trigger_date <= '$filterEndDate'";
1214 $sql .=
" ORDER BY next_trigger_date ASC";
1216 $sth = db_query( $sql, $pHBEnv[
"dbh"] );
1218 throw new exception( $pHBEnv[
"MC"]->msg(
"ACH Query Error", HCU_DISPLAY_AS_RAW ) .
" 1408" );
1234 $schedInfo = array();
1235 while ( $schedRow = db_fetch_assoc( $sth, $row++ ) ) {
1236 $schedRow[
"table"] =
"sched";
1238 $txnInfo = HCU_JsonDecode( $schedRow[
"txn_data"] );
1241 $schedRow[
"type"] = $schedRow[
"feature_code"];
1242 $featureName = $transferFeatures[$schedRow[
"feature_code"]];
1243 $schedRow[
"feature"] = $featureName;
1248 $status = $schedRow[
"approved_status"];
1249 $schedRow[
"status"] = $allowedStatuses[$status];
1253 $schedRow[
"actions"] = ( $status == 10 ?
"cancel" :
"" );
1256 if ( $status == 0 ) {
1258 $statusColor = ( $schedRow[
"user_id"] == $pHBEnv[
"Uid"] ) ?
"info" :
"warning";
1259 }
else if ( $status == 10 ) {
1260 $statusColor =
"success";
1261 }
else if ( $status == 90 || $status == 99 ) {
1262 $statusColor =
"danger";
1264 $statusColor =
"unknown";
1266 $schedRow[
"color"] = $statusColor;
1268 $transactionCode = $txnInfo[
"txn"][
"transactioncode"];
1270 if ( $transactionCode ==
"2W" ) {
1272 $extId = $txnInfo[
"txn"][
"from"];
1274 $fromInfo = _GetExternalAccount( $pHBEnv, $extId );
1276 $fromDesc = $fromInfo[
"display"];
1278 $acctParts = explode(
"|", $txnInfo[
"txn"][
"from"] );
1279 $certNumber = isset( $acctParts[3] ) && $acctParts[3] > 0 ? $acctParts[3] : 0;
1280 $fromDesc = FindAccountDisplay( $pHBEnv, $pHBEnv[
"dbh"], $pHBEnv[
'Cu'], $txnInfo[
'txn'][
'frommember'], $txnInfo[
'txn'][
'fromsuffix'], $txnInfo[
'txn'][
'fromtype'], $certNumber );
1283 if ( $transactionCode ==
"1W" || $transactionCode ==
"MM" ) {
1285 $extId = $txnInfo[
"txn"][
"to"];
1287 $toInfo = _GetExternalAccount( $pHBEnv, $extId );
1289 $toDesc = $toInfo[
"display"];
1291 $acctParts = explode(
"|", $txnInfo[
"txn"][
"to"] );
1292 $certNumber = isset( $acctParts[3] ) && $acctParts[3] > 0 ? $acctParts[3] : 0;
1293 $toDesc = FindAccountDisplay( $pHBEnv, $pHBEnv[
"dbh"], $pHBEnv[
'Cu'], $txnInfo[
'txn'][
'tomember'], $txnInfo[
'txn'][
'tosuffix'], $txnInfo[
'txn'][
'totype'], $certNumber );
1297 $schedRow[
"area1_label"] = $pHBEnv[
"MC"]->msg(
"From", HCU_DISPLAY_AS_RAW );
1298 $schedRow[
"area1_value"] = $fromDesc;
1301 $schedRow[
"area2_label"] = $pHBEnv[
"MC"]->msg(
"To", HCU_DISPLAY_AS_RAW );
1302 $schedRow[
"area2_value"] = $toDesc;
1305 $repeatingParams = HCU_JsonDecode( $schedRow[
"repeating_parameters"],
false,
true );
1306 $intervalName = $recurringIntervals[$repeatingParams[
"interval"]];
1307 $amount = number_format( $txnInfo[
"txn"][
"amount"], 2 );
1308 $schedRow[
"area3_label"] =
"";
1309 $schedRow[
"area3_value"] =
"\${$amount} {$intervalName}";
1312 $nextTrigger = strtotime( $schedRow[
"date"] );
1313 if ( $nextTrigger == 0 ) {
1315 $dateString = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
1317 $dateString = date(
"m/d/Y", $nextTrigger );
1319 $schedRow[
"area4_label"] = $pHBEnv[
"MC"]->msg(
"Next Date", HCU_DISPLAY_AS_RAW );
1320 $schedRow[
"area4_value"] = $dateString;
1323 unset( $schedRow[
"txn_data"] );
1324 unset( $schedRow[
"repeating_parameters"] );
1326 $schedInfo[][
"txn"] = $schedRow;
1329 $returnData[
"data"] = $schedInfo;
1331 }
catch( Exception $e ) {
1333 $message = $e->getMessage();
1335 $returnData[
"code"] =
"999";
1336 $returnData[
"error"] = $message;
1344 function GetUserIdsForGroup( $pHBEnv ) {
1347 $sql =
"SELECT u2.user_id 1348 FROM {$pHBEnv["Cu
"]}user u1 1349 INNER JOIN {$pHBEnv["Cu
"]}user u2 ON u2.group_id = u1.group_id 1350 WHERE u1.user_id = {$pHBEnv["Uid
"]}";
1352 $sth = db_query( $sql, $pHBEnv[
"dbh"] );
1354 throw new exception( $pHBEnv[
"MC"]->msg(
"ACH Query Error", HCU_DISPLAY_AS_RAW ) .
" 1423" );
1358 $userIdList = array();
1359 while ( $userRow = db_fetch_assoc( $sth, $row++ ) ) {
1360 $userIdList[] = $userRow[
"user_id"];
1362 }
catch( Exception $e ) {
1364 $userIdList = array();
1375 function _GetUserActivityPending( $pHBEnv, $pParams, $pConfirmPermissions ) {
1376 $returnData = array(
"code" =>
"000",
"error" =>
"",
"data" => array() );
1380 $transferFeatureList = GetTransferFeatureList( $pHBEnv );
1383 $transferFeatures = ConvertToLookupArray( $transferFeatureList );
1386 $recurringIntervals = getIntervalLookup( $pHBEnv[
"MC"] );
1389 $allowedTypes = getApprovalList();
1392 $userIdList = GetUserIdsForGroup( $pHBEnv );
1393 $userIdStr = implode(
",", $userIdList );
1396 $filterTransferType = isset( $pParams[
"filter"][
"type"] ) && in_array( $pParams[
"filter"][
"type"], $allowedTypes ) ? $pParams[
"filter"][
"type"] :
"";
1400 $sql =
"SELECT hdr.posted_date as sortkey, 'trans' as table_type, hdr.id, hdr.feature_code, 1401 hdr.posted_date as create_date, hdr.effective_date as process_date, hdr.posted_by as create_id, 1402 hdr.approved_status, dtl.amount, '' as repeating_parameters, hdr.transactioncode, 1403 dtl.transdata as txn_data, '' as status 1404 FROM {$pHBEnv["Cu
"]}transhdr hdr 1405 INNER JOIN {$pHBEnv["Cu
"]}transdtl dtl ON dtl.transhdr_id = hdr.id 1406 WHERE hdr.posted_by IN ($userIdStr) 1407 AND coalesce( hdr.approved_by, 0 ) = 0";
1410 if ( $filterTransferType !=
"" ) {
1411 $sql .=
" AND feature_code = '$filterTransferType'";
1413 $sql .=
" AND feature_code IN ('" . implode(
"','", $allowedTypes) .
"')";
1418 SELECT sched.create_date as sortkey, 'sched' as table_type, sched.id, sched.feature_code, 1419 sched.create_date as create_date, next_trigger_date as process_date, user_id as create_id, 1420 sched.approved_status, 0 as amount, repeating_parameters, '' as transactioncode, 1422 FROM cu_scheduledtxn sched 1423 WHERE sched.cu = '{$pHBEnv["Cu
"]}' 1424 AND sched.user_id IN ($userIdStr) 1425 AND coalesce( sched.approved_by, 0 ) = 0";
1428 if ( $filterTransferType !=
"" ) {
1429 $sql .=
" AND feature_code = '$filterTransferType'";
1431 $sql .=
" AND feature_code IN ('" . implode(
"','", $allowedTypes) .
"')";
1434 $sql .=
" ORDER BY 1 ASC";
1436 $sth = db_query( $sql, $pHBEnv[
"dbh"] );
1438 throw new exception( $pHBEnv[
"MC"]->msg(
"ACH Query Error", HCU_DISPLAY_AS_RAW ) .
" 1424" );
1457 $approveInfo = array();
1458 while ( $approveRow = db_fetch_assoc( $sth, $row++ ) ) {
1460 if ( $approveRow[
"create_id"] != $pHBEnv[
"Uid"] ) {
1461 if ( !$pConfirmPermissions[$approveRow[
"feature_code"]] ) {
1466 $txnInfo = HCU_JsonDecode( $approveRow[
"txn_data"] );
1470 $approveRow[
"actions"] = ( $approveRow[
"create_id"] == $pHBEnv[
"Uid"] ) ?
"cancel" :
"approve,decline";
1473 $approveRow[
"type"] = $approveRow[
"feature_code"];
1474 $featureName = $transferFeatures[$approveRow[
"feature_code"]];
1475 $approveRow[
"feature"] = $featureName;
1478 if ( $approveRow[
"create_id"] == $pHBEnv[
"Uid"] ) {
1479 $statusColor =
"info";
1480 }
else if ( $approveRow[
"create_id"] != $pHBEnv[
"Uid"] ) {
1481 $statusColor =
"warning";
1483 $statusColor =
"unknown";
1485 $approveRow[
"color"] = $statusColor;
1489 if ( $approveRow[
"status"] ==
"A" ) {
1490 $txnStatus = $pHBEnv[
"MC"]->msg(
"Active" );
1491 }
else if ( $approveRow[
"status"] ==
"I" ) {
1492 $txnStatus = $pHBEnv[
"MC"]->msg(
"Inactive" );
1496 $approveRow[
"status"] = $txnStatus;
1500 if ( $approveRow[
"table_type"] ==
"sched" ) {
1501 $approveRow[
"table"] =
"sched";
1503 $transactionCode = $txnInfo[
"txn"][
"transactioncode"];
1506 $approveRow[
"date"] = date(
"m/d/Y", strtotime( $approveRow[
"sortkey"] ) );
1509 if ( $transactionCode ==
"2W" ) {
1511 $extId = $txnInfo[
"txn"][
"from"];
1513 $fromInfo = _GetExternalAccount( $pHBEnv, $extId );
1515 $fromDesc = $fromInfo[
"display"];
1517 $acctParts = explode(
"|", $txnInfo[
"txn"][
"from"] );
1518 $certNumber = isset( $acctParts[3] ) && $acctParts[3] > 0 ? $acctParts[3] : 0;
1520 $fromDesc = FindAccountDisplay( $pHBEnv, $pHBEnv[
"dbh"], $pHBEnv[
'Cu'], $txnInfo[
'txn'][
'frommember'], $txnInfo[
'txn'][
'fromsuffix'], $txnInfo[
'txn'][
'fromtype'], $certNumber );
1523 if ( $fromDesc ==
"" ) {
1524 $fromDesc = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
1528 if ( $transactionCode ==
"1W" || $transactionCode ==
"MM" ) {
1530 $extId = $txnInfo[
"txn"][
"to"];
1532 $toInfo = _GetExternalAccount( $pHBEnv, $extId );
1533 $toDesc = $toInfo[
"display"];
1535 $acctParts = explode(
"|", $txnInfo[
"txn"][
"to"] );
1539 $certNumber = isset( $acctParts[3] ) && $acctParts[3] > 0 ? $acctParts[3] : 0;
1540 $toDesc = FindAccountDisplay( $pHBEnv, $pHBEnv[
"dbh"], $pHBEnv[
'Cu'], $txnInfo[
'txn'][
'tomember'], $txnInfo[
'txn'][
'tosuffix'], $txnInfo[
'txn'][
'totype'], $certNumber );
1543 if ( $toDesc ==
"" ) {
1544 $toDesc = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
1547 $repeatingParams = HCU_JsonDecode( $approveRow[
"repeating_parameters"],
false,
true );
1548 $intervalName = $recurringIntervals[$repeatingParams[
"interval"]];
1549 $amount = number_format( $txnInfo[
"txn"][
"amount"], 2 );
1552 $amountString =
"\${$amount} {$intervalName}";
1554 $dateLabel = $pHBEnv[
"MC"]->msg(
"ACH Effective Date", HCU_DISPLAY_AS_RAW );
1555 $processTime = strtotime( $approveRow[
"process_date"] );
1556 if ( $processTime == 0 ) {
1558 $dateString = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
1560 $dateString = date(
"m/d/Y", $processTime );
1564 $approveRow[
"table"] =
"trans";
1566 $transactionCode = $approveRow[
"transactioncode"];
1569 if ( in_array( $transactionCode, array(
"1W",
"1P",
"AT",
"LP",
"LA",
"MM",
"CW",
"OT") ) ) {
1570 $acctParts = explode(
"|", $txnInfo[
"acct_source"] );
1571 $certNumber = isset( $acctParts[3] ) && $acctParts[3] > 0 ? $acctParts[3] : 0;
1572 $accountType = $txnInfo[
'source_key'][
'recordtype'] ==
"L" ? $txnInfo[
'source_key'][
'loannumber'] : $txnInfo[
'source_key'][
'accounttype'];
1574 $fromDesc = FindAccountDisplay( $pHBEnv, $pHBEnv[
"dbh"], $pHBEnv[
'Cu'], $txnInfo[
'source_key'][
'accountnumber'], $accountType, $txnInfo[
'source_key'][
'recordtype'], $certNumber );
1575 }
else if ( in_array( $transactionCode, array(
"2W",
"2P") ) ) {
1577 $fromDesc = $txnInfo[
"acct_source"][
"remote_entity"][
"name"];
1581 $fromDesc = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
1585 if ( in_array( $transactionCode, array(
"2W",
"2P",
"AT",
"LP",
"LA") ) ) {
1586 $acctParts = explode(
"|", $txnInfo[
"acct_dest"] );
1587 $certNumber = isset( $acctParts[3] ) && $acctParts[3] > 0 ? $acctParts[3] : 0;
1588 $accountType = $txnInfo[
'dest_key'][
'recordtype'] ==
"L" ? $txnInfo[
'dest_key'][
'loannumber'] : $txnInfo[
'dest_key'][
'accounttype'];
1590 $toDesc = FindAccountDisplay( $pHBEnv, $pHBEnv[
"dbh"], $pHBEnv[
'Cu'], $txnInfo[
'dest_key'][
'accountnumber'], $accountType, $txnInfo[
'dest_key'][
'recordtype'], $certNumber );
1591 }
else if ( in_array( $transactionCode, array(
"1W",
"1P") ) ) {
1593 $toDesc = $txnInfo[
"acct_dest"][
"remote_entity"][
"name"];
1594 }
else if ( in_array( $transactionCode, array(
"MM" ) ) ) {
1596 $toDesc = $txnInfo[
"dest_key"][
"name"];
1597 }
else if ( in_array( $transactionCode, array(
"OT",
"CW" ) ) ) {
1598 $acctParts = explode(
"|", $txnInfo[
"acct_dest"] );
1600 if ( $acctParts[0] ==
"O" ) {
1601 if ( $trans ==
null ) {
1602 $trans = Get_HaveTrans( $pHBEnv[
"dbh"], $pHBEnv );
1605 $otherDesc = HCU_array_key_value($acctParts[2], $trans);
1607 $cuDesc = isset($otherDesc[2]) ? trim($otherDesc[2]) :
"";
1608 $nonCUDesc = isset($otherDesc[0]) ? trim($otherDesc[0]) :
"";
1610 $toDesc = $cuDesc !=
"" ? $cuDesc : $nonCUDesc;
1615 $toDesc = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
1618 $amount = number_format( $approveRow[
"amount"], 2 );
1621 $amountString =
"\${$amount}";
1623 $dateLabel = $pHBEnv[
"MC"]->msg(
"ACH Effective Date", HCU_DISPLAY_AS_RAW );
1624 $processTime = strtotime( $approveRow[
"process_date"] );
1625 if ( $processTime == 0 ) {
1627 $dateString = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
1629 $dateString = date(
"m/d/Y", $processTime );
1634 $approveRow[
"area1_label"] = $pHBEnv[
"MC"]->msg(
"From", HCU_DISPLAY_AS_RAW );
1635 $approveRow[
"area1_value"] = $fromDesc;
1638 $approveRow[
"area2_label"] = $pHBEnv[
"MC"]->msg(
"To", HCU_DISPLAY_AS_RAW );
1639 $approveRow[
"area2_value"] = $toDesc;
1642 $approveRow[
"area3_label"] = $amountLabel;
1643 $approveRow[
"area3_value"] = $amountString;
1646 $approveRow[
"area4_label"] = $dateLabel;
1647 $approveRow[
"area4_value"] = $dateString;
1650 $approveRow[
"status"] = $txnStatus;
1653 unset( $approveRow[
"txn_data"] );
1654 unset( $approveRow[
"repeating_parameters"] );
1655 unset( $approveRow[
"sortkey"] );
1656 unset( $approveRow[
"amount"] );
1657 unset( $approveRow[
"transactioncode"] );
1659 $approveInfo[][
"txn"] = $approveRow;
1662 $returnData[
"data"] = $approveInfo;
1664 }
catch( Exception $e ) {
1666 $message = $e->getMessage();
1668 $returnData[
"code"] =
"999";
1669 $returnData[
"error"] = $message;
1682 function _GetUserActivityPrior( $pHBEnv, $pParams ) {
1683 $returnData = array(
"code" =>
"000",
"error" =>
"",
"data" => array() );
1687 $filterStartDate = isset( $pParams[
"filter"][
"start"] ) ? $pParams[
"filter"][
"start"] :
"";
1688 $filterEndDate = isset( $pParams[
"filter"][
"end"] ) ? $pParams[
"filter"][
"end"] :
"";
1690 $startDate = strtotime( $filterStartDate );
1691 $endDate = strtotime( $filterEndDate );
1694 if ( $filterStartDate ==
"" || $startDate == 0 ) {
1695 throw new exception( $pHBEnv[
"MC"]->msg(
"Please provide a Start Date", HCU_DISPLAY_AS_RAW ) .
" 1420" );
1698 if ( $filterEndDate ==
"" || $endDate == 0 ) {
1699 throw new exception( $pHBEnv[
"MC"]->msg(
"Please provide an End Date", HCU_DISPLAY_AS_RAW ) .
" 1421" );
1702 if ( $startDate > $endDate ) {
1703 throw new exception( $pHBEnv[
"MC"]->msg(
"Please provide an End Date", HCU_DISPLAY_AS_RAW ) .
" 1422" );
1706 $formattedStartDate = date(
"Y-m-d ", $startDate );
1707 $formattedEndDate = date(
"Y-m-d", $endDate );
1710 $transferFeatureList = GetTransferFeatureList( $pHBEnv );
1713 $transferFeatures = ConvertToLookupArray( $transferFeatureList );
1716 $recurringIntervals = getIntervalLookup( $pHBEnv[
"MC"] );
1719 $allowedTypes = getApprovalList();
1722 $filterTransferType = isset( $pParams[
"filter"][
"type"] ) && in_array( $pParams[
"filter"][
"type"], $allowedTypes ) ? $pParams[
"filter"][
"type"] :
"";
1725 $allowedStatuses = _GetAllowedStatuses( $pHBEnv[
"MC"] );
1727 $filterStatus = isset( $pParams[
"filter"][
"status"] ) && in_array( $pParams[
"filter"][
"status"], $allowedStatuses ) ? $pParams[
"filter"][
"status"] : 0;
1732 $sql =
"SELECT hdr.posted_date as sortkey, 'trans' as table_type, hdr.id, hdr.feature_code, 1733 hdr.posted_date as create_date, hdr.approved_status, hdr.processed_date, 1734 hdr.processed_status, hdr.transactioncode, 1735 dtl.amount, '' as repeating_parameters, dtl.transdata as txn_data 1736 FROM {$pHBEnv["Cu
"]}transhdr hdr 1737 INNER JOIN {$pHBEnv["Cu
"]}transdtl dtl ON dtl.transhdr_id = hdr.id 1738 WHERE (hdr.posted_by = {$pHBEnv["Uid
"]} OR hdr.approved_by = {$pHBEnv["Uid
"]}) 1739 AND hdr.posted_date > '$formattedStartDate 23:59:59' 1740 AND hdr.posted_date <= '$formattedEndDate 23:59:59' 1741 AND hdr.approved_by IS NOT NULL";
1744 if ( $filterTransferType !=
"" ) {
1745 $sql .=
" AND feature_code = '$filterTransferType'";
1747 $sql .=
" AND feature_code IN ('" . implode(
"','", $allowedTypes) .
"')";
1755 SELECT sched.approved_date as sortkey, 'sched' as table_type, sched.id, sched.feature_code, 1756 sched.create_date as create_date, sched.approved_status, sched.approved_date as processed_date, 1757 0 as processed_status, '' as transactioncode, 0 as amount, repeating_parameters, txn_data 1758 FROM cu_scheduledtxn sched 1759 WHERE sched.cu = '{$pHBEnv["Cu
"]}' 1760 AND sched.user_id != {$pHBEnv["Uid
"]} 1761 AND sched.approved_by = {$pHBEnv["Uid
"]} 1762 AND sched.approved_date > '$formattedStartDate 23:59:59' 1763 AND sched.approved_date <= '$formattedEndDate 23:59:59'";
1766 if ( $filterTransferType !=
"" ) {
1767 $sql .=
" AND feature_code = '$filterTransferType'";
1769 $sql .=
" AND feature_code IN ('" . implode(
"','", $allowedTypes) .
"')";
1772 $sql .=
" ORDER BY 1 DESC";
1774 $sth = db_query( $sql, $pHBEnv[
"dbh"] );
1776 throw new exception( $pHBEnv[
"MC"]->msg(
"ACH Query Error", HCU_DISPLAY_AS_RAW ) .
" 1419" );
1796 $priorInfo = array();
1797 while ( $priorRow = db_fetch_assoc( $sth, $row++ ) ) {
1799 $priorRow[
"date"] = date(
"m/d/Y", strtotime( $priorRow[
"sortkey"] ) );
1801 $txnInfo = HCU_JsonDecode( $priorRow[
"txn_data"] );
1804 if ( $priorRow[
"transactioncode"] ==
"1P" ||
1805 $priorRow[
"transactioncode"] ==
"2P" ) {
1806 if ( (isset( $txnInfo[
"acct_source"] ) && $txnInfo[
"acct_source"] ==
"micro") ||
1807 (isset( $txnInfo[
"acct_dest"] ) && $txnInfo[
"acct_dest"] ==
"micro") ) {
1812 if ( $priorRow[
"table_type"] ==
"trans" &&
1813 !isset( $txnInfo[
"source_key"] ) && !isset( $txnInfo[
"dest_key"] ) ) {
1819 $priorRow[
"actions"] =
"";
1822 $priorRow[
"type"] = $priorRow[
"feature_code"];
1823 $featureName = $transferFeatures[$priorRow[
"feature_code"]];
1824 $priorRow[
"feature"] = $featureName;
1827 $status = $priorRow[
"approved_status"];
1828 $priorRow[
"status"] = $allowedStatuses[$status];
1831 if ( $status == 10 ) {
1832 $statusColor =
"success";
1833 }
else if ( $status == 90 || $status == 99 ) {
1834 $statusColor =
"danger";
1836 $statusColor =
"unknown";
1838 $priorRow[
"color"] = $statusColor;
1841 if ( $priorRow[
"table_type"] ==
"sched" ) {
1842 $priorRow[
"table"] =
"sched";
1844 $transactionCode = $txnInfo[
"txn"][
"transactioncode"];
1847 if ( $transactionCode ==
"2W" ) {
1849 $extId = $txnInfo[
"txn"][
"from"];
1851 $fromInfo = _GetExternalAccount( $pHBEnv, $extId );
1853 $fromDesc = $fromInfo[
"display"];
1855 $acctParts = explode(
"|", $txnInfo[
"txn"][
"from"] );
1856 $certNumber = isset( $acctParts[3] ) && $acctParts[3] > 0 ? $acctParts[3] : 0;
1857 $fromDesc = FindAccountDisplay( $pHBEnv, $pHBEnv[
"dbh"], $pHBEnv[
'Cu'], $txnInfo[
'txn'][
'frommember'], $txnInfo[
'txn'][
'fromsuffix'], $txnInfo[
'txn'][
'fromtype'], $certNumber );
1861 $fromDesc = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
1865 if ( $transactionCode ==
"1W" || $transactionCode ==
"MM" ) {
1867 $extId = $txnInfo[
"txn"][
"to"];
1869 $toInfo = _GetExternalAccount( $pHBEnv, $extId );
1871 $toDesc = $toInfo[
"display"];
1873 $acctParts = explode(
"|", $txnInfo[
"txn"][
"to"] );
1875 if ( $acctParts[0] ==
"O" ) {
1876 if ( $trans ==
null ) {
1877 $trans = Get_HaveTrans( $pHBEnv[
"dbh"], $pHBEnv );
1880 $otherDesc = HCU_array_key_value($acctParts[2], $trans);
1882 $cuDesc = isset($otherDesc[2]) ? trim($otherDesc[2]) :
"";
1883 $nonCUDesc = isset($otherDesc[0]) ? trim($otherDesc[0]) :
"";
1885 $toDesc = $cuDesc !=
"" ? $cuDesc : $nonCUDesc;
1888 $toDesc = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
1891 $certNumber = isset( $acctParts[3] ) && $acctParts[3] > 0 ? $acctParts[3] : 0;
1892 $toDesc = FindAccountDisplay( $pHBEnv, $pHBEnv[
"dbh"], $pHBEnv[
'Cu'], $txnInfo[
'txn'][
'tomember'], $txnInfo[
'txn'][
'tosuffix'], $txnInfo[
'txn'][
'totype'], $certNumber );
1897 $toDesc = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
1900 $repeatingParams = HCU_JsonDecode( $priorRow[
"repeating_parameters"],
false,
true );
1901 $intervalName = $recurringIntervals[$repeatingParams[
"interval"]];
1902 $amount = number_format( $txnInfo[
"txn"][
"amount"], 2 );
1905 $amountString =
"\${$amount} {$intervalName}";
1908 if ( $priorRow[
"approved_status"] == 10 ) {
1909 $dateLabel = $pHBEnv[
"MC"]->msg(
"Processed Date", HCU_DISPLAY_AS_RAW );
1910 $processTime = strtotime( $priorRow[
"processed_date"] );
1911 if ( $processTime == 0 ) {
1912 $dateString = $pHBEnv[
"MC"]->msg(
"Not processed", HCU_DISPLAY_AS_RAW );
1914 $dateString = date(
"m/d/Y", $processTime );
1922 $priorRow[
"table"] =
"trans";
1924 $transactionCode = $priorRow[
"transactioncode"];
1927 if ( in_array( $transactionCode, array(
"1W",
"1P",
"AT",
"LP",
"LA",
"MM",
"CW",
"OT") ) ) {
1928 $acctParts = explode(
"|", $txnInfo[
"acct_source"] );
1929 $certNumber = isset( $acctParts[3] ) && $acctParts[3] > 0 ? $acctParts[3] : 0;
1930 $accountType = $txnInfo[
'source_key'][
'recordtype'] ==
"L" ? $txnInfo[
'source_key'][
'loannumber'] : $txnInfo[
'source_key'][
'accounttype'];
1932 $fromDesc = FindAccountDisplay( $pHBEnv, $pHBEnv[
"dbh"], $pHBEnv[
'Cu'], $txnInfo[
'source_key'][
'accountnumber'], $accountType, $txnInfo[
'source_key'][
'recordtype'], $certNumber );
1933 }
else if ( in_array( $transactionCode, array(
"2W",
"2P") ) ) {
1935 $fromDesc = $txnInfo[
"acct_source"][
"remote_entity"][
"name"];
1939 $fromDesc = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
1943 if ( in_array( $transactionCode, array(
"2W",
"2P",
"AT",
"LP",
"LA") ) ) {
1944 $acctParts = explode(
"|", $txnInfo[
"acct_dest"] );
1945 $certNumber = isset( $acctParts[3] ) && $acctParts[3] > 0 ? $acctParts[3] : 0;
1946 $accountType = $txnInfo[
'dest_key'][
'recordtype'] ==
"L" ? $txnInfo[
'dest_key'][
'loannumber'] : $txnInfo[
'dest_key'][
'accounttype'];
1948 $toDesc = FindAccountDisplay( $pHBEnv, $pHBEnv[
"dbh"], $pHBEnv[
'Cu'], $txnInfo[
'dest_key'][
'accountnumber'], $accountType, $txnInfo[
'dest_key'][
'recordtype'], $certNumber );
1949 }
else if ( in_array( $transactionCode, array(
"1W",
"1P") ) ) {
1951 $toDesc = $txnInfo[
"acct_dest"][
"remote_entity"][
"name"];
1952 }
else if ( in_array( $transactionCode, array(
"MM" ) ) ) {
1954 $toDesc = $txnInfo[
"dest_key"][
"name"];
1955 }
else if ( in_array( $transactionCode, array(
"OT",
"CW" ) ) ) {
1956 $acctParts = explode(
"|", $txnInfo[
"acct_dest"] );
1958 if ( $acctParts[0] ==
"O" ) {
1959 if ( $trans ==
null ) {
1960 $trans = Get_HaveTrans( $pHBEnv[
"dbh"], $pHBEnv );
1963 $otherDesc = HCU_array_key_value($acctParts[2], $trans);
1965 $cuDesc = isset($otherDesc[2]) ? trim($otherDesc[2]) :
"";
1966 $nonCUDesc = isset($otherDesc[0]) ? trim($otherDesc[0]) :
"";
1968 $toDesc = $cuDesc !=
"" ? $cuDesc : $nonCUDesc;
1973 $toDesc = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
1976 $amount = number_format( $priorRow[
"amount"], 2 );
1979 $amountString =
"\${$amount}";
1982 $dateLabel = $pHBEnv[
"MC"]->msg(
"Processed Date", HCU_DISPLAY_AS_RAW );
1983 $processTime = strtotime( $priorRow[
"processed_date"] );
1984 if ( $processTime == 0 || $priorRow[
"processed_status"] == 90 ) {
1985 $dateString = $pHBEnv[
"MC"]->msg(
"Not processed", HCU_DISPLAY_AS_RAW );
1987 $dateString = date(
"m/d/Y", $processTime );
1992 $priorRow[
"area1_label"] = $pHBEnv[
"MC"]->msg(
"From", HCU_DISPLAY_AS_RAW );
1993 $priorRow[
"area1_value"] = $fromDesc;
1996 $priorRow[
"area2_label"] = $pHBEnv[
"MC"]->msg(
"To", HCU_DISPLAY_AS_RAW );
1997 $priorRow[
"area2_value"] = $toDesc;
2000 $priorRow[
"area3_label"] = $amountLabel;
2001 $priorRow[
"area3_value"] = $amountString;
2004 $priorRow[
"area4_label"] = $dateLabel;
2005 $priorRow[
"area4_value"] = $dateString;
2008 unset( $priorRow[
"txn_data"] );
2009 unset( $priorRow[
"repeating_parameters"] );
2010 unset( $priorRow[
"sortkey"] );
2012 $priorInfo[][
"txn"] = $priorRow;
2015 $returnData[
"data"] = $priorInfo;
2017 }
catch( Exception $e ) {
2019 $message = $e->getMessage();
2021 $returnData[
"code"] =
"999";
2022 $returnData[
"error"] = $message;
2041 function DoActivityAction( $pHBEnv, $pDetailId, $pIsScheduled, $pAction ) {
2042 $returnData = array(
"code" =>
"000",
"error" =>
"",
"data" => array() );
2046 $userIdList = GetUserIdsForGroup( $pHBEnv );
2047 $userIdStr = implode(
",", $userIdList );
2051 $confirmPermissions = array();
2052 $results = Perm_FeatureAccessList( $pHBEnv[
"dbh"], $pHBEnv );
2053 if ( !intval($results[
"status"][
"code"] ) == 0) {
2054 throw new exception($results[
"status"][
"error"] .
" 1404");
2058 $permissions = $results[
"data"][$pHBEnv[
"Uid"]];
2061 $approvalFeatureList = getApprovalList();
2062 $confirmFound =
false;
2063 foreach( $permissions as $featureCode => $featureRecord )
2065 if ( !in_array( $featureCode, $approvalFeatureList ) ) {
2069 $confirmFound = $confirmFound || $featureRecord[
"confirm"];
2070 $confirmPermissions[$featureCode] = $featureRecord[
"confirm"];
2074 if ( !$confirmFound ) {
2075 if ( in_array( $pHBEnv[
"Uid"], $userIdList ) &&
2076 count( $userIdList ) == 1 ) {
2077 $confirmFound =
true;
2081 if ( !$confirmFound ) {
2082 throw new exception( $pHBEnv[
"MC"]->msg(
"Trans approval failure", HCU_DISPLAY_AS_RAW ) .
" 1427");
2086 $table = $pIsScheduled ?
"cu_scheduledtxn" :
"{$pHBEnv["Cu
"]}transhdr";
2087 $postedField = $pIsScheduled ?
"user_id" :
"posted_by";
2088 $sql =
"SELECT feature_code, $postedField as user_id, approved_status 2090 WHERE id = $pDetailId 2091 AND $postedField IN ($userIdStr)";
2093 $sth = db_query( $sql, $pHBEnv[
"dbh"] );
2095 throw new exception( $pHBEnv[
"MC"]->msg(
"ACH Query Error", HCU_DISPLAY_AS_RAW ) .
" 1428" );
2098 $txnRow = db_fetch_assoc($sth, 0);
2099 $transferFeatureCode = trim( $txnRow[
"feature_code"] );
2102 if ( !$confirmPermissions[$transferFeatureCode] ) {
2103 throw new exception( $pHBEnv[
"MC"]->msg(
"Trans approval failure", HCU_DISPLAY_AS_RAW ) .
" 1429");
2108 if ( $pAction ==
"approve" ) {
2110 }
else if ( $pAction ==
"decline" ) {
2112 }
else if ( $pAction ==
"cancel" ) {
2115 throw new exception( $pHBEnv[
"MC"]->msg(
"ACH Unknown Action", HCU_DISPLAY_AS_RAW ) .
" 1425");
2119 if ( ($actionStatus == 10 || $actionStatus == 90) &&
2120 ($txnRow[
"user_id"] == $pHBEnv[
"Uid"]) ) {
2121 throw new exception( $pHBEnv[
"MC"]->msg(
"Trans approval failure", HCU_DISPLAY_AS_RAW ) .
" 1430");
2125 if ( ($actionStatus == 99) &&
2126 ($txnRow[
"user_id"] != $pHBEnv[
"Uid"]) ) {
2127 throw new exception( $pHBEnv[
"MC"]->msg(
"Trans approval failure", HCU_DISPLAY_AS_RAW ) .
" 1436");
2131 if ( ($actionStatus == 10 || $actionStatus == 90) &&
2132 $txnRow[
"approved_status"] != 0 ) {
2133 throw new exception( $pHBEnv[
"MC"]->msg(
"Trans approval failure", HCU_DISPLAY_AS_RAW ) .
" 1431");
2136 if ( $pIsScheduled ) {
2138 if ( $actionStatus == 99 &&
2139 $txnRow[
"approved_status"] != 0 &&
2140 $txnRow[
"approved_status"] != 10 &&
2141 $txnRow[
"approved_status"] != 99 ) {
2142 throw new exception( $pHBEnv[
"MC"]->msg(
"Trans approval failure", HCU_DISPLAY_AS_RAW ) .
" 1437");
2146 $sql =
"UPDATE cu_scheduledtxn SET approved_by = {$pHBEnv["Uid
"]}, approved_date = now(), approved_status = $actionStatus WHERE id = $pDetailId AND user_id IN ($userIdStr)";
2148 $sth = db_query( $sql, $pHBEnv[
"dbh"] );
2150 throw new exception( $pHBEnv[
"MC"]->msg(
"ACH Query Error", HCU_DISPLAY_AS_RAW ) .
" 1426" );
2153 $resultDetail = _GetActivityDetailScheduled( $pHBEnv, $pDetailId );
2155 if ( $actionStatus == 10 ) {
2157 $aryApprovalResults = array();
2158 if (!ApproveTransfer($pHBEnv[
"dbh"], $pHBEnv, $pHBEnv[
"MC"], $pDetailId, $aryApprovalResults)) {
2159 throw new exception($aryApprovalResults[
"status"][
"errors"][0] .
"1432");
2163 $confirmationCode = $aryApprovalResults[
"status"][
"confirm"];
2166 if ( in_array( $transferFeatureCode, array(FEATURE_TRANSFERS, FEATURE_M2M_TRANSFERS) ) ) {
2167 $aryProcessResults = array();
2168 if (!ProcessTransfer($pHBEnv[
"dbh"], $pHBEnv, $pHBEnv[
"MC"], $pDetailId, $aryProcessResults,
true)) {
2171 RevertMarkAsApproved($pDetailId, $pHBEnv[
"dbh"], $pHBEnv[
"Cu"],
"1433");
2175 throw new exception($aryProcessResults[
"status"][
"errors"][0] .
"1433");
2179 $confirmationCode = $aryProcessResults[
"txn"][
"data_confirm"];
2183 $returnData[
"data"][
"confirm"] = $confirmationCode;
2187 $sql =
"UPDATE {$pHBEnv["Cu
"]}transhdr SET approved_by = {$pHBEnv["Uid
"]}, approved_date = now(), approved_status = $actionStatus WHERE id = $pDetailId AND posted_by IN ($userIdStr)";
2189 $sth = db_query( $sql, $pHBEnv[
"dbh"] );
2191 throw new exception( $pHBEnv[
"MC"]->msg(
"ACH Query Error", HCU_DISPLAY_AS_RAW ) .
" 1426" );
2195 $resultDetail = _GetActivityDetailRegular( $pHBEnv, $pDetailId );
2198 $returnData[
"data"][
"details"] = $resultDetail[
"data"];
2199 }
catch( Exception $e ) {
2201 $message = $e->getMessage();
2203 $returnData[
"code"] =
"999";
2204 $returnData[
"error"] = $message;
2222 function RevertMarkAsApproved($transferId, $dbh, $Cu, $errCode) {
2225 $transHdrTbl = trim(strtolower($Cu)) .
"transhdr";
2228 $sqlUpdateHdr =
"UPDATE ${transHdrTbl} SET".
2229 " approved_by = NULL,".
2230 " approved_date = NULL,".
2231 " approved_status = NULL".
2232 " WHERE id = ${transferId}";
2234 $sqlUpdateHdrRs = db_query($sqlUpdateHdr, $dbh);
2236 if (!$sqlUpdateHdrRs) {
2237 if ($errCode ==
"1433") {
2238 throw new exception(
"Transfer approval reset failed.". $errCode);
2240 throw new exception(
"Transfer approval reset failed.", $errCode);
2244 db_work($dbh, HOMECU_WORK_COMMIT);
2246 }
catch (Exception $ex) {
2253 function _GetExternalAccount( $pHBEnv, $pExtId ) {
2254 $returnData = array(
"display" =>
"000",
"name" =>
"",
"routing" =>
"",
"account" =>
"" );
2258 $sql =
"SELECT e.*, u.group_id as user_group, t.group_id as test_group 2259 FROM {$pHBEnv["Cu
"]}extaccount e 2260 INNER JOIN {$pHBEnv["Cu
"]}user u ON u.user_id = e.user_id 2261 INNER JOIN {$pHBEnv["Cu
"]}user t ON t.user_id = {$pHBEnv["Uid
"]} 2262 WHERE e.id = $pExtId";
2264 $sth = db_query( $sql, $pHBEnv[
"dbh"] );
2266 throw new exception($pHBEnv[
"MC"]->msg(
"ACH Query Error", HCU_DISPLAY_AS_RAW ) .
" 1434");
2269 $accountRow = db_fetch_assoc($sth, 0);
2271 if ( $accountRow[
"user_group"] != $accountRow[
"test_group"] ) {
2272 throw new exception($pHBEnv[
"MC"]->msg(
"Invalid account access", HCU_DISPLAY_AS_RAW ) .
" 1435");
2275 $acctInfo = HCU_JsonDecode( $accountRow[
"remote_info"] );
2277 $returnData[
"display"] = $accountRow[
"display_name"];
2279 if ( $accountRow[
"type"] ==
"EXT" ) {
2280 $returnData[
"name"] = $acctInfo[
"rdfi"][
"name"];
2281 $returnData[
"routing"] = $acctInfo[
"rdfi"][
"routing"];
2282 $returnData[
"account"] = $acctInfo[
"rdfi"][
"account"];
2284 $returnData[
"name"] = $acctInfo[
"rdfi"][
"name"];
2285 $returnData[
"account"] = $acctInfo[
"rdfi"][
"account"];
2287 }
catch( Exception $e ) {
2290 $returnData[
"display"] = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
2291 $returnData[
"name"] = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
2292 $returnData[
"routing"] = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );
2293 $returnData[
"account"] = $pHBEnv[
"MC"]->msg(
"Unknown", HCU_DISPLAY_AS_RAW );