Odyssey
hcuMobilePayHistory.prg
1 <?php
2  /*
3  * File: hcuMobilePayHistory.prg
4  *
5  * Purpose: This script will show the main menu for mobile banking.
6  * Added: Recurring payment features
7  *
8  * Created by KKL
9  * Updated by ENR
10  *
11  */
12 
13  $serviceViewFromCUAdmin = (isset($serviceViewFromCUAdmin) ? $serviceViewFromCUAdmin : false);
14  if (!$serviceViewFromCUAdmin) {
15  // ** SET SCRIPT LEVEL VARIABLES
16  $serviceShowInfo = true;
17  $serviceLoadMenu = true;
18  $serviceShowMenu = true;
19  $serviceLiveCheck = true;
20  // ** INCLUDE MAIN GLOBAL SCRIPT -- Handles security / global variable values
21  require_once(dirname(__FILE__) . '/../library/hcuService.i');
22  }
23 
24  require_once(dirname(__FILE__) . '/hcuMobilePay.plugin');
25  require_once(dirname(__FILE__) . '../../../shared/library/cutrusted.i');
26 
27  /*
28  * ** CHECK USER FEATURE PERMISSIONS **
29  * NOTE: DOES NOT RETURN ON FAILURE
30  */
31  PermCheckFeatureScreen($dbh, $HB_ENV, $MC, FEATURE_BASIC);
32 
33 
34  // ** INSERT BUSINESS LOGIC FOR THIS FORM
35  $inputVars = array();
36  $varOk = array("mp_token"=>"string", "mp_type"=>"string", "allowp2p"=>"string");
37  HCU_ImportVars( $inputVars, "", $varOk );
38 
39  //0217 copy paste start
40  // extract the encrypted stuff
41  if ( strpos( $inputVars['mp_token'], "=" ) !== false ||
42  strpos( $inputVars['mp_token'], "+" ) !== false ) {
43  // already decoded
44  $decodedToken = $inputVars['mp_token'];
45  $encodedToken = urlencode( $inputVars['mp_token'] );
46  } else {
47  $encodedToken = $inputVars['mp_token'];
48  $decodedToken = urldecode( $inputVars['mp_token'] );
49  }
50  $commonString = hcu_decrypturl( $decodedToken, $HB_ENV['2factorkey']);
51 
52  parse_str( $commonString, $commonParms );
53 
54  $mpVendorKey = $commonParms["mpVendor"];
55  $mpDateModel = $commonParms["mpDateModel"];
56  $mpToken = $commonParms["mpToken"];
57  $mpAccount = $commonParms["mpAccount"];
58  $mobilePayName = $commonParms["mpName"];
59  //pulling permission from vendor/cu to allow P2P type Payees
60  $allowP2P = $commonParms["allowp2p"];
61 
62  $frequencyList = GetBillingFreq($HB_ENV["MC"]);
63 
64  // extras need to be in an array
65  $extrasString = str_replace( "|", "&", $commonParms["mpExtras"] );
66  $extrasString = str_replace( ":", "=", $extrasString );
67  parse_str( $extrasString, $mpExtras );
68 
69  $mpType = $inputVars["mp_type"];
70 
71  //pulling permission from trusted details for Recurring Payment controls
72  if ( HCU_array_key_value('Recur', $mpExtras) == 1 ) {
73  $allowRecur = "true";
74  } else {
75  $allowRecur = "false";
76  }
77 
78  if (strlen( $mpToken )) {
79  // ** SUCCESS -- FETCH REQUESTED TRANSACTIONS
80  $mobilePayParams = array();
81  $mobilePayParams["MP_VENDOR"] = $mpVendorKey;
82  $mobilePayParams["MP_ACTION"] = $mpType == "Scheduled" ? "MP_SCHEDULED" : "MP_HISTORY";
83  $mobilePayParams["MP_ACCOUNT"] = $mpAccount;
84  $mobilePayParams["Token"] = $mpToken;
85 
86  // turn the extra options into a string like: key1:value1|key2:value2|key3:value3...
87  $extrasString = "";
88  foreach ($mpExtras as $key => $val) {
89  if ( strlen( $extrasString ) > 0 ) $extrasString .= "|";
90  $extrasString .= "$key:$val";
91  }
92  // set up common parameters
93  $commonURL = "mpToken=$mpToken&mpVendor=$mpVendorKey&mpDateModel=$mpDateModel&mpName=$mobilePayName&mpExtras=$extrasString&allowp2p=$allowP2P&mpAccount=$mpAccount";
94  $encryptedCommonURL = hcu_encrypturl( $commonURL, $HB_ENV['2factorkey'] );
95  $encodedCommonURL = urlencode( $encryptedCommonURL );
96 
97  } else {
98 
99  // no token
100  // show error message
101  $serviceErrorMsg = $MC->msg('Feature Not Set', HCU_DISPLAY_AS_HTML);
102  $serviceErrorCode = '915';
103  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
104  // ** DO NOT CONTINUE
105  exit;
106  }
107 
108  require_once(dirname(__FILE__) . '/../includes/hcuPreContent.i');
109 
110 ?>
111 <!-- kendo mobile -->
112 <style>
113  .btn-group-wrap {
114  text-align: center;
115  }
116 
117  .btn-group {
118  text-align: center;
119  }
120 
121  .k-grid .scheduled-view {
122  border-left-width: 0;
123  }
124 
125  .payee-name {
126  font-weight: bold;
127  }
128  .detail-description {
129  font-weight: bold;
130  text-align: left;
131  }
132  .detail-value {
133  text-align: left;
134  }
135  .payee-amount {
136  text-align: right;
137  color: darkblue;
138  }
139 
140  .payee-date {
141  font-size: .8em;
142  }
143 
144  .k-radio-label {
145  padding-bottom: .5em;
146  font-weight: normal;
147  }
148 
149  h6 {
150  font-weight: bold;
151  padding-bottom: .5em;
152  }
153 
154  #payNum {
155  padding-bottom: .5em;
156  }
157 
158  .k-window-titlebar .k-window-actions {
159  display: none;
160  }
161 
162 </style>
163 <!-- template for scheduled/history grid -->
164 <script id="scheduledRow" type="text/x-kendo-template">
165  <tr>
166  <td class="scheduled-view">
167  <div class="col-xs-12 payee-name">#: ToName#</div>
168  <div class="col-xs-12 payee-date"><?php echo $MC->msg("Process on", HCU_DISPLAY_AS_HTML) ?>: #: kendo.toString(kendo.parseDate(Date), "MM/dd/yyyy") #</div>
169  </td>
170  <td class="scheduled-view">
171  <div class="col-xs-12 payee-amount">#: kendo.toString(Amount, 'C')#</div>
172  </td>
173  </tr>
174 </script>
175 <!-- template for detail -->
176 <script id="detailPaymentRow" type="text/x-kendo-template">
177  <tr>
178  <td class="scheduled-view">
179  <div class="col-xs-12 col-sm-6 detail-description" n>#: description#</div>
180  <div class="col-xs-12 col-sm-6 detail-value" >#: dvalue#</div>
181  </td>
182  </tr>
183 </script>
184 
185  <div id="confirmTemplate"></div>
186  <div id="confirmationWindow"></div>
187  <div id="discardDialog"></div>
188  <div id="formStatusMain" class="homecu-formStatus k-block k-error-colored" style="display:none; margin: 10px;"></div>
189  <div id="detailTemplate" class="k-content" hidden>
190  <!-- Payment Detail Window -->
191  <div class="container-fluid hcu-scrolling-dialog">
192  <div class="k-content col-xs-12 ">
193  <div id="detailPaymentFormStatus" class="homecu-formStatus k-block k-error-colored" style="display:none; margin-bottom:10px;max-width:800px;"></div>
194  </div>
195  <div class="row">
196  <div class="col-xs-12">
197  <div id="detailGrid"></div>
198  </div>
199  </div>
200  <div class="row">
201  <?php if ($mpType == "Scheduled") : ?>
202  <div class="col-xs-12 col-sm-4 col-md-4 col-lg-4">
203  <button id="btnStopPayment" name="btnStopPayment" type="submit" class="k-button hcu-all-100 hcu-xs-btn-margin-top hcu-xs-btn-pad" ><?php echo $MC->msg("CU feature STOP", HCU_DISPLAY_AS_HTML)?></button>
204  </div>
205  <div class="col-xs-12 col-sm-4 col-md-4 col-lg-4">
206  <button id="btnPayment" name="btnPayment" type="submit" class="k-button hcu-all-100 hcu-xs-btn-margin-top hcu-xs-btn-pad"><?php echo $MC->msg("Edit Payment", HCU_DISPLAY_AS_HTML)?></button>
207  </div>
208  <?php endif; ?>
209  <div class="col-xs-12 col-sm-4 col-md-4 col-lg-4">
210  <button id="btnDetailClose" name="btnDetailClose" type="submit" class="k-button k-primary hcu-all-100 hcu-xs-btn-margin-top hcu-xs-btn-pad"><?php echo $MC->msg("Close", HCU_DISPLAY_AS_HTML)?></button>
211  </div>
212  </div>
213  </div>
214  </div>
215  <!-- Edit Payment -->
216  <div id="editPaymentTemplate" name="editPaymentTemplate" style="display: none;" class="container-fluid"><!-- DISPLAY NONE -->
217  <div class="row">
218  <div class="k-content col-xs-12 ">
219  <div id="editPaymentFormStatus" class="homecu-formStatus k-block k-error-colored" style="display:none; margin-bottom:10px;max-width:800px;"></div>
220  <div id='editErrors'></div>
221  <div class="form-horizontal form-widgets well well-sm">
222  <!-- Pay or Transfer to -->
223  <div class="form-group">
224  <div class="">
225  <label class="col-sm-12" for="payTo" id="editPayTo"></label>
226  <div class="col-sm-12">
227  <input id='payTo' class='distinctAcct hcu-all-100 k-textbox' name='payTo'
228  data-bind='value: bpToName, events:{change: SetDirty}' readonly
229  data-required-msg="<?php echo $MC->msg('Payee is required', HCU_DISPLAY_AS_HTML);?>"
230  required />
231  </div>
232  </div>
233  </div>
234  <!-- from ACCOUNT -->
235  <div class="form-group">
236  <div class="">
237  <label class="col-sm-12" for="toFrom" id="editToFrom"><?php echo $MC->msg("Account", HCU_DISPLAY_AS_HTML)?>
238  </label>
239  <div class="col-sm-12">
240  <input id='toFrom' class='distinctAcct hcu-all-100' name='toFrom'
241  data-role='dropdownlist'
242  data-bind='value: bpFromId, events:{change: SetDirty}'
243  data-required-msg="<?php echo $MC->msg('Account is required', HCU_DISPLAY_AS_HTML);?>"
244  homecu-distinct="distinctAcct"
245  required />
246  </div>
247  </div>
248  </div>
249  <!-- AMOUNT -->
250  <div class="form-group">
251  <div class="">
252  <label class="col-sm-12" for="payAmount"><?php echo $MC->msg('Amount', HCU_DISPLAY_AS_HTML); ?>
253  <span class="hcu-required-field"><sup>*</sup></span></label>
254  <div class="col-sm-12">
255  <input type="number" id="payAmount" name="payAmount" class="hcu-all-100"
256  placeholder="<?php echo $MC->msg('Amount', HCU_DISPLAY_AS_HTML); ?>"
257  data-bind="value: bpAmt, events:{change: SetDirty}"
258  data-required-msg="<?php echo $MC->msg('Amount Missing', HCU_DISPLAY_AS_HTML); ?>"
259  required />
260  </div>
261  </div>
262  </div>
263  <!-- Proccess Date -->
264  <div class="form-group">
265  <div class="">
266  <label class="col-sm-12" for="payDate" id="editPayDate"><?php echo $MC->msg('Transfer On', HCU_DISPLAY_AS_HTML); ?>
267  </label>
268  <div class="col-sm-12">
269  <input class="hcu-all-100" type="text" placeholder="eg. MM/DD/YYYY" id="payDate" name="payDate"
270  data-role='datepicker'
271  data-bind="value: bpDate, events:{change: SetDirty}"
272  data-format='MM/dd/yyyy'
273  data-required-msg="<?php echo $MC->msg('Process Date Missing', HCU_DISPLAY_AS_HTML); ?>"
274  onkeydown="return false;"
275  required />
276  </div>
277  </div>
278  </div>
279  <?php if ( $allowRecur == 'true' ) : ?>
280  <!-- Billing Frequency -->
281  <div class="form-group">
282  <div class="">
283  <label class="col-sm-12" for="billFreq" id="editBillFreq"><?php echo $MC->msg('Payment Frequency', HCU_DISPLAY_AS_HTML); ?>
284  </label>
285  <div class="col-sm-12">
286  <input id='billFreq' class='distinctAcct hcu-all-100' name='billFreq'
287  data-role='dropdownlist'
288  data-bind='value: bpFreq, events:{change: SetDirty}'
289  data-required-msg="<?php echo $MC->msg('Payment Frequency Missing', HCU_DISPLAY_AS_HTML); ?>"
290  required />
291  </div>
292  </div>
293  </div>
294  <!-- Payment Duration -->
295  <div class="form-group">
296  <div class="">
297  <div class="col-sm-12">
298  <div class="row">
299  <div class="col-sm-12">
300  <h6 id="editDuration"><?php echo $MC->msg('Duration', HCU_DISPLAY_AS_HTML); ?></h6>
301  </div>
302  </div>
303  </div>
304  <div class="col-sm-12">
305  <div class="row">
306  <div class="col-sm-6">
307  <input class="k-radio" type="radio" id="rdNvr" name="duration" value="never"/>
308  <label class="k-radio-label" for="rdNvr"><?php echo $MC->msg('Never Stop', HCU_DISPLAY_AS_HTML); ?></label>
309  </div>
310  </div>
311  <div class="row">
312  <div class="col-sm-6">
313  <input class="k-radio" type="radio" id="rdNum" name="duration" value="number"/>
314  <label class="k-radio-label" for="rdNum"><?php echo $MC->msg('Until Payments', HCU_DISPLAY_AS_HTML); ?></label>
315  </div>
316  <div class="col-sm-3" style="padding-bottom:.5em;">
317  <input class="hcu-all-100" type="number" id="payNum" name="payNum"
318  data-bind="value: bpPayNum, events:{change: SetDirty}"
319  data-required-msg="<?php echo $MC->msg('Number Payments Missing', HCU_DISPLAY_AS_HTML); ?>"
320  />
321  </div>
322  </div>
323  <div class="row">
324  <div class="col-sm-6">
325  <input class="k-radio" type="radio" id="rdEnd" name="duration" value="date"/>
326  <label class="k-radio-label" for="rdEnd"><?php echo $MC->msg('Until Date', HCU_DISPLAY_AS_HTML); ?></label>
327  </div>
328  <div class="col-sm-6">
329  <input class="hcu-all-100" type="text" placeholder="eg. MM/DD/YYYY" id="endDate" name="endDate"
330  data-role='datepicker'
331  data-bind="value: bpEndDate, events:{change: SetDirty}"
332  data-format='MM/dd/yyyy'
333  data-required-msg="<?php echo $MC->msg('End Date Missing', HCU_DISPLAY_AS_HTML); ?>"
334  onkeydown="return false;"
335  />
336  </div>
337  </div>
338  </div>
339  </div>
340  </div>
341  <?php endif; ?>
342  <?php if ( strtolower($mpDateModel) == "due") : ?>
343  <!-- proccess date label for due date model -->
344  <div class="form-group">
345  <div class="">
346  <label class="col-sm-12" for="payDate" id="editPayDueDate"><?php echo $MC->msg('Process Date', HCU_DISPLAY_AS_HTML); ?></label>
347  <div class="col-xs-12 col-sm-1">
348  <label class="col-sm-12 " for="payDate" id="valuePayDueDate" data-bind="value: bpDueModelProcessDate"></label>
349  </div>
350  </div>
351  </div>
352  <?php endif; ?>
353  <!-- ACTION BUTTONS -->
354  <div class="hcu-template">
355  <div class="hcu-edit-buttons k-state-default">
356  <a href="##" id="closeEditBtn" style=""><?php echo $MC->msg("Cancel", HCU_DISPLAY_AS_HTML)?></a>&emsp;
357  <a href="##" id="btnUpdatePayment" class="k-button k-primary">
358  <i class="fa fa-check fa-lg"></i><?php echo $MC->msg("Update", HCU_DISPLAY_AS_HTML)?>
359  </a>
360  </div>
361  </div>
362  </div>
363  </div>
364  </div>
365 </div>
366  <!-- Grid to show payment list -->
367  <div class="historyC">
368  <div class="container-fluid">
369  <div class="row">
370  <div class='col-xs-12' style="margin: 10px 0px 10px 0px;" >
371  <span class="hcu-breadcrumbs"><a href='hcuMobilePay.prg?mp_token=<?php echo $encodedCommonURL ?>&<?php echo $HB_ENV['cuquery'] ?>' class="tabReturnBtn"><?php echo $mobilePayName . " " . $MC->msg("Menu", HCU_DISPLAY_AS_HTML) ?></a> / <span class="realname">
372  <?php if ($mpType == "Scheduled") : ?><?php echo $MC->msg("Scheduled", HCU_DISPLAY_AS_HTML) ?><?php else : ?><?php echo $MC->msg("History", HCU_DISPLAY_AS_HTML) ?><?php endif; ?></span></span>
373  </div>
374  </div>
375  <div class="row">
376  <div class="hcu-xs-btn-margin-top text-center" style="max-width:800px;">
377  <div class="btn-group" role="group" id="typeGroupButtonSelect">
378  <button type="button" class="btn btn-default" ><?php echo $MC->msg("Payments", HCU_DISPLAY_AS_HTML)?></button>
379  <button type="button" class="btn btn-default" ><?php echo $MC->msg("Transfers", HCU_DISPLAY_AS_HTML)?></button>
380  <button type="button" class="btn btn-default active" ><?php echo $MC->msg("All", HCU_DISPLAY_AS_HTML)?></button>
381  </div>
382  </div>
383  </div>
384  <div class="row">
385  <div class="col-xs-12" style="max-width:800px;">
386  <div id="grid" class="hcu-xs-btn-margin-top">
387  </div>
388  </div>
389  </div>
390  </div>
391 </div>
392 <script id="confirmationTemplateEdit" type="text/x-kendo-tmpl">
393  <div id="confirmationStatus"></div>
394  <div id="responseDiv">
395  <div class="local-transfer-msg">
396  <?php echo $MC->msg('Payment Updated', HCU_DISPLAY_AS_JS); ?>
397  </div>
398  </div>
399 </script>
400 <script id="confirmationTemplateStop" type="text/x-kendo-tmpl">
401  <div id="confirmationStatus"></div>
402  <div id="responseDiv">
403  <div class="local-transfer-msg">
404  <?php echo $MC->msg('Payment Stopped', HCU_DISPLAY_AS_JS); ?>
405  </div>
406  </div>
407 </script>
408 <script id="freqTemplate" type="text/x-kendo-tmpl">
409  <span class="#: isDeleted ? 'k-state-disabled': ''#">
410  #: name #
411  </span>
412 </script>
413 <script type="text/javascript">
414 
415  var windowStack = [];
416  var dataPayFrom = [];
417  var dsGetAccounts = [];
418  var dsGetPayFrom = [];
419  var dsGetDates = [];
420  var dsAcctHistory = [];
421  var dsPayment = [];
422 
423  var detailWindow;
424  var confirmDialog;
425  var editPaymentWindow;
426  var discardDialog;
427  var mindate;
428  var endMinDate;
429  var maxdate;
430  var maxindex;
431  var selectedItem;
432  var currentSelectedRow;
433 
434  var editPaymentModel;
435  var processDates;
436  var mpType;
437  var mpAction;
438 
439  var freqTypes = <?php echo HCU_JsonEncode($frequencyList); ?>;
440 
441  //set fields as required according to radio button selection
442  $("input:radio[name=duration]").change( function() {
443  var selectedOption = $("input:radio[name=duration]:checked").val();
444 
445  if ( selectedOption == 'number' ) {
446  //set number of payments to required
447  $("#payNum").attr('required', true);
448  $("#endDate").attr('required', false);
449  } else if ( selectedOption == 'date' ) {
450  //set end date to required
451  $("#endDate").attr('required', true);
452  $("#payNum").attr('required', false);
453  } else {
454  $("#endDate").attr('required', false);
455  $("#payNum").attr('required', false);
456  }
457  editPaymentModel.set("bpDuration", selectedOption);
458  });
459 
460  function InitDataSources() {
461 
462  //adding datasource to frequency types field
463  $("#billFreq").kendoDropDownList({
464  dataTextField: "name",
465  dataValueField: "value",
466  dataSource: freqTypes,
467  template: kendo.template($("#freqTemplate").html()),
468  select: function(e){
469  if(e.dataItem.isDeleted){
470  e.preventDefault();
471  }
472  },
473  change: function(e) {
474  var dropdown = this;
475  var dropdownValue = dropdown.value();
476  editPaymentModel.set("bpFreq", dropdownValue);
477 
478  //if only paying once, disable duration controls
479  if ( dropdownValue == "Once" ) {
480  //reset duration to empty
481  editPaymentModel.set("bpDuration", "");
482  $("input[name=duration]").attr('disabled',true);
483  $("#payNum").attr('disabled',true);
484  $("#endDate").data('kendoDatePicker').enable(false);
485  //clear out any previous values
486  $("#rdNum").prop("checked", false);
487  $("#rdNvr").prop("checked", false);
488  $("#rdEnd").prop("checked", false);
489  } else {
490  $("input[name=duration]").attr('disabled',false);
491  $("input:radio[name=duration]").attr("required", true);
492 
493  //add data required message for radio buttons
494  $("input:radio[name=duration]").attr("data-required-msg", "<?php echo $MC->msg("Duration Required", HCU_DISPLAY_AS_JS) ?>");
495  $("#payNum").attr('disabled',false);
496  $("#endDate").data('kendoDatePicker').enable(true);
497  }
498  },
499  optionLabel: {value: "", name: "<?php echo $MC->msg("Frequency Select", HCU_DISPLAY_AS_JS) ?>"},
500  });
501 
502  $("#payNum").kendoNumericTextBox({
503  format: "n0",
504  decimals: 0,
505  step: 1,
506  spinners: false,
507  min: 1,
508  max: 1000,
509  change: function(e){
510  var textbox = this;
511  var textboxValue = textbox.value();
512  editPaymentModel.set("bpPayNum", textboxValue);
513 
514  //select the correct radio button
515  $("#rdNum").prop("checked", true);
516  //set model value
517  var selectedOption = $("input:radio[name=duration]:checked").val();
518  editPaymentModel.set("bpDuration", selectedOption);
519  },
520  });
521 
522  $("#payAmount").kendoNumericTextBox({
523  format: "c",
524  decimals: 2,
525  step: 0,
526  spinners: false,
527  min: .01,
528  max: 9999999,
529  placeholder: '<?php echo $MC->msg('Amount', HCU_DISPLAY_AS_JS); ?>'
530  });
531 
532  $("#endDate").kendoDatePicker({
533  value: new Date(),
534  min: mindate,
535  disableDates: ["sa", "su"],
536  });
537 
538  dsGetPayFrom = new kendo.data.DataSource ({
539  data: dataPayFrom
540  });
541 
542  //pulling user account information
543  dsGetAccounts = new kendo.data.DataSource ({
544  transport: {
545  read: {
546  url: "hcuMobilePay.data?cu=<?php echo $HB_ENV['cu']; ?>&mp_token=<?php echo $encodedToken ?>&mp_type=Accounts&<?php echo $HB_ENV['cuquery'] ?>",
547  contentType: 'application/x-www-form-urlencoded',
548  type: 'POST',
549  data: {},
550  pageable: true,
551  cache: false
552  }
553  },
554  requestStart: function( e ) {
555  ShowWaitWindow();
556  },
557  requestEnd: function( e ) {
558  CloseWaitWindow();
559  var error = null;
560  // see if there is an error
561  if ( e.response && e.response.homecuErrors )
562  error = e.response.homecuErrors;
563  if ( error && error.length > 0 ) {
564  e.preventDefault();
565  $.homecuValidator.displayMessage(error, $.homecuValidator.settings.statusError);
566  } else {
567  // not sure
568  }
569  },
570  // code to run if the request fails; the raw request and
571  // status codes are passed to the function
572  error: function( e ) {
573  alert( "Transport error" );
574  },
575  schema: {
576  data: function (response) {
577  /* PARSE RESPONSE DATA */
578  var returnData = Array();
579  try {
580  if (response.homecuData) {
581  //Get Accounts List
582  dataPayFrom = (response.homecuData.source ? response.homecuData.source : []);
583  dsGetPayFrom.data(dataPayFrom);
584  returnData = response.homecuData;
585  } else if (response.homecuErrors) {
586  //error has been handled
587  } else {
588  throw "Error Parsing Result From Server";
589  }
590  } catch (err) {
591  // ** Need to report the message to the main screen
592  alert(err);
593  returnData = [];
594  }
595  return [response];
596  },
597  }
598  });
599 
600  dsGetDates = new kendo.data.DataSource ({
601  transport: {
602  read: {
603  url: "hcuMobilePay.data?cu=<?php echo $HB_ENV['cu']; ?>&mp_token=<?php echo $encodedToken ?>&mp_type=DATES&<?php echo $HB_ENV['cuquery'] ?>",
604  contentType: 'application/x-www-form-urlencoded',
605  type: 'POST',
606  data: {},
607  pageable: true,
608  cache: false
609  }
610  },
611  requestStart: function( e ) {
612  ShowWaitWindow();
613  },
614  requestEnd: function( e ) {
615  CloseWaitWindow();
616  <?php if ( strtolower($mpDateModel) == "due") : ?>
617  //for due date model show delivery by dates
618  mindate = kendo.toString(e.response.homecuData.data.PaymentDates[0].Due, "yyyy-MM-dd");
619  maxindex = e.response.homecuData.data.PaymentDates.length -1;
620  maxdate = kendo.toString(e.response.homecuData.data.PaymentDates[maxindex].Due, "yyyy-MM-dd");
621  <?php else : ?>
622  mindate = kendo.toString(e.response.homecuData.data.PaymentDates[0].Proc, "yyyy-MM-dd");
623  maxindex = e.response.homecuData.data.PaymentDates.length -1;
624  maxdate = kendo.toString(e.response.homecuData.data.PaymentDates[maxindex].Proc, "yyyy-MM-dd");
625  <?php endif; ?>
626 
627  <?php if ( $allowRecur == 'true' ) : ?>
628  var endDatePicker = $("#endDate").data('kendoDatePicker');
629  endDatePicker.setOptions({
630  min: mindate,
631  disableDates: ["sa", "su"],
632  });
633  endDatePicker.bind("change", function () {
634  var datePicker = this;
635  var dateValue = datePicker.value();
636  editPaymentModel.set("bpEndDate", dateValue);
637  //select the correct radio button
638  $("#rdEnd").prop("checked", true);
639  //set model value
640  var selectedOption = $("input:radio[name=duration]:checked").val();
641  editPaymentModel.set("bpDuration", selectedOption);
642  });
643  <?php endif; ?>
644 
645  $("#payDate").kendoDatePicker({
646  value: new Date(),
647  min: mindate,
648  max: maxdate,
649  disableDates: function (date) {
650  var bpDates = [];
651  bpDates = e.response.homecuData.data.PaymentDates;
652  var bpFormatDates = [];
653  var i, s, len = bpDates.length;
654  for (i=0; i<len; ++i) {
655  if (i in bpDates) {
656  <?php if ( strtolower($mpDateModel) == "due") : ?>
657  // for due date model show delivery by dates
658  s = bpDates[i]["Due"];
659  s = s.replace(/-/g, '/') // using 'g' to replace globally
660  // s = s.replace(/-/, '/'); // replace 2nd "-" with "/"
661  <?php else : ?>
662  s = bpDates[i]["Proc"];
663  <?php endif; ?>
664  bpFormatDates.push(new Date(s));
665  }
666  }
667  if (date && compareDates(date, bpFormatDates)) {
668  return false;
669  } else {
670  return true;
671  }
672  },
673  change: function () {
674  var processDate = new Date();
675  processDate = editPaymentModel.bpDate;
676  <?php if ( strtolower($mpDateModel) == "due" ) : ?>
677  // for due date model show delivery by dates
678  var sDate = processDates[kendo.toString(processDate, "yyyy/MM/dd")];
679  $("#valuePayDueDate").text(sDate);
680  editPaymentModel.bpDueModelProcessDate = sDate;
681  <?php endif; ?>
682  <?php if ( $allowRecur == 'true' ) : ?>
683  var endDatePicker = $("#endDate").data('kendoDatePicker');
684  endMinDate = kendo.toString(kendo.date.addDays(processDate, 1), "yyyy/MM/dd");
685  endDatePicker.setOptions({
686  min: endMinDate
687  });
688  <?php endif; ?>
689  }
690  });
691 
692  var error = null;
693  // see if there is an error
694  if ( e.response && e.response.homecuErrors )
695  error = e.response.homecuErrors;
696  if ( error && error.length > 0 ) {
697  e.preventDefault();
698  $.homecuValidator.displayMessage(error, $.homecuValidator.settings.statusError);
699  } else {
700  // not sure
701  }
702  },
703  // code to run if the request fails; the raw request and
704  // status codes are passed to the function
705  error: function( e ) {
706  alert( "Transport error" );
707  },
708  schema: {
709  model: {
710  fields: {
711  Proc: { type: "date" },
712  Date: { type: "date" }
713  }
714  },
715  data: "homecuData.data.PaymentDates"
716  }
717  });
718 
719  dsAcctHistory = new kendo.data.DataSource({
720  transport: {
721  read: {
722  url: "hcuMobilePay.data?cu=<?php echo $HB_ENV['cu']; ?>&mp_token=<?php echo $encodedToken ?>&mp_type=<?php echo $mpType; ?>&<?php echo $HB_ENV['cuquery'] ?>",
723  contentType: 'application/x-www-form-urlencoded',
724  type: 'POST',
725  data: function() {
726  return {};
727  },
728  pageable: true,
729  cache: false
730  }
731  },
732  requestStart: function( e ) {
733  ShowWaitWindow();
734  },
735  requestEnd: function( e ) {
736  CloseWaitWindow();
737  var error = null;
738  // see if there is an error
739  if ( e.response && e.response.homecuErrors )
740  error = e.response.homecuErrors;
741 
742  if ( error && error.length > 0 ) {
743  e.preventDefault();
744  $.homecuValidator.displayMessage(error, $.homecuValidator.settings.statusError);
745  } else {
746  // not sure
747  }
748  },
749  // code to run if the request fails; the raw request and
750  // status codes are passed to the function
751  error: function( e ) {
752  alert( "Transport error" );
753  },
754  schema: {
755  model: {
756  id: "TxnId",
757  fields: {
758  ToId: { type: "number" },
759  Type: { type: "string" },
760  ToName: { type: "string" },
761  FromId: { type: "number" },
762  Amount: { type: "number" },
763  Date: { type: "date" },
764  Frequency: { type: "string" },
765  },
766  },
767  data: "homecuData.data"
768  },
769  });
770 
771  dsPayment = new kendo.data.DataSource({
772  transport: {
773  read: {
774  url: 'hcuMobilePay.data?cu=<?php echo $HB_ENV['cu']; ?>&mp_token=<?php echo $encodedToken ?>&<?php echo $HB_ENV['cuquery'] ?>',
775  //'hcuMobilePay.data?cu=<?php echo $HB_ENV['cu']; ?>&mp_token=<?php echo $encodedToken ?>&mp_type=UpdatePayments&<?php echo $HB_ENV['cuquery'] ?>',
776  dataType: "json",
777  contentType: "application/x-www-form-urlencoded",
778  type: "POST",
779  data: {},
780  cache: false
781  }
782  },
783  schema: {
784  model: {
785  id: "TxnId",
786  fields: {
787  ToId: { type: "number" },
788  Type: { type: "string" },
789  ToName: { type: "string" },
790  FromId: { type: "number" },
791  Amount: { type: "number" },
792  Date: { type: "date" },
793  StartDate: { type: "date" },
794  Frequency: { type: "string" },
795  PmtDayWeek: { type: "string" },
796  PmtDayMonth: { type: "number" },
797  PmtOccur: { type: "number" },
798  PmtSerFinite: { type: "string" }
799  },
800  },
801  },
802  requestStart: function( e ) {
803  ShowWaitWindow();
804  },
805  requestEnd: function( e ) {
806  var error = null;
807  CloseWaitWindow();
808  // see if there is an error
809  if ( e.response && e.response.homecuErrors ) {
810  error = e.response.homecuErrors;
811  if ( error && error.length > 0 ) {
812  e.preventDefault();
813  // $.homecuValidator.settings.formValidate = "editPaymentFormStatus";
814  $.homecuValidator.settings.formErrorTitle = "Error";
815  $.homecuValidator.displayMessage(error, $.homecuValidator.settings.statusError);
816  }
817  } else if ( e.response && e.response.homecuData ) {
818  var results = e.response.homecuData;
819  if ( results.data ) {
820  var paymentInfo = results.data;
821 
822  editPaymentModel.set( "bpTxnId", paymentInfo.TxnId );
823  editPaymentModel.set( "bpToId", paymentInfo.ToId );
824  editPaymentModel.set( "bpToName", paymentInfo.ToName );
825  editPaymentModel.set( "bpFromId", paymentInfo.FromId );
826  editPaymentModel.set( "bpAmt", parseFloat( paymentInfo.Amount ));
827 
828  //keeping dates the same as before - taken from current row info
829  <?php if ( strtolower($mpDateModel) == "due") : ?>
830  editPaymentModel.set( "bpDate", currentSelectedRow.AdditionalInfo.Estimated_Arrival );
831  editPaymentModel.set( "bpDueModelProcessDate",currentSelectedRow.Date );
832  <?php else : ?>
833  editPaymentModel.set( "bpDate", paymentInfo.Date );
834  <?php endif; ?>
835 
836  <?php if ( $allowRecur == 'true' ) : ?>
837  editPaymentModel.set( "bpPayNum", paymentInfo.PmtOccur );
838  editPaymentModel.set( "bpEndDate", paymentInfo.PmtExpDate );
839 
840  //if finite is false, series never ends
841  if ( paymentInfo.PmtSerFinite == "false" ) {
842  editPaymentModel.set( "bpDuration", "never" );
843  }
844 
845  if ( paymentInfo.Frequency === "" ) {
846  editPaymentModel.set( "bpFreq", "Once" );
847  } else {
848  editPaymentModel.set( "bpFreq", paymentInfo.Frequency );
849  }
850 
851  //if only paying once, disable duration controls and frequency dropdown
852  //cannot change one time payment to a recurring payment
853 
854  if ( editPaymentModel.bpFreq == "Once" ) {
855  $("#billFreq").data('kendoDropDownList').enable(false);
856  $("input[name=duration]").attr('disabled',true);
857  $("#payNum").attr('disabled',true);
858  $("#endDate").data('kendoDatePicker').enable(false);
859  } else {
860  $("#billFreq").data('kendoDropDownList').enable(true);
861  $("input[name=duration]").attr('disabled',false);
862  $("input:radio[name=duration]").attr("required", true);
863 
864  //add data required message for radio buttons
865  $("input:radio[name=duration]").attr("data-required-msg", "<?php echo $MC->msg("Duration Required", HCU_DISPLAY_AS_JS) ?>");
866  $("#payNum").attr('disabled',false);
867  $("#endDate").data('kendoDatePicker').enable(true);
868  }
869 
870  if ( editPaymentModel.bpPayNum ) {
871  //select the correct radio button
872  $("#rdNum").prop("checked", true);
873  editPaymentModel.set( "bpDuration", "number");
874  }
875 
876  if ( editPaymentModel.bpEndDate ) {
877  //select the correct radio button
878  $("#rdEnd").prop("checked", true);
879  editPaymentModel.set( "bpDuration", "date");
880  }
881 
882  if ( editPaymentModel.bpDuration == "never" ) {
883  //select the correct radio button
884  $("#rdNvr").prop("checked", true);
885  }
886  <?php endif; ?>
887 
888  LoadPaymentWindow();
889 
890  } else {
891  ShowSuccess();
892  }
893  }
894  },
895  error: function( e ) {
896  alert( "<?php echo $MC->msg("Transport error", HCU_DISPLAY_AS_JS); ?>: " + e.status );
897  }
898  });
899  }
900 
901  function ShowSuccess() {
902  var confirmationTemplate;
903 
904  if ( mpAction == "UpdatePayments" ){
905  confirmationTemplate = kendo.template($("#confirmationTemplateEdit").html());
906  } else if ( mpAction == "StopPayment" ) {
907  confirmationTemplate = kendo.template($("#confirmationTemplateStop").html());
908  }
909 
910  var confirmationDisplay = confirmationTemplate;
911  $("#confirmationWindow").data("kendoDialog").content(confirmationDisplay);
912  $("#confirmationWindow").data("kendoDialog").open();
913  editPaymentModel.ResetModel();
914  }
915 
916  // Confirmation dialog
917  $("#confirmationWindow").kendoDialog({
918  title: "<?php echo $MC->msg('Success', HCU_DISPLAY_AS_JS); ?>",
919  width: "85%",
920  maxWidth: "768px",
921  minWidth: "300px",
922  modal: true,
923  closable: false,
924  visible: false,
925  resizable: false,
926  actions: [
927  {
928  text: "<?php echo $MC->msg('Close', HCU_DISPLAY_AS_JS); ?>",
929  primary: true
930  }
931  ],
932  show: function(e) {
933  windowStack.push(this);
934  },
935  close: function(e) {
936  windowStack.pop();
937  // Reset validator to use page status field.
938  $.homecuValidator.settings.formStatusField = "formStatus";
939  $.homecuValidator.settings.formInfoTitle = "";
940  //redirect back to history page
941  window.location = 'hcuMobilePayHistory.prg?mp_token=<?php echo $encodedToken ?>&mp_type=Scheduled&<?php echo $HB_ENV['cuquery'] ?>';
942  }
943  });
944 
945  $(".btn-group > .btn").click(function(e){
946  $(this).addClass("active").siblings().removeClass("active");
947  var grid = $("#grid").data("kendoGrid");
948  var dataSource = grid.dataSource;
949  switch($('.btn-group > .btn.active').text()) {
950  case "<?php echo $MC->msg('Payments', HCU_DISPLAY_AS_JS); ?>":
951  dataSource.filter ({
952  "field": "Type",
953  "operator": "eq",
954  "value": "Payment"
955  });
956  break;
957  case "<?php echo $MC->msg('Transfers', HCU_DISPLAY_AS_JS); ?>":
958  dataSource.filter ({
959  "field": "Type",
960  "operator": "eq",
961  "value": "Transfer"
962  });
963  break;
964  default:
965  dataSource.filter ({
966  });
967  }
968 
969  });
970 
971  // detail dialog
972  detailWindow = $("#detailTemplate").kendoWindow({
973  width: "85%",
974  height: "85%",
975  title: "",
976  visible: false,
977  modal: true,
978  scrollable: true,
979  maxWidth: 600,
980  position: { top: 100, left: "10%" , right: "10%"},
981  activate: function(e) {
982  windowStack.push(function(e) {
983  detailWindow.close(e);
984  });
985  $.homecuValidator.setup({formValidate: "detailTemplate",
986  formErrorTitle: "<?php echo $MC->msg("Error Occurred", HCU_DISPLAY_AS_JS) ?>",
987  formStatusField: "detailPaymentFormStatus"});
988 
989  // add the close function to the window stack
990  $("#btnDetailClose").click( function() {
991  detailWindow.close();
992  });
993 
994  $("#btnPayment").click( function() {
995  detailWindow.close();
996  EditPayment();
997  });
998 
999  $("#btnStopPayment").click( function() {
1000  StopPayment();
1001  });
1002  },
1003  close: function(e) {
1004  // now remove the close function call
1005  windowStack.pop();
1006  $('#btnDetailClose').off();
1007  $('#btnPayment').off();
1008  $('#btnStopPayment').off();
1009  },
1010  }).data('kendoWindow');
1011 
1012  // This will open the detailed transaction window
1013  function showDetailWindow() {
1014 
1015  mpType = currentSelectedRow.Type;
1016  var title = "";
1017  var lblPlaceHolder = "";
1018  if ( mpType == "Payment" ) {
1019  lblPlaceHolder = "<?php echo $MC->msg("Select Payee", HCU_DISPLAY_AS_HTML)?>";
1020  title = "<?php echo $MC->msg("Payment", HCU_DISPLAY_AS_HTML)?>";
1021  } else {
1022  lblPlaceHolder = "<?php echo $MC->msg("Select Transfer", HCU_DISPLAY_AS_HTML)?>";
1023  title = "<?php echo $MC->msg("Transfer", HCU_DISPLAY_AS_HTML)?>";
1024  }
1025 
1026  detailWindow.title(title + " <?php echo $MC->msg("Detail", HCU_DISPLAY_AS_HTML)?>");
1027 
1028  $("#toFrom").kendoDropDownList({
1029  optionLabel: "<?php echo $MC->msg("ACH Select Account", HCU_DISPLAY_AS_JS) ?>",
1030  dataSource: dsGetPayFrom,
1031  dataTextField: "Name",
1032  dataValueField: "FromId",
1033  });
1034 
1035  var ds = currentSelectedRow.AdditionalInfo;
1036  var cjson = JSON.parse(JSON.stringify(ds));
1037  var dataSource = new kendo.data.DataSource;
1038 
1039  dataSource.add({ description: "<?php echo $MC->msg("Type", HCU_DISPLAY_AS_JS) ?>", dvalue: title});
1040  dataSource.add({ description: "<?php echo $MC->msg("To", HCU_DISPLAY_AS_JS) ?>", dvalue: currentSelectedRow.ToName});
1041  dataSource.add({ description: "<?php echo $MC->msg("Amount", HCU_DISPLAY_AS_JS) ?>", dvalue: kendo.toString(currentSelectedRow.Amount, "c")});
1042  dataSource.add({ description: "<?php echo $MC->msg("Date", HCU_DISPLAY_AS_JS) ?>", dvalue: kendo.toString(kendo.parseDate(currentSelectedRow.Date), "MM/dd/yyyy")});
1043 
1044  var desc = "";
1045  for(var key in cjson){
1046  var keyname = key.replace("_", " ");
1047  if(keyname == 'From') {
1048  desc = "<?php echo $MC->msg("From", HCU_DISPLAY_AS_JS) ?>";
1049  } else if(keyname == 'Method') {
1050  desc = "<?php echo $MC->msg("Method", HCU_DISPLAY_AS_JS) ?>";
1051  } else if(keyname == 'Estimated Arrival'){
1052  desc = "<?php echo $MC->msg("Estimated Arrival", HCU_DISPLAY_AS_JS) ?>";
1053  } else if(keyname == 'Status'){
1054  desc = "<?php echo $MC->msg("Status", HCU_DISPLAY_AS_JS) ?>";
1055  }else {
1056  desc = keyname;
1057  }
1058  dataSource.add({ description: desc, dvalue: cjson[key]});
1059  }
1060 
1061  dataSource.add({ description: "<?php echo $MC->msg("ACH Frequency", HCU_DISPLAY_AS_JS) ?>", dvalue: currentSelectedRow.Frequency});
1062 
1063  if (currentSelectedRow.Type === "Transfer"){
1064  $("#btnStopPayment").text("<?php echo $MC->msg("Stop Transfer", HCU_DISPLAY_AS_JS) ?>");
1065  $("#btnPayment").text("<?php echo $MC->msg("Edit Transfer", HCU_DISPLAY_AS_JS) ?>");
1066  } else {
1067  $("#btnStopPayment").text("<?php echo $MC->msg("CU feature STOP", HCU_DISPLAY_AS_JS) ?>");
1068  $("#btnPayment").text("<?php echo $MC->msg("Edit Payment", HCU_DISPLAY_AS_JS) ?>");
1069  }
1070 
1071  myDetailGrid = $("#detailGrid");
1072  myDetailGrid.kendoGrid({
1073  dataSource: dataSource,
1074  rowTemplate: kendo.template($("#detailPaymentRow").html()),
1075  selectable: true,
1076  visible: true,
1077  columns: [ { headerAttributes: {style: "display: none"}}],
1078  noRecords: {template: "<?php echo $MC->msg('No Scheduled Found', HCU_DISPLAY_AS_JS); ?>"},
1079  }).data('kendoWindow');
1080 
1081  detailWindow.open().toFront().center();
1082  }
1083 
1084  editPaymentModel = kendo.observable({
1085  bpTxnId: "",
1086  bpFromId: "",
1087  bpToId: "",
1088  bpToName: "",
1089  bpAmt: "",
1090  bpDate: "",
1091  bpDueModelProcessDate: "",
1092  bpFreq: "",
1093  bpPayNum: "",
1094  bpEndDate: "",
1095  bpDuration: "",
1096  dirtyFlag: false,
1097  ResetModel: function() {
1098  this.set( "bpFromId", "" );
1099  this.set( "bpToId", "" );
1100  this.set( "bpToName", "" );
1101  this.set( "bpAmt", "" );
1102  <?php if ( strtolower($mpDateModel) == "due") : ?>
1103  this.set( "bpDate", "" );
1104  this.set ("bpDueModelProcessDate", "");
1105  <?php else : ?>
1106  this.set( "bpDate", "" );
1107  <?php endif; ?>
1108  this.set( "bpTxnId", 0 );
1109  this.set( "bpFreq", "" );
1110  this.set( "bpPayNum", "" );
1111  this.set( "bpEndDate", "" );
1112  this.set( "bpDuration", "" );
1113  //unchecking radio buttons
1114  $("#rdNum").prop("checked", false);
1115  $("#rdNvr").prop("checked", false);
1116  $("#rdEnd").prop("checked", false);
1117  this.set( "dirtyFlag", false );
1118  },
1119  SetPaymentValues: function(currentSelectedRow) {
1120  this.set( "bpFromId", currentSelectedRow.FromId );
1121  this.set( "bpToId", currentSelectedRow.ToId );
1122  this.set( "bpToName", currentSelectedRow.ToName );
1123  this.set( "bpAmt", currentSelectedRow.Amount );
1124  <?php if ( strtolower($mpDateModel) == "due") : ?>
1125  this.set( "bpDate", currentSelectedRow.AdditionalInfo.Estimated_Arrival );
1126  this.set( "bpDueModelProcessDate",currentSelectedRow.Date);
1127  <?php else : ?>
1128  this.set( "bpDate", currentSelectedRow.Date );
1129  <?php endif; ?>
1130  this.set( "bpTxnId", currentSelectedRow.TxnId );
1131  },
1132  SetDirty: function(e) {
1133  this.set( "dirtyFlag", true );
1134  },
1135  ClearDirty: function() {
1136  this.set( "dirtyFlag", false );
1137  },
1138  Save: function() {
1139  dsPayment.options.transport.read.data.mp_type = mpAction;
1140  dsPayment.options.transport.read.data.txnid = this.bpTxnId;
1141  dsPayment.options.transport.read.data.toid = this.bpToId;
1142  dsPayment.options.transport.read.data.fromid = this.bpFromId;
1143  dsPayment.options.transport.read.data.amount = kendo.parseFloat(this.bpAmt);
1144  <?php if ( strtolower($mpDateModel) == "due") : ?>
1145  dsPayment.options.transport.read.data.paydate = kendo.toString(this.bpDueModelProcessDate,"yyyy-MM-dd");
1146  <?php else : ?>
1147  dsPayment.options.transport.read.data.paydate = kendo.toString(this.bpDate,"yyyy-MM-dd");
1148  <?php endif; ?>
1149  dsPayment.options.transport.read.data.freq = this.bpFreq;
1150  dsPayment.options.transport.read.data.paynum = this.bpPayNum;
1151  dsPayment.options.transport.read.data.enddate = kendo.toString(this.bpEndDate,"yyyy-MM-dd");
1152  dsPayment.options.transport.read.data.duration = this.bpDuration;
1153  dsPayment.read();
1154  }
1155  });
1156 
1157  function PaymentSave(){
1158  var confirmBtn;
1159  var msgConfirm;
1160  var type;
1161  <?php if ($mpType == "Payment") : ?>
1162  confirmBtn = "<?php echo $MC->msg("Confirm New Payment", HCU_DISPLAY_AS_JS) ?>" ;
1163  type = "<?php echo $MC->msg("Pay", HCU_DISPLAY_AS_JS) ?>";
1164  <?php else : ?>
1165  confirmBtn = "<?php echo $MC->msg("Confirm New Transfer", HCU_DISPLAY_AS_JS)?>" ;
1166  type = "<?php echo $MC->msg("Transfer", HCU_DISPLAY_AS_JS) ?>"
1167  <?php endif; ?>
1168 
1169  <?php if ( $allowRecur == "true" ) : ?>
1170  msgConfirm = type + " <b>" + kendo.toString(editPaymentModel.bpAmt, "c2") + "</b> " + ($("#billFreq").data("kendoDropDownList").text()).toLowerCase() + " <?php echo $MC->msg("To", HCU_DISPLAY_AS_JS) ?> <b>" + editPaymentModel.bpToName + "</b> <?php echo $MC->msg("From Account", HCU_DISPLAY_AS_JS) ?> <b>" + $("#toFrom").data("kendoDropDownList").text();
1171 
1172  //changing message according to duration of recurrring payment
1173  if ( editPaymentModel.bpDuration == "never" ) {
1174  msgConfirm += "</b> <?php echo $MC->msg("starting on", HCU_DISPLAY_AS_JS) ?> <b>" + kendo.toString(editPaymentModel.bpDate,"MM/dd/yyyy") + "</b> <?php echo $MC->msg("until", HCU_DISPLAY_AS_JS) ?> <?php echo $MC->msg("Cancelled", HCU_DISPLAY_AS_JS) ?>".toLowerCase() + "?";
1175  } else if ( editPaymentModel.bpDuration == "number" ) {
1176  msgConfirm += "</b> <?php echo $MC->msg("starting on", HCU_DISPLAY_AS_JS) ?> <b>" + kendo.toString(editPaymentModel.bpDate,"MM/dd/yyyy") + "</b> <?php echo $MC->msg("for", HCU_DISPLAY_AS_JS) ?> <b>" + editPaymentModel.bpPayNum + "</b> <?php echo $MC->msg("Payments", HCU_DISPLAY_AS_JS) ?>".toLowerCase() + "?";
1177  } else if ( editPaymentModel.bpDuration == "date" ) {
1178  msgConfirm += "</b> <?php echo $MC->msg("starting on", HCU_DISPLAY_AS_JS) ?> <b>" + kendo.toString(editPaymentModel.bpDate,"MM/dd/yyyy") +
1179  "</b> <?php echo $MC->msg("until", HCU_DISPLAY_AS_JS) ?> <b>" + kendo.toString(editPaymentModel.bpEndDate,"MM/dd/yyyy") + "</b>?" ;
1180  } else {
1181  msgConfirm += "</b> <?php echo $MC->msg("on", HCU_DISPLAY_AS_JS) ?> <b>" + kendo.toString(editPaymentModel.bpDate,"MM/dd/yyyy") + "</b>?";
1182  }
1183 
1184  <?php else : ?>
1185  msgConfirm = type + " <b>" + kendo.toString(editPaymentModel.bpAmt, "c2") + "</b> to <b>" + editPaymentModel.bpToName + "</b> from account <b>" +
1186  $("#toFrom").data("kendoDropDownList").text() + "</b> on <b>" + kendo.toString(editPaymentModel.bpDate,"MM/dd/yyyy") + "</b>?";
1187  <?php endif; ?>
1188 
1189  confirmDialog = $("#confirmTemplate").kendoDialog({
1190  visible:false,
1191  width: "400px",
1192  title: "<?php echo $MC->msg("Save", HCU_DISPLAY_AS_JS) ?> " + type,
1193  closable: false,
1194  modal: true,
1195  content: msgConfirm,
1196  actions: [
1197  { text: '<?php echo $MC->msg("Close", HCU_DISPLAY_AS_JS) ?>',
1198  action: function(e) {
1199  // ** Close the current dialog
1200  }
1201  },
1202  { text: confirmBtn,
1203  primary: true,
1204  action: function(e) {
1205  //save payment or transfer
1206  editPaymentModel.Save();
1207  windowStack.pop();
1208  }
1209  }
1210  ],
1211  show: function() {
1212  // add the close function to the window stack
1213  windowStack.push(function(e) {
1214  confirmDialog.close(e);
1215  });
1216  },
1217  close: function(e) {
1218  // now remove the close function call
1219  windowStack.pop();
1220  }
1221  }).data("kendoDialog");
1222  confirmDialog.open();
1223  }
1224 
1225  function StopPayment(){
1226  mpAction = "StopPayment";
1227  var msgConfirm;
1228 
1229  if ( mpType == "Payment" ) {
1230  confirmBtn = "<?php echo $MC->msg("Confirm Stop Payment", HCU_DISPLAY_AS_JS) ?>" ;
1231  type = "<?php echo $MC->msg("Pay", HCU_DISPLAY_AS_JS) ?>";
1232  } else {
1233  confirmBtn = "<?php echo $MC->msg("Confirm Stop Transfer", HCU_DISPLAY_AS_JS) ?>" ;
1234  type = "<?php echo $MC->msg("Transfer", HCU_DISPLAY_AS_JS) ?>"
1235  }
1236 
1237  <?php if ( $allowRecur == "true" ) : ?>
1238  msgConfirm = "<?php echo $MC->msg("Confirm Stop", HCU_DISPLAY_AS_JS) ?> " + type.toLowerCase() + "</b> <?php echo $MC->msg("To", HCU_DISPLAY_AS_JS) ?> <b>" + currentSelectedRow.ToName + "</b> " + " <?php echo $MC->msg("for", HCU_DISPLAY_AS_JS) ?> <b>" + kendo.toString(currentSelectedRow.Amount, "c2");
1239 
1240  if ( currentSelectedRow.Frequency == "Once" ) {
1241  msgConfirm += "</b> <?php echo $MC->msg("on", HCU_DISPLAY_AS_JS) ?> <b>" + kendo.toString(currentSelectedRow.Date,"MM/dd/yyyy") + "</b>?";
1242  } else if ( currentSelectedRow.Frequency == "Annual" ) {
1243  msgConfirm += "</b> <?php echo $MC->msg("Recurring", HCU_DISPLAY_AS_JS) ?> <b><?php echo $MC->msg("Annually", HCU_DISPLAY_AS_JS) ?>".toLowerCase() + "</b> <?php echo $MC->msg("Set Start", HCU_DISPLAY_AS_JS) ?> <b>" + kendo.toString(currentSelectedRow.Date,"MM/dd/yyyy") + "</b>?";
1244  } else {
1245  msgConfirm += "</b> <?php echo $MC->msg("Recurring", HCU_DISPLAY_AS_JS) ?> <b>" + (currentSelectedRow.Frequency).toLowerCase() +
1246  "</b> <?php echo $MC->msg("Set Start", HCU_DISPLAY_AS_JS) ?> <b>" + kendo.toString(currentSelectedRow.Date,"MM/dd/yyyy") + "</b>?";
1247  }
1248 
1249  <?php else : ?>
1250  msgConfirm = "<?php echo $MC->msg("Confirm Stop", HCU_DISPLAY_AS_JS) ?> " + type.toLowerCase() + "</b> <?php echo $MC->msg("To", HCU_DISPLAY_AS_JS) ?> <b>" + currentSelectedRow.ToName + "</b>" + " <?php echo $MC->msg("on", HCU_DISPLAY_AS_JS) ?> <b>" + kendo.toString(currentSelectedRow.Date,"MM/dd/yyyy") + "</b>" + " <?php echo $MC->msg("for", HCU_DISPLAY_AS_JS) ?> <b>" + kendo.toString(currentSelectedRow.Amount, "c2") + "?";
1251  <?php endif; ?>
1252 
1253  //setting model fields for deletion
1254  editPaymentModel.set("bpTxnId", currentSelectedRow.TxnId);
1255 
1256  confirmDialog = $("#confirmTemplate").kendoDialog({
1257  width: "55%",
1258  title: "<?php echo $MC->msg('Stop', HCU_DISPLAY_AS_JS); ?> " + type,
1259  maxWidth: "500px",
1260  minWidth: "300px",
1261  modal: true,
1262  closable: false,
1263  visible: false,
1264  resizable: false,
1265  content: msgConfirm,
1266  actions: [
1267  { text: '<?php echo $MC->msg('Close', HCU_DISPLAY_AS_JS); ?>',
1268  action: function(e) {
1269  // ** Close the current dialog
1270  }
1271  },
1272  { text: confirmBtn,
1273  primary: true,
1274  action: function(e) {
1275  // stop the payment
1276  editPaymentModel.Save();
1277  }
1278  }
1279  ],
1280  show: function() {
1281  // add the close function to the window stack
1282  windowStack.push(function(e) {
1283  confirmDialog.close(e);
1284  });
1285  },
1286  close: function(e) {
1287  //now remove the close function call
1288  windowStack.pop();
1289  }
1290  }).data("kendoDialog");;
1291  confirmDialog.open();
1292  }
1293 
1294  discardDialog = $("#discardDialog").kendoDialog({
1295  visible: false,
1296  closable: false,
1297  title: "<?php echo $MC->msg("ACH Discard Changes?", HCU_DISPLAY_AS_JS) ?>",
1298  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) ?>",
1299  show: function(e) {
1300  // add the close function to the window stack
1301  windowStack.push(function(e) {
1302  discardDialog.close(e);
1303  });
1304  },
1305  close: function(e) {
1306  // remove the close function from the window windowStack
1307  windowStack.pop();
1308  },
1309  actions: [{
1310  text: "<?php echo $MC->msg("Cancel", HCU_DISPLAY_AS_JS) ?>",
1311  action: function(e) {
1312  // ** Close the current dialog
1313  }
1314  },
1315  {
1316  text: "<?php echo $MC->msg("Continue", HCU_DISPLAY_AS_JS) ?>",
1317  primary: true,
1318  action: function(e) {
1319  // clear any dirty flags
1320  editPaymentModel.ClearDirty();
1321  // remove this dialog's close
1322  windowStack.pop();
1323 
1324  /* ** DISCARD CHANGES by calling prior window's close ** */
1325  editPaymentWindow.close();
1326  }
1327  }]
1328  }).data("kendoDialog");
1329 
1330  function compareDates(xdate, mdates) {
1331  for (var i = 0; i < mdates.length; i++) {
1332  if (mdates[i].getDate() == xdate.getDate() &&
1333  mdates[i].getMonth() == xdate.getMonth() &&
1334  mdates[i].getYear() == xdate.getYear()) {
1335  return true
1336  }
1337  }
1338  }
1339 
1340  function EditPayment() {
1341 
1342  var txnId = currentSelectedRow.TxnId;
1343  if (currentSelectedRow.Type === "Transfer"){
1344  $("#editPayTo").text("<?php echo $MC->msg("ACH To Account", HCU_DISPLAY_AS_JS) ?>");
1345  $("#editToFrom").text("<?php echo $MC->msg("From Account", HCU_DISPLAY_AS_JS) ?>");
1346  $("#editPayDate").text("<?php echo $MC->msg("Process Date", HCU_DISPLAY_AS_JS) ?>");
1347  $("#payTo").attr("data-required-msg", "<?php echo $MC->msg("Transfer To Account Missing", HCU_DISPLAY_AS_JS) ?>");
1348  $("#toFrom").attr("data-required-msg", "<?php echo $MC->msg("Transfer From Account Missing", HCU_DISPLAY_AS_JS) ?>");
1349  $("#payAmount").attr("data-required-msg", "<?php echo $MC->msg("Transfer Amount Missing", HCU_DISPLAY_AS_JS) ?>");
1350  $("#payDate").attr("data-required-msg", "<?php echo $MC->msg("Process Date Missing", HCU_DISPLAY_AS_JS) ?>");
1351  } else {
1352  $("#editPayTo").text("<?php echo $MC->msg("ACH Payee", HCU_DISPLAY_AS_JS) ?>");
1353  $("#editToFrom").text("<?php echo $MC->msg("Account", HCU_DISPLAY_AS_JS) ?>");
1354 
1355  <?php if ( strtolower($mpDateModel) == "due") : ?>
1356  $("#editPayDate").text("<?php echo $MC->msg("Deliver By Date", HCU_DISPLAY_AS_JS) ?>");
1357  $("#editPayDueDate").text("<?php echo $MC->msg("Process Date", HCU_DISPLAY_AS_JS) ?>");
1358  <?php else : ?>
1359  $("#editPayDate").text("<?php echo $MC->msg("Process Date", HCU_DISPLAY_AS_JS) ?>");
1360  <?php endif; ?>
1361 
1362  $("#payTo").attr("data-required-msg", "<?php echo $MC->msg("Payee Missing", HCU_DISPLAY_AS_JS) ?>");
1363  $("#toFrom").attr("data-required-msg", "<?php echo $MC->msg("Account is required", HCU_DISPLAY_AS_HTML)?>");
1364  $("#payAmount").attr("data-required-msg", "<?php echo $MC->msg("Payment Amount Missing", HCU_DISPLAY_AS_JS) ?>");
1365  $("#payDate").attr("data-required-msg", "<?php echo $MC->msg("Process Date Missing", HCU_DISPLAY_AS_JS) ?>");
1366  }
1367 
1368  $("#payDate").attr("autocomplete", "off").kendoDatePicker();
1369 
1370  //adding required stars
1371  $("#editPayTo").append('<span class="hcu-required-field"><sup>*</sup></span>');
1372  $("#editToFrom").append('<span class="hcu-required-field"><sup>*</sup></span>');
1373  $("#editPayDate").append('<span class="hcu-required-field"><sup>*</sup></span>');
1374 
1375  <?php if ( $allowRecur == 'true' ) : ?>
1376  $("#endDate").attr("autocomplete", "off").kendoDatePicker();
1377  $("#editBillFreq").text("<?php echo $MC->msg('Payment Frequency', HCU_DISPLAY_AS_HTML); ?>");
1378 
1379  $("#editBillFreq").append('<span class="hcu-required-field"><sup>*</sup></span>');
1380  $("#editBillFreq").append('<span class="fa fa-question-circle-o" id="freqTip"></span>');
1381 
1382  homecuTooltip.bind({
1383  freqTip:
1384  "<?php echo $MC->msg("Billing Frequency Tip", HCU_DISPLAY_AS_HTML)?>"
1385  });
1386  <?php endif; ?>
1387 
1388  editPaymentModel.SetPaymentValues(currentSelectedRow);
1389 
1390  $("#closeEditBtn").click( function() {
1391  if (editPaymentModel.dirtyFlag){
1392  discardDialog.open();
1393  } else {
1394  editPaymentWindow.close();
1395  }
1396  });
1397 
1398  $("#btnUpdatePayment").click( function() {
1399  if ( $.homecuValidator.validate() ) {
1400  mpAction = "UpdatePayments";
1401  PaymentSave();
1402  }
1403  });
1404 
1405  $("#valuePayDueDate").text(currentSelectedRow.Date);
1406 
1407  // For PSCUPAY_API, Pay_From is used - may want to fix this in the future
1408  if(currentSelectedRow.AdditionalInfo.Pay_From){
1409  var acctDDL = $("#toFrom").data("kendoDropDownList");
1410  // selects item
1411  acctDDL.select(function(dataItem) {
1412  return dataItem.FromId === currentSelectedRow.AdditionalInfo.Pay_From;
1413  });
1414  }
1415 
1416  if(currentSelectedRow.Frequency){
1417  var freqDDL = $("#billFreq").data("kendoDropDownList");
1418  // selects item
1419  freqDDL.select(function(dataItem) {
1420  return dataItem.value === currentSelectedRow.Frequency;
1421  });
1422  }
1423 
1424  if ( currentSelectedRow.Frequency == "Once" ) {
1425  $("#billFreq").data('kendoDropDownList').enable(false);
1426  $("input[name=duration]").attr('disabled',true);
1427  $("#payNum").attr('disabled',true);
1428  $("#endDate").data('kendoDatePicker').enable(false);
1429  } else {
1430  $("#billFreq").data('kendoDropDownList').enable(true);
1431  $("input[name=duration]").attr('disabled',false);
1432  $("input:radio[name=duration]").attr("required", true);
1433 
1434  //add data required message for radio buttons
1435  $("input:radio[name=duration]").attr("data-required-msg", "<?php echo $MC->msg("Duration Required", HCU_DISPLAY_AS_JS) ?>");
1436  $("#payNum").attr('disabled',false);
1437  $("#endDate").data('kendoDatePicker').enable(true);
1438  }
1439 
1440  var payAmount = $("#payAmount").data("kendoNumericTextBox");
1441  payAmount.value(currentSelectedRow.Amount);
1442 
1443  LoadPaymentWindow();
1444  }
1445 
1446  function LoadPaymentWindow() {
1447 
1448  //waiting to load payment window until all data has loaded
1449  editPaymentWindow = $("#editPaymentTemplate").kendoWindow({
1450  modal: true,
1451  visible: false,
1452  resizable: false,
1453  title: "<?php echo $MC->msg("Edit", HCU_DISPLAY_AS_JS) ?>",
1454  minWidth: "80%",
1455  position: { top: 100, left: "10%" , right: "10%"},
1456  activate: function(e) {
1457  windowStack.push(function(e) {
1458  editPaymentWindow.close(e);
1459  });
1460  $.homecuValidator.setup({formValidate: "editPaymentTemplate",
1461  formErrorTitle: "<?php echo $MC->msg("Error Occurred", HCU_DISPLAY_AS_JS) ?>",
1462  formStatusField: "editPaymentFormStatus"});
1463  },
1464  close: function() {
1465 
1466  windowStack.pop();
1467  $('#closeEditBtn').off();
1468  $('#btnUpdatePayment').off();
1469  }
1470  }).data('kendoWindow');
1471 
1472  // editPaymentWindow.title("<?php echo $MC->msg("Edit", HCU_DISPLAY_AS_JS) ?> " + currentSelectedRow.Type);
1473  editPaymentWindow.open().toFront().center();
1474 
1475  }
1476 
1477  function onChange(arg) {
1478  var selected = $.map(this.select(), function(item) {
1479  return $(item).text();
1480  });
1481 
1482  var entityGrid = $("#grid").data("kendoGrid");
1483  currentSelectedRow = entityGrid.dataItem(entityGrid.select());
1484  dsGetAccounts.options.transport.read.data.paymentType = currentSelectedRow.Type;
1485  dsGetAccounts.read();
1486 
1487  //setting alowed dates for payments before pulling in current transaction details
1488  dsGetDates.options.transport.read.data.vPayeeId = currentSelectedRow.ToId;
1489  dsGetDates.read();
1490 
1491  showDetailWindow();
1492 
1493  }
1494 
1495  $(document).on("click", ".k-overlay", function (e) {
1496  if(windowStack.length > 0) {
1497  // get the close function from the stack, without poping it (the close will pop it)
1498  var fn = windowStack[windowStack.length - 1];
1499  var ret = fn(e);
1500  }
1501  });
1502 
1503  $(document).ready(function () {
1504  $.homecuValidator.setup({formErrorTitle: "<?php echo $MC->msg("Error Occurred", HCU_DISPLAY_AS_JS) ?>"});
1505 
1506  InitDataSources();
1507 
1508  $("#grid").kendoGrid({
1509  dataSource: dsAcctHistory,
1510  rowTemplate: kendo.template($("#scheduledRow").html()),
1511  change: onChange,
1512  selectable: true,
1513  visible: false,
1514  columns: [ {headerAttributes: {style: "display: none"}, attributes:{style:"border-left-width: 0;"}},
1515  {width: "100px", headerAttributes: {style: "display: none"},attributes:{style:"border-left-width: 0;"}}],
1516  noRecords: {template: "<?php echo $MC->msg('No Records Found', HCU_DISPLAY_AS_JS); ?>"},
1517  });
1518 
1519  <?php if ( $mpType == "Payment") : ?>
1520  $( "#grid" ).hide();
1521  $( "#typeGroupButtonSelect" ).hide();
1522  <?php endif; ?>
1523 
1524  kendo.bind($("#editPaymentTemplate"), editPaymentModel);
1525 
1526  });
1527 
1528 </script>
1529 <?php
1530  /*
1531  * ** END CONTENT
1532  */
1533 
1534 
1535  // ** INCLUDE POST CONTENT SCRIPT
1536  require_once(dirname(__FILE__) . '/../includes/hcuPostContent.i');
1537 ?>