Odyssey
hcuACHBatch.prg
1 <?php
2  /*
3  * File: hcuACHBatch.prg
4  *
5  * Purpose: To let the user do ACH batch operations - payments and collections.
6  *
7  * Steps:
8  * 1) Show the template management screen. Can start new ACH operation or create/edit
9  * a template.
10  * 2) User can manage the ACH Partners in the template and choose which are in the batch.
11  * 3) Fill in amounts and addenda for partners in batch.
12  * 4) Specify the local account for the payment or collection.
13  * 5) Submit
14  *
15  * Example tmpl_meta: {"type":"PPD","total":"0.00","last_proc":"","last_edit":"2016-12-16","count":"2"}
16  * Example tmpl_data: [{"partner":"1","notify":"1","amount":"3.45","addenda":"Parking reimburse"},
17  * {"partner":"2","notify":"1","amount":"7.77","addenda":"Ticket to heaven"}]
18 
19  * NOTES:
20  * 1. Any changes to the partner information will be sent to the server as it occurs - add partner,
21  * update address, update dfi, remove from batch.
22  * 2. The user has the choice of updating the template partner list on the page with the amounts. This
23  * means the JSON list in the template gets updated with what was in the actual batch.
24  * 3. Adding a parter through the batch interface will put that partner into the template as well as save
25  * in the ach partner file.
26  * 4. The PartnerType flag will be used as a casual filter that the user can use to shorten the list.
27  */
28  require_once(dirname(__FILE__) . '/../library/permissions.i');
29  require_once(dirname(__FILE__) . '/../library/hcuACH.i');
30 
31 
32  // ** SET SCRIPT LEVEL VARIABLES
33  $serviceShowInfo = true;
34  $serviceLoadMenu = true;
35  $serviceShowMenu = true;
36 
37  // ** INCLUDE MAIN GLOBAL SCRIPT -- Handles security / global variable values
38  require_once(dirname(__FILE__) . '/../library/hcuService.i');
39 //Implement the Partner Type feature: Kendo multi-select, casual filter, default to something, manage partner_type in table
40  // ** INSERT BUSINESS LOGIC FOR THIS FORM
41  try {
42  $Cu = $HB_ENV["Cu"];
43  $Cn = $HB_ENV["Cn"];
44  $chome = $HB_ENV["chome"];
45  $Flang = $HB_ENV["Flang"];
46 
47  // get initial variables
48  $inputVars = array();
49  $varOk = array(
50  "ach_feature" => array('filter' => FILTER_SANITIZE_STRING)
51  );
52 
53  HCU_ImportVars($inputVars, "", $varOk);
54 
55  $ach_feature = isset($inputVars['ach_feature']) && strlen( trim( $inputVars['ach_feature'] ) ) ? trim( $inputVars['ach_feature'] ) : "choose_single_payment";
56 
57  // redirect if the action is for something other than what this file can handle
58  if ( $ach_feature == "choose_single_collection" ||
59  $ach_feature == "choose_single_payment" ) {
60  header("Location: {$HB_ENV["homebankingpath"]}/hcuACHSingle.prg?{$HB_ENV["cuquery"]}&ach_feature=$ach_feature");
61  exit;
62  }
63 
64  // ** INCLUDE PRE CONTENT SCRIPT
65  require_once(dirname(__FILE__) . '/../includes/hcuPreContent.i');
66 
67  // ** Verify the feature is enabled for the Credit Union.
68  $achEnabled = Check_ACHEnabled( $dbh, $HB_ENV );
69  if ( $achEnabled === false ) {
70  // * Feature NOT set
71  throw new Exception( HCU_JsonEncode( $MC->msg('Option not set', HCU_DISPLAY_AS_HTML) ), 915 );
72  }
73 
74  // set the initial type based on what the activity is
75  if ( $ach_feature == "choose_batch_payment" ) {
76  $initialPartnerType = "e";
77  $batchActivity = $MC->msg("ACH Payment Template Info", HCU_DISPLAY_AS_HTML);
78  $achAction = "submit_batch_payment";
79  $featureCode = FEATURE_ACH_PAYMENTS;
80  // get the templates
81  $templateAction = "read_templates";
82  // type of account
83  $accountTypeWords = $MC->msg("ACH From Account", HCU_DISPLAY_AS_HTML);
84  $dfiAccountWords = $MC->msg("ACH Deposit Account", HCU_DISPLAY_AS_HTML); // remote deposit account
85  $batchButton = "choose_single_payment";
86  $pageTitle = $MC->msg("ACH Payment Title", HCU_DISPLAY_AS_HTML);
87  $progressStep3 = $MC->msg("ACH Payment", HCU_DISPLAY_AS_HTML);
88  } else if ( $ach_feature == "choose_batch_collection" ) {
89  $initialPartnerType = "r";
90  $batchActivity = $MC->msg("ACH Collection Template Info", HCU_DISPLAY_AS_HTML);
91  $achAction = "submit_batch_collection";
92  $featureCode = FEATURE_ACH_COLLECTIONS;
93  // get the templates
94  $templateAction = "read_templates";
95  // type of account
96  $accountTypeWords = $MC->msg("ACH To Account", HCU_DISPLAY_AS_HTML);
97  $dfiAccountWords = $MC->msg("ACH Withdrawl Account", HCU_DISPLAY_AS_HTML); // remote withdrawl account
98  $batchButton = "choose_single_collection";
99  $pageTitle = $MC->msg("ACH Collection Title", HCU_DISPLAY_AS_HTML);
100  $progressStep3 = $MC->msg("ACH Collection", HCU_DISPLAY_AS_HTML);
101  } else {
102  // unassigned
103  $initialPartnerType = "";
104  $batchActivity = $MC->msg("Unknown", HCU_DISPLAY_AS_HTML);
105  $achAction = "unknown";
106  $featureCode = "unknown";
107  $templateAction = "unknown";
108  $batchButton = "choose_single_payment";
109  }
110 
111  // these are the same for either payments or collections
112  $progressStep1 = $MC->msg("ACH Template", HCU_DISPLAY_AS_HTML);
113  $progressStep2 = $MC->msg("Edit", HCU_DISPLAY_AS_HTML);
114  $progressStep4 = $MC->msg("ACH Account", HCU_DISPLAY_AS_HTML);
115 
116  // ** Verify the user can access this feature.
117  $permissionInputs = array( "feature" => $featureCode );
118  $accessRights = Perm_AccessRights( $dbh, $HB_ENV, $permissionInputs );
119 
120  if ( !$accessRights["create"] ) {
121  // * Rights NOT set
122  throw new Exception( HCU_JsonEncode( $MC->msg('Rights not set', HCU_DISPLAY_AS_HTML) ), 915 );
123  }
124 
125  // get some allowed amounts for client-side validation
126  $limits = Perm_GetValidationLimits( $dbh, $HB_ENV, $permissionInputs );
127 
128  if ( $limits === false || !isset( $limits["amount_per_transaction"] ) ) {
129  // error occurred - assume count of zero
130  $allowedAmount = 0;
131  } else {
132  $allowedAmount = intval( $limits["amount_per_transaction"] );
133  }
134 
135  $Fset = $HB_ENV["Fset"];
136 
137  // ** Retrieve the Terms of Use for ACH Transactions
138  $noticesAry = Get_NoticeInfo($dbh, $HB_ENV, $MC, "D", "achNotice", true);
139 
140  $hasNoticeACH = false;
141  $hasNoticePopupACH = false;
142  $noticeURLACH = "";
143  $noticeLinkDisplayACH = "";
144 
145  if ( $noticesAry["status"]["code"] == "000" && HCU_array_key_exists('0', $noticesAry['notice'])) {
146  if ( $noticesAry["notice"][0]["notice_id"] ) {
147  $hasNoticeACH = true;
148  $noticeOption = $noticesAry['notice'][0];
149 
150  $noticeOptions = Array (
151  'docsid' => $noticeOption['notice_id'],
152  'docstype' => $noticeOption['notice_type'],
153  'device' => 'D',
154  'noticeOnly' => '0',
155  'expireTime' => mktime() + 86400
156  );
157 
158  $encryptedDocDetails= HCU_PayloadEncode($HB_ENV['Cu'], $noticeOptions);
159 
160  $noticeOptions['noticeOnly'] = 1;
161 
162  $encryptedDocDetailsNoticeOnly= HCU_PayloadEncode($HB_ENV['Cu'], $noticeOptions);
163 
164  // build the url encoded string
165  // * For the popup terms
166  $noticeURLACH = $HB_ENV['homebankingpath'] . '/hcuViewNotice.prg?cu=' . $HB_ENV['cu'] . '&x=' . urlencode($encryptedDocDetails);
167 
168  // * For the regular Button
169  $noticeURLNoticeOnly = $HB_ENV['homebankingpath'] . '/hcuViewNotice.prg?cu=' . $HB_ENV['cu'] . '&x=' . urlencode($encryptedDocDetailsNoticeOnly);
170 
171  // see if there is a popup notice
172  $hasNoticePopupACH = $noticeOption["notice_popup"] ? true : false;
173 
174  $noticeButtonText = $noticeOption["notice_linkdisplay"];
175  }
176  }
177 
178  // ** Retrieve the Terms of Use for ACH Transcations
179  $noticesAry = Get_NoticeInfo($dbh, $HB_ENV, $MC, "D", "achTerms", true);
180 
181  $hasTermsACH = false;
182  $hasTermsPopupACH = false;
183  $termsURLACH = "";
184  $termsLinkDisplayACH = "";
185 
186  if ( $noticesAry["status"]["code"] == "000" && HCU_array_key_exists('0', $noticesAry['notice'])) {
187  if ( $noticesAry["notice"][0]["notice_id"] ) {
188  $hasTermsACH = true;
189  $noticeOption = $noticesAry['notice'][0];
190 
191  $noticeOptions = Array (
192  'docsid' => $noticeOption['notice_id'],
193  'docstype' => $noticeOption['notice_type'],
194  'device' => 'D',
195  'noticeOnly' => '0',
196  'expireTime' => mktime() + 86400
197  );
198 
199  $encryptedDocDetails= HCU_PayloadEncode($HB_ENV['Cu'], $noticeOptions);
200 
201  $noticeOptions['noticeOnly'] = 1;
202 
203  $encryptedDocDetailsNoticeOnly= HCU_PayloadEncode($HB_ENV['Cu'], $noticeOptions);
204 
205  // build the url encoded string
206  // * For the popup terms
207  $termsURLACH = $HB_ENV['homebankingpath'] . '/hcuViewNotice.prg?cu=' . $HB_ENV['cu'] . '&x=' . urlencode($encryptedDocDetails);
208 
209  // * For the regular Button
210  $termsURLNoticeOnly = $HB_ENV['homebankingpath'] . '/hcuViewNotice.prg?cu=' . $HB_ENV['cu'] . '&x=' . urlencode($encryptedDocDetailsNoticeOnly);
211 
212  // see if there is a popup notice
213  $hasTermsPopupACH = $noticeOption["notice_popup"] ? true : false;
214 
215  $termsButtonText = $noticeOption["notice_linkdisplay"];
216  }
217  }
218 
219  // ** Retrieve the notice for ACH Batch
220  $noticesAry = Get_NoticeInfo($dbh, $HB_ENV, $MC, "D", "achUploadCSV", true);
221 
222  $hasNoticeCSV = false;
223  $hasNoticePopupCSV = false;
224  $noticeURLCSV = "";
225  $noticeLinkDisplayCSV = "";
226  $noticeURLNoticeOnlyCSV = "";
227 
228  if ( $noticesAry["status"]["code"] == "000" && HCU_array_key_exists('0', $noticesAry['notice'])) {
229  if ($noticesAry["notice"][0]["notice_id"] ) {
230  $hasNoticeCSV = true;
231  $noticeLinkDisplayCSV = $noticesAry["notice"][0]["notice_linkdisplay"];
232 
233  $noticeOption = $noticesAry['notice'][0];
234 
235  $noticeOptions = Array (
236  'docsid' => $noticeOption['notice_id'],
237  'docstype' => $noticeOption['notice_type'],
238  'device' => 'D',
239  'noticeOnly' => '0',
240  'expireTime' => mktime() + 86400
241  );
242 
243  $encryptedDocDetails= HCU_PayloadEncode($HB_ENV['Cu'], $noticeOptions);
244 
245  $noticeOptions['noticeOnly'] = 1;
246 
247  $encryptedDocDetailsNoticeOnly= HCU_PayloadEncode($HB_ENV['Cu'], $noticeOptions);
248 
249  // build the url encoded string
250  // * For the popup terms
251  $noticeURLCSV = $HB_ENV['homebankingpath'] . '/hcuViewNotice.prg?cu=' . $HB_ENV['cu'] . '&x=' . urlencode($encryptedDocDetails);
252 
253  // * For the regular Button
254  $noticeURLNoticeOnlyCSV = $HB_ENV['homebankingpath'] . '/hcuViewNotice.prg?cu=' . $HB_ENV['cu'] . '&x=' . urlencode($encryptedDocDetailsNoticeOnly);
255 
256  // see if there is a popup notice
257  $hasNoticePopupCSV = $noticeOption["notice_popup"] ? true : false;
258  }
259  }
260 
261  // include common functions
262 
263  /********* functions ************/
264  /********* end functions ********/
265 
266  /*
267  * ** START ACH CONTENT
268  */
269 
270  // get the initial effective date, which may be in the future, based on the time
271  $initialEffDate = ACH_GetEffectiveDate( $HB_ENV );
272 
273  // External transfers have a cutoff time, the user
274  // must be notified that the transaction will process
275  // the next business day if the current time is after
276  // the cutoff.
277  $achCutoffMessageString = ACH_GetCutoffTimeMessage($HB_ENV);
278 
279  // get company information, this includes the company/group nameand tax id
280  // check if tax id is set up, if no tax id issetup the user is not able to
281  // make ach commercial transactions.
282  $companyData = ACH_GetCompanyData($HB_ENV);
283  if (HCU_array_key_exists("tax_id", $companyData)) {
284  if ($companyData['tax_id'] == null || trim($companyData['tax_id']) == "") {
285  throw new Exception( HCU_JsonEncode( $MC->msg('ACH Tax ID Error', HCU_DISPLAY_AS_HTML) ), 915 );
286  }
287  }
288 
289  // list the account types for remote account (for ach) - used in dropdown list
290  $accountTypes = array(
291  array( "type" => ACCOUNT_TYPE_CHECKING, "display" => $MC->msg("ACH Checking", HCU_DISPLAY_AS_HTML) ),
292  array( "type" => ACCOUNT_TYPE_SAVINGS, "display" => $MC->msg("ACH Savings", HCU_DISPLAY_AS_HTML) )
293  );
294 
295  // list the partner types for different ACH partners
296  $partnerTypes = array( array( "type" => ACH_PARTNER_TYPE_PAYEE, "display" => $MC->msg("ACH Payee", HCU_DISPLAY_AS_HTML) ),
297  array( "type" => ACH_PARTNER_TYPE_PAYOR, "display" => $MC->msg("ACH Payor", HCU_DISPLAY_AS_HTML) ),
298  array( "type" => ACH_PARTNER_TYPE_PAYROLL, "display" => $MC->msg("ACH Payroll", HCU_DISPLAY_AS_HTML) ),
299  array( "type" => ACH_PARTNER_TYPE_UNASSIGNED, "display" => $MC->msg("ACH Unassigned", HCU_DISPLAY_AS_HTML) )
300  );
301  PrintPartnerEditor($HB_ENV);
302  ?>
303  <div class="col-xs-12" style='font-size:12px;'>
304  <div id="hcuAchTables" class="k-content" style="max-width:700px;"></div>
305  </div>
306  <?php
307 
308  if ( $ach_feature == "choose_batch_payment" ||
309  $ach_feature == "choose_batch_collection" ) {
310  ?>
311  <script >
312  var windowStack = [];
313  var viewModel;
314  var dsACHHelper;
315  var achAccountTypes = <?php echo HCU_JsonEncode( $accountTypes ); ?>;
316  var achCurrentList = [];
317  var achPartnerTypes = <?php echo HCU_JsonEncode( $partnerTypes ); ?>;
318  var achTemplateList = [];
319  var achPartnerList = [];
320  var achAllAccounts = []; // hold all accounts (to get sub-accounts for accounts)
321  var achAcctsList = []; // unique list of accounts
322  var achSubAccounts = []; // build dynamically
323  var achStateList = <?php echo HCU_JsonEncode( GetStateList() ); ?>;
324  var editTemplateModel;
325  var deleteDialog;
326  var editTemplateDialog;
327  var discardDialog;
328  var editPartnerDialog;
329  var selectedTemplate = 0; // which template is currently being worked on
330  var progressStep = 0;
331  var achTemplatePartnerList = []; // initialize list for partner grid
332  var achBatchList = []; // initialize list for batch grid
333  var partnerDataSource;
334  var partnerGrid;
335  var chooserGrid;
336  var removePartnerDialog;
337  var batchDataSource;
338  var batchGrid;
339  var batchModel;
340  var editPartnerModel;
341  var window_stack = [];
342  var templateChanged = true; // cause templates to be re-read
343  var saveStatus = false; // only to save status message after successful batch submission and re-reading templates
344  var progressSteps;
345  var infoResults;
346  var uploadCSVDialog;
347  var csvInfoDialog;
348  var csvNotSelected = null;
349  var csvNotMatched = null;
350  var uploadWidget = null;
351 
352  var effDatePicker = null;
353  var achFeature = <?php echo HCU_JsonEncode($ach_feature); ?>;
354 
355  // check for notices
356  var terms = <?php echo HCU_JsonEncode($hasTermsACH && $hasTermsPopupACH); ?>;
357  var notice = <?php echo HCU_JsonEncode($hasNoticeACH && $hasNoticePopupACH); ?>;
358  // upload csv notice
359  var noticeCsv = <?php echo HCU_JsonEncode($hasNoticeCSV && $hasNoticePopupCSV); ?>;
360 
361  var companyData = <?php echo HCU_JsonEncode($companyData); ?>;
362 
363  function ClearPaymentInfo() {
364  viewModel.set( "achType", "" );
365 
366  viewModel.set( "achBatchTotal", 0 );
367  viewModel.set( "achMemo", "" );
368 
369  viewModel.set( "achMyAcctSelected", "" );
370  viewModel.set( "achSubAcctSelected", 0 );
371 
372  viewModel.set( "achEffDate", "<?php echo $initialEffDate; ?>" );
373  }
374 
375  // status will be shown in the default info location
376  function ShowStatus( statusMessage ) {
377  $.homecuValidator.settings.formStatusField = "formStatus";
378  $.homecuValidator.settings.formInfoTitle = "";
379  $.homecuValidator.displayMessage(statusMessage);
380  }
381 
382  //******* Functions ********
383  // set up validation for this step
384  function StartValidator( thisStep ) {
385  if ( thisStep === 1 ) {
386  // no validation on Step 1
387  } else if ( thisStep === 2 ) {
388  $.homecuValidator.setup( {formValidate: "achEditTemplate"} );
389  } else if ( thisStep === 3 ) {
390  $.homecuValidator.setup( {formValidate: "achBatchRemote"} );
391  } else if ( thisStep === 4 ) {
392  $.homecuValidator.setup( {formValidate: "achLocal"} );
393  }
394 
395  } // end StartValidator
396 
397  // handle the validation
398  // NOTE: The homecuValidator and Kendo Validator has some kind of problem with complex html;
399  // text boxes seem to work but do the rest manually.
400  // NOTE: Use the validation message; need a validation message where it is used.
401  function ValidateThisStep( thisStep ) {
402  var otherErrors = Array();
403 
404  // see which form we are checking
405  var needValidation = true;
406  if ( thisStep === 1 ) {
407  // don't validate this step because there are no inputs
408  needValidation = false;
409  } else if ( thisStep === 2 ) {
410 
411  // make sure ACH Type checked
412  var test = viewModel.achType.toLowerCase();
413  if ( !(test === "ppd" || test === "ccd") ) {
414  otherErrors.push( "<?php echo $MC->msg("ACH Type needed", HCU_DISPLAY_AS_JS) ?>" );
415  }
416 
417  // make sure at least one parter is chosen
418  var atLeastOne = false;
419  for ( var i = 0; i < achTemplatePartnerList.length; i++ ) {
420  if ( achTemplatePartnerList[i].inBatch ) {
421  atLeastOne = true;
422  break;
423  }
424  }
425 
426  if ( !atLeastOne ) {
427  otherErrors.push( "<?php echo $MC->msg("ACH Need one partner", HCU_DISPLAY_AS_JS) ?>" );
428  }
429  } else if ( thisStep === 3 ) {
430  // nothing to validate in HTML
431  needValidation = false;
432 
433  // check batch total
434  var totalAmount = GetTotalBatchAmount();
435  if ( totalAmount == 0 ) {
436  otherErrors.push( "<?php echo $MC->msg("ACH Batch need amount", HCU_DISPLAY_AS_JS) ?>" );
437  } else if ( totalAmount > <?php echo $allowedAmount ?> ) {
438  otherErrors.push( '<?php echo $MC->msg('ACH Amount over allowed', HCU_DISPLAY_AS_JS); ?>' );
439  }
440 
441  } else if ( thisStep === 4 ) {
442  var available = viewModel.achAvailable;
443  var totalAmount = GetTotalBatchAmount();
444  if ( achFeature == "choose_batch_payment" ) {
445 
446  if ( totalAmount > available ) {
447  otherErrors.push( "<?php echo $MC->msg("Transfer exceeds", HCU_DISPLAY_AS_JS); ?>" );
448  }
449  }
450  }
451 
452  if (otherErrors.length > 0) {
453  $.homecuValidator.homecuResetMessage = true;
454  $.homecuValidator.displayMessage(otherErrors, $.homecuValidator.settings.statusError);
455  $.homecuValidator.homecuValidate = false;
456  } else {
457  // general validation
458  if ( needValidation ) {
459  $.homecuValidator.homecuValidate = $.homecuValidator.validate();
460  } else {
461  // pretend it validated
462  $.homecuValidator.homecuValidate = true;
463  }
464  }
465 
466  return ( $.homecuValidator.homecuValidate );
467  }
468 
469  function GetTotalBatchAmount() {
470  var totalAmount = 0;
471  for ( var i = 0; i < achBatchList.length; i++ ) {
472  var numerictextbox = $("#amount" + achBatchList[i].id).data("kendoNumericTextBox");
473 
474  if ( numerictextbox ) {
475  var value = numerictextbox.value();
476  if ( value === null || value === undefined || value === "" ) {
477  value = 0;
478  }
479 
480  // if any batch amount field is empty, return 0 to throw error.
481  if ( value == 0 ) {
482  return 0;
483  }
484 
485  totalAmount += value;
486  }
487  }
488 
489  return totalAmount;
490  }
491 
492  function ShowThisStep( step ) {
493  if ( step === 0 || step === 1 ) {
494  // initialize components
495  viewModel.trigger( "reset" );
496  $('#checkAllForBatch').removeAttr('checked');
497 
498  // hide the back button
499  viewModel.set( "showBack", false );
500  // hide the 2nd, 3rd and 4th steps
501  $("#achEditTemplate").hide();
502  $("#achBatchRemote").hide();
503  $("#achLocal").hide();
504  // show the 1st step
505  $("#achTemplate").show();
506  progressSteps.value( 1 );
507  $("#stepName").html( "<?php echo $progressStep1; ?>" );
508  // now the Next button is hidden so user clicks on a template
509  $("#nextButton").hide();
510 
511  // read the templates
512  GetACHTemplates( "<?php echo $templateAction ?>" );
513 
514  // clear the update flag
515  viewModel.set( "achUpdateTemplate", false );
516 
517  } else if ( step === 2 ) {
518  // hide the first, third, and fourth steps
519  $("#achTemplate").hide();
520  $("#achBatchRemote").hide();
521  $("#achLocal").hide();
522  // show the 2nd step
523  $("#achEditTemplate").show();
524  progressSteps.value( 2 );
525  $("#stepName").html( "<?php echo $progressStep2; ?>" );
526  // make sure back button is visible
527  viewModel.set( "showBack", true );
528  $("#nextButton").show();
529  $("#nextButton").html("<?php echo $MC->msg("Next", HCU_DISPLAY_AS_JS) ?>");
530 
531  // make sure the partner grid is up to date
532  PopulatePartnerGrid();
533 
534  // hide the csv links, just in case
535  csvNotMatched = null;
536  $("#csvNotMatched").hide();
537  csvNotSelected = null;
538  $("#csvNotSelected").hide();
539  } else if ( step === 3 ) {
540  // hide the first, second, and fourth steps
541  $("#achTemplate").hide();
542  $("#achEditTemplate").hide();
543  $("#achLocal").hide();
544  // show the 3rd step
545  $("#achBatchRemote").show();
546  progressSteps.value( 3 );
547  $("#stepName").html( "<?php echo $progressStep3; ?>" );
548  // make sure back button is visible
549  viewModel.set( "showBack", true );
550  // now the Next button is "Submit"
551  $("#nextButton").html("<?php echo $MC->msg("Next", HCU_DISPLAY_AS_JS) ?>");
552 
553  PopulateBatchGrid();
554  } else if ( step === 4 ) {
555  // hide the first, second, and third steps
556  $("#achTemplate").hide();
557  $("#achEditTemplate").hide();
558  $("#achBatchRemote").hide();
559  // show the 4th step
560  $("#achLocal").show();
561  progressSteps.value( 4 );
562  $("#stepName").html( "<?php echo $progressStep4; ?>" );
563  // make sure back button is visible
564  viewModel.set( "showBack", true );
565  // now the Next button is "Submit"
566  $("#nextButton").html("<?php echo $MC->msg("Submit", HCU_DISPLAY_AS_JS) ?>");
567  } else {
568  // do nothing
569  }
570 
571  StartValidator( step );
572  }
573 
574  function HandleNavClick( nextStep ) {
575  // let them go back without validation
576  $.homecuValidator.hideMessage();
577 
578  // don't let go forward using tabs
579  if ( nextStep >= progressStep ) {
580  return;
581  }
582 
583  progressStep = nextStep;
584  ShowThisStep( progressStep );
585  }
586 
587  // make the list using the template info
588  function PopulatePartnerGrid() {
589  if ( selectedTemplate > 0 ) {
590  var templateInfo = GetTemplateInfo( selectedTemplate );
591  viewModel.set( "achTemplateName", templateInfo.templateName );
592 
593  var partnerList = templateInfo.templatePartner;
594  }
595  } // end PopulatePartnerGrid
596 
597  function SortBatchList(a, b){
598  var aName = a.name.toLowerCase();
599  var bName = b.name.toLowerCase();
600  return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0));
601  }
602 
603  // make the list using the selected partners
604  <?php /* NOTES: The batch list is reset when the template is picked and updated when
605  * showing the batch payments page (i.e. partners added or removed). This way
606  * the edits are maintained if the user is clicking between tabs. The list of
607  * partners in the batch is dependant on what is selected in the achTemplatePartnerList.
608  * The partner information should all be updated on the server at this time.
609  */ ?>
610  function PopulateBatchGrid() {
611  // remove any partners that might be in the batch already
612  achBatchList = [];
613 
614  for ( var i = 0; i < achTemplatePartnerList.length; i++ ) {
615  if ( achTemplatePartnerList[i].inBatch ) {
616  // see if the partner is already in the batch
617  var found = false;
618  for ( var b = 0; b < achBatchList.length; b++ ) {
619  if ( achBatchList[b].id == achTemplatePartnerList[i].partnerId ) {
620  found = true;
621  break;
622  }
623  }
624 
625  if ( !found ) {
626 
627  var newObject = {
628  id: achTemplatePartnerList[i].partnerId,
629  name: achTemplatePartnerList[i].partnerDisplayName,
630  amount: achTemplatePartnerList[i].lastAmount,
631  addenda: achTemplatePartnerList[i].lastAddenda,
632  notify: (
633  achTemplatePartnerList[i].partnerEmail != "" &&
634  achTemplatePartnerList[i].partnerNotify
635  ),
636  disable: (
637  achTemplatePartnerList[i].partnerEmail == ""
638  )
639  };
640  achBatchList.push( newObject );
641  }
642 
643  } else {
644  // make sure not in the batch
645  for ( var b = 0; b < achBatchList.length; b++ ) {
646  if ( achBatchList[b].id == achTemplatePartnerList[i].partnerId ) {
647  achBatchList.splice(b, 1);
648  break;
649  }
650  }
651  }
652  }
653 
654  // sort the data
655  achBatchList.sort( SortBatchList );
656 
657  // build the grid
658  var javascriptTemplate = kendo.template($("#batchTemplate").html());
659  $("#batchGrid").html(javascriptTemplate(achBatchList));
660 
661  // set up numeric textboxes
662  $(".batch-amount").each( function() {
663  $("#" + this.id).kendoNumericTextBox({
664  min: 0.01,
665  max: <?php echo $allowedAmount ?>,
666  format: "c",
667  decimals: 2,
668  restrictDecimals: true,
669  spinners: false,
670  change: function(e) {
671  var elementId = this.element[0].id;
672  var value = this.value();
673 
674  if ( value === null || value === undefined || value === "" ) {
675  value = 0;
676  } else {
677  this.value(0.00);
678  }
679 
680  if ( $.isNumeric( value ) ) {
681  var partnerId = elementId.slice( "amount".length );
682  SetBatchAmount( partnerId, value );
683 
684  ShowBatchTotal();
685  } else {
686  this.value(0.00);
687  }
688  }
689  });
690 
691  $("#" + this.id).focus(function() {
692  var input = $(this);
693 
694  clearTimeout(input.data("selectTimeId")); //stop started time out if any
695 
696  var selectTimeId = setTimeout(function() {
697  input.select();
698  }, 10);
699 
700  input.data("selectTimeId", selectTimeId);
701  }).blur(function(e) {
702  clearTimeout($(this).data("selectTimeId"));
703  });
704  });
705 
706  // update the batch total
707  ShowBatchTotal();
708  } // end PopulateBatchGrid
709 
710  // make the list using the partners from the CSV file
711  function PopulateBatchGridUsingCSV( partnerSelectedList ) {
712  // remove any partners that might be in the batch already
713  achBatchList = [];
714 
715  // go through and set up the new batch list
716  for ( var i = 0; i < partnerSelectedList.length; i++ ) {
717  // get the display name
718  displayName = "Unknown";
719  for ( var p = 0; p < achPartnerList.length; p++ ) {
720  if ( achPartnerList[p].id == partnerSelectedList[i].id ) {
721  displayName = achPartnerList[p].display_name;
722  break;
723  }
724  }
725 
726  var newObject = {
727  id: partnerSelectedList[i].id,
728  name: displayName,
729  amount: partnerSelectedList[i].amount,
730  addenda: partnerSelectedList[i].addenda,
731  notify: (
732  achTemplatePartnerList[i].partnerEmail != "" &&
733  achTemplatePartnerList[i].partnerNotify
734  ),
735  disable: (
736  achTemplatePartnerList[i].partnerEmail == ""
737  )
738  };
739  achBatchList.push( newObject );
740  }
741 
742  // sort the data
743  achBatchList.sort( SortBatchList );
744 
745  // build the grid
746  var javascriptTemplate = kendo.template($("#batchTemplate").html());
747  $("#batchGrid").html(javascriptTemplate(achBatchList));
748 
749  // set up numeric textboxes
750  $(".batch-amount").each( function() {
751  $("#" + this.id).kendoNumericTextBox({
752  min: 0.01,
753  max: <?php echo $allowedAmount ?>,
754  format: "c",
755  decimals: 2,
756  restrictDecimals: true,
757  spinners: false,
758  change: function(e) {
759  var elementId = this.element[0].id;
760  var value = this.value();
761 
762  if ( value === null || value === undefined || value === "" ) {
763  value = 0;
764  } else {
765  this.value(0.00);
766  }
767 
768  if ( $.isNumeric( value ) ) {
769  var partnerId = elementId.slice( "amount".length );
770  SetBatchAmount( partnerId, value );
771 
772  ShowBatchTotal();
773  } else {
774  this.value(0.00);
775  }
776  }
777  });
778 
779  $("#" + this.id).focus(function() {
780  var input = $(this);
781 
782  clearTimeout(input.data("selectTimeId")); //stop started time out if any
783 
784  var selectTimeId = setTimeout(function() {
785  input.select();
786  }, 10);
787 
788  input.data("selectTimeId", selectTimeId);
789  }).blur(function(e) {
790  clearTimeout($(this).data("selectTimeId"));
791  });
792  });
793 
794  // update the batch total
795  ShowBatchTotal();
796  } // end PopulateBatchGridUsingCSV
797 
798  function GetACHAccounts( action ) {
799  var request = { action: action };
800 
801  dsACHHelper.read( request );
802  } // end GetACHAccounts
803 
804  function GetACHPartners() {
805  var request = { action: "get_ach_partners" };
806 
807  dsACHHelper.read( request ).then( function() {
808  // get the account lists - get after template returned so can filter the list against that
809  GetACHAccounts( "payments_list" );
810  });
811  } // end GetACHAccounts
812 
813  function GetACHTemplates( action ) {
814  // only read if one changed
815  if ( templateChanged ) {
816  var request = { action: action };
817 
818  dsACHHelper.read( request );
819  }
820  } // end GetACHTemplates
821 
822  function GetACHTemplatePartners( templateId ) {
823  var request = { action: "read_template_partners", template_id: templateId };
824 
825  dsACHHelper.read( request ).then( function() {
826  // get the partner lists - get after template returned so can filter the list against that
827  GetACHPartners();
828  });
829  } // end GetACHTemplatePartners
830 
831  function DeleteACHTemplate( templateId ) {
832  var request = { action: "delete_template", template_id: selectedTemplate };
833 
834  dsACHHelper.read( request );
835  } // end DeleteACHTemplate
836 
837  function UpdateACHTemplate( ) {
838  // get the current values from the view model
839  var id = selectedTemplate;
840  var newName = editTemplateModel.templateName;
841 
842  var request = { action: "update_template", template_id: id, template_name: newName };
843 
844  dsACHHelper.read( request );
845  } // end UpdateACHTemplate
846 
847  // Remove a partner from the template grid. This will cause it to go back into the chooser list.
848  function RemovePartner( id ) {
849  // find the partner
850  for ( var i = 0; i < achTemplatePartnerList.length; i++ ) {
851  if ( achTemplatePartnerList[i].partnerId == id ) {
852  // flag for removal
853  achTemplatePartnerList[i].remove = true;
854 
855  var request = { action: "remove_template_partner", partner_id: id, template_id: selectedTemplate };
856 
857  dsACHHelper.read( request );
858  break;
859  }
860  }
861 
862  } // end RemovePartner
863 
864  function SubmitACHRequest() {
865  // set up the fields
866  // package up the batch information
867  var batchData = JSON.stringify( achBatchList );
868 
869  var request = {
870  action: "<?php echo $achAction ?>",
871  batch_data: batchData,
872  internal_acct: viewModel.achMyAcctSelected,
873  internal_sub_acct: viewModel.achSubAcctSelected,
874  eff_date: viewModel.achEffDate,
875  memo: viewModel.achMemo,
876  ach_type: viewModel.achType,
877  template_id: selectedTemplate,
878  update_template: viewModel.achUpdateTemplate ? 1 : 0
879  };
880 
881  dsACHHelper.read( request );
882  } // end SubmitACHRequest
883 
884  // handle a new account list from the server
885  function HandleUpdatedAccountList() {
886  achSubAccounts = [];
887  // iterate through accounts, add to sub-account list
888  for (var i = 0; i < achAllAccounts.length; i++) {
889  achSubAccounts.push({
890  name: achAllAccounts[i].account_name,
891  id: achAllAccounts[i].acctid,
892  amount: achAllAccounts[i].amount,
893  account: achAllAccounts[i].account
894  });
895  }
896 
897  // add to dropdown list
898  var dataSource = new kendo.data.DataSource({
899  data: achSubAccounts
900  });
901  var dropdownlist = $("#achSubAcctList").data("kendoDropDownList");
902  dropdownlist.setDataSource(dataSource);
903 
904  if (achSubAccounts.length == 1) {
905  dropdownlist.select(1);
906  dropdownlist.trigger("change");
907  }
908  } // end HandleUpdatedAccountList
909 
910  // handle a new partner list from the server
911  function HandleUpdatedPartnerList() {
912  var filterTest = [];
913  if ( $("#achPartnerFilterPayee").prop( "checked" ) ) {
914  filterTest.push("e");
915  }
916  if ( $("#achPartnerFilterPayroll").prop( "checked" ) ) {
917  filterTest.push("$");
918  }
919  if ( $("#achPartnerFilterPayor").prop( "checked" ) ) {
920  filterTest.push("r");
921  }
922  if ( $("#achPartnerFilterUnassigned").prop( "checked" ) ) {
923  filterTest.push("");
924  }
925 
926  // get the unique partners that aren't already in the template
927  achCurrentList = [];
928  for ( var i = 0; i < achPartnerList.length; i++ ) {
929  // set email_notify to true/false
930  // check if already in template
931  var found = false;
932  for ( var t = 0; t < achTemplatePartnerList.length; t++ ) {
933  if ( achPartnerList[i].id == achTemplatePartnerList[t].partnerId ) {
934  found = true;
935  break;
936  }
937  }
938 
939  if ( !found ) {
940  var test = filterTest.indexOf( achPartnerList[i].partner_type );
941  if ( test >= 0 ) {
942  achCurrentList.push( {name: achPartnerList[i].display_name, id: achPartnerList[i].id} );
943  }
944  }
945  }
946 
947  // reset the partner list
948  var dropdownlist = $("#achPartnerDD").data("kendoDropDownList");
949  dropdownlist.dataSource.data(achCurrentList);
950  dropdownlist.select(0);
951 
952  // show the updated partner list
953  var grid = $('#achPartnerChooser').data("kendoGrid");
954  grid.dataSource.data(achCurrentList);
955 
956  } // end HandleUpdatedPartnerList
957 
958  // Create an address string based on what exists.
959  // partnerAddress1# / #: partnerCity#, #: partnerState# #: partnerZip
960  function CreateAddressString( partnerListEntry ) {
961  var showString = "";
962  if ( partnerListEntry.partnerCity.length > 0 ||
963  partnerListEntry.partnerState.length > 0 ||
964  partnerListEntry.partnerZip.length > 0 ) {
965  showString = partnerListEntry.partnerCity.trim();
966  if ( showString.length > 0 &&
967  (partnerListEntry.partnerState.length > 0 ||
968  partnerListEntry.partnerZip.length > 0) ) {
969  showString = showString + ", " + partnerListEntry.partnerState + " " + partnerListEntry.partnerZip;
970  showString = showString.trim();
971  }
972  }
973 
974  if ( partnerListEntry.partnerAddress1.length > 0 ) {
975  if ( showString.length > 0 ) {
976  showString = partnerListEntry.partnerAddress1 + " / " + showString;
977  } else {
978  showString = partnerListEntry.partnerAddress1;
979  }
980  }
981 
982  return showString.trim();
983  } // end CreateAddressString
984 
985  // Handle a partner that was updated. We don't want to refresh the grid.
986  // If not found in the achTemplatePartnerList add the partner to that list.
987  function HandlePartnerUpdate( partnerInfo ) {
988  // find the partner in the template source
989  var found = false;
990  for ( var i = 0; i < achTemplatePartnerList.length; i++ ) {
991  if ( achTemplatePartnerList[i].partnerId == partnerInfo.id ) {
992  achTemplatePartnerList[i].partnerDisplayName = partnerInfo.display_name;
993  achTemplatePartnerList[i].partnerACHName = partnerInfo.ach_name;
994  achTemplatePartnerList[i].partnerNotify = partnerInfo.email_notify;
995  achTemplatePartnerList[i].partnerType = partnerInfo.partner_type;
996  achTemplatePartnerList[i].partnerAddress1 = partnerInfo.address1;
997  achTemplatePartnerList[i].partnerAddress2 = partnerInfo.address2;
998  achTemplatePartnerList[i].partnerCity = partnerInfo.city,
999  achTemplatePartnerList[i].partnerState = partnerInfo.state;
1000  achTemplatePartnerList[i].partnerZip = partnerInfo.zip;
1001  achTemplatePartnerList[i].partnerCountry = partnerInfo.country;
1002  achTemplatePartnerList[i].partnerEmail = partnerInfo.email;
1003  achTemplatePartnerList[i].partnerDfiAccount = partnerInfo.dfi_account;
1004  achTemplatePartnerList[i].partnerDfiType = partnerInfo.dfi_account_type;
1005  achTemplatePartnerList[i].partnerDfiRouting = partnerInfo.dfi_routing;
1006  // this is just to aid in displaying address
1007  achTemplatePartnerList[i].showPartnerAddress = CreateAddressString( achTemplatePartnerList[i] );
1008  // don't adjust the inBatch or remove settings
1009  achTemplatePartnerList[i].changed = false;
1010 
1011  found = true;
1012  break;
1013  }
1014  }
1015 
1016  if ( !found ) {
1017  // must have been an Add New Partner - add to the template list
1018  var newObject = {
1019  partnerId: partnerInfo.id,
1020  partnerDisplayName: partnerInfo.display_name,
1021  partnerACHName: partnerInfo.ach_name,
1022  partnerNotify: partnerInfo.email_notify,
1023  partnerType: partnerInfo.partner_type,
1024  partnerAddress1: partnerInfo.address1,
1025  partnerAddress2: partnerInfo.address2,
1026  partnerCity: partnerInfo.city,
1027  partnerState: partnerInfo.state,
1028  partnerZip: partnerInfo.zip,
1029  partnerCountry: partnerInfo.country,
1030  partnerEmail: partnerInfo.email,
1031  partnerDfiAccount: partnerInfo.dfi_account,
1032  partnerDfiType: partnerInfo.dfi_account_type,
1033  partnerDfiRouting: partnerInfo.dfi_routing,
1034  // this is just to aid in displaying address
1035  showPartnerAddress: "",
1036  lastAmount: 0,
1037  lastAddenda: "",
1038  inBatch: false,
1039  remove: false,
1040  changed: false
1041  };
1042 
1043  // now that we have an object
1044  newObject.showPartnerAddress = CreateAddressString( newObject );
1045 
1046  achTemplatePartnerList.push( newObject );
1047  }
1048 
1049  // reset the datasource
1050  var grid = $("#partnerGrid").data("kendoGrid");
1051  grid.dataSource.data(achTemplatePartnerList);
1052 
1053  // find the partner in the partner info
1054  var found = false;
1055  for ( var i = 0; i < achPartnerList.length; i++ ) {
1056  if ( achPartnerList[i].id == partnerInfo.id ) {
1057  // just the display name and partner type
1058  achPartnerList[i].name = partnerInfo.display_name;
1059  achPartnerList[i].partner_type = partnerInfo.partner_type;
1060 
1061  found = true;
1062  break;
1063  }
1064  }
1065 
1066  if ( !found ) {
1067  achPartnerList.push( {id: partnerInfo.id,
1068  name: partnerInfo.display_name,
1069  partner_type: partnerInfo.partner_type} );
1070  }
1071  } // end HandlePartnerUpdate
1072 
1073  // Helper function to sort the TemplatePartnerList.
1074  // Sort order,
1075  function SortTemplateList(a, b){
1076  var aName = a.partnerDisplayName.toLowerCase();
1077  var bName = b.partnerDisplayName.toLowerCase();
1078  return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0));
1079  }
1080 
1081 
1082  // Handle a parter being added to the template. There is additional information that came in.
1083  <?php /* Note: we are adding it to the underlying array in case the user updates the template in
1084  * the database.
1085  */ ?>
1086  function HandlePartnerForTemplate( partnerInfo ) {
1087  // add to the template list
1088  var newObject = {
1089  partnerId: partnerInfo.id,
1090  partnerDisplayName: partnerInfo.display_name,
1091  partnerACHName: partnerInfo.ach_name,
1092  partnerNotify: partnerInfo.email_notify,
1093  partnerType: partnerInfo.partner_type,
1094  partnerAddress1: partnerInfo.address1,
1095  partnerAddress2: partnerInfo.address2,
1096  partnerCity: partnerInfo.city,
1097  partnerState: partnerInfo.state,
1098  partnerZip: partnerInfo.zip,
1099  partnerCountry: partnerInfo.country,
1100  partnerEmail: partnerInfo.email,
1101  partnerDfiAccount: partnerInfo.dfi_account,
1102  partnerDfiType: partnerInfo.dfi_account_type,
1103  partnerDfiRouting: partnerInfo.dfi_routing,
1104  // this is just to aid in displaying address
1105  showPartnerAddress: "",
1106  lastAmount: 0,
1107  lastAddenda: "",
1108  inBatch: false,
1109  remove: false,
1110  changed: false
1111  };
1112 
1113  // now that we have an object
1114  newObject.showPartnerAddress = CreateAddressString( newObject );
1115 
1116  achTemplatePartnerList.push( newObject );
1117 
1118  // reset the datasource
1119  partnerDataSource = new kendo.data.DataSource({
1120  data: achTemplatePartnerList,
1121  filter: { field: "remove", operator: "neq", value: true },
1122  sort: { field: "partnerDisplayName", dir: "asc" }
1123  });
1124 
1125  // reset the template list
1126  var grid = $("#partnerGrid").data("kendoGrid");
1127  grid.setDataSource(partnerDataSource);
1128  grid.refresh();
1129 
1130  } // end HandlePartnerForTemplate
1131 
1132  // Handle removing a parter from the template.
1133  <?php /* Note: we are adding it to the underlying array in case the user updates the template in
1134  * the database.
1135  */ ?>
1136  function HandleRemovePartnerFromTemplate( partnerId ) {
1137  // remove from the template list
1138  for ( var i = 0; i < achTemplatePartnerList.length; i++ ) {
1139  if ( achTemplatePartnerList[i].partnerId == partnerId ) {
1140  achTemplatePartnerList.splice(i, 1);
1141  break;
1142  }
1143  }
1144 
1145  // reset the template partner grid
1146  var grid = $("#partnerGrid").data("kendoGrid");
1147  grid.dataSource.data(achTemplatePartnerList);
1148 
1149  // now update the partner choosers
1150  HandleUpdatedPartnerList();
1151 
1152  } // end HandleRemovePartnerFromTemplate
1153 
1154  // handle a new template list from the server (show info plus an Add New)
1155  function HandleUpdatedTemplateList( oTemplateInfo ) {
1156 
1157  // get the original data and break out the JSON information so it is available
1158  achTemplateList = [];
1159  for ( var i = 0; i < oTemplateInfo.length; i++ ) {
1160  var templateMeta = JSON.parse( oTemplateInfo[i].tmpl_meta );
1161  var templatePartner = JSON.parse( oTemplateInfo[i].tmpl_partner );
1162 
1163  var newObject = {
1164  templateId: oTemplateInfo[i].tmpl_id,
1165  templateName: oTemplateInfo[i].tmpl_name,
1166  templateType: oTemplateInfo[i].tmpl_type,
1167  templateACHType: oTemplateInfo[i].ach_type,
1168  templateMeta: templateMeta,
1169  templatePartner: templatePartner
1170  };
1171 
1172  achTemplateList.push( newObject );
1173  }
1174 
1175  // add one more to add a new template
1176  var newObject = {
1177  templateId: -1,
1178  templateName: "<?php echo $MC->msg("ACH Add New Template", HCU_DISPLAY_AS_JS) ?>",
1179  templateType: "",
1180  templateMeta: "",
1181  templatePartner: ""
1182  };
1183 
1184  achTemplateList.push( newObject );
1185  var listview = $("#templateList").data("kendoListView");
1186  listview.dataSource.data(achTemplateList);
1187  } // end HandleUpdatedTemplateList
1188 
1189  // handle a new template list from the server
1190  function HandleTemplatePartnerList( oTemplatePartnerInfo ) {
1191  // get the original data and break out the JSON information so it is available
1192  achTemplatePartnerList = [];
1193  for ( var i = 0; i < oTemplatePartnerInfo.length; i++ ) {
1194  var partnerAddress = JSON.parse( oTemplatePartnerInfo[i].address );
1195  var partnerDFI = JSON.parse( oTemplatePartnerInfo[i].dfi_data );
1196  var newObject = {
1197  partnerId: oTemplatePartnerInfo[i].id,
1198  partnerDisplayName: oTemplatePartnerInfo[i].display_name,
1199  partnerACHName: oTemplatePartnerInfo[i].ach_name,
1200  partnerNotify: oTemplatePartnerInfo[i].email_notify == "t",
1201  partnerType: oTemplatePartnerInfo[i].partner_type,
1202  partnerAddress1: partnerAddress.address1,
1203  partnerAddress2: partnerAddress.address2,
1204  partnerCity: partnerAddress.city,
1205  partnerState: partnerAddress.state,
1206  partnerZip: partnerAddress.zip,
1207  partnerCountry: partnerAddress.country,
1208  partnerEmail: partnerAddress.email,
1209  partnerDfiAccount: partnerDFI.dfi_account,
1210  partnerDfiType: partnerDFI.dfi_account_type,
1211  partnerDfiRouting: partnerDFI.dfi_routing,
1212  // this is just to aid in displaying address
1213  showPartnerAddress: "",
1214  lastAmount: oTemplatePartnerInfo[i].last_amount,
1215  lastAddenda: oTemplatePartnerInfo[i].last_addenda,
1216  inBatch: false,
1217  remove: false,
1218  changed: false
1219  };
1220 
1221  // now that we have an object
1222  newObject.showPartnerAddress = CreateAddressString( newObject );
1223 
1224  achTemplatePartnerList.push( newObject );
1225  }
1226  var grid = $("#partnerGrid").data("kendoGrid");
1227  grid.dataSource.data(achTemplatePartnerList);
1228 
1229  } // end HandleTemplatePartnerList
1230 
1231 
1232  // Handle of template
1233  function ShowDeleteTemplate(templateId) {
1234  selectedTemplate = templateId;
1235  deleteDialog.open();
1236  } // end ShowDeleteTemplate
1237 
1238  // Handle edit of template
1239  function ShowEditTemplate(templateId) {
1240  selectedTemplate = templateId;
1241 
1242  // set up the current name
1243  var templateInfo = GetTemplateInfo( templateId );
1244  var currentName = templateInfo.templateName;
1245  editTemplateModel.SetTemplate( currentName );
1246 
1247  editTemplateDialog.title("<?php echo $MC->msg("ACH Edit Template Name", HCU_DISPLAY_AS_JS) ?>").open();
1248  } // end ShowDeleteTemplate
1249 
1250  function GetTemplateInfo( templateId ) {
1251  var found = false;
1252  var returnObject = null;
1253 
1254  for ( var i = 0; i < achTemplateList.length; i++ ) {
1255  if ( achTemplateList[i].templateId == templateId ) {
1256  found = true;
1257  break;
1258  }
1259  }
1260 
1261  if ( found ) {
1262  returnObject = achTemplateList[i];
1263  }
1264 
1265  return returnObject;
1266  } // end GetTemplateInfo
1267 
1268  function SelectTemplate( templateId ) {
1269  selectedTemplate = templateId;
1270 
1271  if ( templateId == -1 ) {
1272  ShowAddTemplate();
1273  } else {
1274  // get the template partners (also gets the partner list when done)
1275  GetACHTemplatePartners( selectedTemplate );
1276 
1277  // go to the next page as if by "clicking" on the Next button
1278  GoToNextTab();
1279 
1280  // set the ach type
1281  for ( var i = 0; i < achTemplateList.length; i++ ) {
1282  if ( achTemplateList[i].templateId == templateId ) {
1283  if ( achTemplateList[i].templateACHType !== "" ) {
1284  viewModel.set( "achType", achTemplateList[i].templateACHType );
1285  }
1286 
1287  break;
1288  }
1289  }
1290  }
1291 
1292  // reset the batch list
1293  achBatchList = [];
1294  } // SelectTemplate
1295 
1296  // This acts if clicking on the next button
1297  function GoToNextTab() {
1298  // clear out any current message
1299  $.homecuValidator.hideMessage();
1300 
1301  // scroll to the top - in case of error, next page, or reply from server
1302  $("#content-wrapper").animate({ scrollTop: 0 }, { duration: 500 } );
1303 
1304  // validate the data for the current step
1305  if ( ValidateThisStep( progressStep ) ) {
1306  if ( progressStep >= 4 ) {
1307  // submit the payment
1308  SubmitACHRequest();
1309  } else {
1310  progressStep++;
1311  ShowThisStep( progressStep );
1312  }
1313  }
1314  } // end GoToNextTab
1315 
1316  // act if the next button was clicked after the CSV successful upload
1317  function NextClickedByCSVSuccess() {
1318  // clear out any current message
1319  $.homecuValidator.displayMessage( "", $.homecuValidator.settings.statusError );
1320 
1321  // scroll to the top - in case of error, next page, or reply from server
1322  $("#content-wrapper").animate({ scrollTop: 0 }, { duration: 500 } );
1323 
1324  progressStep++;
1325 
1326  // hide the first, second, and fourth steps
1327  $("#achTemplate").hide();
1328  $("#achEditTemplate").hide();
1329  $("#achLocal").hide();
1330  // show the 3rd step
1331  $("#achBatchRemote").show();
1332  progressSteps.value( 3 );
1333  $("#stepName").html( "<?php echo $progressStep3; ?>" );
1334  // make sure back button is visible
1335  viewModel.set( "showBack", true );
1336  // now the Next button is "Submit"
1337  $("#nextButton").html("<?php echo $MC->msg("Next", HCU_DISPLAY_AS_JS) ?>");
1338 
1339  // remove any existing batch info
1340  $("#batchGrid").html( "" );
1341 
1342  viewModel.set( "achBatchTotal", 0.00 );
1343  }
1344 
1345  // Handle delete of partner
1346  function ShowRemovePartner(partnerId) {
1347  var found = false;
1348  for ( var i = 0; i < achTemplatePartnerList.length; i++ ) {
1349  if ( achTemplatePartnerList[i].partnerId == partnerId ) {
1350  // set the current data in the observable
1351 
1352  partnerName = achTemplatePartnerList[i].partnerDisplayName;
1353 
1354  found = true;
1355  break;
1356  }
1357  }
1358 
1359  if ( !found ) {
1360  partnerName = "<?php echo $MC->msg("Unknown", HCU_DISPLAY_AS_JS) ?>";
1361  }
1362 
1363  var content = "<p><?php echo $MC->msg("ACH Continue remove template partner", HCU_DISPLAY_AS_JS) ?>" + partnerName + "</p><p>" +
1364  "<?php echo $MC->msg("ACH Continue", HCU_DISPLAY_AS_JS) ?></p>" +
1365  "<input type='hidden' id='removePartnerId' value='" + partnerId + "'>";
1366  removePartnerDialog.content(content).open();
1367  } // end ShowRemovePartner
1368 
1369  // Handle adding a new template
1370  function ShowAddTemplate() {
1371  selectedTemplate = -1;
1372  editTemplateModel.SetTemplate( "" );
1373 
1374  editTemplateDialog.title("<?php echo $MC->msg("ACH Enter Template Name", HCU_DISPLAY_AS_JS) ?>").open();
1375  } // end ShowAddTemplate
1376 
1377  // Handle editing of partner information
1378  function ShowEditPartner(partnerId) {
1379  // find the parter's information
1380  var found = false;
1381  for ( var i = 0; i < achTemplatePartnerList.length; i++ ) {
1382  if ( achTemplatePartnerList[i].partnerId == partnerId ) {
1383  // set the current data in the observable
1384  editPartnerModel.init({
1385  partner_id: achTemplatePartnerList[i].partnerId,
1386  partner_type: achTemplatePartnerList[i].partnerType,
1387  display_name: achTemplatePartnerList[i].partnerDisplayName,
1388  ach_name: achTemplatePartnerList[i].partnerACHName,
1389  email: achTemplatePartnerList[i].partnerEmail,
1390  email_notify: achTemplatePartnerList[i].partnerNotify,
1391  address1: achTemplatePartnerList[i].partnerAddress1,
1392  address2: achTemplatePartnerList[i].partnerAddress2,
1393  city: achTemplatePartnerList[i].partnerCity,
1394  state: achTemplatePartnerList[i].partnerState,
1395  zip: achTemplatePartnerList[i].partnerZip,
1396  country: achTemplatePartnerList[i].partnerCountry,
1397  dfi_routing: achTemplatePartnerList[i].partnerDfiRouting,
1398  dfi_account: achTemplatePartnerList[i].partnerDfiAccount,
1399  dfi_account_confirm: achTemplatePartnerList[i].partnerDfiAccount,
1400  dfi_account_type: achTemplatePartnerList[i].partnerDfiType
1401  });
1402 
1403  partnerName = achTemplatePartnerList[i].partnerDisplayName;
1404 
1405  found = true;
1406  break;
1407  }
1408  }
1409 
1410  // error if not found
1411  if ( !found ) {
1412  var editDialog = $("#deleteDialog").kendoDialog({
1413  visible: false,
1414  title: "<?php echo $MC->msg("ACH Edit Partner", HCU_DISPLAY_AS_JS) ?>",
1415  content: "<p>" + "<?php echo $MC->msg("ACH Partner not found", HCU_DISPLAY_AS_JS) ?>" + "</p><p>" + "<?php echo $MC->msg("problem encountered", HCU_DISPLAY_AS_JS) ?>" + "</p>",
1416  show: function(e) {
1417  // add the close function to the window stack
1418  window_stack.push(function(e) {
1419  deleteDialog.close(e);
1420  });
1421  },
1422  close: function(e) {
1423  // remove the close function from the window stack
1424  window_stack.pop();
1425  },
1426  actions: [
1427  {
1428  text: "<?php echo $MC->msg("Close", HCU_DISPLAY_AS_JS) ?>",
1429  primary: true
1430  }]
1431  }).data("kendoDialog");
1432  editDialog.open();
1433  } else {
1434  if ($(window).width() > 768) {
1435  $(".achAccordionContent").show();
1436  $("span[data-accordion-plus]").hide();
1437  $("span[data-accordion-minus]").show();
1438 
1439  } else {
1440  $(".achAccordionContent").hide();
1441  $(".achAccordionContent[data-accordion-index=0]").show();
1442 
1443  $("span[data-accordion-plus]").show();
1444  $("span[data-accordion-minus]").hide();
1445 
1446  $("span[data-accordion-plus=0]").hide();
1447  $("span[data-accordion-minus=0]").show();
1448  }
1449  // open dialog
1450  var title = "<?php echo $MC->msg("ACH Edit Partner", HCU_DISPLAY_AS_JS) ?>" + ": " + partnerName;
1451  editPartnerDialog.title(title);
1452  editPartnerDialog.center();
1453  editPartnerDialog.open();
1454  }
1455  } // end ShowEditPartner
1456 
1457  // Add up and show the batch total.
1458  function ShowBatchTotal() {
1459  // add up the amounts
1460  var total = 0;
1461  for ( var i = 0; i < achBatchList.length; i++ ) {
1462  var amount = isNaN( achBatchList[i].amount ) ? 0 : achBatchList[i].amount;
1463  total += amount * 1;
1464  }
1465 
1466  viewModel.set( "achBatchTotal", total );
1467  } // end ShowBatchTotal
1468 
1469  function SetPartnerInBatch( partnerId, state ) {
1470  for ( var i = 0; i < achTemplatePartnerList.length; i++ ) {
1471  if ( achTemplatePartnerList[i].partnerId == partnerId ) {
1472  achTemplatePartnerList[i].inBatch = state;
1473  break;
1474  }
1475  }
1476  } // end SetPartnerInBatch
1477  function SetBatchAmount( partnerId, value ) {
1478  for ( var i = 0; i < achBatchList.length; i++ ) {
1479  if ( achBatchList[i].id == partnerId ) {
1480  achBatchList[i].amount = value * 1;
1481  break;
1482  }
1483  }
1484 
1485  // When a user navigates the steps using the
1486  // Back and Next buttons, and returns to the
1487  // Batch Amounts step, any data entered will be
1488  // overwritten with the orginal data.
1489 
1490  // To make the newly entered data persist through
1491  // navigation, we must save it to the achTemplatePartnerList.
1492  for ( var i = 0; i < achTemplatePartnerList.length; i++) {
1493  if (achTemplatePartnerList[i].partnerId == partnerId) {
1494  achTemplatePartnerList[i].lastAmount = value * 1;
1495  }
1496  }
1497  } // SetBatchAmount
1498  function SetBatchAddenda( partnerId, value ) {
1499  for ( var i = 0; i < achBatchList.length; i++ ) {
1500  if ( achBatchList[i].id == partnerId ) {
1501  achBatchList[i].addenda = value;
1502  break;
1503  }
1504  }
1505 
1506  // When a user navigates the steps using the
1507  // Back and Next buttons, and returns to the
1508  // Batch Amounts step, any data entered will be
1509  // overwritten with the orginal data.
1510 
1511  // To make the newly entered data persist through
1512  // navigation, we must save it to the achTemplatePartnerList.
1513  for ( var i = 0; i < achTemplatePartnerList.length; i++) {
1514  if (achTemplatePartnerList[i].partnerId == partnerId) {
1515  achTemplatePartnerList[i].lastAddenda = value;
1516  }
1517  }
1518  } // SetBatchAddenda
1519  function SetBatchNotify( partnerId, value ) {
1520  for ( var i = 0; i < achBatchList.length; i++ ) {
1521  if ( achBatchList[i].id == partnerId ) {
1522  achBatchList[i].notify = value;
1523  break;
1524  }
1525  }
1526 
1527  // When a user navigates the steps using the
1528  // Back and Next buttons, and returns to the
1529  // Batch Amounts step, any data entered will be
1530  // overwritten with the orginal data.
1531 
1532  // To make the newly entered data persist through
1533  // navigation, we must save it to the achTemplatePartnerList.
1534  for ( var i = 0; i < achTemplatePartnerList.length; i++) {
1535  if (achTemplatePartnerList[i].partnerId == partnerId) {
1536  achTemplatePartnerList[i].partnerNotify = value;
1537  }
1538  }
1539  } // SetBatchNotify
1540 
1541  // used to strip unwanted characters from zipcode
1542  // input field
1543  var StripZip = function(zip) {
1544  var splitZip = zip.split("-");
1545  var halfOne = splitZip[0].replace(/_/g, "");
1546  var halfTwo = null;
1547 
1548  try {
1549  halfTwo = splitZip[1].replace(/_/g, "");
1550  } catch(e) {
1551  halfTwo = "";
1552  }
1553 
1554  if (halfTwo.length == 0) {
1555  return halfOne;
1556  } else {
1557  return halfOne + "-" + halfTwo;
1558  }
1559  }
1560 
1561  function InitDataSources() {
1562  dsACHHelper = new kendo.data.DataSource({
1563  autoSync: false,
1564  batch: false,
1565  transport: {
1566  read: {
1567  url: 'hcuACH.data?cu=<?php echo $HB_ENV['cu']; ?>',
1568  dataType: "json",
1569  contentType: "application/x-www-form-urlencoded",
1570  type: "POST",
1571  cache: false
1572  }
1573  },
1574  schema: {
1575  parse: function(response) {
1576  // not showing data, so return empty array
1577  var display = [];
1578  return display;
1579  }
1580  },
1581  requestStart: function( e ) {
1582  if ( !saveStatus ) {
1583  $.homecuValidator.hideMessage();
1584  }
1585 
1586  ShowWaitWindow();
1587  },
1588  requestEnd: function( e ) {
1589  var error = null;
1590  var results = null;
1591 
1592  CloseWaitWindow();
1593 
1594  if ( e.response && e.response.Results ) {
1595  results = e.response.Results;
1596 
1597  // see if there is an error
1598  if ( results && results.homecuErrors )
1599  error = results.homecuErrors;
1600 
1601  if ( error && error.length > 0 ) {
1602  e.preventDefault();
1603  // make sure only old data
1604  dsACHHelper.cancelChanges();
1605  // show the error information
1606  $.homecuValidator.displayMessage(error, $.homecuValidator.settings.statusError);
1607  } else {
1608  // handle any returned data
1609  if ( results && results.homecuData ) {
1610  // set the partner list
1611  if ( results.homecuData.partners ) {
1612  achPartnerList = results.homecuData.partners;
1613  HandleUpdatedPartnerList();
1614  }
1615 
1616  // set the account lists
1617  if ( results.homecuData.accounts ) {
1618  achAllAccounts = results.homecuData.accounts;
1619 
1620  HandleUpdatedAccountList();
1621  }
1622 
1623  // the list of templates
1624  if ( results.homecuData.templates ) {
1625  HandleUpdatedTemplateList( results.homecuData.templates );
1626  // clear the changed flag
1627  templateChanged = false;
1628 
1629  // don't need to save status any more
1630  saveStatus = false;
1631  }
1632 
1633  // set the template partner list
1634  if ( results.homecuData.read_template_partners ) {
1635  HandleTemplatePartnerList( results.homecuData.read_template_partners );
1636  }
1637 
1638  // update the template partner information
1639  if ( results.homecuData.update_partner ) {
1640 
1641  // the partner results come in results.homecuData.partner_data
1642  HandlePartnerUpdate( results.homecuData.partner_data );
1643  editPartnerModel.reset();
1644  editPartnerDialog.close();
1645  }
1646 
1647  // add the one parter to the template
1648  if ( results.homecuData.one_partner ) {
1649  // add to template
1650  HandlePartnerForTemplate( results.homecuData.one_partner );
1651 
1652  // set the changed flag
1653  templateChanged = true;
1654 
1655  // remove from available list
1656  HandleUpdatedPartnerList();
1657  }
1658 
1659  // remove the one parter from the template
1660  if ( results.homecuData.partner_removed ) {
1661  // remove from template
1662  HandleRemovePartnerFromTemplate( results.homecuData.partner_removed );
1663 
1664  // set the changed flag
1665  templateChanged = true;
1666  }
1667 
1668  // see if the batch was submitted successfully
1669  if ( results.homecuData.submit_batch && results.homecuData.submit_batch == "Success" ) {
1670  // need to save the status when getting the templates after this successful batch submission
1671  saveStatus = true;
1672  // set the changed flag -- assume it changed
1673  templateChanged = true;
1674 
1675  ShowThisStep( 0 );
1676  progressStep = 1;
1677  ShowThisStep( progressStep );
1678 
1679  // Display confirmation dialog
1680  ShowConfirmation( results.homecuData.txn );
1681  }
1682  }
1683 
1684  if ( results && results.homecuInfo && (results.homecuInfo.length > 0) ) {
1685  $.homecuValidator.settings.formStatusField = "confirmationStatus";
1686  $.homecuValidator.settings.formInfoTitle = "";
1687  $.homecuValidator.displayMessage(results.homecuInfo, $.homecuValidator.settings.statusSuccess);
1688  }
1689 
1690  }
1691  } else {
1692  error = "Error occurred on server that halted this operation.";
1693  $.homecuValidator.displayMessage(error, $.homecuValidator.settings.statusError);
1694  }
1695  },
1696 
1697  // code to run if the request fails; the raw request and
1698  // status codes are passed to the function
1699  error: function( e ) {
1700  }
1701  });
1702  }
1703 
1704  function UpdateBatchAmount( partnerId ) {
1705  // validate
1706  if ( Number.isInteger(partnerId) ) {
1707  var numerictextbox = $("#amount" + partnerId).data("kendoNumericTextBox");
1708  if ( numerictextbox ) {
1709  var value = numerictextbox.value();
1710  if ( value === null || value === undefined || value === "" ) {
1711  value = 0;
1712  }
1713 
1714  if ( $.isNumeric( value ) ) {
1715  SetBatchAmount( partnerId, value );
1716 
1717  ShowBatchTotal();
1718  } else {
1719  numerictextbox.value(0.00);
1720  }
1721  }
1722  }
1723  } // end UpdateBatchAmount
1724  function UpdateBatchAddenda( partnerId ) {
1725  // validate
1726  if ( Number.isInteger(partnerId) ) {
1727  var value = $("#addenda"+partnerId).val();
1728  SetBatchAddenda( partnerId, value );
1729  }
1730  } // end UpdateBatchAddenda
1731  function UpdateBatchNotify( partnerId ) {
1732  // validate
1733  if ( Number.isInteger(partnerId) ) {
1734  var value = $("#notify"+partnerId).prop("checked");
1735 
1736  SetBatchNotify( partnerId, value );
1737  }
1738  } // end UpdateBatchNotify
1739 
1740  function InitDataViews() {
1741  viewModel = kendo.observable({
1742  // these help control visuals
1743  showSingle: true,
1744  showBatch: false,
1745  showRecipient: false,
1746  showPayment: false,
1747  showNext: true,
1748  showBack: false,
1749  disableSaveButton: false,
1750  // these get sent to server
1751  action: "",
1752  achMyAcctSelected: "",
1753  achSubAcctSelected: 0,
1754  achAvailable: "",
1755  achEffDate: "",
1756  achBatchTotal: "",
1757  achType: "",
1758  achMemo: "",
1759  achTemplateName: "",
1760  achDFISelectedType: "",
1761  achUpdateTemplate: false,
1762  nextClick: function(e) {
1763  e.preventDefault();
1764 
1765  GoToNextTab();
1766  },
1767  backClick: function( e ) {
1768  e.preventDefault();
1769 
1770  // let them go back without validation
1771  $.homecuValidator.hideMessage();
1772 
1773  progressStep--;
1774 
1775  ShowThisStep( progressStep );
1776 
1777  // scroll to the top
1778  $("#content-wrapper").animate({ scrollTop: 0 }, { duration: 500 } );
1779  },
1780  cancel: function( e ) {
1781  e.preventDefault();
1782  <?php // go to self so can set correct cookie
1783  ?>
1784  document.formCancel.submit();
1785  }
1786  });
1787 
1788  // this is used with the add/edit partner information in editPartnerDialog template
1789  // NOTE: The model field names match the Single ACH model.
1790  editPartnerModel = kendo.observable({
1791  sourcePartner: null,
1792  sourceDirty: false,
1793  sourceDirtyInfo: false,
1794  sourceDirtyAddr: false,
1795  sourceDirtyAcct: false,
1796  showDelete: false,
1797  showDeleteWarn: false,
1798  listPartnerTypes: achPartnerTypes,
1799  listAccountTypes: achAccountTypes,
1800  listStates: achStateList,
1801  init: function(partnerInfo) {
1802  this.set("sourcePartner", partnerInfo);
1803 
1804  // setup validator
1805  $.homecuValidator.hideMessage();
1806  $.homecuValidator.setup({
1807  formValidate: "achPartnerEditor",
1808  formStatusField: "achPartnerStatus",
1809  });
1810 
1811  // bind data
1812  kendo.bind($("#achPartnerEditor"), this);
1813  },
1814  reset: function() {
1815  this.set("sourcePartner", null);
1816  this.set("sourceDirty", false);
1817  this.set("sourceDirtyInfo", false);
1818  this.set("sourceDirtyAddr", false);
1819  this.set("sourceDirtyAcct", false);
1820 
1821  $.homecuValidator.hideMessage();
1822  $.homecuValidator.setup({
1823  formValidate: "achEditTemplate",
1824  formStatusField: "formStatus"
1825  });
1826 
1827  // unbind data
1828  kendo.unbind($("#achPartnerEditor"));
1829  },
1830  save: function() {
1831  var otherErrors = [];
1832  // validate other non-required fields
1833  if (this.sourcePartner.zip != "") {
1834  // must validate zip code
1835  var zip = this.sourcePartner.zip;
1836  var zipReplace = zip.replace(/_/g, "");
1837  var zipSplit = zipReplace.split("-");
1838  var zipConstruct = "";
1839 
1840  // validate section 1, must be 5 digits
1841  if (zipSplit[0].length < 5) {
1842  otherErrors.push("<?php echo $MC->msg("Zip Code Invalid", HCU_DISPLAY_AS_JS) ?>");
1843  } else if (zipSplit.length > 1) {
1844  if (zipSplit[1].length > 0 && zipSplit[1].length < 4) {
1845  otherErrors.push("<?php echo $MC->msg("Zip Code Invalid", HCU_DISPLAY_AS_JS) ?>");
1846  }
1847  }
1848 
1849  // reconstruct zip code
1850  if (zipSplit[1]) {
1851  zipConstruct += zipSplit[0] + "-" + zipSplit[1];
1852  } else {
1853  zipConstruct += zipSplit[0];
1854  }
1855 
1856  this.set("sourcePartner.zip", zipConstruct);
1857  }
1858 
1859  if (this.sourcePartner.dfi_routing != "") {
1860  // must vlalidate routing number
1861  var routing = this.sourcePartner.dfi_routing;
1862  var routingReplace = routing.replace(/_/g, "");
1863 
1864  if (routingReplace.length < 9) {
1865  otherErrors.push("<?php echo $MC->msg("ACH Routing number 9 digits", HCU_DISPLAY_AS_HTML); ?>");
1866  }
1867 
1868  this.set("sourcePartner.dfi_routing", routingReplace);
1869  }
1870 
1871  $.homecuValidator.validate();
1872  var totalErrors = $.homecuValidator.homecuKendoValidator.errors();
1873 
1874  // cannot concat errors together because there may be duplicate errors
1875  for (var i = 0; i < otherErrors.length; i++) {
1876  if ($.inArray(otherErrors[i], totalErrors) == -1) {
1877  totalErrors.push(otherErrors[i]);
1878  }
1879  }
1880 
1881  if (totalErrors.length > 0) {
1882  $.homecuValidator.displayMessage(totalErrors, $.homecuValidator.settings.statusError);
1883  } else {
1884  var request = {
1885  action: this.sourcePartner.partner_id == 0 ?
1886  "add_ach_partner" :
1887  "update_ach_partner",
1888  display_name: this.sourcePartner.display_name,
1889  ach_name: this.sourcePartner.ach_name ?
1890  this.sourcePartner.ach_name :
1891  this.sourcePartner.display_name,
1892  email: this.sourcePartner.email,
1893  email_notify: this.sourcePartner.email_notify ? 1 : 0,
1894  partner_type: this.sourcePartner.partner_type,
1895  address1: this.sourcePartner.address1,
1896  address2: this.sourcePartner.address2,
1897  city: this.sourcePartner.city,
1898  state: this.sourcePartner.state,
1899  zip: this.sourcePartner.zip,
1900  country: this.sourcePartner.country,
1901  dfi_routing: this.sourcePartner.dfi_routing,
1902  dfi_account: this.sourcePartner.dfi_account,
1903  dfi_account_type: this.sourcePartner.dfi_account_type,
1904  partner_id: this.sourcePartner.partner_id,
1905  template_id: selectedTemplate
1906  };
1907 
1908  dsACHHelper.read( request );
1909  }
1910  },
1911  cancel: function(e) {
1912  editPartnerDialog.close();
1913  },
1914  change: function(e) {
1915  var target = null;
1916  var accordion = null;
1917 
1918  e.hasOwnProperty("sender") ?
1919  target = $(e.sender.element[0]) :
1920  target = $(e.target);
1921 
1922  accordion = target.closest(".achAccordionContent");
1923  accordionIndex = accordion.data("accordion-index");
1924 
1925  switch (accordionIndex) {
1926  case 0: this.set("sourceDirtyInfo", true); break;
1927  case 1: this.set("sourceDirtyAddr", true); break;
1928  case 2: this.set("sourceDirtyAcct", true); break;
1929  }
1930 
1931  // check if checkbox or label has been clicked
1932  $(target).parent().attr("for") == "achPartnerNotify" ||
1933  $(target).attr("name") == "achPartnerNotify" ?
1934  this.set("sourcePartner.email_notify", !this.sourcePartner.email_notify) :
1935  "";
1936 
1937  this.set("sourceDirty", true);
1938  }
1939  });
1940 
1941  editTemplateModel = kendo.observable({
1942  templateName: "",
1943  dirtyFlag: false,
1944  setDirty: function(e) {
1945  this.set("dirtyFlag", true);
1946  },
1947  SetTemplate: function( name ) {
1948  this.set( "templateName", name );
1949  this.set( "dirtyFlag", false );
1950  },
1951  ClearDirty: function() {
1952  this.set("dirtyFlag", false);
1953  }
1954  });
1955 
1956  // set up an error validator in case of an error
1957  $.homecuValidator.setup({formErrorTitle: "<?php echo $MC->msg("Error Occurred", HCU_DISPLAY_AS_JS) ?>"});
1958 
1959  partnerGrid = $('#partnerGrid').kendoGrid({
1960  dataSource: achTemplatePartnerList,
1961  autoBind: true,
1962  rowTemplate: kendo.template($("#partnerRow").html()),
1963  selectable: "cell",
1964  maxHeight: 300,
1965  change: function(e) {
1966  var selectedCell = this.select();
1967  var selectedRow = selectedCell.closest("tr");
1968  var cellIndex = selectedCell.index();
1969 
1970  if ( cellIndex <= 1 ) {
1971  checkbox = selectedRow.find("td:first input");
1972  checkbox.prop("checked", !checkbox.prop("checked"));
1973 
1974  var dataItem = partnerGrid.dataItem(selectedRow);
1975 
1976  // save the checked state
1977  SetPartnerInBatch( dataItem.partnerId, checkbox.prop("checked") );
1978  }
1979 
1980  selectedCell.removeClass( "k-state-selected" );
1981  },
1982  columns: [
1983  { field: "partnerId", width: 40, headerTemplate: "<span id='batchTip'><input id='checkAllForBatch' type='checkbox' /> <span class='fa fa-question-circle-o visible-xs-inline'></span></span>" },
1984  { field: "partnerName", title: "<?php echo $MC->msg("Name", HCU_DISPLAY_AS_JS); ?>" },
1985  { title: "<?php echo $MC->msg("Edit", HCU_DISPLAY_AS_JS); ?>", width: 65 }
1986  ],
1987  dataBound: function(e) {
1988  // tool tips
1989  homecuTooltip.bind({
1990  batchTip: "<?php echo $MC->msg("ACH Set All", HCU_DISPLAY_AS_JS) ?>",
1991  deleteTip: "<?php echo $MC->msg("ACH Remove from batch", HCU_DISPLAY_AS_JS) ?>",
1992  editTip: "<?php echo $MC->msg("ACH Edit partner", HCU_DISPLAY_AS_JS) ?>",
1993  updateTemplateTip: "<?php echo $MC->msg("ACH Update template help", HCU_DISPLAY_AS_JS) ?>",
1994  achPartnerNotifyTip: "<?php echo $MC->msg("ACH Notify Info Init", HCU_DISPLAY_AS_JS); ?>",
1995  achAmountNotifyTip: "<?php echo $MC->msg("ACH Notify Info Init", HCU_DISPLAY_AS_JS); ?>"
1996  });
1997  }
1998  }).data('kendoGrid');
1999 
2000  chooserGrid = $('#achPartnerChooser').kendoGrid({
2001  dataSource: achPartnerList,
2002  autoBind: true,
2003  selectable: "cell",
2004  scrollable: true,
2005  noRecords: {template: "<span class='hcu-sub-text'><?php echo $MC->msg("ACH No Partners", HCU_DISPLAY_AS_JS) ?></span>"},
2006  columns: [
2007  { field: "id",
2008  hidden: true },
2009  { field: "name",
2010  title: "<?php echo $MC->msg("Name", HCU_DISPLAY_AS_JS) ?>" }
2011  ],
2012  change: function(e) {
2013  var selectedCell = this.select();
2014  var selectedRow = selectedCell.closest("tr");
2015 
2016  var dataItem = chooserGrid.dataItem(selectedRow);
2017 
2018  // add selection to the template
2019  var selectedId = dataItem.id;
2020 
2021  if ( selectedId > 0 ) {
2022  var request = { action: "add_template_partner", partner_id: selectedId, template_id: selectedTemplate };
2023 
2024  dsACHHelper.read( request );
2025  }
2026  }
2027  }).data('kendoGrid');
2028 
2029  $("#templateList").kendoListView({
2030  dataSource: achTemplateList,
2031  selectable: false,
2032  template: kendo.template($("#templateTemplate").html()),
2033  dataBound: function() {
2034  // set the width of the template box to look more natural
2035  var boxWidth = $("#templateList").innerWidth();
2036  var columns = Math.trunc( boxWidth / 200);
2037  if ( columns > 0 ) {
2038  var templateWidth = Math.trunc(boxWidth / columns) - 22;
2039  $(".tmplMeta").width( templateWidth );
2040  }
2041  }
2042  });
2043 
2044  $("#achPartnerDD").kendoDropDownList({
2045  dataTextField: "name",
2046  dataValueField: "id",
2047  dataSource: achPartnerList,
2048  optionLabel: {id: "", name: "<?php echo $MC->msg("ACH Choose Partner", HCU_DISPLAY_AS_JS) ?>"},
2049  change: function(e) {
2050  // get the partner information from the server
2051  var selectedId = this.value();
2052  if ( selectedId > 0 ) {
2053  var request = { action: "add_template_partner", partner_id: selectedId, template_id: selectedTemplate };
2054 
2055  dsACHHelper.read( request );
2056  }
2057  }
2058  });
2059 
2060  $("#addPartnerButton").kendoButton({
2061  click: function(e) {
2062  var title = "<?php echo $MC->msg("ACH Add New Partner", HCU_DISPLAY_AS_JS) ?>";
2063 
2064  var defaultPartnerType = "<?php echo $initialPartnerType ?>";
2065 
2066  editPartnerModel.reset();
2067  editPartnerModel.init({
2068  partner_id: 0,
2069  partner_type: defaultPartnerType,
2070  ach_batch: false,
2071  ach_name: "",
2072  display_name: "",
2073  email: "",
2074  email_notify: false,
2075  address1: "",
2076  address2: "",
2077  city: "",
2078  state: "",
2079  zip: "",
2080  country: "",
2081  dfi_routing: "",
2082  dfi_account: "",
2083  dfi_account_confirm: "",
2084  dfi_account_type: ""
2085  });
2086 
2087  editPartnerDialog.title(title);
2088  editPartnerDialog.center();
2089  editPartnerDialog.open();
2090  }
2091  });
2092 
2093  $("#achSubAcctList").kendoDropDownList({
2094  dataTextField: "name",
2095  dataValueField: "id",
2096  dataSource: achSubAccounts,
2097  valueTemplate: '<span class="local-subleft">#: name #</span><span class="local-subright">#: amount #</span>',
2098  template: '<span class="k-state-default"><span class="local-subleft local-subname">#: name #</span><span class="local-subright">#: amount #</span></span>',
2099  optionLabel: {name: "<?php echo $MC->msg("ACH Select Account", HCU_DISPLAY_AS_JS) ?>", id: "", amount: ""},
2100  change: function(e) {
2101  var dataIndex = this.selectedIndex > 0 ? this.selectedIndex-1 : 0;
2102  var dataSource = this.dataSource.data();
2103  var dataItem = dataSource[dataIndex];
2104 
2105  var selectedAccount = dataItem.account;
2106  var selectedAvailable = dataItem.amount.substring(1);
2107  viewModel.set("achMyAcctSelected", selectedAccount);
2108  viewModel.set("achAvailable", selectedAvailable);
2109  }
2110  });
2111 
2112  // set up the date picker to also be a masked text box
2113  effDatePicker = $("#achEffDate");
2114  effDatePicker.kendoMaskedTextBox({
2115  mask: "00/00/0000"
2116  });
2117  effDatePicker.kendoDatePicker({
2118  min: Date(),
2119  format: "MM/dd/yyyy"
2120  });
2121  effDatePicker.closest(".k-datepicker").add(effDatePicker).removeClass("k-textbox");
2122 
2123  $("#achPartnerFilter").kendoMultiSelect({
2124  dataTextField: "display",
2125  dataValueField: "type",
2126  placeholder: "<?php echo $MC->msg("ACH Select Types", HCU_DISPLAY_AS_JS); ?>",
2127  dataSource: achPartnerTypes,
2128  dataBound: function( e ) {
2129  var multiselect = $("#achPartnerFilter").data("kendoMultiSelect");
2130 
2131  multiselect.value(["<?php echo $initialPartnerType ?>"]);
2132  },
2133  change: function( e ) {
2134  HandleUpdatedPartnerList();
2135  }
2136  });
2137 
2138  // set up initial state
2139  if ( "<?php echo $initialPartnerType ?>" === "e" ) {
2140  $("#achPartnerFilterPayee").prop( "checked", true );
2141  $("#achPartnerFilterPayroll").prop( "checked", true );
2142  $("#achPartnerFilterUnassigned").prop( "checked", true );
2143  } else if ( "<?php echo $initialPartnerType ?>" === "r" ) {
2144  $("#achPartnerFilterPayor").prop( "checked", true );
2145  $("#achPartnerFilterUnassigned").prop( "checked", true );
2146  } else {
2147  $("#achPartnerFilterUnassigned").prop( "checked", true );
2148  }
2149 
2150  // set up the partner filter
2151  $(".partner-filter-chooser").click( function() {
2152  HandleUpdatedPartnerList();
2153  });
2154 
2155  // handle clicking on the tab strip
2156  $("#step1").click( function(e) {
2157  e.preventDefault();
2158  HandleNavClick(1);
2159  });
2160  $("#step2").click( function(e) {
2161  e.preventDefault();
2162  HandleNavClick(2);
2163  });
2164  $("#step3").click( function(e) {
2165  e.preventDefault();
2166  HandleNavClick(3);
2167  });
2168  $("#step4").click( function(e) {
2169  e.preventDefault();
2170  HandleNavClick(4);
2171  });
2172 
2173  $('#formChangeType').change(function(){
2174  $('#formChangeType').submit();
2175  });
2176 
2177  $("#checkAllForBatch").click( function() {
2178  var state = $("#checkAllForBatch").prop( "checked" );
2179  $(".in-batch-checkbox").prop( "checked", state );
2180 
2181  // now set each entry in the array
2182  for ( var i = 0; i < achTemplatePartnerList.length; i++ ) {
2183  achTemplatePartnerList[i].inBatch = state;
2184  }
2185  });
2186 
2187  // set up an event to save the data
2188  viewModel.bind( "save", function(e) {
2189  viewModel.achServer.read();
2190  });
2191 
2192  // set up an event to reset the data
2193  viewModel.bind( "reset", function(e) {
2194  ClearPaymentInfo();
2195  });
2196 
2197  // bind the visual to the view model
2198  kendo.bind($("#ach-payment"), viewModel);
2199 
2200  // set up the progress bar
2201  $("#progressBar").kendoProgressBar({
2202  type: "value",
2203  min: 0,
2204  max: 4,
2205  value: 1,
2206  change: function( e ) {
2207  progressSteps = $("#progressBar").data("kendoProgressBar");
2208  progressSteps.progressStatus.text( "(" + progressSteps.value() + " / 4)" );
2209  }
2210  });
2211  progressSteps = $("#progressBar").data("kendoProgressBar");
2212  progressSteps.progressStatus.text( "(1 / 4)" );
2213  // start at first step
2214  progressSteps.value( 1 );
2215  progressStep = 1;
2216  ShowThisStep( progressStep );
2217 
2218  deleteDialog = $("#deleteDialog").kendoDialog({
2219  visible: false,
2220  title: "<?php echo $MC->msg("ACH Delete Template", HCU_DISPLAY_AS_JS) ?>",
2221  content: "<p>" + "<?php echo $MC->msg("ACH Continue delete", HCU_DISPLAY_AS_JS) ?>" + "</p><p>" + "<?php echo $MC->msg("ACH Continue", HCU_DISPLAY_AS_JS) ?>" + "</p>",
2222  show: function(e) {
2223  // add the close function to the window stack
2224  window_stack.push(function(e) {
2225  deleteDialog.close(e);
2226  });
2227  },
2228  close: function(e) {
2229  // remove the close function from the window stack
2230  window_stack.pop();
2231  },
2232  actions: [{text: "<?php echo $MC->msg("Cancel", HCU_DISPLAY_AS_JS) ?>"},
2233  {
2234  text: "<?php echo $MC->msg("ACH Continue", HCU_DISPLAY_AS_JS) ?>",
2235  action: function(e){
2236  DeleteACHTemplate();
2237 
2238  // Returning false will prevent the closing of the dialog
2239  return true;
2240  },
2241  primary: true
2242  }]
2243  }).data("kendoDialog");
2244 
2245  editTemplateDialog = $("#editDialog").kendoDialog({
2246  visible: false,
2247  title: "<?php echo $MC->msg("ACH Edit Template Name", HCU_DISPLAY_AS_JS) ?>",
2248  content: "<div id='editTemplate' class='form-group hcu-form-group-spacer'>" +
2249  "<div id='editFormStatus' class='homecu-formStatus k-block k-error-colored' style='display:none; margin-bottom:10px;max-width:800px;'></div>" +
2250  "<label class='col-xs-12' for='templateNameUpdate'><?php echo $MC->msg("ACH Template Name", HCU_DISPLAY_AS_JS) ?></label>" +
2251  "<div class='col-xs-12'>" +
2252  "<input id='templateNameUpdate' \
2253  name='templateNameUpdate' \
2254  maxlength='100' \
2255  data-bind='value: templateName, events:{change: setDirty}' \
2256  placeholder='<?php echo $MC->msg("ACH Template Name required", HCU_DISPLAY_AS_JS) ?>' \
2257  type='text' \
2258  class='k-textbox k-autocomplete hcu-all-100' \
2259  required \
2260  validationMessage = '<?php echo $MC->msg("ACH Template Name required", HCU_DISPLAY_AS_JS) ?>' \
2261  autocomplete='off'/>" +
2262  "</div>" +
2263  "</div>" +
2264  "<br><br><br>",
2265  open: function(e) {
2266  editTemplateModel.ClearDirty();
2267  },
2268  show: function(e) {
2269  // focus
2270  $("#templateNameUpdate").focus();
2271 
2272  // validation
2273  $.homecuValidator.setup( {formStatusField: "editFormStatus", formValidate: "editTemplate"} );
2274 
2275  // now that the dialog is visible, bind to the view model
2276  kendo.bind($("#editTemplate"), editTemplateModel);
2277 
2278  // add the close function to the window stack
2279  window_stack.push(function(e) {
2280  if ( editTemplateModel.dirtyFlag ) {
2281  discardDialog.open();
2282  } else {
2283  editTemplateDialog.close(e);
2284  }
2285  });
2286  },
2287  close: function(e) {
2288  // REVERT Form Status back to main FORM
2289  $.homecuValidator.setup({formStatusField: 'formStatus'});
2290 
2291  // now remove the close function call
2292  window_stack.pop();
2293  },
2294  actions: [
2295  {
2296  text: "<?php echo $MC->msg("Cancel", HCU_DISPLAY_AS_JS) ?>",
2297  action: function(e){
2298  if ( editTemplateModel.dirtyFlag ) {
2299  discardDialog.open();
2300  return false;
2301  }
2302  }
2303  },
2304  {
2305  text: "<?php echo $MC->msg("Save", HCU_DISPLAY_AS_JS) ?>",
2306  action: function(e){
2307  // validate the name
2308  if ( $.homecuValidator.validate() ) {
2309  // update the new template name
2310  UpdateACHTemplate();
2311 
2312  return true;
2313  }
2314  return false;
2315  },
2316  primary: true
2317  }]
2318  }).data("kendoDialog");
2319 
2320  removePartnerDialog = $("#removePartnerDialog").kendoDialog({
2321  visible: false,
2322  title: "<?php echo $MC->msg("ACH Remove Partner", HCU_DISPLAY_AS_JS) ?>",
2323  content: "",
2324  show: function(e) {
2325  // add the close function to the window stack
2326  window_stack.push(function(e) {
2327  removePartnerDialog.close(e);
2328  });
2329  },
2330  close: function(e) {
2331  // remove the close function from the window stack
2332  window_stack.pop();
2333  },
2334  actions: [{text: "<?php echo $MC->msg("Cancel", HCU_DISPLAY_AS_JS) ?>"},
2335  {
2336  text: "<?php echo $MC->msg("ACH Continue", HCU_DISPLAY_AS_JS) ?>",
2337  action: function(e){
2338  var partnerId = $("#removePartnerId").val();
2339  RemovePartner( partnerId );
2340 
2341  // Returning false will prevent the closing of the dialog
2342  return true;
2343  },
2344  primary: true
2345  }]
2346  }).data("kendoDialog");
2347 
2348  uploadCSVDialog = $("#csvDialog").kendoDialog({
2349  visible: false,
2350  maxWidth: 600,
2351  minWidth: 300,
2352  title: "<?php echo $MC->msg("CSV File", HCU_DISPLAY_AS_JS) ?>",
2353  content: "<div class='k-content'>" +
2354  " <div id='uploadCustomContent'></div>" +
2355  " <br /><br />" +
2356  " <h4><?php echo $MC->msg("ACH Upload CSV File", HCU_DISPLAY_AS_JS); ?></h4>" +
2357  " <div class='dropZoneArea'>" +
2358  " <input id='csvFile' name='csvFile' type='file'>" +
2359  " </div>" +
2360  " <div class='upload-hint'><?php echo $MC->msg("ACH Upload CSV Max", HCU_DISPLAY_AS_JS); ?></div>" +
2361  " <div class='upload-hint'><?php echo $MC->msg("ACH Upload CSV Select", HCU_DISPLAY_AS_JS); ?></div>" +
2362  "</div>",
2363  open: function(e) {
2364  },
2365  show: function(e) {
2366  // add the custom content
2367  if (noticeCsv) {
2368  ShowNotice('<?php echo $noticeURLCSV; ?>', "<?php echo $noticeLinkDisplayCSV ?>",
2369  function() {
2370  // because most notices only show on page load
2371  // we set this to false to only show it once even if
2372  // 'don't tell me again' is not selected.
2373 
2374  // the user could possibly click the link more than
2375  // one time, there is no reason to show more than once.
2376  noticeCsv = false;
2377  }
2378  );
2379  }
2380 
2381  // hide any previous CSV file links
2382  csvNotMatched = null;
2383  $("#csvNotMatched").hide();
2384  csvNotSelected = null;
2385  $("#csvNotSelected").hide();
2386 
2387  // create the upload widget if not yet created
2388  if ( !uploadWidget ) {
2389  uploadWidget = $("#csvFile").kendoUpload({
2390  async: {
2391  saveUrl: 'hcuACH.data?cu=<?php echo $HB_ENV['cu']; ?>&action=csv&template_id=' + selectedTemplate
2392  },
2393  multiple: false,
2394  localization: {
2395  dropFilesHere: "Drop file here, or select one for upload.",
2396  select: "Select CSV File"
2397  },
2398  validation: {
2399  allowedExtensions: [".csv", ".txt"],
2400  maxFileSize: 100 * 1024
2401  },
2402  upload: function(e) {
2403  },
2404  complete: function(e) {
2405  },
2406  success: function(e) {
2407  var serverReply = e.response.Results.homecuData.csv;
2408  var upload = $("#csvFile").data("kendoUpload");
2409  upload.clearAllFiles();
2410  uploadCSVDialog.close();
2411 
2412  // simulate the "Next" click
2413  NextClickedByCSVSuccess();
2414  PopulateBatchGridUsingCSV( serverReply.found );
2415 
2416  // save the other lists
2417  csvNotMatched = null;
2418  if ( serverReply.not_found.length > 0 ) {
2419  csvNotMatched = serverReply.not_found;
2420  $("#csvNotMatched").show();
2421  }
2422 
2423  csvNotSelected = null;
2424  if ( serverReply.missed.length > 0 ) {
2425  csvNotSelected = serverReply.missed;
2426  $("#csvNotSelected").show();
2427  }
2428  }
2429  });
2430 
2431  // apply the style since it wasn't in the DOM earlier
2432  $("div.k-dropzone em").css("visibility", "visible");
2433  }
2434 
2435  // add the close function to the window stack
2436  window_stack.push(function(e) {
2437  uploadCSVDialog.close(e);
2438  });
2439  },
2440  close: function(e) {
2441  // now remove the close function call
2442  window_stack.pop();
2443  },
2444  actions: [
2445  {
2446  text: "<?php echo $MC->msg("Close", HCU_DISPLAY_AS_JS) ?>",
2447  action: function(e){
2448  uploadCSVDialog.close(e);
2449  },
2450  primary: true
2451  }]
2452  }).data("kendoDialog");
2453 
2454  // This is used for both adding and editing a Partner
2455  var maxHeight = parseInt($(window).height() * .85, 10);
2456  var editPartnerTemplate = $("#achPartnerEditorTmp").html();
2457  editPartnerDialog = $(editPartnerTemplate).kendoWindow({
2458  width: "85%",
2459  minWidth: "300px",
2460  maxWidth: "750px",
2461  maxHeight: maxHeight,
2462  modal: true,
2463  visible: false,
2464  resizable: false,
2465  activate: function() {
2466  window_stack.push(function(e) {
2467  if ( editPartnerModel.sourceDirty ) {
2468  e.preventDefault();
2469  discardDialog.open();
2470  } else {
2471  editPartnerDialog.close(e);
2472  }
2473  });
2474  $("#achPartnerEditor").scrollTop(0);
2475  },
2476  close: function(e) {
2477  // remove window from stack
2478  if (editPartnerModel.sourceDirty) {
2479  var fn = window_stack[window_stack.length-1];
2480  var rtrn = fn(e);
2481  } else {
2482  window_stack.pop();
2483  $.homecuValidator.setup({
2484  formValidate: "achEditTemplate",
2485  formStatusField: "formStatus"
2486  });
2487  }
2488  }
2489  }).data("kendoWindow");
2490 
2491  // This is used to show both the partners not selected and the partners not matched.
2492  csvInfoDialog = $("#csvInfoDialog").kendoDialog({
2493  visible: false,
2494  title: "",
2495  content: "",
2496  minWidth: 350,
2497  show: function(e) {
2498  // add the close function to the window stack
2499  window_stack.push(function(e) {
2500  csvInfoDialog.close(e);
2501  });
2502  },
2503  close: function(e) {
2504  // remove the close function from the window stack
2505  window_stack.pop();
2506  },
2507  actions: [{text: "<?php echo $MC->msg("Close", HCU_DISPLAY_AS_JS) ?>",
2508  primary: true}]
2509  }).data("kendoDialog");
2510 
2511  discardDialog = $("#discardDialog").kendoDialog({
2512  visible: false,
2513  title: "<?php echo $MC->msg("ACH Discard Changes?", HCU_DISPLAY_AS_JS) ?>",
2514  content: "<?php echo $MC->msg("ACH Discard changes warning", HCU_DISPLAY_AS_JS) ?>" + "<br><br>" + "<?php echo $MC->msg("ACH Continue", HCU_DISPLAY_AS_JS) ?>",
2515  show: function(e) {
2516  // add the close function to the window stack
2517  window_stack.push(function(e) {
2518  discardDialog.close(e);
2519  });
2520  },
2521  close: function(e) {
2522  // remove the close function from the window stack
2523  window_stack.pop();
2524  },
2525  actions: [{
2526  text: "<?php echo $MC->msg("Cancel", HCU_DISPLAY_AS_JS) ?>",
2527  action: function(e) {
2528  // ** Close the current dialog
2529  }
2530  }, {
2531  text: "<?php echo $MC->msg("ACH Continue", HCU_DISPLAY_AS_JS) ?>",
2532  primary: true,
2533  action: function(e) {
2534  // clear any dirty flags
2535  editTemplateModel.ClearDirty();
2536  editPartnerModel.reset();
2537 
2538  // remove this dialog's close
2539  window_stack.pop();
2540 
2541  /* ** DISCARD CHANGES by calling prior window's close ** */
2542  var fn = window_stack[window_stack.length - 1];
2543  var ret = fn(e);
2544  }
2545  }]
2546  }).data("kendoDialog");
2547 
2548  // This is used in the edit dialog but needs to be outside of the Show event so
2549  // it won't get duplicated.
2550  $("#achPartnerType").kendoDropDownList({
2551  dataTextField: "display",
2552  dataValueField: "type",
2553  dataSource: achPartnerTypes
2554  });
2555 
2556  // handle clicking on the ach type button group
2557  $("#achTypeSingle").click( function(e) {
2558  $("#achFeatureChoice").val( "<?php echo $batchButton ?>" );
2559  $("#formChangeType").submit();
2560  });
2561 
2562  // set up masks this way because mvvm mask for digits doesn't work
2563  $("input[name=\"achPartnerZip\"]").kendoMaskedTextBox({
2564  mask: "00000-9999",
2565  clearPromptChar: true
2566  });
2567 
2568  $("input[name=\"achPartnerRouting\"]").kendoMaskedTextBox({
2569  mask: "000000000",
2570  clearPromptChar: true
2571  });
2572 
2573  kendo.data.binders.required = kendo.data.Binder.extend({
2574  refresh: function() {
2575  var required = this.bindings.required.get();
2576  if (required) {
2577  this.element.setAttribute("required", "required");
2578  } else {
2579  this.element.removeAttribute("required");
2580  }
2581  }
2582  });
2583 
2584  $("#csvUploaderLink").click(function() {
2585  uploadCSVDialog.open();
2586  });
2587 
2588  $("#csvNotSelected").click(function() {
2589  // set the title
2590  var title = "<?php echo $MC->msg("ACH Not Selected", HCU_DISPLAY_AS_JS) ?>";
2591 
2592  // build up the content
2593  var content = "";
2594 
2595  if ( csvNotSelected && csvNotSelected.length ) {
2596  content = content + "<ul style='list-style: none'>";
2597 
2598  for ( var i = 0; i < csvNotSelected.length; i++ ) {
2599  content = content + "<li>" + csvNotSelected[i] + "</li>";
2600  }
2601 
2602  content = content + "</ul>";
2603  } else {
2604  content = content + "<?php echo $MC->msg("None", HCU_DISPLAY_AS_JS) ?><br><br>";
2605  }
2606 
2607  csvInfoDialog.title(title).content(content).open();
2608  });
2609 
2610  $("#csvNotMatched").click(function() {
2611  // set the title
2612  var title = "<?php echo $MC->msg("ACH Not Matched", HCU_DISPLAY_AS_JS) ?>";
2613 
2614  // build up the content
2615  var content = "";
2616 
2617  if ( csvNotMatched && csvNotMatched.length ) {
2618  content = content + "<ul style='list-style: none'>";
2619 
2620  for ( var i = 0; i < csvNotMatched.length; i++ ) {
2621  content = content + "<li>" + csvNotMatched[i] + "</li>";
2622  }
2623 
2624  content = content + "</ul>";
2625  } else {
2626  content = content + "<?php echo $MC->msg("None", HCU_DISPLAY_AS_JS) ?><br><br>";
2627  }
2628 
2629  csvInfoDialog.title(title).content(content).open();
2630  });
2631 
2632  homecuTooltip.bind({
2633  companyNameTip: "<?php echo $MC->msg("ACH Company Name Help", HCU_DISPLAY_AS_JS) ?>"
2634  });
2635 
2636  // Confirmation dialog
2637  $("#confirmationWindow").kendoDialog({
2638  title: "<?php echo $MC->msg('ACH Batch Confirmation'); ?>",
2639  width: "85%",
2640  maxWidth: "768px",
2641  minWidth: "300px",
2642  modal: true,
2643  visible: false,
2644  resizable: false,
2645  actions: [
2646  {
2647  text: "<?php echo $MC->msg('Close', HCU_DISPLAY_AS_JS); ?>",
2648  primary: true
2649  }
2650  ],
2651  show: function(e) {
2652  windowStack.push(this);
2653  },
2654  close: function(e) {
2655  windowStack.pop();
2656 
2657  // Reset to step one for another transfer
2658 
2659 
2660  // Reset validator to use page status field.
2661  $.homecuValidator.settings.formStatusField = "formStatus";
2662  $.homecuValidator.settings.formInfoTitle = "";
2663  }
2664  });
2665  }
2666 
2667  function InitScreen() {
2668  InitDataSources();
2669  InitDataViews();
2670 
2671  // initialize then display
2672  $("#ach-payment").show();
2673  }
2674 
2675  function ShowConfirmation(txn) {
2676  var confirmationTemplate = kendo.template($("#confirmationTemplate").html());
2677  var confirmationDisplay = confirmationTemplate(txn);
2678 
2679  $("#confirmationWindow").data("kendoDialog").content(confirmationDisplay);
2680  $("#confirmationWindow").data("kendoDialog").open();
2681  }
2682 
2683  $(document).ready(function(){
2684  if (terms) {
2685  ShowNotice('<?php echo $termsURLACH; ?>', "<?php echo $termsLinkDisplayACH ?>",
2686  function() {
2687  InitScreen();
2688  if (notice) {
2689  ShowNotice('<?php echo $noticeURLACH; ?>', "<?php echo $noticeLinkDisplayACH ?>");
2690  }
2691  },
2692  function() {
2693  // if they do not accept, send them to banking accounts screen
2694  ShowWaitWindow();
2695 
2696  var urlInit = window.location.href.substring(0, window.location.href.indexOf("hcu"));
2697  var urlCu = "<?php echo $Cu ?>";
2698  var urlPage = "hcuAccounts.prg";
2699  var urlRedirect = urlInit + urlPage + "?cu=" + urlCu;
2700 
2701  window.location.replace(urlRedirect);
2702  }
2703  );
2704  } else if (notice) {
2705  InitScreen();
2706  ShowNotice('<?php echo $noticeURLACH; ?>', "<?php echo $noticeLinkDisplayACH ?>");
2707  } else {
2708  InitScreen();
2709  }
2710  }); // end ready function
2711 
2712  // Handle clicking on the overlay
2713  $(document).on("click", ".k-overlay", function (e) {
2714  if(windowStack.length > 0) {
2715  // get the close function from the stack, without poping it (the close will pop it)
2716  var win = windowStack[windowStack.length - 1];
2717  win.close();
2718  }
2719  });
2720 </script>
2721 
2722 <div id="confirmationWindow"></div>
2723 <div id="disclosureWindow" name="disclosureWindow"></div>
2724 <style type="text/css">
2725 /**
2726  * Tab directives:
2727  */
2728  .local-subleft { float:left; }
2729  .local-subname { font-weight: 500; }
2730  .local-subright { float:right; }
2731 
2732  .tabFooter > div {
2733  border-top: 2px solid rgba(0,0,0,.37);
2734  }
2735 
2736  .tabSpacer {
2737  margin-top: 10px;
2738  }
2739  .tabHide {
2740  display:none;
2741  }
2742  #ach-payment {
2743  max-width: 700px;
2744  margin-left: 0px;
2745  }
2746  #templateList {
2747  padding: 10px 5px;
2748  margin-bottom: -1px;
2749  max-width: 800px;
2750  }
2751  .tmpl {
2752  float: left;
2753  position: relative;
2754  margin: 5px;
2755  padding: 5px;
2756  border: 1px solid black;
2757  border-radius: 5px;
2758  }
2759  .tmplMeta {
2760  height: 150px;
2761  width: 200px;
2762  overflow-y: scroll;
2763  overflow-x: scroll;
2764  }
2765  .tmpl h3 {
2766  margin: 0;
2767  padding: 3px 5px 0 0;
2768  white-space: nowrap;
2769  line-height: 1.2em;
2770  font-size: 1em;
2771  font-weight: 600;
2772  text-transform: uppercase;
2773  color: rgba(0,0,0,.56);
2774  }
2775  .tmpl p {
2776  margin: 0;
2777  padding: 3px 5px 0 0;
2778  white-space: nowrap;
2779  font-size: .8em;
2780  font-weight: normal;
2781  color: rgba(0,0,0,.56);
2782  }
2783  .tmpl .p#add-template {
2784  color: green;
2785  }
2786  .k-listview:after {
2787  content: ".";
2788  display: block;
2789  height: 0;
2790  clear: both;
2791  visibility: hidden;
2792  }
2793  div.icon-container {
2794  position: relative;
2795  height: 1em;
2796  }
2797 
2798  div.left-icon {
2799  position: absolute;
2800  bottom: 10px;
2801  left: 10px;
2802  }
2803  div.right-icon {
2804  position: absolute;
2805  bottom: 10px;
2806  right: 10px;
2807  }
2808  .k-grid .k-grid-content tr:hover {
2809  cursor: pointer;
2810  }
2811  .k-grid .partner-details, .k-grid .partner-edits {
2812  border-left-width: 0;
2813  }
2814  .partner-details .partner-name {
2815  font-weight: 600;
2816  }
2817  .partner-details .partner-address {
2818  color: rgba(0,0,0,.87);
2819  font-size: smaller;
2820  font-weight: 400;
2821  float: right;
2822  }
2823  .partner-edits a {
2824  padding-left: 5px;
2825  }
2826 
2827  #achPartnerChooser .k-grid-content {
2828  max-height: 120px;
2829  }
2830 
2831  .hcu-scrolling-dialog {
2832  overflow-y: auto;
2833  }
2834  .hcu-sub-text {
2835  color: rgba(0,0,0,.54);
2836  }
2837  .ach-title {
2838  font-size: 24px;
2839  font-weight: 500;
2840  margin-top: 5px;
2841  margin-bottom: 5px;
2842  }
2843  .ach-switch-button {
2844  margin-bottom: 15px;
2845  }
2846  .csv-uploader-style, .csv-not-matched-style {
2847  text-align: right;
2848  }
2849  .local-link-style a:link, a:visited, a:hover, a:active {
2850  text-decoration: none;
2851  cursor: pointer;
2852  }
2853  .local-sm-align-right {
2854  text-align:left;
2855  }
2856 
2857  /* dropzone customization */
2858  div.k-dropzone {
2859  border: 0px solid;
2860  }
2861 
2862  .dropZoneArea .k-dropzone-active {
2863  border: 1px solid red;
2864  }
2865 
2866  .dropZoneArea .k-dropzone-active.k-dropzone-hovered {
2867  border: 1px solid green;
2868  }
2869 
2870  .upload-hint {
2871  line-height: 22px;
2872  color: #aaa;
2873  font-style: italic;
2874  font-size: .9em;
2875  padding-top: 1em;
2876  }
2877 
2878  /* Small devices @screen-sm-min (tablets, 768px and up) */
2879  @media (min-width: 768px) {
2880  .local-sm-align-right {
2881  text-align: right;
2882  }
2883  }
2884 
2885  /* Medium devices @screen-md-min (desktops, 992px and up) */
2886  @media (min-width: 992px) {
2887  }
2888 
2889  .response-label {
2890  font-weight: bold;
2891  }
2892 
2893  .local-transfer-msg {
2894  padding: 1em;
2895  }
2896  </style>
2897  <script type="text/x-kendo-template" id="templateTemplate">
2898  <div class="tmpl">
2899  <div class="tmplMeta" onClick='javascript:SelectTemplate(#= templateId #);'>
2900  <h3>#:templateName#</h3>
2901  # if ( templateId == -1 ) { #
2902  <p id="add-template"><?php echo $MC->msg("ACH Click add template", HCU_DISPLAY_AS_HTML) ?></p>
2903  # } else { #
2904  <p>Last edit <b>#:templateMeta.last_edit#</b></p>
2905  <p>Submitted <b>#:templateMeta.last_proc#</b></p>
2906  <p>Template Total <b>#:kendo.toString(templateMeta.total, "c")#</b></p>
2907  <p>Partners <b>#:templateMeta.count#</b></p>
2908  <p>Type <b>#:templateMeta.type#</b></p>
2909  <p>&nbsp;</p>
2910  <p>&nbsp;</p>
2911  # } #
2912  </div>
2913  # if ( templateId != -1 ) { #
2914  <div id="icon-container">
2915  <a href="javascript:ShowDeleteTemplate('#= templateId #')"><div class="left-icon fa fa-trash"></div></a>
2916  <a href="javascript:ShowEditTemplate('#= templateId #')"><div class="right-icon fa fa-pencil"></div></a>
2917  </div>
2918  # } #
2919  </div>
2920  </script>
2921  <script id="partnerRow" type="text/x-kendo-template">
2922  <tr>
2923  <td>
2924  <label>
2925  <input type="checkbox" # if ( inBatch ) { # CHECKED # } # class="in-batch-checkbox" name="inBatch" value="1" onClick="javascript: SetPartnerInBatch( #:partnerId#, this.checked);">
2926  </label>
2927  </td>
2928  <td class="partner-details">
2929  <span class="partner-name">#: partnerDisplayName#</span>
2930  <span class="partner-address">#: showPartnerAddress#</span><br>
2931  </td>
2932  <td class="partner-edits">
2933  <a href="javascript:ShowRemovePartner('#= partnerId #')"><div id="deleteTip" class="fa fa-trash"></div></a>
2934  <a href="javascript:ShowEditPartner('#= partnerId #')"><div id="editTip" class="fa fa-pencil"></div></a>
2935  </td>
2936  </tr>
2937  </script>
2938  <script id="batchTemplate" type="text/x-kendo-template">
2939  # for (var i = 0; i < data.length; i++) { #
2940  <div class="form-group">
2941  <div class="col-xs-12 visible-xs-block h4">#= data[i].name#</div>
2942  <div class="col-sm-3 hidden-xs">#= data[i].name#</div>
2943  <label class="col-xs-12 visible-xs-block"><?php echo $MC->msg("Amount", HCU_DISPLAY_AS_JS) ?></label>
2944  <div class="col-xs-12 col-sm-3"><input value="#: kendo.toString(data[i].amount, '0.00') #" type="text" pattern="" id="amount#: data[i].id#" class="hcu-all-100 batch-amount" maxlength="15" required></div>
2945  <label class="col-xs-12 visible-xs-block"><?php echo $MC->msg("ACH Addenda", HCU_DISPLAY_AS_JS) ?></label>
2946  <div class="col-xs-12 col-sm-4"><input value="#: data[i].addenda #" type="text" id='addenda#: data[i].id#' class="k-textbox hcu-all-100" maxlength="100" onchange="javascript:UpdateBatchAddenda(#: data[i].id#)"></div>
2947  <label class="col-xs-12 visible-xs-block"><?php echo $MC->msg("Notify", HCU_DISPLAY_AS_JS) ?></label>
2948  <div class="col-xs-12 col-sm-2"><input value='1' # if ( data[i].notify ) {# CHECKED #}# type="checkbox" id='notify#: data[i].id#' onchange="javascript:UpdateBatchNotify(#: data[i].id#)" # if (data[i].disable) {# DISABLED #}#></div>
2949  </div>
2950  # } #
2951  </script>
2952 
2953  <div id="deleteDialog"></div>
2954  <div id="editDialog"></div>
2955  <div id="discardDialog"></div>
2956  <div id="successDialog"></div>
2957  <div id="removePartnerDialog"></div>
2958  <div id="csvDialog"></div>
2959  <div id="csvInfoDialog"></div>
2960  <div class="k-content container-fluid" id="ach-payment" style="display: none;">
2961  <div class='ach-title'><?php echo $pageTitle ?></div>
2962  <form method="post" id="formChangeType" name="formChangeType" action='<?php echo $HB_ENV["loginpath"]."/{$HB_ENV['currentscript']}?".$HB_ENV["cuquery"] ?>'>
2963  <input type='hidden' id="achFeatureChoice" name='ach_feature' value='' />
2964  </form>
2965  <div class="col-xs-12">
2966  <div class="row">
2967  <div class="col-xs-4 ach-switch-button">
2968  <div class="btn-group" role="group" aria-label="...">
2969  <button type="button" id="achTypeSingle" class="btn btn-default"><?php echo $MC->msg("ACH Single", HCU_DISPLAY_AS_HTML); ?></button>
2970  <button type="button" id="achTypeBatch" class="btn btn-primary"><?php echo $MC->msg("ACH Batch", HCU_DISPLAY_AS_HTML); ?></button>
2971  </div>
2972  </div>
2973 
2974  <div class="col-xs-8 text-right">
2975  <label><?php echo $MC->msg("ACH Company Name Label", HCU_DISPLAY_AS_HTML); ?>: <span class="fa fa-question-circle-o" id="companyNameTip"></span></label><br>
2976  <span> <?php echo $companyData['group_name']; ?></span>
2977  </div>
2978  </div>
2979  </div>
2980  <div class="row">
2981  <div class="col-xs-12">
2982  <div id="stepName"><?php echo $progressStep1; ?></div>
2983  </div>
2984  </div>
2985  <div class="row">
2986  <div class="col-xs-12">
2987  <div id="progressBar" class="hcu-all-100"></div>
2988  </div>
2989  </div>
2990  <div class="row">
2991  <div class="col-xs-12">&nbsp;</div>
2992  </div>
2993  <?php // this tab is for choosing a template
2994  ?>
2995  <div class="tabTemplate tabHide" id="achTemplate">
2996  <div class="tabContents">
2997  <div class="well well-sm">
2998  <div id="templateList"></div>
2999  </div>
3000  </div>
3001  </div>
3002  <?php // this tab is for editing the template
3003  ?>
3004  <div class="tabPayment tabHide" id="achEditTemplate">
3005  <div class="tabContents">
3006  <div class="form-horizontal">
3007  <div class="well well-sm">
3008  <div class="form-group">
3009  <label class="col-sm-4 col-xs-12 control-label"><?php echo $MC->msg("ACH Type", HCU_DISPLAY_AS_HTML); ?><span class="hcu-required-field"><sup>*</sup></span></label>
3010  <div class="col-sm-8 col-xs-12">
3011  <label class="radio-inline">
3012  <input type='radio'
3013  name='ach_entry_type'
3014  value='PPD'
3015  data-bind="checked: achType"
3016  required>&nbsp;<?php echo $MC->msg("ACH PPD", HCU_DISPLAY_AS_HTML); ?>
3017  </label>
3018  <label class="radio-inline">
3019  <input type='radio' name='ach_entry_type' value='CCD' data-bind="checked: achType">&nbsp;<?php echo $MC->msg("ACH CCD", HCU_DISPLAY_AS_HTML); ?>
3020  </label>
3021  </div>
3022  </div>
3023  <div class="form-group">
3024  <div class="hidden-xs col-sm-4">&nbsp;</div>
3025  <div class="col-xs-12 col-sm-8"><span class="hcu-required-field"><sup>*</sup></span><?php echo $MC->msg("ACH Required", HCU_DISPLAY_AS_HTML); ?></div>
3026  </div>
3027  <div data-bind="visible: achType">
3028  <div class="hcu-filter-group">
3029  <div class="form-group">
3030  <div class="col-xs-12 h4"><?php echo $MC->msg("ACH Add Partners Template", HCU_DISPLAY_AS_HTML); ?></div>
3031  </div>
3032  <div class="form-group">
3033  <div class="col-xs-12 visible-xs-block"><div id="achPartnerDD" class="hcu-all-100"></div></div>
3034  <div class="col-sm-10 col-sm-offset-1 hidden-xs"><div id="achPartnerChooser" class="hcu-all-100"></div></div>
3035  </div>
3036  <div class="form-group">
3037  <div class="col-sm-2 hidden-xs">&nbsp;</div>
3038  <div class="col-sm-2 col-sm-offset-0 col-xs-10 col-xs-offset-1">
3039  <label class="checkbox-inline">
3040  <input type="checkbox" id="achPartnerFilterPayee" class="partner-filter-chooser">&nbsp;<?php echo $MC->msg("ACH Payee", HCU_DISPLAY_AS_HTML); ?>
3041  </label>
3042  </div>
3043  <div class="col-sm-2 col-sm-offset-0 col-xs-10 col-xs-offset-1">
3044  <label class="checkbox-inline">
3045  <input type="checkbox" id="achPartnerFilterPayroll" class="partner-filter-chooser">&nbsp;<?php echo $MC->msg("ACH Payroll", HCU_DISPLAY_AS_HTML); ?>
3046  </label>
3047  </div>
3048  <div class="col-sm-2 col-sm-offset-0 col-xs-10 col-xs-offset-1">
3049  <label class="checkbox-inline">
3050  <input type="checkbox" id="achPartnerFilterPayor" class="partner-filter-chooser">&nbsp;<?php echo $MC->msg("ACH Payor", HCU_DISPLAY_AS_HTML); ?>
3051  </label>
3052  </div>
3053  <div class="col-sm-2 col-sm-offset-0 col-xs-10 col-xs-offset-1">
3054  <label class="checkbox-inline">
3055  <input type="checkbox" id="achPartnerFilterUnassigned" class="partner-filter-chooser">&nbsp;<?php echo $MC->msg("ACH Unassigned", HCU_DISPLAY_AS_HTML); ?>
3056  </label>
3057  </div>
3058  </div>
3059  <div class="form-group">
3060  <div class="col-sm-5 col-sm-offset-1 col-xs-12">
3061  <button id="addPartnerButton" class="">
3062  <span class="fa fa-plus"></span>
3063  <span>&nbsp;<?php echo $MC->msg("ACH Add Partner", HCU_DISPLAY_AS_HTML); ?></span>
3064  </button>
3065  </div>
3066  </div>
3067  </div>
3068  </div>
3069  <div class="row">
3070  <div class="col-xs-12">&nbsp;</div>
3071  </div>
3072  <div data-bind="visible: achType">
3073  <div class="row">
3074  <div class="col-xs-12 h4"><?php echo $batchActivity ?></div>
3075  </div>
3076  <div class="form-group">
3077  <label class="col-sm-4 col-xs-12 local-sm-align-right"><?php echo $MC->msg("ACH Template Name", HCU_DISPLAY_AS_HTML); ?></label>
3078  <div class="col-sm-8 col-xs-12"><span data-bind="text: achTemplateName"></span></div>
3079  </div>
3080  <div class="row">
3081  <div class="hidden-xs col-sm-10 small hcu-sub-text"><?php echo $MC->msg("ACH Template change note", HCU_DISPLAY_AS_HTML); ?></div>
3082  <div class="hidden-xs col-sm-2 csv-uploader-style local-link-style"><a id="csvUploaderLink" class=""><?php echo $MC->msg("CSV File", HCU_DISPLAY_AS_HTML); ?></a></div>
3083  </div>
3084  <div class="form-group">
3085  <div class="col-xs-12"><div id="partnerGrid"></div></div>
3086  </div>
3087  </div>
3088  </div>
3089  </div>
3090  </div>
3091  </div>
3092  <?php // this tab is for setting batch amounts
3093  ?>
3094  <div class="tabPayment tabHide" id="achBatchRemote">
3095  <div class="tabContents form-horizontal">
3096  <div class="form-group">
3097  <div class="hidden-xs col-sm-6 local-link-style"><a id="csvNotSelected" style="display:none;"><?php echo $MC->msg("ACH Not Selected", HCU_DISPLAY_AS_HTML); ?> <span class='fa fa-exclamation-triangle k-error-colored'></span></a></div>
3098  <div class="hidden-xs col-sm-6 csv-not-matched-style local-link-style"><a id="csvNotMatched" style="display:none;"><?php echo $MC->msg("ACH Not Matched", HCU_DISPLAY_AS_HTML); ?> <span class='fa fa-exclamation-triangle k-error-colored'></a></div>
3099  </div>
3100  <div class="well well-sm">
3101  <div class="form-group">
3102  <div class="col-xs-12 h4"><?php echo $MC->msg('ACH Batch Amounts', HCU_DISPLAY_AS_HTML) ?></div>
3103  </div>
3104  <div class="form-group hidden-xs">
3105  <label class="col-sm-3"><?php echo $MC->msg('Name', HCU_DISPLAY_AS_HTML) ?></label>
3106  <label class="col-sm-3"><?php echo $MC->msg('Amount', HCU_DISPLAY_AS_HTML) ?></label>
3107  <label class="col-sm-4"><?php echo $MC->msg('ACH Addenda', HCU_DISPLAY_AS_HTML) ?></label>
3108  <label class="col-sm-2"><?php echo $MC->msg('Notify', HCU_DISPLAY_AS_HTML) ?>&nbsp;<span class="fa fa-question-circle-o" id="achAmountNotifyTip"></span></label>
3109  </div>
3110  <div class="form-group">
3111  <div class="col-xs-12"><div id="batchGrid"></div></div>
3112  </div>
3113  <div class="form-group">
3114  <label class="col-sm-3 col-xs-3"><?php echo $MC->msg('ACH Batch Total', HCU_DISPLAY_AS_HTML) ?></label>
3115  <div class="col-sm-9 col-xs-9"><span data-format="c2" data-bind="text: achBatchTotal"></span></div>
3116  </div>
3117  <div class="form-group">
3118  <div class="col-sm-3 col-xs-3"><label for="updateTemplateFlag" class=""><?php echo $MC->msg('ACH Update Template', HCU_DISPLAY_AS_HTML) ?></label> <span id='updateTemplateTip'><span class='fa fa-question-circle-o'></span></span></div>
3119  <div class="col-sm-9 col-xs-9"><input type="checkbox" id="updateTemplateFlag" name="updateTemplateFlag" data-bind="checked: achUpdateTemplate"></span></div>
3120  </div>
3121  </div>
3122  </div>
3123  </div>
3124  <?php // this tab is for setting withdrawl/deposit account information (for payments or collections)
3125  ?>
3126  <div class="tabPayment tabHide" id="achLocal">
3127  <div class="tabContents">
3128  <div class="form-horizontal">
3129  <div class="well well-sm">
3130  <div class="form-group">
3131  <div class="col-xs-12 h4"><?php echo $MC->msg('ACH Account Info', HCU_DISPLAY_AS_HTML) ?></div>
3132  </div>
3133  <div class="form-group">
3134  <label class="col-xs-12 col-sm-3 control-label"><?php echo $accountTypeWords ?><span class="hcu-required-field"><sup>*</sup></span></label>
3135  <div class="col-xs-12 col-sm-9 col-md-6"><input id="achSubAcctList"
3136  name="achSubAcctList"
3137  class="hcu-all-100"
3138  data-bind="value: achSubAcctSelected"
3139  validationMessage="<?php echo $MC->msg("Please select an account", HCU_DISPLAY_AS_HTML); ?>"
3140  required /></div>
3141  </div>
3142  <div class="form-group">
3143  <label class="col-xs-12 col-sm-3 control-label"><?php echo $MC->msg('ACH Effective Date', HCU_DISPLAY_AS_HTML) ?><span class="hcu-required-field"><sup>*</sup></span></label>
3144  <div class="col-xs-12 col-sm-4"><input id="achEffDate"
3145  name="achEffDate"
3146  class="hcu-xs-100-only"
3147  data-bind="value: achEffDate"
3148  homecu-match='date'
3149  homecu-dategtvalue="<?php echo $initialEffDate; ?>"
3150  homecu-dategttype="string"
3151  validationMessage="<?php echo $MC->msg("ACH Date in past", HCU_DISPLAY_AS_HTML); ?>"
3152  required /></div>
3153  <div class="col-xs-12 col-sm-5 hcu-secondary">
3154  <span class="hcu-secondary-alt-text"><?php echo $achCutoffMessageString; ?></span>
3155  </div>
3156  </div>
3157  <div class="form-group">
3158  <label class="col-xs-12 col-sm-3 control-label"><?php echo $MC->msg("ACH Memo", HCU_DISPLAY_AS_HTML); ?></label>
3159  <div class="col-xs-12 col-sm-9 col-md-6"><input type="text" class="k-textbox hcu-all-100" placeholder="<?php echo $MC->msg('ACH memo reminder', HCU_DISPLAY_AS_HTML) ?>" maxlength="100" data-bind="value: achMemo" /></div>
3160  </div>
3161  <div class="form-group">
3162  <div class="hidden-xs col-sm-3">&nbsp;</div>
3163  <div class="col-xs-12 col-sm-6"><span class="hcu-required-field"><sup>*</sup></span><?php echo $MC->msg('ACH Required', HCU_DISPLAY_AS_HTML) ?></div>
3164  </div>
3165  </div>
3166  </div>
3167  </div>
3168  </div>
3169  <?php // this footer is for all pages
3170  ?>
3171  <div class=" tabFooter hcu-template">
3172  <div class="hcu-edit-buttons k-state-default">
3173  <span class="hcu-icon-delete">
3174  <a id="backButton" class="k-link" data-bind="visible: showBack, events:{ click: backClick }"><?php echo $MC->msg('Back', HCU_DISPLAY_AS_HTML) ?></a>
3175  </span>
3176  <a class="k-button k-primary" id="nextButton" data-bind="disabled: disableSaveButton, events:{ click: nextClick }"><?php echo $MC->msg('Next', HCU_DISPLAY_AS_HTML) ?></a>
3177  </div>
3178  </div>
3179  </div>
3180 
3181 <script id="confirmationTemplate" type="text/x-kendo-tmpl">
3182  <div id="confirmationStatus"></div>
3183  <div id="responseDiv">
3184  <div class="local-transfer-msg">
3185  <?php echo $MC->msg('ACH Batch Posted', HCU_DISPLAY_AS_JS); ?>
3186  </div>
3187 
3188  # if (data) { #
3189  # for (i=0; i < data.length; i++ ) { #
3190  <div class="row">
3191  <div class="col-xs-6 text-right">
3192  <span class="response-label">#= data[i]['label'] #:</span>
3193  </div>
3194  <div class="col-xs-6">
3195  <span class="response-field">#= data[i]['caption'] #</span>
3196  </div>
3197  </div>
3198  # } #
3199  # } #
3200  <div>&emsp;</div>
3201  </div>
3202 </script>
3203  <?php
3204 
3205  } else {
3206  // wasn't an allowed operation
3207  throw new Exception( HCU_JsonEncode( $MC->msg('Feature Unavailable', HCU_DISPLAY_AS_HTML) ), 915 );
3208  }
3209  } catch (Exception $ex) {
3210  // * Include the Error page and then end the content
3211  // NOTE: this is for when the page is first loading
3212  $serviceErrorMsg = HCU_JsonDecode($ex->getMessage());
3213 
3214  $serviceErrorCode = $ex->getCode(); // this chooses which error page to show
3215 
3216  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
3217  }
3218  /*
3219  * ** END CONTENT
3220  */
3221 
3222 
3223  // ** INCLUDE POST CONTENT SCRIPT
3224  require_once(dirname(__FILE__) . '/../includes/hcuPostContent.i');