40 define(
"ACH_PARTNER_TYPE_PAYEE",
"e" );
41 define(
"ACH_PARTNER_TYPE_PAYOR",
"r" );
42 define(
"ACH_PARTNER_TYPE_UNASSIGNED",
"" );
43 define(
"ACH_PARTNER_TYPE_PAYROLL",
"$" );
45 define(
"TEMPLATE_TYPE_PAYMENT",
"P" );
46 define(
"TEMPLATE_TYPE_COLLECTION",
"C" );
47 define(
"TEMPLATE_TYPE_PAYROLL",
"$" );
50 function Check_ACHEnabled( $pDbh, $pHBEnv ) {
52 }
catch (Exception $ex) {
53 $logInfo = array(
"message" => $ex->getMessage(),
"code" => $ex->getCode() );
67 function ACH_GetPartners( $pDbh, $pHBEnv ) {
69 $returnData = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
72 $SQL =
"SELECT id, display_name, ach_name, partner_type, address, dfi_data, email_notify 73 FROM {$pHBEnv["Cu
"]}achpartner 74 WHERE group_id = (SELECT group_id FROM {$pHBEnv["Cu
"]}user WHERE user_id = {$pHBEnv["Uid
"]}) 75 ORDER BY display_name";
77 $rs = db_query( $SQL, $pDbh );
82 while ( $partnerRow = db_fetch_assoc( $rs, $row++ ) ) {
84 $partnerRow[
"partner_type"] = trim( $partnerRow[
"partner_type"] );
85 $partnerRow[
"address"] = HCU_JsonDecode( $partnerRow[
"address"] );
86 $partnerRow[
"dfi_data"] = HCU_JsonDecode( $partnerRow[
"dfi_data"] );
88 $return[] = $partnerRow;
91 $returnData[
"data"] = $return;
92 }
catch (Exception $ex) {
93 $logInfo = array(
"message" => $ex->getMessage(),
"code" => $ex->getCode() );
94 $returnData[
"code"] =
"999";
109 function ACH_GetSinglePartner( $pDbh, $pHBEnv, $pPartnerId ) {
111 $returnData = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
114 $SQL =
"SELECT * FROM {$pHBEnv["Cu
"]}achpartner WHERE id = {$pPartnerId}";
116 $rs = db_query( $SQL, $pDbh );
118 $partnerRow = db_fetch_assoc( $rs, 0 );
121 $addressData = HCU_JsonDecode( $partnerRow[
"address"],
true );
122 $dfiData = HCU_JsonDecode( $partnerRow[
"dfi_data"],
true );
125 $basicInfo = array();
126 $basicInfo[
"id"] = $partnerRow[
"id"];
127 $basicInfo[
"ach_name"] = $partnerRow[
"ach_name"];
128 $basicInfo[
"display_name"] = $partnerRow[
"display_name"];
129 $basicInfo[
"email_notify"] = $partnerRow[
"email_notify"] ==
't' ? true :
false;
130 $basicInfo[
"partner_type"] = trim( $partnerRow[
"partner_type"] );
132 $returnData[
"data"] = array_merge( $basicInfo, $addressData, $dfiData );
134 }
catch (Exception $ex) {
135 $logInfo = array(
"message" => $ex->getMessage(),
"code" => $ex->getCode() );
136 $returnData[
"code"] =
"999";
152 function ACH_GetAccounts( $pDbh, $pHBEnv, $pFromTo ) {
154 $returnData = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
157 $Fset = HCU_array_key_exists(
"Fset", $pHBEnv) ? intval($pHBEnv[
"Fset"]) : 0;
158 $Fset2 = HCU_array_key_exists(
"Fset2", $pHBEnv) ? intval($pHBEnv[
"Fset2"]) : 0;
168 $orderBy .=
"recordtype, display_order,";
169 $orderBy .=
" CASE recordtype";
170 if ($Fset & GetFlagsetValue(
'CU_SORTORDER4')) {
171 $orderBy .=
" WHEN 'D' THEN btrim(accounttype, 'DIS')";
173 $orderBy .=
" WHEN 'D' THEN accounttype";
177 $orderBy .=
" certnumber";
179 if ( $pFromTo ===
"withdrawl" ) {
183 SELECT u.accountnumber, u.accounttype, u.certnumber, recordtype, display_name, display_order, view_balances, description, available AS balance 184 FROM {$pHBEnv["Cu
"]}useraccounts u 185 INNER JOIN {$pHBEnv["Cu
"]}accountbalance a ON a.accountnumber = u.accountnumber 186 AND a.accounttype = u.accounttype 187 AND a.certnumber = u.certnumber 188 AND a.may_withdraw = 't' 189 WHERE u.user_id = {$pHBEnv["Uid
"]} 190 AND u.ext_withdraw = 't' 191 AND u.recordtype = 'D' 192 ) accts ORDER BY $orderBy";
193 }
else if ( $pFromTo ===
"deposit" ) {
197 SELECT u.accountnumber, u.accounttype, u.certnumber, recordtype, display_name, display_order, view_balances, description, available AS balance 198 FROM {$pHBEnv["Cu
"]}useraccounts u 199 INNER JOIN {$pHBEnv["Cu
"]}accountbalance a ON a.accountnumber = u.accountnumber 200 AND a.accounttype = u.accounttype 201 AND a.certnumber = u.certnumber 202 AND a.may_deposit = 't' 203 WHERE u.user_id = {$pHBEnv["Uid
"]} 204 AND u.ext_deposit = 't' 205 AND u.recordtype = 'D' 206 ) accts ORDER BY $orderBy";
208 throw new Exception(
"Invalid operation" );
211 $rs = db_query( $SQL, $pDbh );
216 while ( $accountRow = db_fetch_array( $rs, $row++ ) ) {
222 $isOverloadedAry = explode(
"@", $accountRow[
'accounttype']);
223 $isOverloaded = count($isOverloadedAry) > 1;
230 $coreDescription = trim( $accountRow[
"description"] );
231 if ( strlen( trim( $accountRow[
"accounttype"] ) ) > 0 ) {
232 $coreDescription .=
" - " . $accountRow[
"accounttype"];
236 $accountNumber = trim( $accountRow[
"accountnumber"] );
237 $accountType = trim( $accountRow[
"accounttype"] );
238 $certNumber = trim( $accountRow[
"certnumber"] );
239 $acctId =
"{$accountRow["recordtype
"]}|{$accountNumber}|{$accountType}|{$certNumber}";
240 $acctIdEncrypted = hcu_encrypturl( $acctId, $pHBEnv[
'historyHash'] );
241 $balanceStr = $accountRow[
"view_balances"] ==
't' ?
"$" . $accountRow[
"balance"] :
"N/A";
242 $saveRow = array(
"account" => $accountNumber,
243 "account_name" => getAccountDescription($pDbh, $pHBEnv[
"Cu"], $accountRow[
"accountnumber"], $accountRow[
"description"], $accountRow[
"accounttype"],
244 $accountRow[
"display_name"], $pHBEnv[
"Fset3"], $certNumber,
false),
245 "acctid" => $acctIdEncrypted,
246 "amount" => $balanceStr );
248 $return[] = $saveRow;
251 $returnData[
"data"] = $return;
252 }
catch (Exception $ex) {
253 $logInfo = array(
"message" => $ex->getMessage(),
"code" => $ex->getCode() );
254 $returnData[
"code"] =
"999";
269 function ACH_ValidateInputs( $pHBEnv, $pDbh, $pInputVars, $pMC ) {
271 $aryReturnErrors = array();
272 $retACHValidate = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
275 if ( trim( $pInputVars[
"internal_acct"] ) ==
"" ) {
276 $aryReturnErrors[] = $pMC->msg(
"ACH Validation Local Account") .
" 1029";
279 if ( trim( $pInputVars[
"internal_sub_acct"] ) ==
"" ) {
280 $aryReturnErrors[] = $pMC->msg(
"ACH Validation Local Account") .
" 1016";
284 $acctIdDecrypted = hcu_decrypturl( $pInputVars[
"internal_sub_acct"], $pHBEnv[
'historyHash'] );
285 $accountParts = explode(
"|", $acctIdDecrypted );
288 $localAccount = TX_list($pHBEnv[
'dbh'], $pHBEnv, $acctIdDecrypted);
290 if ( count( $accountParts ) < 3 || count( $accountParts ) > 4 ) {
291 $aryReturnErrors[] = $pMC->msg(
"ACH Validation Local Account") .
" 1017";
294 if ( trim( $pInputVars[
"eff_date"] ) ==
"" ) {
295 $aryReturnErrors[] = $pMC->msg(
"ACH Validation Eff Date Missing") .
" 1030";
297 $timeTest = strtotime($pInputVars[
"eff_date"]);
298 if ( !intval( $timeTest ) ) {
299 $aryReturnErrors[] = $pMC->msg(
"ACH Validation Eff Date") .
" 1031";
301 $today = strtotime( date(
"m/d/Y" ) );
302 if ( $timeTest < $today ) {
303 $aryReturnErrors[] = $pMC->msg(
"ACH Validation Eff Date Today") .
" 1032";
308 if ( !(strtoupper( trim( $pInputVars[
"ach_type"] ) ) ===
"PPD" ||
309 strtoupper( trim( $pInputVars[
"ach_type"] ) ) ===
"CCD") ) {
310 $aryReturnErrors[] = $pMC->msg(
"ACH Validation ACH Type") .
" 1033";
314 if ( $pInputVars[
"action"] ==
"submit_payment" ||
315 $pInputVars[
"action"] ==
"submit_collection" ) {
319 $achName = trim( $pInputVars[
"ach_name"] ) ==
"" ? $pInputVars[
"display_name"] : $pInputVars[
"ach_name"];
320 if ( strlen( trim( $achName ) ) == 0 ) {
321 $aryReturnErrors[] = $pMC->msg(
"ACH Validation Name", HCU_DISPLAY_AS_HTML) .
" 1043";
324 if ( trim( $pInputVars[
"dfi_routing"] ) ==
"" ||
325 !ctype_digit( trim( $pInputVars[
"dfi_routing"] ) ) ||
326 strlen( trim( $pInputVars[
"dfi_routing"] ) ) != 9 ) {
327 $aryReturnErrors[] = $pMC->msg(
"ACH Validation DFI Routing") .
" 1034";
330 if ( trim( $pInputVars[
"dfi_account"] ) ==
"" ) {
331 $aryReturnErrors[] = $pMC->msg(
"ACH Validation DFI Account") .
" 1035";
334 if ( !(trim( $pInputVars[
"dfi_account_type"] ) == ACCOUNT_TYPE_CHECKING ||
335 trim( $pInputVars[
"dfi_account_type"] ) == ACCOUNT_TYPE_SAVINGS )) {
336 $aryReturnErrors[] = $pMC->msg(
"ACH Validation DFI Type") .
" 1036";
339 if ( trim( $pInputVars[
"amount"] ) ==
"" || $pInputVars[
"amount"] == 0) {
340 $aryReturnErrors[] = $pMC->msg(
"ACH Validation Amount") .
" 1037";
346 $scheduled = $pInputVars[
'frequency'] !==
"OneTime";
347 if (!$scheduled && $pInputVars[
"action"] ==
"submit_payment") {
349 if ($localAccount[
"acctlist"][
"balance"] < $pInputVars[
"amount"]) {
350 $aryReturnErrors[] = $pMC->msg(
"Transfer exceeds") .
" 1050";
354 }
else if ( $pInputVars[
"action"] ==
"submit_batch_payment" ||
355 $pInputVars[
"action"] ==
"submit_batch_collection" ) {
356 if ( trim( $pInputVars[
"template_id"] ) ==
"" || intval( trim( $pInputVars[
"template_id"] ) ) == 0 ) {
357 $aryReturnErrors[] = $pMC->msg(
"ACH Validation Template") .
" 1038";
361 $batchData = html_entity_decode( trim( $pInputVars[
"batch_data"], ENT_QUOTES ) );
363 if ( !strlen( $batchData ) ) {
364 $aryReturnErrors[] = $pMC->msg(
"ACH Validation Batch Data Missing") .
" 1039";
366 $batchInfo = HCU_JsonDecode( $batchData,
true );
368 if ( !count( $batchInfo ) ) {
369 $aryReturnErrors[] = $pMC->msg(
"ACH Validation Batch Data Invalid") .
" 1040";
371 $batchPartnerTotal = 0;
372 for ( $i = 0; $i < count( $batchInfo ); $i++ ) {
374 $batchPartnerId = $batchInfo[$i][
"id"];
375 $batchPartnerAmount = $batchInfo[$i][
"amount"];
376 $batchPartnerTotal += $batchPartnerAmount;
378 if ( !is_int( $batchPartnerId ) && !( $batchPartnerId > 0 ) ) {
379 $aryReturnErrors[] = $pMC->msg(
"ACH Validation Batch PartnerId") .
" 1041";
384 if ( !is_numeric( $batchPartnerAmount ) && !( $batchPartnerAmount > 0 ) ) {
385 $aryReturnErrors[] = $pMC->msg(
"ACH Validation Batch Partner Amount") .
" 1042";
392 if ( $pInputVars[
"action"] ==
"submit_batch_payment" ) {
393 if ( $localAccount[
"acctlist"][
"balance"] < $batchPartnerTotal ) {
394 $aryReturnErrors[] = $pMC->msg(
"Transfer exceeds") .
" 1051";
401 if ( count( $aryReturnErrors ) > 0 ) {
403 $retACHValidate[
'code'] =
'999';
404 $retACHValidate[
"errors"] = $aryReturnErrors;
407 return $retACHValidate;
419 function privValidateAddress( $pHBEnv, $pInputVars ) {
421 $pOutputVars = array(
"address1" =>
"",
430 $address = $pInputVars[
"address1"];
434 $pOutputVars[
"address1"] = $address;
436 $address2 = $pInputVars[
"address2"];
440 $pOutputVars[
"address2"] = $address2;
442 $city = $pInputVars[
"city"];
446 $pOutputVars[
"city"] = $city;
448 $state = $pInputVars[
"state"];
452 $pOutputVars[
"state"] = $state;
454 $zip = $pInputVars[
"zip"];
458 $pOutputVars[
"zip"] = $zip;
460 $country = $pInputVars[
"country"];
464 $pOutputVars[
"country"] = $country;
466 $email = filter_var($pInputVars[
"email"], FILTER_VALIDATE_EMAIL);
467 if ( $email ===
false ) {
470 $pOutputVars[
"email"] = $email;
472 }
catch (Exception $ex) {
487 function privValidateName( $pDbh, $pHBEnv, $pInputVars, $pMC ) {
493 if ( trim( $pInputVars[
"display_name"] ) ==
"" ) {
494 throw new Exception( $pMC->msg(
"ACH Validation Name", HCU_DISPLAY_AS_HTML) .
" 1022" );
499 $displayName = prep_save( html_entity_decode( trim( $pInputVars[
"display_name"] ), ENT_QUOTES ) );
500 $sql =
"SELECT id FROM {$pHBEnv["Cu
"]}achpartner WHERE display_name = '{$displayName}'";
501 $rs = db_query( $sql, $pDbh );
504 $partnerIdList = array();
505 while ( $partnerRow = db_fetch_assoc( $rs, $row++ ) ) {
507 $partnerIdList[] = $partnerRow[
"id"];
511 if ( (count( $partnerIdList ) > 1) ||
512 (count( $partnerIdList ) == 1 && intval( $pInputVars[
"partner_id"] ) == 0) ) {
513 throw new Exception( $pMC->msg(
"ACH Validation Unique Display Name", HCU_DISPLAY_AS_HTML) .
" 1009" );
514 }
else if ( count( $partnerIdList ) == 1 ) {
516 if ( $partnerIdList[0] != $pInputVars[
"partner_id"] ) {
517 throw new Exception( $pMC->msg(
"ACH Validation Unique Display Name", HCU_DISPLAY_AS_HTML) .
" 1010" );
522 }
catch (Exception $ex) {
524 $retString = $ex->getMessage();
538 function ACH_GetTransCode( $pFeatureCode, $pACHType ) {
539 $achType = strtoupper( $pACHType );
540 if ( $pFeatureCode == constant(
"FEATURE_ACH_PAYMENTS" ) ) {
542 $transCode = ( $achType ==
"PPD" ?
"1P" : ( $achType ==
"CCD" ?
"1C" :
"1X" ) );
545 $transCode = ( $achType ==
"PPD" ?
"2P" : ( $achType ==
"CCD" ?
"2C" :
"2X" ) );
560 function ACH_Submit( $pDbh, $pHBEnv, $pInputVars, $pMC ) {
562 $returnData = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
564 $achFeatureCode = $pInputVars[
"action"] ===
"submit_payment" ? constant(
"FEATURE_ACH_PAYMENTS" ) : constant(
"FEATURE_ACH_COLLECTIONS" );
570 $sql =
"BEGIN TRANSACTION";
571 $achRs = db_query( $sql, $pDbh );
573 $acctIdDecrypted = hcu_decrypturl( $pInputVars[
"internal_sub_acct"], $pHBEnv[
'historyHash'] );
574 $accountParts = explode(
"|", $acctIdDecrypted );
575 $account = $accountParts[1];
576 $accountType = $accountParts[2];
579 $effDateTime = strtotime( $pInputVars[
"eff_date"] );
580 $nowDateTime = strtotime( date(
"Y/m/d" ) );
582 if ( $effDateTime ===
false ||
583 $effDateTime < $nowDateTime ) {
584 $effDateTime = time();
587 $effDate = date(
"Y-m-d", $effDateTime );
590 $depositType = $accountParts[0];
593 $transactionCode = ACH_GetTransCode( $achFeatureCode, $pInputVars[
"ach_type"] );
595 $memo = prep_save( html_entity_decode( trim( $pInputVars[
"memo"] ), ENT_QUOTES ) );
598 if ( $pInputVars[
"needs_confirmation"] ) {
599 $approvedBy =
"NULL";
600 $approvedDate =
"NULL";
601 $approvedStatus =
"NULL";
603 $approvedBy = $pHBEnv[
"Uid"];
604 $approvedDate =
"now()";
605 $approvedStatus =
"10";
611 $transMeta = array();
612 $transMeta[
"source"] =
"immed";
613 $transMeta[
"recurr"] =
"no";
614 $transMeta[
"interval"] = 0;
615 $jsonTransMeta = HCU_JsonEncode($transMeta);
616 $jsonTransMeta = prep_save($jsonTransMeta);
619 $sql =
"INSERT INTO {$pHBEnv["Cu
"]}transhdr (feature_code, effective_date, 620 posted_by, posted_date, approved_by, approved_date, approved_status, 621 accountnumber, transactioncode, memo, transmeta) 622 VALUES ('{$achFeatureCode}', '{$effDate}', 623 {$pHBEnv["Uid
"]}, now(), $approvedBy, $approvedDate, $approvedStatus, 624 '{$account}', '$transactionCode', '$memo', '{$jsonTransMeta}' ) 625 RETURNING id, posted_date, approved_date";
627 $hdrRs = db_query( $sql, $pDbh );
630 throw new Exception( $pMC->msg(
"ACH Query Error", HCU_DISPLAY_AS_HTML) .
" 1001" );
634 list($headerId, $postedDate, $approvedDate) = db_fetch_array($hdrRs, 0);
637 throw new Exception( $pMC->msg(
"ACH Query Error", HCU_DISPLAY_AS_HTML) .
" 1002" );
641 $achName = trim( $pInputVars[
"ach_name"] ) ==
"" ? $pInputVars[
"display_name"] : $pInputVars[
"ach_name"];
642 $achName = prep_save(hcu_displayHtml( preg_replace(
"/[\`\;]/",
"", $achName ) ) );
645 if ( strlen( $achName ) == 0 ) {
646 throw new Exception( $pMC->msg(
"ACH Validation Name", HCU_DISPLAY_AS_HTML) .
" 1019" );
649 $addressVars = privValidateAddress( $pHBEnv, $pInputVars );
652 if ( strlen( $pInputVars[
"email"] ) > 0 && !strlen( $addressVars[
"email"] ) ) {
653 throw new Exception( $pMC->msg(
"Email appears invalid", HCU_DISPLAY_AS_RAW) .
" 1023" );
654 }
else if ( isset( $pInputVars[
'email_notify'] ) && $pInputVars[
'email_notify'] == 1 && !strlen( $addressVars[
"email"] ) ) {
655 throw new Exception( $pMC->msg(
"EMail Missing", HCU_DISPLAY_AS_RAW) .
" 1020" );
661 $rdfiTransCode = ( $achFeatureCode == constant(
"FEATURE_ACH_PAYMENTS" ) ?
"CR" :
"DB" );
662 $achData = array(
"rdfi" => array(
"rdfi_routing" => $pInputVars[
"dfi_routing"],
663 "rdfi_account" => $pInputVars[
"dfi_account"],
664 "rdfi_account_type" => $pInputVars[
"dfi_account_type"],
665 "rdfi_txn_type" => $rdfiTransCode,
666 "addenda" => prep_save( html_entity_decode( $pInputVars[
"addenda"], ENT_QUOTES ) ) ),
667 "remote_entity" => array(
"name" => $achName,
668 "address1" => prep_save( html_entity_decode( $pInputVars[
"address1"], ENT_QUOTES ) ),
669 "address2" => prep_save( html_entity_decode( $pInputVars[
"address2"], ENT_QUOTES ) ),
670 "email" => $pInputVars[
"email"] ) );
673 if ( $achFeatureCode == constant(
"FEATURE_ACH_PAYMENTS" ) ) {
675 $sourceAccountInfo = $acctIdDecrypted;
676 $sourceAccountKey = array(
677 "accountnumber"=>$accountParts[1],
678 "recordtype"=>$accountParts[0]
680 if ($sourceAccountKey[
'recordtype'] ==
"D") {
681 $sourceAccountKey[
'accounttype'] = $accountParts[2];
682 $sourceAccountKey[
'certnumber'] = $accountParts[3];
683 }
else if ($sourceAccountKey[
'recordtype'] ==
"L") {
684 $sourceAccountKey[
'loannumber'] = $accountParts[2];
687 $destAccountInfo = $achData;
688 $destAccountKey = array();
691 $sourceAccountInfo = $achData;
692 $sourceAccountKey = array();
694 $destAccountInfo = $acctIdDecrypted;
695 $destAccountKey = array(
696 "accountnumber"=>$accountParts[1],
697 "recordtype"=>$accountParts[0]
699 if ($destAccountKey[
'recordtype'] ==
"D") {
700 $destAccountKey[
'accounttype'] = $accountParts[2];
701 $destAccountKey[
'certnumber'] = $accountParts[3];
702 }
else if ($destAccountKey[
'recordtype'] ==
"L") {
703 $destAccountKey[
'loannumber'] = $accountParts[2];
708 $transData = array(
"acct_source" => $sourceAccountInfo,
"acct_dest" => $destAccountInfo,
"source_key"=>$sourceAccountKey,
"dest_key"=>$destAccountKey );
710 $jsonTransData = HCU_JsonEncode( $transData );
711 $jsonTransDataWithMeta = AddAccountMetaData($pHBEnv, $achFeatureCode, $transactionCode, $jsonTransData);
714 $amount = $pInputVars[
'amount'];
715 $emailNotify = isset( $pInputVars[
'email_notify'] ) ? intval($pInputVars[
'email_notify']) : 0;
718 $referenceId = isset( $pInputVars[
'partner_id'] ) && intval( $pInputVars[
"partner_id"] ) > 0 ? intval( $pInputVars[
'partner_id'] ) : 0;
722 $sql =
"INSERT INTO {$pHBEnv["Cu
"]}transdtl (transhdr_id, reference_id, amount, email_notify, transdata) 723 VALUES ($headerId, $referenceId, $amount, '$emailNotify', '$jsonTransDataWithMeta')";
725 $dtlRs = db_query( $sql, $pDbh );
728 throw new Exception( $pMC->msg(
"ACH Query Error", HCU_DISPLAY_AS_HTML) .
" 1003" );
732 $sql =
"COMMIT TRANSACTION";
733 $achRs = db_query( $sql, $pDbh );
738 $confCodeBuilder[
"id"] = $headerId;
739 if ($pInputVars[
"needs_confirmation"]) {
740 $confCodeBuilder[
"posted_by"] = $pHBEnv[
"Uid"];
741 $confCodeBuilder[
"posted_date"] = $postedDate;
742 $confirmationCode = GetTransferConfirmCode( $pHBEnv,
"post", $confCodeBuilder );
744 $confCodeBuilder[
"approved_by"] = $pHBEnv[
"Uid"];
745 $confCodeBuilder[
"approved_date"] = $approvedDate;
746 $confirmationCode = GetTransferConfirmCode( $pHBEnv,
"approve", $confCodeBuilder );
750 $myDateTime =
new DateTime( $postedDate );
751 $myDateTime->setTimezone(
new DateTimeZone($pHBEnv[
"tz"]));
752 $displayDate = $myDateTime->format(
"m/d/Y g:ia");
753 $returnData[
'data'][
'data_date'] = $displayDate;
754 $returnData[
'data'][
'data_amount'] = $amount;
755 $returnData[
'data'][
'data_confirm'] = $confirmationCode;
757 $companyData = ACH_GetCompanyData($pHBEnv);
758 $returnData[
'data'][
'data_company'] = $companyData[
'group_name'];
760 $returnData[
'data'][
'data_action'] = (
761 $achFeatureCode == constant(
"FEATURE_ACH_PAYMENTS" ) ?
762 $pMC->msg(
'ACH Payment Title', HCU_DISPLAY_AS_RAW) :
763 $pMC->msg(
'ACH Collection Title', HCU_DISPLAY_AS_RAW)
769 $achFeatureCode == constant(
"FEATURE_ACH_PAYMENTS" ) ?
770 GetMemberDescription($pDbh, $pHBEnv[
'Cu'], $pHBEnv[
'Uid'], $sourceAccountKey) :
771 GetMemberDescription($pDbh, $pHBEnv[
'Cu'], $pHBEnv[
'Uid'], $destAccountKey)
773 $returnData[
'data'][
'data_account'] = getAccountDescription(
774 $pDbh, $pHBEnv[
"Cu"],
776 $acctDesc[
'description'],
778 $acctDesc[
"display_name"],
779 $pHBEnv[
"Fset3"], $accountParts[3],
false 782 }
catch (Exception $ex) {
784 $message = $ex->getMessage();
785 $code = $ex->getCode();
788 $sql =
"ROLLBACK TRANSACTION";
789 db_query( $sql, $pDbh );
791 $logInfo = array(
"message" => $message,
"code" => $code );
792 $returnData[
"code"] =
"999";
793 $returnData[
"errors"][] = $message;
810 function ACH_SubmitBatch( $pDbh, $pHBEnv, $pInputVars, $pBatchInfo, $pMC ) {
812 $returnData = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
814 if ( $pInputVars[
"action"] ===
"submit_payment" ||
815 $pInputVars[
"action"] ===
"submit_batch_payment" ) {
816 $achFeatureCode = constant(
"FEATURE_ACH_PAYMENTS" );
818 $achFeatureCode = constant(
"FEATURE_ACH_COLLECTIONS" );
825 $sql =
"BEGIN TRANSACTION";
826 $achRs = db_query( $sql, $pDbh );
829 $sql =
"SELECT tmpl_meta 830 FROM {$pHBEnv["Cu
"]}achtemplate 831 WHERE tmpl_id = {$pInputVars['template_id']}";
833 $rs = db_query( $sql, $pDbh );
836 $templateRow = db_fetch_assoc( $rs, 0 );
839 $currentMetaInfo = HCU_JsonDecode( $templateRow[
"tmpl_meta"],
true );
842 $acctIdDecrypted = hcu_decrypturl( $pInputVars[
"internal_sub_acct"], $pHBEnv[
'historyHash'] );
843 $accountParts = explode(
"|", $acctIdDecrypted );
844 $account = $accountParts[1];
849 "accountnumber" => $accountParts[1],
850 "recordtype" => $accountParts[0],
851 "accounttype" => $accountParts[2],
852 "certnumber" => $accountParts[3]
856 $effDateTime = strtotime( $pInputVars[
"eff_date"] );
857 $nowDateTime = strtotime( date(
"Y/m/d" ) );
859 if ( $effDateTime ===
false ||
860 $effDateTime < $nowDateTime ) {
861 $effDateTime = time();
864 $effDate = date(
"Y-m-d", $effDateTime );
867 $depositType = $accountParts[0];
870 $transactionCode = ACH_GetTransCode( $achFeatureCode, $pInputVars[
"ach_type"] );
872 $memo = prep_save( html_entity_decode( trim( $pInputVars[
"memo"] ), ENT_QUOTES ) );
875 if ( $pInputVars[
"needs_confirmation"] ) {
876 $approvedBy =
"NULL";
877 $approvedDate =
"NULL";
878 $approvedStatus =
"NULL";
880 $approvedBy = $pHBEnv[
"Uid"];
881 $approvedDate =
"now()";
882 $approvedStatus =
"10";
888 $transMeta = array();
889 $transMeta[
"source"] =
"immed";
890 $transMeta[
"recurr"] =
"no";
891 $transMeta[
"interval"] = 0;
892 $jsonTransMeta = HCU_JsonEncode($transMeta);
893 $jsonTransMeta = prep_save($jsonTransMeta);
896 $sql =
"INSERT INTO {$pHBEnv["Cu
"]}transhdr (feature_code, effective_date, 897 posted_by, posted_date, approved_by, approved_date, approved_status, 898 accountnumber, transactioncode, memo, transmeta) 899 VALUES ('{$achFeatureCode}', '{$effDate}', 900 {$pHBEnv["Uid
"]}, now(), $approvedBy, $approvedDate, $approvedStatus, '{$account}', 901 '$transactionCode', '{$memo}', '{$jsonTransMeta}' ) 902 RETURNING id, posted_date, approved_date";
904 $hdrRs = db_query( $sql, $pDbh );
907 throw new Exception( $pMC->msg(
"ACH Query Error", HCU_DISPLAY_AS_HTML) .
" 1004" );
911 list($headerId, $postedDate, $approvedDate) = db_fetch_array($hdrRs, 0);
914 throw new Exception( $pMC->msg(
"ACH Query Error", HCU_DISPLAY_AS_HTML) .
" 1005" );
919 for ( $i = 0; $i < count( $pBatchInfo ); $i++ ) {
921 $partnerId = $pBatchInfo[$i][
"id"];
924 $sql =
"SELECT * FROM {$pHBEnv["Cu
"]}achpartner WHERE id = {$partnerId}";
926 $rs = db_query( $sql, $pDbh );
928 $partnerRow = db_fetch_assoc( $rs, 0 );
931 $achName = trim( $partnerRow[
"ach_name"] ) ==
"" ? $partnerRow[
"display_name"] : $partnerRow[
"ach_name"];
932 $achName = prep_save(hcu_displayHtml( preg_replace(
"/[\`\;]/",
"", $achName ) ) );
935 $dfiData = HCU_JsonDecode( $partnerRow[
"dfi_data"],
true );
936 $addressData = HCU_JsonDecode( $partnerRow[
"address"],
true );
939 if ( isset( $pBatchInfo[$i][
'notify'] ) && $pBatchInfo[$i][
'notify'] == 1 && !strlen( $addressData[
"email"] ) ) {
940 throw new Exception( $pMC->msg(
"Please specify email address", HCU_DISPLAY_AS_RAW) .
" 1021" );
944 $address1 = isset( $pInputVars[
"address1"] ) ? trim( $pInputVars[
"address1"] ) :
"";
945 $address2 = isset( $pInputVars[
"address2"] ) ? trim( $pInputVars[
"address2"] ) :
"";
949 $rdfiTransCode = ( $achFeatureCode == constant(
"FEATURE_ACH_PAYMENTS" ) ?
"CR" :
"DB" );
951 $achData = array(
"rdfi" => array(
"rdfi_routing" => $dfiData[
"dfi_routing"],
952 "rdfi_account" => $dfiData[
"dfi_account"],
953 "rdfi_account_type" => $dfiData[
"dfi_account_type"],
954 "rdfi_txn_type" => $rdfiTransCode,
955 "addenda" => $pBatchInfo[$i][
"addenda"] ),
956 "remote_entity" => array(
"name" => $achName,
957 "address1" => prep_save( html_entity_decode( $address1, ENT_QUOTES ) ),
958 "address2" => prep_save( html_entity_decode( $address2, ENT_QUOTES ) ),
959 "email" => $addressData[
"email"] ) );
962 if ( $achFeatureCode == constant(
"FEATURE_ACH_PAYMENTS" ) ) {
964 $sourceAccountInfo = $acctIdDecrypted;
965 $destAccountInfo = $achData;
969 $sourceKey = $accountKey;
973 $sourceAccountInfo = $achData;
974 $destAccountInfo = $acctIdDecrypted;
978 $sourceKey = array();
979 $destKey = $accountKey;
983 $transData = array(
"acct_source" => $sourceAccountInfo,
"acct_dest" => $destAccountInfo,
"source_key" => $sourceKey,
"dest_key" => $destKey );
985 $jsonTransData = HCU_JsonEncode( $transData );
986 $jsonTransDataWithMeta = AddAccountMetaData($pHBEnv, $achFeatureCode, $transactionCode, $jsonTransData);
988 $amount = floatval( $pBatchInfo[$i][
'amount'] );
989 $totalAmount += $amount;
990 $emailNotify = isset( $pBatchInfo[$i][
'notify'] ) ? intval($pBatchInfo[$i][
'notify']) : 0;
993 $referenceId = $partnerRow[
'id'];
997 $sql =
"INSERT INTO {$pHBEnv["Cu
"]}transdtl (transhdr_id, reference_id, amount, email_notify, transdata) 998 VALUES ($headerId, $referenceId, $amount, '$emailNotify', '$jsonTransDataWithMeta')";
1000 $dtlRs = db_query( $sql, $pDbh );
1003 throw new Exception( $pMC->msg(
"ACH Query Error", HCU_DISPLAY_AS_HTML) .
" 1006" );
1008 $myDateTime =
new DateTime();
1009 $myDateTime->setTimezone(
new DateTimeZone( $pHBEnv[
"tz"] ));
1010 $formattedTime = $myDateTime->format(
"m/d/y g:ia T");
1013 $currentMetaInfo[
"type"] = $pInputVars[
"ach_type"];
1014 $currentMetaInfo[
"last_proc"] = $formattedTime;
1015 $templateMeta = HCU_JsonEncode( $currentMetaInfo );
1017 if ( !$templateMeta ) {
1018 throw new Exception( $pMC->msg(
"ACH Error Encoding", HCU_DISPLAY_AS_HTML) .
" 1045" );
1021 $SQL =
"UPDATE {$pHBEnv["Cu
"]}achtemplate SET tmpl_meta = '$templateMeta' WHERE tmpl_id = {$pInputVars['template_id']}";
1022 $rs = db_query( $SQL, $pDbh );
1025 $sql =
"COMMIT TRANSACTION";
1026 $achRs = db_query( $sql, $pDbh );
1031 $confCodeBuilder[
"id"] = $headerId;
1032 if ($pInputVars[
"needs_confirmation"]) {
1033 $confCodeBuilder[
"posted_by"] = $pHBEnv[
"Uid"];
1034 $confCodeBuilder[
"posted_date"] = $postedDate;
1035 $confirmationCode = GetTransferConfirmCode( $pHBEnv,
"post", $confCodeBuilder );
1037 $confCodeBuilder[
"approved_by"] = $pHBEnv[
"Uid"];
1038 $confCodeBuilder[
"approved_date"] = $approvedDate;
1039 $confirmationCode = GetTransferConfirmCode( $pHBEnv,
"approve", $confCodeBuilder );
1043 $myDateTime =
new DateTime( $postedDate );
1044 $myDateTime->setTimezone(
new DateTimeZone($pHBEnv[
"tz"]));
1045 $displayDate = $myDateTime->format(
"m/d/Y g:ia");
1046 $returnData[
'data'][
'data_date'] = $displayDate;
1047 $returnData[
'data'][
'data_amount'] = $totalAmount;
1048 $returnData[
'data'][
'data_confirm'] = $confirmationCode;
1050 $companyData = ACH_GetCompanyData($pHBEnv);
1051 $returnData[
'data'][
'data_company'] = $companyData[
'group_name'];
1053 $returnData[
'data'][
'data_action'] = (
1054 $achFeatureCode == constant(
"FEATURE_ACH_PAYMENTS" ) ?
1055 $pMC->msg(
'ACH Payment Title', HCU_DISPLAY_AS_RAW) :
1056 $pMC->msg(
'ACH Collection Title', HCU_DISPLAY_AS_RAW)
1061 $acctDesc = GetMemberDescription($pDbh, $pHBEnv[
'Cu'], $pHBEnv[
'Uid'], $accountKey);
1062 $returnData[
'data'][
'data_account'] = getAccountDescription(
1063 $pDbh, $pHBEnv[
"Cu"],
1065 $acctDesc[
'description'],
1067 $acctDesc[
"display_name"],
1068 $pHBEnv[
"Fset3"], $accountParts[3],
false 1071 }
catch (Exception $ex) {
1073 $message = $ex->getMessage();
1074 $code = $ex->getCode();
1077 $sql =
"ROLLBACK TRANSACTION";
1078 db_query( $sql, $pDbh );
1080 $logInfo = array(
"message" => $message,
"code" => $code );
1081 $returnData[
"code"] =
"999";
1082 $returnData[
"errors"][] = $message;
1099 function ACH_UpdatePartner( $pDbh, $pHBEnv, $pInputVars, $pMC ) {
1101 $returnData = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
1107 if ( $pInputVars[
"partner_type"] ===
"e" ) {
1110 }
else if ( $pInputVars[
"partner_type"] ===
"r" ) {
1113 }
else if ( $pInputVars[
"partner_type"] ===
"$" ) {
1118 $return = privValidateName( $pDbh, $pHBEnv, $pInputVars, $pMC );
1119 if ( strlen( $return ) > 0 ) {
1120 throw new Exception( $return );
1123 $addressVars = privValidateAddress( $pHBEnv, $pInputVars );
1126 if ( strlen( $pInputVars[
"email"] ) > 0 && !strlen( $addressVars[
"email"] ) ) {
1127 throw new Exception( $pMC->msg(
"Email appears invalid", HCU_DISPLAY_AS_RAW) .
" 1023" );
1128 }
else if ( isset( $pInputVars[
'email_notify'] ) && $pInputVars[
'email_notify'] == 1 && !strlen( $addressVars[
"email"] ) ) {
1129 throw new Exception( $pMC->msg(
"EMail Missing", HCU_DISPLAY_AS_RAW) .
" 1025" );
1133 $address = array(
"address1" => prep_save( html_entity_decode( $addressVars[
"address1"], ENT_QUOTES ) ),
1134 "address2" => prep_save( html_entity_decode( $addressVars[
"address2"], ENT_QUOTES ) ),
1135 "city" => prep_save( html_entity_decode( $addressVars[
"city"], ENT_QUOTES ) ),
1136 "state" => $addressVars[
"state"],
1137 "zip" => $addressVars[
"zip"],
1138 "country" => $addressVars[
"country"],
1139 "email" => $addressVars[
"email"] );
1140 $jsonAddress = HCU_JsonEncode( $address );
1144 $dfi = array(
"dfi_routing" => $pInputVars[
"dfi_routing"],
1145 "dfi_account" => $pInputVars[
"dfi_account"],
1146 "dfi_account_type" => $pInputVars[
"dfi_account_type"] );
1147 $jsonDFI = HCU_JsonEncode( $dfi );
1150 $emailNotify = isset( $pInputVars[
'email_notify'] ) && $pInputVars[
'email_notify'] == 1 ?
"true" :
"false";
1152 $achName = prep_save( trim( html_entity_decode( $pInputVars[
"ach_name"], ENT_QUOTES ) ) );
1154 $displayName = prep_save( trim( html_entity_decode( $pInputVars[
"display_name"], ENT_QUOTES ) ) );
1156 if ( $achName ==
"" ) $achName = $displayName;
1159 if ( $pInputVars[
"partner_id"] > 0 ) {
1160 $SQL =
"UPDATE {$pHBEnv["Cu
"]}achpartner 1161 SET partner_type = '{$partnerType}', 1162 ach_name = '{$achName}', 1163 display_name = '{$displayName}', 1164 email_notify = $emailNotify, 1165 address = '$jsonAddress', 1166 dfi_data = '$jsonDFI' 1167 WHERE id = {$pInputVars["partner_id
"]}";
1169 $SQL =
"INSERT INTO {$pHBEnv["Cu
"]}achpartner (group_id, partner_type, ach_name, 1170 display_name, email_notify, address, dfi_data) 1171 VALUES ( (SELECT group_id FROM {$pHBEnv["Cu
"]}user WHERE user_id = {$pHBEnv["Uid
"]}), 1172 '{$pInputVars["partner_type
"]}', '{$pInputVars["ach_name
"]}', '{$displayName}', 1173 '$emailNotify', '$jsonAddress', '$jsonDFI' ) 1177 $achRs = db_query( $SQL, $pDbh );
1180 throw new Exception( $pMC->msg(
"ACH Query Error", HCU_DISPLAY_AS_HTML) .
" 1007" );
1184 if ( $pInputVars[
"partner_id"] == 0 &&
1185 isset( $pInputVars[
"template_id"] ) &&
1186 intval( $pInputVars[
"template_id"] ) > 0 ) {
1188 list($partnerId) = db_fetch_array($achRs, 0);
1191 $result = ACH_AddPartnerToTemplate( $pDbh, $pHBEnv, $pInputVars[
"template_id"], $partnerId, $pMC );
1192 if ($result[
'code'] !=
'000') {
1193 throw new Exception( $pMC->msg(
"ACH Query Error", HCU_DISPLAY_AS_HTML) .
" 1008" );
1195 }
else if ( $pInputVars[
"partner_id"] == 0 ) {
1196 list($partnerId) = db_fetch_array($achRs, 0);
1198 $partnerId = $pInputVars[
"partner_id"];
1202 $return[
"partner_id"] = $partnerId;
1204 $returnData[
"data"] = $return;
1208 }
catch (Exception $ex) {
1210 $message = $ex->getMessage();
1211 $code = $ex->getCode();
1213 $logInfo = array(
"message" => $message,
"code" => $code );
1214 $returnData[
"code"] =
"999";
1215 $returnData[
"errors"][] = $message;
1232 function ACH_DeletePartner( $pDbh, $pHBEnv, $pInputVars, $pMC ) {
1234 $returnData = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
1242 SELECT json_array_elements(tmpl_partner::json) AS partners 1243 FROM scrubcuachtemplate) AS partners 1244 WHERE partners::json->>'partner'='{$pInputVars["partner_id
"]}'";
1245 $sqlRs = db_query($sql, $pDbh);
1247 throw new Exception( $pMC->msg(
"ACH Query Error", HCU_DISPLAY_AS_HTML) .
" 1049" );
1249 $tmplData = db_fetch_all($sqlRs);
1252 if (!empty($tmplData) && count($tmplData) > 0) {
1253 throw new Exception($pMC->msg(
"ACH Error Delete Partner TE", HCU_DISPLAY_AS_HTML));
1259 SELECT * FROM cu_scheduledtxn WHERE txn_data::json->'txn'->>'from'='{$pInputVars["partner_id
"]}' 1261 SELECT * FROM cu_scheduledtxn WHERE txn_data::json->'txn'->>'to'='{$pInputVars["partner_id
"]}'";
1262 $txnRs = db_query( $sql, $pDbh );
1264 throw new Exception( $pMC->msg(
"ACH Error Delete Partner SE", HCU_DISPLAY_AS_HTML));
1266 $txnData = db_fetch_all($txnRs);
1270 if (!empty($txnData) && count($txnData) > 0) {
1271 throw new Exception($pMC->msg(
"ACH Error Delete Partner SE", HCU_DISPLAY_AS_HTML));
1275 DELETE FROM {$pHBEnv["Cu
"]}achpartner 1276 WHERE id = {$pInputVars["partner_id
"]}";
1277 $achSqlRs = db_query( $achSql, $pDbh );
1279 throw new Exception( $pMC->msg(
"ACH Query Error", HCU_DISPLAY_AS_HTML) .
" 1044" );
1282 $returnData[
'data'] = $pInputVars[
'partner_id'];
1283 }
catch ( Exception $ex ) {
1285 $message = $ex->getMessage();
1286 $code = $ex->getCode();
1288 $logInfo = array(
"message" => $message,
"code" => $code );
1289 $returnData[
"code"] =
"999";
1290 $returnData[
"errors"][] = $message;
1305 function ACH_GetTemplates( $pDbh, $pHBEnv, $pAction, $pMC ) {
1307 $returnData = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
1311 FROM {$pHBEnv["Cu
"]}user u 1312 INNER JOIN {$pHBEnv["Cu
"]}achtemplate at ON at.group_id = u.group_id 1313 WHERE u.user_id = {$pHBEnv["Uid
"]} 1314 ORDER BY tmpl_name";
1316 $rs = db_query( $SQL, $pDbh );
1321 while ( $templateRow = db_fetch_assoc( $rs, $row++ ) ) {
1323 $tmplMeta = HCU_JsonDecode( $templateRow[
"tmpl_meta"],
true );
1324 $achType = $tmplMeta[
"type"];
1326 $templateRow[
"ach_type"] = $achType;
1329 $return[] = $templateRow;
1332 $returnData[
"data"] = $return;
1333 }
catch (Exception $ex) {
1334 $logInfo = array(
"message" => $ex->getMessage(),
"code" => $ex->getCode() );
1335 $returnData[
"code"] =
"999";
1336 $returnData[
"errors"] = $pMC->msg(
"ACH Error Reading Templates", HCU_DISPLAY_AS_HTML) .
" 1026";
1352 function ACH_GetTemplatePartners( $pDbh, $pHBEnv, $pTemplateId, $pMC ) {
1354 $returnData = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
1357 $SQL =
"SELECT tmpl_partner 1358 FROM {$pHBEnv["Cu
"]}achtemplate 1359 WHERE tmpl_id = $pTemplateId";
1361 $rs = db_query( $SQL, $pDbh );
1364 $templateRow = db_fetch_assoc( $rs, 0 );
1367 $partnerInfo = HCU_JsonDecode( $templateRow[
"tmpl_partner"],
true );
1370 if ( count( $partnerInfo ) > 0 ) {
1373 for ( $i = 0; $i < count( $partnerInfo ); $i++ ) {
1374 $idList[] = $partnerInfo[$i][
"partner"];
1377 $idString = implode(
",", $idList );
1379 FROM {$pHBEnv["Cu
"]}achpartner 1380 WHERE id IN ($idString) 1381 ORDER BY display_name ";
1383 $rs = db_query( $SQL, $pDbh );
1386 while ( $partnerRow = db_fetch_assoc( $rs, $row++ ) ) {
1388 $partnerRow[
"partner_type"] = trim( $partnerRow[
"partner_type"] );
1391 $partnerRow[
"last_amount"] = 0;
1392 $partnerRow[
"last_addenda"] =
"";
1394 for ( $pi = 0; $pi < count( $partnerInfo ); $pi++ ) {
1395 if ( $partnerInfo[$pi][
"partner"] == $partnerRow[
"id"] ) {
1396 $partnerRow[
"last_amount"] = $partnerInfo[$pi][
"amount"];
1397 $partnerRow[
"last_addenda"] = $partnerInfo[$pi][
"addenda"];
1404 $return[] = $partnerRow;
1408 $returnData[
"data"] = $return;
1409 }
catch (Exception $ex) {
1410 $logInfo = array(
"message" => $ex->getMessage(),
"code" => $ex->getCode() );
1411 $returnData[
"code"] =
"999";
1412 $returnData[
"errors"] = $pMC->msg(
"ACH Error Reading Template Partners", HCU_DISPLAY_AS_HTML) .
" 1027";
1428 function ACH_AddPartnerToTemplate( $pDbh, $pHBEnv, $pTemplateId, $pPartnerId, $pMC ) {
1430 $returnData = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
1434 $SQL =
"SELECT email_notify, dfi_data 1435 FROM {$pHBEnv["Cu
"]}achpartner 1436 WHERE id = $pPartnerId";
1438 $rs = db_query( $SQL, $pDbh );
1441 $partnerData = db_fetch_assoc( $rs, 0 );
1444 $partnerDFI = HCU_JsonDecode( $partnerData[
"dfi_data"],
true );
1446 $defaultAddenda = isset( $partnerDFI[
"addenda"] ) && strlen( $partnerDFI[
"addenda"] ) > 0 ? html_entity_decode( $partnerDFI[
"addenda"], ENT_QUOTES ) :
"";
1447 $defaultEmailNotify = $partnerData[
"email_notify"] ==
"t" ? true :
false;
1449 $SQL =
"SELECT tmpl_partner, tmpl_meta 1450 FROM {$pHBEnv["Cu
"]}achtemplate 1451 WHERE tmpl_id = $pTemplateId";
1453 $rs = db_query( $SQL, $pDbh );
1456 $templateRow = db_fetch_assoc( $rs, 0 );
1459 $partnerInfo = HCU_JsonDecode( $templateRow[
"tmpl_partner"],
true );
1462 $partnerInfo[] = array(
"partner" => $pPartnerId,
1463 "notify" => $defaultEmailNotify,
1465 "addenda" => prep_save( $defaultAddenda ) );
1468 $templatePartners = HCU_JsonEncode( $partnerInfo );
1471 $myDateTime =
new DateTime();
1472 $myDateTime->setTimezone(
new DateTimeZone( $pHBEnv[
"tz"] ));
1473 $formattedTime = $myDateTime->format(
"m/d/y g:ia T");
1476 $metaInfo = HCU_JsonDecode( $templateRow[
"tmpl_meta"],
true );
1477 $metaInfo[
"count"] = count( $partnerInfo );
1478 $metaInfo[
"last_edit"] = $formattedTime;
1480 $templateMeta = HCU_JsonEncode( $metaInfo );
1483 if ( !$templatePartners || !$templateMeta ) {
1484 throw new Exception( $pMC->msg(
"ACH Error Encoding", HCU_DISPLAY_AS_HTML) .
" 1013" );
1487 $SQL =
"UPDATE {$pHBEnv["Cu
"]}achtemplate SET 1488 tmpl_partner = '$templatePartners', 1489 tmpl_meta = '$templateMeta' 1490 WHERE tmpl_id = $pTemplateId";
1491 $rs = db_query( $SQL, $pDbh );
1494 }
catch (Exception $ex) {
1495 $message = $ex->getMessage();
1496 $logInfo = array(
"message" => $message,
"code" => $ex->getCode() );
1497 if ( trim( $message ) ==
"" ) {
1498 $message = $pMC->msg(
"ACH Error Adding Template Partner", HCU_DISPLAY_AS_HTML) .
" 1028";
1501 $returnData[
"code"] =
"999";
1502 $returnData[
"errors"] = $message;
1517 function ACH_UpdateTemplate( $pDbh, $pHBEnv, $pInputVars, $pMC ) {
1519 $returnData = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
1523 $templateId = intval( $pInputVars[
"template_id"] );
1525 if ( $templateId == 0 ) {
1526 throw new Exception( $pMC->msg(
"ACH Validation Template", HCU_DISPLAY_AS_HTML) .
" 1011" );
1530 if ( $pInputVars[
"action"] ===
"update_template" ) {
1532 $templateName = prep_save( html_entity_decode( $pInputVars[
"template_name"], ENT_QUOTES ) );
1534 if ( $templateId == -1 ) {
1536 $myDateTime =
new DateTime();
1537 $myDateTime->setTimezone(
new DateTimeZone( $pHBEnv[
"tz"] ));
1538 $formattedTime = $myDateTime->format(
"m/d/y g:ia T");
1541 $defaultMeta = HCU_JsonEncode( array(
"type" =>
"",
1544 "last_edit" => $formattedTime,
1546 $defaultPartner =
"[]";
1549 $SQL =
"INSERT INTO {$pHBEnv["Cu
"]}achtemplate 1550 ( tmpl_name, group_id, tmpl_type, tmpl_meta, tmpl_partner ) 1551 VALUES ( '$templateName', (SELECT group_id FROM {$pHBEnv["Cu
"]}user WHERE user_id = {$pHBEnv["Uid
"]}), '', '{$defaultMeta}', '{$defaultPartner}' )";
1553 $SQL =
"UPDATE {$pHBEnv["Cu
"]}achtemplate SET tmpl_name = '$templateName' WHERE tmpl_id = $templateId";
1555 }
else if ( $pInputVars[
"action"] ===
"delete_template" ) {
1556 $SQL =
"DELETE FROM {$pHBEnv["Cu
"]}achtemplate WHERE tmpl_id = $templateId";
1559 $rs = db_query( $SQL, $pDbh );
1561 throw new Exception( $pMC->msg(
"ACH Query Error", HCU_DISPLAY_AS_HTML) .
" 1018" );
1566 }
catch (Exception $ex) {
1567 $logInfo = array(
"message" => $ex->getMessage(),
"code" => $ex->getCode() );
1568 $returnData[
"code"] =
"999";
1569 $returnData[
"errors"] = $ex->getMessage();
1585 function ACH_RemovePartnerFromTemplate( $pDbh, $pHBEnv, $pTemplateId, $pPartnerId, $pMC ) {
1587 $returnData = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
1590 if ( $pTemplateId == 0 ) {
1591 throw new Exception( $pMC->msg(
"ACH Validation Template", HCU_DISPLAY_AS_HTML) .
" 1012" );
1594 $SQL =
"SELECT tmpl_partner, tmpl_meta 1595 FROM {$pHBEnv["Cu
"]}achtemplate 1596 WHERE tmpl_id = $pTemplateId";
1598 $rs = db_query( $SQL, $pDbh );
1601 $templateRow = db_fetch_assoc( $rs, 0 );
1604 $partnerInfo = HCU_JsonDecode( $templateRow[
"tmpl_partner"],
true );
1608 $newPartnerList = array();
1609 for ( $i = 0; $i < count( $partnerInfo ); $i++ ) {
1610 if ( $partnerInfo[$i][
"partner"] == $pPartnerId ) {
1613 $newPartnerList[] = $partnerInfo[$i];
1619 $templatePartners = HCU_JsonEncode( $newPartnerList );
1622 $myDateTime =
new DateTime();
1623 $myDateTime->setTimezone(
new DateTimeZone( $pHBEnv[
"tz"] ));
1624 $formattedTime = $myDateTime->format(
"m/d/y g:ia T");
1627 $metaInfo = HCU_JsonDecode( $templateRow[
"tmpl_meta"],
true );
1628 $metaInfo[
"count"] = count( $newPartnerList );
1629 $metaInfo[
"last_edit"] = $formattedTime;
1631 $templateMeta = HCU_JsonEncode( $metaInfo );
1634 if ( !$templatePartners || !$templateMeta ) {
1635 throw new Exception( $pMC->msg(
"ACH Error Encoding", HCU_DISPLAY_AS_HTML) .
" 1014", 1014 );
1638 $SQL =
"UPDATE {$pHBEnv["Cu
"]}achtemplate SET 1639 tmpl_partner = '$templatePartners', 1640 tmpl_meta = '$templateMeta' 1641 WHERE tmpl_id = $pTemplateId";
1642 $rs = db_query( $SQL, $pDbh );
1646 }
catch (Exception $ex) {
1647 $message = $ex->getMessage();
1648 $logInfo = array(
"message" => $ex->getMessage(),
"code" => $ex->getCode() );
1649 $returnData[
"code"] =
"999";
1650 $returnData[
"errors"] = $message;
1670 function ACH_UpdateTemplatePartners( $pDbh, $pHBEnv, $pTemplateId, $pPartnerInfo, $pMC ) {
1672 $returnData = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
1675 $SQL =
"SELECT tmpl_meta 1676 FROM {$pHBEnv["Cu
"]}achtemplate 1677 WHERE tmpl_id = $pTemplateId";
1679 $rs = db_query( $SQL, $pDbh );
1682 $templateRow = db_fetch_assoc( $rs, 0 );
1685 $currentPartnerInfo = array();
1688 $currentMetaInfo = HCU_JsonDecode( $templateRow[
"tmpl_meta"],
true );
1693 for ( $p = 0; $p < count( $pPartnerInfo ); $p++ ) {
1694 $partnerToAdd = array (
"partner" => $pPartnerInfo[$p][
"id"],
1695 "notify" => ($pPartnerInfo[$p][
"notify"] ?
"1" :
"0"),
1696 "amount" => $pPartnerInfo[$p][
"amount"],
1697 "addenda" => $pPartnerInfo[$p][
"addenda"]
1700 $currentPartnerInfo[] = $partnerToAdd;
1703 $batchTotal += $pPartnerInfo[$p][
"amount"];
1707 $templatePartners = HCU_JsonEncode( $currentPartnerInfo );
1709 if ( !$templatePartners ) {
1710 throw new Exception( $pMC->msg(
"ACH Error Encoding", HCU_DISPLAY_AS_HTML) .
" 1015", 1015 );
1713 $currentMetaInfo[
"count"] = count( $currentPartnerInfo );
1714 $currentMetaInfo[
"total"] = $batchTotal;
1715 $templateMeta = HCU_JsonEncode( $currentMetaInfo );
1717 if ( !$templateMeta ) {
1718 throw new Exception( $pMC->msg(
"ACH Error Encoding", HCU_DISPLAY_AS_HTML) .
" 1046", 1046 );
1721 $SQL =
"UPDATE {$pHBEnv["Cu
"]}achtemplate SET tmpl_partner = '$templatePartners', tmpl_meta = '$templateMeta' WHERE tmpl_id = $pTemplateId";
1722 $rs = db_query( $SQL, $pDbh );
1725 }
catch (Exception $ex) {
1726 $message = $ex->getMessage();
1727 $logInfo = array(
"message" => $message,
"code" => $ex->getCode() );
1728 $returnData[
"code"] =
"999";
1729 $returnData[
"errors"] = $message;
1748 function ACH_ProcessCSV( $pHBEnv, $pTemplateId, $pCSV, $pMC ) {
1750 $returnData = array(
"code" =>
"000",
"errors" => array(),
"data" => array() );
1753 $dbh = $pHBEnv[
"dbh"];
1756 $SQL =
"SELECT tmpl_partner 1757 FROM {$pHBEnv["Cu
"]}achtemplate 1758 WHERE tmpl_id = $pTemplateId";
1760 $rs = db_query( $SQL, $dbh );
1762 throw new Exception( $pMC->msg(
"ACH Query Error", HCU_DISPLAY_AS_HTML) .
" 1047" );
1766 $templateRow = db_fetch_assoc( $rs, 0 );
1769 $templatePartnerInfo = HCU_JsonDecode( $templateRow[
"tmpl_partner"],
true );
1772 $SQL =
"SELECT p.id, p.display_name, p.email_notify 1773 FROM {$pHBEnv["Cu
"]}user u 1774 INNER JOIN {$pHBEnv["Cu
"]}achpartner p ON p.group_id = u.group_id 1775 WHERE u.user_id = {$pHBEnv["Uid
"]}";
1777 $rs = db_query( $SQL, $dbh );
1779 throw new Exception( $pMC->msg(
"ACH Query Error", HCU_DISPLAY_AS_HTML) .
" 1048" );
1784 $partnerLookup = array();
1785 $partnerFound = array();
1786 while ( $partnerRow = db_fetch_assoc( $rs, $row++ ) ) {
1787 $partnerLookupByName[$partnerRow[
"display_name"]] = array(
"id" => $partnerRow[
"id"] ,
"notify" => $partnerRow[
"email_notify"] );
1789 $partnerLookupById[$partnerRow[
"id"]] = array(
"name" => $partnerRow[
"display_name"] ,
"notify" => $partnerRow[
"email_notify"] );
1793 $foundList = array();
1794 $notFoundList = array();
1795 $missedList = array();
1798 for ( $i = 0; $i < count( $pCSV ); $i++ ) {
1799 $parts = explode(
",", $pCSV[$i] );
1801 $name = filter_var( $parts[0], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES );
1802 $amount = filter_var( $parts[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
1803 if ( isset( $parts[2] ) ) {
1804 $addenda = filter_var( $parts[2], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES );
1810 if ( $amount < 0 ) {
1815 $foundId = isset( $partnerLookupByName[$name] ) ? $partnerLookupByName[$name][
"id"] : 0;
1816 if ( $foundId > 0 ) {
1818 $notify = $partnerLookupByName[$name][
"notify"] ==
"t";
1821 for ( $t = 0; $t < count( $templatePartnerInfo ); $t++ ) {
1822 if ( $templatePartnerInfo[$t][
"partner"] == $foundId ) {
1824 $notify = $templatePartnerInfo[$t][
"notify"] == 1;
1827 if ( !isset( $addenda ) ) {
1828 $addenda = $templatePartnerInfo[$t][
"addenda"];
1835 if ( !isset( $addenda ) ) { $addenda =
""; }
1838 $alreadyAdded =
false;
1839 for ( $test = 0; $test < count( $foundList ); $test++ ) {
1840 if ( $foundList[$test][
"id"] == $foundId ) {
1841 $alreadyAdded =
true;
1846 if ( !$alreadyAdded ) {
1847 $foundList[] = array(
"id" => $foundId,
"amount" => $amount,
"addenda" => $addenda,
"notify" => $notify );
1851 if ( !in_array( $name, $notFoundList ) ) {
1852 $notFoundList[] = $name;
1858 for ( $t = 0; $t < count( $templatePartnerInfo ); $t++ ) {
1860 for ( $p = 0; $p < count( $foundList ); $p++ ) {
1861 if ( $foundList[$p][
"id"] == $templatePartnerInfo[$t][
"partner"] ) {
1868 $missedList[] = $partnerLookupById[$templatePartnerInfo[$t][
"partner"]][
"name"];
1873 $returnData[
"data"][
"found"] = $foundList;
1875 $returnData[
"data"][
"not_found"] = $notFoundList;
1877 $returnData[
"data"][
"missed"] = $missedList;
1880 }
catch (Exception $ex) {
1881 $message = $ex->getMessage();
1882 $logInfo = array(
"message" => $message,
"code" => $ex->getCode() );
1883 $returnData[
"code"] =
"999";
1884 $returnData[
"errors"] = $message;
1900 function ACH_GetCutoffTimeMessage($pHBEnv) {
1901 $MC = $pHBEnv[
'MC'];
1903 $achCutoffTime = ACH_GetCutoffTime($pHBEnv);
1908 if (strlen($achCutoffTime) == 3) {
1909 $achCutoffTime =
"0" . $achCutoffTime;
1911 $achTime = strtotime($achCutoffTime);
1912 $achTimeFormatted = date(
"g:i A", $achTime);
1913 $achCutoffMessage = $MC->combo_msg(
"ACH Cutoff Notice", HCU_DISPLAY_AS_RAW,
"#DATE#", $achTimeFormatted);
1915 return $achCutoffMessage;
1928 function ACH_GetCutoffTime($pHBEnv) {
1929 $returnCutoffTime =
null;
1930 $cu = $pHBEnv[
'Cu'];
1931 $dbh = $pHBEnv[
'dbh'];
1932 $MC = $pHBEnv[
'MC'];
1936 SELECT settings::json->>'cutoff' AS cutoff 1939 $sqlRs = db_query($sql, $dbh);
1941 throw new Exception( $MC->msg(
"ACH Query Error", HCU_DISPLAY_AS_HTML) .
" 1100" );
1943 $sqlData = db_fetch_assoc($sqlRs);
1945 $returnCutoffTime = $sqlData[
'cutoff'] !==
null ?
1946 intval($sqlData[
'cutoff']) : 1500;
1947 }
catch (Exception $ex) {
1949 $returnCutoffTime = 1500;
1950 $logInfo = array(
"message" => $message,
"code" => $ex->getCode() );
1953 return $returnCutoffTime;
1966 function ACH_GetEffectiveDate( $pHBEnv, $pTestOverrideDateTime =
"" ) {
1967 $returnEffDate =
null;
1971 $effDate =
new DateTime();
1972 $effDate->setTimezone(
new DateTimeZone( $pHBEnv[
"tz"] ));
1973 $effDateFound =
false;
1975 if ($pTestOverrideDateTime >
"") {
1978 date(
"Y", strtotime( $pTestOverrideDateTime) ),
1979 date(
"m", strtotime( $pTestOverrideDateTime) ),
1980 date(
"d", strtotime( $pTestOverrideDateTime) )
1984 date(
"G", strtotime( $pTestOverrideDateTime) ),
1985 date(
"i", strtotime( $pTestOverrideDateTime) )
1991 $cuCutoffTime = ACH_GetCutoffTime($pHBEnv);
1992 $cuCalendar = ACH_GetCalendarYear($pHBEnv, $effDate->format(
"Y"));
1993 $cuCalendar = $cuCalendar[
'calendar'];
1994 $cuCalendarDates = $cuCalendar[
'dates'];
1995 $cuCalendarDates = HCU_JsonDecode($cuCalendarDates);
2000 $effTime = (int) $effDate->format(
"Gi");
2001 if ($effTime > $cuCutoffTime) {
2002 $effDate->modify(
"+1 day");
2007 while (!$effDateFound) {
2009 $effWeekday = (int) $effDate->format(
"N");
2013 if ($effWeekday >= 6) {
2014 $effDate->modify(
"+1 day");
2025 if (is_array($cuCalendarDates)) {
2026 if (in_array($effDate->format(
"Y-m-d"), $cuCalendarDates)){
2027 $effDate->modify(
"+1 day");
2033 $effDateFound =
true;
2036 $returnEffDate = $effDate->format(
"m/d/Y");
2037 }
catch ( Exception $e ) {
2039 $returnEffDate = date(
"m/d/Y" );
2042 return $returnEffDate;
2045 function ACH_GetCalendarYear($pHBEnv, $pYear) {
2046 $dbh = $pHBEnv[
'dbh'];
2047 $cu = $pHBEnv[
'Cu'];
2049 $sqlReturn = array();
2051 SELECT dates FROM cu_calendar 2053 AND year = '$pYear'";
2054 $sqlRs = db_query($sql, $dbh);
2056 throw new Exception(
"Failed to read calendar for " . $pYear);
2058 $sqlReturn[
'calendar'] = db_fetch_assoc($sqlRs);
2073 function ACH_EnsureBusinessDay( $pEnv, $pEffDate ) {
2074 $returnEffDate =
null;
2078 $effDate =
new DateTime( $pEffDate );
2081 $cuCalendar = ACH_GetCalendarYear($pEnv, $effDate->format(
"Y"));
2082 $cuCalendar = $cuCalendar[
'calendar'];
2083 $cuCalendarDates = $cuCalendar[
'dates'];
2084 $cuCalendarDates = HCU_JsonDecode($cuCalendarDates);
2088 $effDateFound =
false;
2089 while (!$effDateFound) {
2091 $effWeekday = (int) $effDate->format(
"N");
2095 if ($effWeekday >= 6) {
2096 $effDate->modify(
"+1 day");
2107 if (is_array($cuCalendarDates)) {
2108 if (in_array($effDate->format(
"Y-m-d"), $cuCalendarDates)){
2109 $effDate->modify(
"+1 day");
2115 $effDateFound =
true;
2118 $returnEffDate = $effDate->format(
"Y-m-d");
2119 }
catch ( Exception $e ) {
2121 $returnEffDate = $pEffDate;
2124 return $returnEffDate;
2130 function GetStateList() {
2132 [
"name"=>
'Alabama',
"value"=>
'AL'],
2133 [
"name"=>
'Alaska',
"value"=>
'AK'],
2134 [
"name"=>
'Arizona',
"value"=>
'AZ'],
2135 [
"name"=>
'Arkansas',
"value"=>
'AR'],
2136 [
"name"=>
'California',
"value"=>
'CA'],
2137 [
"name"=>
'Colorado',
"value"=>
'CO'],
2138 [
"name"=>
'Connecticut',
"value"=>
'CT'],
2139 [
"name"=>
'Delaware',
"value"=>
'DE'],
2140 [
"name"=>
'Florida',
"value"=>
'FL'],
2141 [
"name"=>
'Georgia',
"value"=>
'GA'],
2142 [
"name"=>
'Hawaii',
"value"=>
'HI'],
2143 [
"name"=>
'Idaho',
"value"=>
'ID'],
2144 [
"name"=>
'Illinois',
"value"=>
'IL'],
2145 [
"name"=>
'Indiana',
"value"=>
'IN'],
2146 [
"name"=>
'Iowa',
"value"=>
'IA'],
2147 [
"name"=>
'Kansas',
"value"=>
'KS'],
2148 [
"name"=>
'Kentucky',
"value"=>
'KY'],
2149 [
"name"=>
'Louisiana',
"value"=>
'LA'],
2150 [
"name"=>
'Maine',
"value"=>
'ME'],
2151 [
"name"=>
'Maryland',
"value"=>
'MD'],
2152 [
"name"=>
'Massachusetts',
"value"=>
'MA'],
2153 [
"name"=>
'Michigan',
"value"=>
'MI'],
2154 [
"name"=>
'Minnesota',
"value"=>
'MN'],
2155 [
"name"=>
'Mississippi',
"value"=>
'MS'],
2156 [
"name"=>
'Missouri',
"value"=>
'MO'],
2157 [
"name"=>
'Montana',
"value"=>
'MT'],
2158 [
"name"=>
'Nebraska',
"value"=>
'NE'],
2159 [
"name"=>
'Nevada',
"value"=>
'NV'],
2160 [
"name"=>
'New Hampshire',
"value"=>
'NH'],
2161 [
"name"=>
'New Jersey',
"value"=>
'NJ'],
2162 [
"name"=>
'New Mexico',
"value"=>
'NM'],
2163 [
"name"=>
'New York',
"value"=>
'NY'],
2164 [
"name"=>
'North Carolina',
"value"=>
'NC'],
2165 [
"name"=>
'North Dakota',
"value"=>
'ND'],
2166 [
"name"=>
'Ohio',
"value"=>
'OH'],
2167 [
"name"=>
'Oklahoma',
"value"=>
'OK'],
2168 [
"name"=>
'Oregon',
"value"=>
'OR'],
2169 [
"name"=>
'Pennsylvania',
"value"=>
'PA'],
2170 [
"name"=>
'Rhode Island',
"value"=>
'RI'],
2171 [
"name"=>
'South Carolina',
"value"=>
'SC'],
2172 [
"name"=>
'South Dakota',
"value"=>
'SD'],
2173 [
"name"=>
'Tennessee',
"value"=>
'TN'],
2174 [
"name"=>
'Texas',
"value"=>
'TX'],
2175 [
"name"=>
'Utah',
"value"=>
'UT'],
2176 [
"name"=>
'Vermont',
"value"=>
'VT'],
2177 [
"name"=>
'Virginia',
"value"=>
'VA'],
2178 [
"name"=>
'Washington',
"value"=>
'WA'],
2179 [
"name"=>
'West Virginia',
"value"=>
'WV'],
2180 [
"name"=>
'Wisconsin',
"value"=>
'WI'],
2181 [
"name"=>
'Wyoming',
"value"=>
'WY']
2185 [
"name"=>
'Alberta',
"value" =>
'AB' ],
2186 [
"name"=>
'British Columbia',
"value" =>
'BC' ],
2187 [
"name"=>
'Manitoba',
"value" =>
'MB' ],
2188 [
"name"=>
'New Brunswick',
"value" =>
'NB' ],
2189 [
"name"=>
'Newfoundland and Labrador',
"value" =>
'NL' ],
2190 [
"name"=>
'Nova Scotia',
"value" =>
'NS' ],
2191 [
"name"=>
'Ontario',
"value" =>
'ON' ],
2192 [
"name"=>
'Prince Edward Island',
"value" =>
'PE' ],
2193 [
"name"=>
'Saskatchewan',
"value" =>
'SK' ],
2194 [
"name"=>
'Quebec',
"value" =>
'QC' ]
2198 [
"name"=>
'US Virgin Islands',
"value" =>
'VI' ],
2199 [
"name"=>
'Trinidad and Tobago',
"value" =>
'TT' ]
2202 $returnData = array_merge( $states, $provinces, $caribbean );
2219 function ACH_GetCompanyData($pEnv) {
2222 SELECT g.group_name, g.tax_id FROM {$pEnv['cu']}user u 2223 LEFT JOIN {$pEnv['cu']}group g ON u.group_id = g.group_id 2224 WHERE u.user_id = {$pEnv['Uid']}";
2225 $sqlRs = db_query($sql, $pEnv[
'dbh']);
2227 throw new Exception(
"Failed to read company information");
2230 $sqlData = db_fetch_assoc($sqlRs);
2234 function PrintPartnerEditor($pEnv) {?>
2235 <?php $MC = $pEnv[
'MC']; ?>
2236 <!-- ACCORDION STYLES -->
2237 <style type=
"text/css">
2238 .achAccordionHeader {
2244 margin-bottom: 7.5px;
2248 background-color: #ddd;
2257 <script type=
"text/x-kendo-template" id=
"achPartnerEditorTmp">
2258 <div
id=
"achPartnerEditor">
2259 <div
id=
"achPartnerStatus"></div>
2260 <div
class=
"col-sm-12"> </div>
2261 <div
class=
"hcu-secondary" 2262 data-bind=
"visible: showDeleteWarn">
2263 <span
class=
"small hcu-secondary-text"><?php echo $MC->msg(
"ACH Remove Partner from batch warning", HCU_DISPLAY_AS_HTML) ?></span>
2265 <div
class=
"well well-sm col-sm-12">
2266 <!-- PARTNER INFORMATION -->
2268 <div
class=
"col-xs-12">
2270 <span><?php echo $MC->msg(
"ACH Partner Information", HCU_DISPLAY_AS_HTML) ?></span>
2271 <span
class=
"achDirty" data-bind=
"visible: sourceDirtyInfo"><sup>*</sup></span>
2277 <div
class=
"row achFieldMargin">
2278 <div
class=
"col-xs-12 col-sm-3">
2279 <label
for=
"achPartnerType">
2280 <span><?php echo $MC->msg(
"ACH Partner Type", HCU_DISPLAY_AS_HTML) ?></span>
2283 <div
class=
"col-xs-12 col-sm-6">
2284 <input type=
"text" name=
"achPartnerType" class=
"hcu-all-100" 2285 data-role=
"dropdownlist" 2286 data-text-field=
"display" 2287 data-value-field=
"type" 2289 source: listPartnerTypes, 2290 value: sourcePartner.partner_type, 2291 events: { change: change }">
2295 <div
class=
"row achFieldMargin">
2296 <div
class=
"col-xs-12 col-sm-3">
2297 <label
for=
"achPartnerDisplay">
2298 <span><?php echo $MC->msg(
"ACH Display Name", HCU_DISPLAY_AS_HTML) ?> </span>
2299 <span
class=
"hcu-required-field"><sup>*</sup></span></span>
2302 <div
class=
"col-xs-12 col-sm-6">
2303 <input type=
"text" name=
"achPartnerDisplay" class=
"k-textbox k-input hcu-all-100" 2306 value: sourcePartner.display_name, 2307 events: { change: change }" 2309 <?php echo $MC->msg("ACH Unique display name required
", HCU_DISPLAY_AS_HTML) ?>" 2314 <div
class=
"row achFieldMargin">
2315 <div
class=
"col-xs-12 col-sm-3">
2316 <label
for=
"achPartnerName">
2317 <span><?php echo $MC->msg(
"Name", HCU_DISPLAY_AS_HTML); ?> </span>
2320 <div
class=
"col-xs-12 col-sm-6">
2321 <input type=
"text" name=
"achPartnerName" class=
"k-textbox k-input hcu-all-100" 2324 value: sourcePartner.ach_name, 2325 events: { change: change }">
2329 <div
class=
"row achFieldMargin">
2330 <div
class=
"col-xs-12 col-sm-3">
2331 <label
for=
"achPartnerEmail">
2332 <span><?php echo $MC->msg(
"ACH E-Mail", HCU_DISPLAY_AS_HTML); ?> </span>
2333 <span
class=
"hcu-required-field" 2334 data-bind=
"visible: sourcePartner.email_notify"><sup>*</sup></span></span>
2337 <div
class=
"col-xs-12 col-sm-6">
2338 <input type=
"TEXT" name=
"achPartnerEmail" class=
"k-textbox k-input hcu-all-100" 2340 homecu-match=
"email" 2342 value: sourcePartner.email, 2343 required: sourcePartner.email_notify, 2344 events: { change: change }" 2345 data-required-msg=
"<?php echo $MC->msg("Please specify email address
", HCU_DISPLAY_AS_HTML); ?>" 2346 validationMessage=
"<?php echo $MC->msg("Enter Valid Email
", HCU_DISPLAY_AS_HTML); ?>">
2348 <div
class=
"col-xs-12 col-sm-3">
2349 <input type=
"checkbox" name=
"achPartnerNotify" style=
"margin-top: -2px;" 2351 checked: sourcePartner.email_notify, 2352 events: { click: change }">
2353 <label
for=
"achPartnerNotify" 2355 events: { click: change }">
2356 <span> <?php echo $MC->msg(
"Notify", HCU_DISPLAY_AS_HTML); ?> <span
class=
"fa fa-question-circle-o" id=
"achPartnerNotifyTip"></span></span>
2361 <div
class=
"achFieldMargin achSpacer"></div>
2364 <div
class=
"col-xs-12">
2366 <span><?php echo $MC->msg(
"ACH Partner Address", HCU_DISPLAY_AS_HTML); ?></span>
2367 <span
class=
"achDirty" data-bind=
"visible: sourceDirtyAddr"><sup>*</sup></span>
2373 <div
class=
"row achFieldMargin">
2374 <div
class=
"col-xs-12 col-sm-3">
2375 <label
for=
"achPartnerAddress1">
2376 <span><?php echo $MC->msg(
"ACH Address", HCU_DISPLAY_AS_HTML) .
" 1"; ?></span>
2379 <div
class=
"col-xs-12 col-sm-6">
2380 <input type=
"text" name=
"achPartnerAddress1" class=
"k-textbox k-input hcu-all-100" 2383 value: sourcePartner.address1, 2384 events: { change: change }">
2388 <div
class=
"row achFieldMargin">
2389 <div
class=
"col-xs-12 col-sm-3">
2390 <label
for=
"achPartnerAddress2">
2391 <span><?php echo $MC->msg(
"ACH Address", HCU_DISPLAY_AS_HTML) .
" 2"; ?></span>
2394 <div
class=
"col-xs-12 col-sm-6">
2395 <input type=
"text" name=
"achPartnerAddress2" class=
"k-textbox k-input hcu-all-100" 2398 value: sourcePartner.address2, 2399 events: { change: change }">
2403 <div
class=
"row achFieldMargin">
2404 <div
class=
"col-xs-12 col-sm-3">
2406 <span><?php echo $MC->msg(
"ACH CityStateZip", HCU_DISPLAY_AS_HTML); ?></span>
2409 <div
class=
"col-xs-12 col-sm-3">
2410 <input type=
"text" name=
"achPartnerCity" class=
"k-textbox k-input hcu-all-100" 2413 value: sourcePartner.city, 2414 events: { change: change }">
2416 <div
class=
"col-xs-12 col-sm-3">
2417 <input type=
"text" name=
"achPartnerState" class=
"hcu-all-100" 2419 data-role=
"dropdownlist" 2420 data-text-field=
"name" 2421 data-value-field=
"value" 2422 data-option-label=
"<?php echo $MC->msg("ACH Select State
", HCU_DISPLAY_AS_JS) ?>" 2425 value: sourcePartner.state, 2426 events: { change: change }">
2428 <div
class=
"col-xs-12 col-sm-3">
2429 <input type=
"text" name=
"achPartnerZip" class=
"k-textbox k-input hcu-all-100" 2430 data-role=
"maskedtextbox" 2432 value: sourcePartner.zip, 2433 events: { change: change }">
2437 <div
class=
"row achFieldMargin">
2438 <div
class=
"col-xs-12 col-sm-3">
2439 <label
for=
"achPartnerCountry">
2440 <span><?php echo $MC->msg(
"ACH Country", HCU_DISPLAY_AS_HTML); ?></span>
2443 <div
class=
"col-xs-12 col-sm-6">
2444 <input type=
"text" name=
"achPartnerCountry" class=
"k-textbox k-input hcu-all-100" 2447 value: sourcePartner.country, 2448 events: { change: change }">
2452 <div
class=
"achFieldMargin achSpacer"></div>
2455 <div
class=
"col-xs-12">
2457 <span><?php echo $MC->msg(
"ACH Remote Account", HCU_DISPLAY_AS_HTML); ?></span>
2458 <span
class=
"achDirty" data-bind=
"visible: sourceDirtyAcct"><sup>*</sup></span>
2463 <div
class=
"row achFieldMargin">
2464 <div
class=
"col-xs-12 col-sm-3">
2465 <label
for=
"achPartnerRouting">
2466 <span><?php echo $MC->msg(
"ACH Routing Number", HCU_DISPLAY_AS_HTML); ?></span>
2467 <span
class=
"hcu-required-field"><sup>*</sup></span></span>
2470 <div
class=
"col-xs-12 col-sm-6">
2471 <input type=
"text" name=
"achPartnerRouting" class=
"k-textbox k-input hcu-all-100" 2473 value: sourcePartner.dfi_routing, 2474 events: { change: change }" 2475 data-required-msg=
"Routing number is required" 2476 validationMessage=
"<?php echo $MC->msg("ACH Routing number 9 digits
", HCU_DISPLAY_AS_HTML); ?>" 2481 <div
class=
"row achFieldMargin">
2482 <div
class=
"col-xs-12 col-sm-3">
2483 <label
for=
"achPartnerAccount">
2484 <span><?php echo $MC->msg(
'ACH Account Number', HCU_DISPLAY_AS_HTML); ?> </span>
2485 <span
class=
"hcu-required-field"><sup>*</sup></span></span>
2488 <div
class=
"col-xs-12 col-sm-6">
2489 <input type=
"text" name=
"achPartnerAccount" class=
"k-textbox k-input hcu-all-100 account-match" 2491 value: sourcePartner.dfi_account, 2492 events: { change: change }" 2493 data-required-msg=
"<?php echo $MC->msg('ACH Need remote account', HCU_DISPLAY_AS_HTML); ?>" 2495 <?php echo $MC->msg('ACH Need remote account', HCU_DISPLAY_AS_HTML); ?>" 2500 <div
class=
"row achFieldMargin">
2501 <div
class=
"col-xs-12 col-sm-3">
2502 <label
for=
"achPartnerAccountConfirm">
2503 <span><?php echo $MC->msg(
'ACH Confirm Account', HCU_DISPLAY_AS_HTML); ?> </span>
2504 <span
class=
"hcu-required-field"><sup>*</sup></span></span>
2507 <div
class=
"col-xs-12 col-sm-6">
2508 <input type=
"text" name=
"achPartnerAccountConfirm" class=
"k-textbox k-input hcu-all-100 account-match" 2509 homecu-equals=
"account-match" 2511 value: sourcePartner.dfi_account_confirm, 2512 events: { change: change }" 2513 data-required-msg=
"<?php echo $MC->msg('ACH Need remote account', HCU_DISPLAY_AS_HTML); ?>" 2515 <?php echo $MC->msg('ACH Accounts no match', HCU_DISPLAY_AS_HTML); ?>" 2520 <div
class=
"row achFieldMargin">
2521 <div
class=
"col-xs-12 col-sm-3">
2522 <label
for=
"achPartnerAccountType">
2523 <span><?php echo $MC->msg(
'Account Type', HCU_DISPLAY_AS_HTML); ?> </span>
2524 <span
class=
"hcu-required-field"><sup>*</sup></span></span>
2527 <div
class=
"col-xs-12 col-sm-6">
2528 <input name=
"achPartnerAccountType" class=
"hcu-all-100" 2529 data-role=
"dropdownlist" 2530 data-text-field=
"display" 2531 data-value-field=
"type" 2532 data-option-label=
"<?php echo $MC->msg("ACH Select Type
", HCU_DISPLAY_AS_JS) ?>" 2534 source: listAccountTypes, 2535 value: sourcePartner.dfi_account_type, 2536 events: { change: change }" 2538 <?php echo $MC->msg('ACH Need remote account type', HCU_DISPLAY_AS_HTML) ?>" 2539 validationMessage=
"" 2544 <div
class=
"achFieldMargin achSpacer"></div>
2546 <div
class=
"achFieldMargin">
2548 <span
class=
"hcu-required-field"><sup>*</sup></span>
2549 <span><?php echo $MC->msg(
'ACH Required', HCU_DISPLAY_AS_HTML) ?></span>
2554 <div
class=
"hcu-template">
2555 <div
class=
"hcu-edit-buttons k-state-default">
2556 <span
class=
"hcu-icon-delete" 2557 data-bind=
"visible: showDelete">
2558 <a href=
"##" id=
"lnkDelete" 2559 data-bind=
"events: { click: delete }">
2560 <i
class=
"fa fa-trash fa-lg"></i>
2563 <a href=
"##" id=
"lnkCancel" 2564 data-bind=
"events: { click: cancel }">
2565 <?php echo $MC->msg(
'Cancel', HCU_DISPLAY_AS_HTML) ?></a>
2567 <a href=
"##" id=
"btnUpdate" class=
"k-button k-primary" 2568 data-bind=
"events: { click: save }">
2569 <i
class=
"fa fa-check fa-lg"></i>
2570 <?php echo $MC->msg(
'Save', HCU_DISPLAY_AS_HTML) ?>
2577 <script type=
"text/x-kendo-template" id=achPartnerDiscardTmp>
2578 <div
id=
"achPartnerDiscard">
2579 <p><?php echo $MC->msg(
"ACH Discard changes warning", HCU_DISPLAY_AS_JS) ?></p>
2580 <p><?php echo $MC->msg(
"ACH Continue", HCU_DISPLAY_AS_JS) ?></p>
2584 <script type=
"text/x-kendo-template" id=
"achPartnerDeleteTmp">
2585 <div
id=
"achPartnerDelete">
2586 <p><?php echo $MC->msg(
"ACH Continue remove partner", HCU_DISPLAY_AS_JS) ?></p>
2587 <p><?php echo $MC->msg(
"ACH Continue", HCU_DISPLAY_AS_JS) ?></p>