Odyssey
hcuMobilePayPayees.prg
1 <?php
2  /*
3  * File: hcuMobilePayPayees.prg
4  *
5  * Purpose: This script will show all current payees for mobile banking.
6  *
7  * Created by ENR, 1/2019
8  *
9  */
10 
11  $serviceViewFromCUAdmin = (isset($serviceViewFromCUAdmin) ? $serviceViewFromCUAdmin : false);
12  if (!$serviceViewFromCUAdmin) {
13  // ** SET SCRIPT LEVEL VARIABLES
14  $serviceShowInfo = true;
15  $serviceLoadMenu = true;
16  $serviceShowMenu = true;
17  $serviceLiveCheck = true;
18  // ** INCLUDE MAIN GLOBAL SCRIPT -- Handles security / global variable values
19  require_once(dirname(__FILE__) . '/../library/hcuService.i');
20  }
21 
22  require_once(dirname(__FILE__) . '/hcuMobilePay.plugin');
23  require_once(dirname(__FILE__) . '../../../shared/library/cutrusted.i');
24 
25  /*
26  * ** CHECK USER FEATURE PERMISSIONS **
27  * NOTE: DOES NOT RETURN ON FAILURE
28  */
29  PermCheckFeatureScreen($dbh, $HB_ENV, $MC, FEATURE_BASIC);
30 
31  // ** INSERT BUSINESS LOGIC FOR THIS FORM
32  $inputVars = array();
33  $varOk = array("mp_token"=>"string", "mp_type"=>"string", "mpVendor"=>"string", "allowp2p"=>"string");
34 
35  HCU_ImportVars( $inputVars, "", $varOk );
36 
37  // extract the encrypted stuff
38  if ( strpos( $inputVars['mp_token'], "=" ) !== false ||
39  strpos( $inputVars['mp_token'], "+" ) !== false ) {
40  // already decoded
41  $decodedToken = $inputVars['mp_token'];
42  $encodedToken = urlencode( $inputVars['mp_token'] );
43  } else {
44  $encodedToken = $inputVars['mp_token'];
45  $decodedToken = urldecode( $inputVars['mp_token'] );
46  }
47 
48  $commonString = hcu_decrypturl( $decodedToken, $HB_ENV['2factorkey']);
49 
50  parse_str( $commonString, $commonParms );
51 
52  $mpType = $inputVars["mp_type"];
53  $mpDateModel = $commonParms["mpDateModel"];
54  $mobilePayName = $commonParms["mpName"];
55  $mpAccount = $commonParms["mpAccount"];
56  $mpVendorKey = $commonParms["mpVendor"];
57  $mpToken = $commonParms["mpToken"];
58  //pulling permission from vendor/cu to allow P2P type Payees
59  $allowP2P = $commonParms["allowp2p"];
60  //get SubId
61  $userTokens = explode("|", $mpToken);
62  $subId = $userTokens[1];
63 
64  $accountTypes = GetBPAccountTypes($HB_ENV["MC"]);
65  $p2pTypes = GetBPP2PTypes($HB_ENV["MC"]);
66 
67  // extras need to be in an array
68  $extrasString = str_replace( "|", "&", $commonParms["mpExtras"] );
69  $extrasString = str_replace( ":", "=", $extrasString );
70 
71  parse_str( $extrasString, $mpExtras );
72 
73  // turn the extra options into a string like: key1:value1|key2:value2|key3:value3...
74  $extrasString = "";
75  foreach ($mpExtras as $key => $val) {
76  if ( strlen( $extrasString ) > 0 ) $extrasString .= "|";
77  $extrasString .= "$key:$val";
78  }
79 
80  if (strlen( $mpToken )) {
81  // set up common parameters
82  $commonURL = "mpToken=$mpToken&mpVendor=$mpVendorKey&mpDateModel=$mpDateModel&mpName=$mobilePayName&mpExtras=$extrasString&allowp2p=$allowP2P&mpAccount=$mpAccount";
83  $encryptedCommonURL = hcu_encrypturl( $commonURL, $HB_ENV['2factorkey'] );
84  $encodedCommonURL = urlencode( $encryptedCommonURL );
85  }
86 
87  //this is the header and side menu
88  // ** INCLUDE PRE CONTENT SCRIPT
89  require_once(dirname(__FILE__) . '/../includes/hcuPreContent.i');
90 ?>
91 
92 <!-- kendo mobile -->
93 <style>
94 .k-grid .payee-view {
95  border-left-width: 0;
96 }
97 
98 .payee-name {
99  font-weight: bold;
100 }
101 
102 .payee-date {
103  font-size: .8em;
104 }
105 
106 #buttonWindow {
107  font-size: 1.1em;
108  font-weight: bold;
109 }
110 
111 .k-icon {
112  padding: 5px;
113 }
114 
115 .k-window-titlebar .k-window-actions {
116  display: none;
117 }
118 
119 </style>
120 <!-- template for payee grid -->
121 <script id="addPayee" type="text/x-kendo-template">
122  <div id="payee-add" class="payee-add">
123  <span class="k-icon k-i-plus"></span>
124  <span class="add"><?php echo $MC->msg("Add New Payee", HCU_DISPLAY_AS_HTML)?></span>
125  </div>
126 </script>
127 <script id="payeeRow" type="text/x-kendo-template">
128  <tr>
129  <td class="payee-view">
130  <div class="col-xs-12 payee-name">#: Name# (#: Nickname#)</div>
131  <div class="col-xs-12 payee-date"><?php echo $MC->msg("Last Paid", HCU_DISPLAY_AS_HTML)?>: #: kendo.toString(Amount, "C")# <?php echo $MC->msg("on", HCU_DISPLAY_AS_JS) ?> #if(Date === "") {# N/A #} else {# #=kendo.toString(kendo.parseDate(Date), "MM/dd/yyyy") # #}#</div>
132  </td>
133  <td class="payee-view">
134  <span class="k-icon k-i-edit k-i-pencil" onclick='EditPayee(this)'></span>
135  <span class="k-icon k-i-delete k-i-trash" onclick='DeletePayee(this)'</span>
136  </td>
137  </tr>
138 </script>
139 
140 <div id="confirmationWindow"></div>
141 <div id="confirmationDeleteTemplate"></div>
142 <div id="buttonWindow" name="buttonWindow" style="display: none;" class="container-fluid">
143  <div class="row">
144  <div class='col-xs-12'>
145  <span id="billPayBtn" class="k-button payBtns" style="width:100%; height:100%; margin-top: 10px;"><span class="fa fa-credit-card"></span>&nbsp;<?php echo $MC->msg("New Bill Payee", HCU_DISPLAY_AS_HTML) ?></span>
146  </div>
147  </div>
148  <div class="row">
149  <div class='col-xs-12'>
150  <span id="extTransBtn" class="k-button payBtns" style="width:100%; height:100%; margin-top: 10px;"><span class="fa fa-exchange"></span>&nbsp;<?php echo $MC->msg("New External Transfer", HCU_DISPLAY_AS_HTML) ?></span>
151  </div>
152  </div>
153  <?php if($allowP2P == 'true') : ?>
154  <div class="row">
155  <div class='col-xs-12'>
156  <span id="indPayBtn" class="k-button payBtns" style="width:100%; height:100%; margin-top: 10px;"><span class="fa fa-user"></span>&nbsp;<?php echo $MC->msg("New Indv Payee", HCU_DISPLAY_AS_HTML) ?></span>
157  </div>
158  </div>
159  <?php endif; ?>
160 </div>
161 <!-- Payee Detail -->
162  <div id="detailPayeeTemplate" name="detailPayeeTemplate" style="display: none;" class="container-fluid">
163  <div class="row">
164  <div class="k-content col-xs-12 " >
165  <div id="detailPayeeFormStatus" class="homecu-formStatus k-block k-error-colored" style="display:none; margin-bottom:10px;"></div>
166  <div id='editErrors'></div>
167  <div class="form-horizontal form-widgets well well-sm">
168  <!-- Payee Name -->
169  <div class="form-group comp indv">
170  <label class="col-sm-12" for="payeeName"><?php echo $MC->msg("Payee Name", HCU_DISPLAY_AS_HTML) ?>
171  <span class="hcu-required-field"><sup>*</sup></span></label>
172  <div class="col-sm-12">
173  <input id='payeeName' class='k-textbox distinctAcct hcu-all-100' name='payeeName' type="text" pattern="[0-9a-zA-Z .,'-]{1,100}"
174  data-required-msg="<?php echo $MC->msg("Payee Name Missing", HCU_DISPLAY_AS_HTML) ?>"
175  data-bind="value: payeeName"
176  validationMessage="<?php echo $MC->msg("Payee Name Invalid", HCU_DISPLAY_AS_HTML) ?>"
177  required/>
178  </div>
179  </div>
180  <!-- Routing Number -->
181  <div class="form-group fininst">
182  <label class="col-sm-12" for="routingNum"><?php echo $MC->msg("Routing Number", HCU_DISPLAY_AS_HTML) ?><span class="hcu-required-field"><sup>*</sup></span></label>
183  <div class="col-sm-12">
184  <input id='routingNum' class='k-textbox distinctAcct hcu-all-100' name='routingNum' type="text"
185  data-required-msg="<?php echo $MC->msg("Routing Number Missing", HCU_DISPLAY_AS_HTML) ?>"
186  data-bind="value: routingNum"
187  validationMessage="<?php echo $MC->msg("Routing Number Invalid", HCU_DISPLAY_AS_HTML) ?>"
188  required/>
189  </div>
190  </div>
191  <!-- Account Number -->
192  <div class="form-group fininst comp ">
193  <label class="col-sm-12" for="accountNum"><?php echo $MC->msg("Account Number", HCU_DISPLAY_AS_HTML) ?><span class="hcu-required-field"><sup>*</sup></span></label>
194  <div class="col-sm-12">
195  <input id='accountNum' class='k-textbox distinctAcct hcu-all-100' name='accountNum' type="text"
196  data-required-msg="<?php echo $MC->msg("Account Number Missing", HCU_DISPLAY_AS_HTML) ?>"
197  data-bind="value: accountNum"
198  validationMessage="<?php echo $MC->msg("Account Number Invalid", HCU_DISPLAY_AS_HTML) ?>"
199  required/>
200  </div>
201  </div>
202  <!-- Account Type -->
203  <div class="form-group fininst">
204  <label class="col-sm-12" for="accountType"><?php echo $MC->msg("Account Type", HCU_DISPLAY_AS_HTML)?><span class="hcu-required-field"><sup>*</sup></span></label>
205  <div class="col-sm-12">
206  <input id='accountType' class='distinctAcct hcu-all-100' name='accountType' data-role='dropdownlist'
207  data-bind="value: accountType"
208  data-required-msg="<?php echo $MC->msg("Account Type Missing", HCU_DISPLAY_AS_HTML)?>"
209  required/>
210  </div>
211  </div>
212  <!-- Address -->
213  <div class="form-group comp indv">
214  <label class="col-sm-12" for="addr1"><?php echo $MC->msg("ACH Address", HCU_DISPLAY_AS_HTML) . " 1"; ?><span class="hcu-required-field"><sup>*</sup></span></label>
215  <div class="col-sm-12">
216  <input id='addr1' class='k-textbox distinctAcct hcu-all-100' name='addr1' maxlength="100"
217  data-required-msg="<?php echo $MC->msg("Address Missing", HCU_DISPLAY_AS_HTML) ?>"
218  data-bind="value: addr1"
219  required/>
220  </div>
221  </div>
222  <!-- Address 2-->
223  <div class="form-group comp indv">
224  <label class="col-sm-12" for="addr1"><?php echo $MC->msg("ACH Address", HCU_DISPLAY_AS_HTML) . " 2"; ?></label>
225  <div class="col-sm-12">
226  <input id='addr2' class='k-textbox distinctAcct hcu-all-100' name='addr2' maxlength="100"
227  data-bind="value: addr2"
228  />
229  </div>
230  </div>
231  <!-- City-->
232  <div class="form-group comp indv">
233  <label class="col-sm-12" for="city"><?php echo $MC->msg("City", HCU_DISPLAY_AS_HTML)?><span class="hcu-required-field"><sup>*</sup></span></label>
234  <div class="col-sm-12">
235  <input id='city' class='k-textbox distinctAcct hcu-all-100' name='city' type='text' type="text" pattern="[[0-9a-zA-Z .,'-]{1,100}"
236  data-required-msg="<?php echo $MC->msg("City Missing", HCU_DISPLAY_AS_HTML)?>"
237  data-bind="value: city"
238  validationMessage="<?php echo $MC->msg("City Invalid", HCU_DISPLAY_AS_HTML)?>"
239  required/>
240  </div>
241  </div>
242  <!-- State-->
243  <div class="form-group comp indv">
244  <label class="col-sm-12" for="state"><?php echo $MC->msg("State", HCU_DISPLAY_AS_HTML)?><span class="hcu-required-field"><sup>*</sup></span></label>
245  <div class="col-sm-12">
246  <input id='state' class='distinctAcct hcu-all-100' name='state' data-role='dropdownlist'
247  data-bind="value: state"
248  data-required-msg="<?php echo $MC->msg("State Missing", HCU_DISPLAY_AS_HTML)?>"
249  required/>
250  </div>
251  </div>
252  <!-- Zipcode-->
253  <div class="form-group comp indv">
254  <label class="col-sm-12" for="zip"><?php echo $MC->msg("Zip Code", HCU_DISPLAY_AS_HTML)?><span class="hcu-required-field"><sup>*</sup></span></label>
255  <div class="col-sm-12">
256  <input id='zip' class='k-textbox distinctAcct hcu-all-100' name='zip' type="text"
257  data-bind="value: zip"
258  data-required-msg='<?php echo $MC->msg("Zip Code Missing", HCU_DISPLAY_AS_HTML)?>'
259  required/>
260  </div>
261  </div>
262  <!-- P2P Type -->
263  <div class="form-group indv">
264  <label class="col-sm-12" for="p2pType"><?php echo $MC->msg("P2P Type", HCU_DISPLAY_AS_HTML)?>
265  <span class="hcu-required-field"><sup>*</sup></span>
266  <span class="fa fa-question-circle-o" id="p2pTip"></span>
267  </label>
268  <div class="col-sm-12">
269  <input id='p2pType' class='distinctAcct hcu-all-100' name='p2pType' data-role='dropdownlist'
270  data-bind="value: p2pType"
271  data-required-msg="<?php echo $MC->msg("P2P Type Missing", HCU_DISPLAY_AS_HTML)?>"
272  required/>
273  </div>
274  </div>
275  <!-- Phone-->
276  <div class="form-group comp indv">
277  <label class="col-sm-12" for="phone"><?php echo $MC->msg("Phone", HCU_DISPLAY_AS_HTML)?>
278  <span id="phoneSpan" class="hcu-required-field"><sup>*</sup></span></label>
279  <div class="col-sm-12">
280  <input id='phone' class='k-textbox distinctAcct hcu-all-100' name='phone' type='tel'
281  data-bind="value: phone"
282  data-required-msg='<?php echo $MC->msg("Phone Missing", HCU_DISPLAY_AS_HTML)?>'
283  />
284  </div>
285  </div>
286  <!-- Email-->
287  <div class="form-group indv">
288  <label class="col-sm-12" for="email"><?php echo $MC->msg("Email", HCU_DISPLAY_AS_HTML)?>
289  <span id="emailSpan" class="hcu-required-field"><sup>*</sup></span>
290  <span class="fa fa-question-circle-o" id="emailTip"></span>
291  </label>
292  <div class="col-sm-12">
293  <input id='email' class='k-textbox distinctAcct hcu-all-100' name='email' type='email'
294  placeholder="<?php echo $MC->msg("Email Placeholder", HCU_DISPLAY_AS_HTML)?>"
295  validationMessage="<?php echo $MC->msg("Email appears invalid", HCU_DISPLAY_AS_HTML)?>"
296  data-required-msg="<?php echo $MC->msg("Email Missing", HCU_DISPLAY_AS_HTML)?>"
297  data-bind="value: email"
298  />
299  </div>
300  </div>
301  <!-- Name on Account / Subscriber Name -->
302  <div class="form-group comp">
303  <label class="col-sm-12" for="subName"><?php echo $MC->msg("EXT Name On Account", HCU_DISPLAY_AS_HTML) ?>
304  <span class="hcu-required-field"><sup>*</sup></span>
305  <span class="fa fa-question-circle-o" id="subNameTip"></span>
306  </label>
307  <div class="col-sm-12">
308  <input id='subName' class='k-textbox distinctAcct hcu-all-100' name='subName' type="text" pattern="[0-9a-zA-Z .,'-]{1,100}"
309  data-required-msg="<?php echo $MC->msg("Name On Account Missing", HCU_DISPLAY_AS_HTML) ?>"
310  data-bind="value: subName"
311  validationMessage="<?php echo $MC->msg("Name On Account Invalid", HCU_DISPLAY_AS_HTML) ?>"
312  required/>
313  </div>
314  </div>
315  <!-- Pay From-->
316  <div class="form-group comp indv fininst">
317  <label class="col-sm-12" for="payFrom"><?php echo $MC->msg("Account", HCU_DISPLAY_AS_HTML)?>
318  <span class="hcu-required-field"><sup>*</sup></span></label>
319  <div class="col-sm-12">
320  <input id='payFrom' class='distinctAcct hcu-all-100' name='payFrom' data-role='dropdownlist'
321  data-bind="value: accountId"
322  data-required-msg="<?php echo $MC->msg("Account is required", HCU_DISPLAY_AS_HTML)?>"
323  required/>
324  </div>
325  </div>
326  <!-- Payee Nickname -->
327  <div class="form-group comp indv fininst">
328  <label class="col-sm-12" for="nickName"><?php echo $MC->msg("Payee Nickname", HCU_DISPLAY_AS_HTML)?>
329  <span id="nickSpan" class="hcu-required-field"><sup>*</sup></span>
330  </label>
331  <div class="col-sm-12">
332  <input id='nickName' class='k-textbox distinctAcct hcu-all-100' name='nickName' type="text" pattern="[0-9a-zA-Z .,'-]{1,100}"
333  data-bind="value: nickName"
334  data-required-msg="<?php echo $MC->msg("Nickname Missing", HCU_DISPLAY_AS_HTML)?>"
335  validationMessage="<?php echo $MC->msg("Nickname Invalid", HCU_DISPLAY_AS_HTML)?>"
336  required/>
337  </div>
338  </div>
339  <!-- Shared Secret code or word -->
340  <div class="form-group indv">
341  <label class="col-sm-12" for="secret"><?php echo $MC->msg("Shared Secret", HCU_DISPLAY_AS_HTML)?>
342  <span class="hcu-required-field"><sup>*</sup></span>
343  <span class="fa fa-question-circle-o" id="secretTip"></span>
344  </label>
345  <div class="col-sm-12">
346  <input id='secret' class='k-textbox distinctAcct hcu-all-100' name='secret' type="text" pattern="[0-9a-zA-Z .,'-]{1,100}"
347  data-bind="value: secret"
348  data-required-msg="<?php echo $MC->msg("Secret Missing", HCU_DISPLAY_AS_HTML)?>"
349  validationMessage="<?php echo $MC->msg("Secret Invalid", HCU_DISPLAY_AS_HTML)?>"
350  required/>
351  </div>
352  </div>
353  <!-- ACTION BUTTONS -->
354  <div class="hcu-template">
355  <div class="hcu-edit-buttons k-state-default">
356  <a href="hcuMobilePayPayees.prg?<?php echo $HB_ENV['cuquery'] ?>&mp_token=<?php echo $encodedToken ?>&mp_type=Payees" id="lnkCancel" style=""><?php echo $MC->msg("Cancel", HCU_DISPLAY_AS_HTML)?></a>
357  &emsp;
358  <button class="k-button k-primary" id="btnEditPayee"><i class="fa fa-check fa-lg"></i><?php echo $MC->msg("Update", HCU_DISPLAY_AS_HTML)?></button>
359  <button class="k-button k-primary" id="btnAddPayee"><i class="fa fa-check fa-lg"></i><?php echo $MC->msg("Add", HCU_DISPLAY_AS_HTML)?></button>
360  </div>
361  </div>
362  </div>
363  </div>
364  </div>
365  </div>
366 <!-- Grid to show payee list -->
367 <div class="">
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 echo $MC->msg("Payees", HCU_DISPLAY_AS_HTML)?></span></span>
373  </div>
374  </div>
375  <div id="formStatusMain" class="homecu-formStatus k-block k-error-colored" style="display:none; margin: 10px;"></div>
376  <div class="row">
377  <div class="hcu-xs-btn-margin-top text-center" style="max-width:800px;">
378  <div class="btn-group" role="group" id="typeGroupButtonSelect">
379  <button type="button" class="btn btn-default" ><?php echo $MC->msg("Payments", HCU_DISPLAY_AS_HTML)?></button>
380  <button type="button" class="btn btn-default" ><?php echo $MC->msg("Transfers", HCU_DISPLAY_AS_HTML)?></button>
381  <button type="button" class="btn btn-default active" ><?php echo $MC->msg("All", HCU_DISPLAY_AS_HTML)?></button>
382  </div>
383  </div>
384  </div>
385  <div class="row">
386  <div class="col-xs-12" style="max-width:800px;">
387  <div id="grid" class="hcu-xs-btn-margin-top">
388  </div>
389  </div>
390  </div>
391  </div>
392 </div>
393 <script id="confirmationTemplateAdd" type="text/x-kendo-tmpl">
394  <div id="confirmationStatus"></div>
395  <div id="responseDiv">
396  <div class="local-transfer-msg">
397  <?php echo $MC->msg('Payee Added', HCU_DISPLAY_AS_JS); ?>
398  </div>
399  </div>
400 </script>
401 <script id="confirmationTemplateEdit" type="text/x-kendo-tmpl">
402  <div id="confirmationStatus"></div>
403  <div id="responseDiv">
404  <div class="local-transfer-msg">
405  <?php echo $MC->msg('Payee Updated', HCU_DISPLAY_AS_JS); ?>
406  </div>
407  </div>
408 </script>
409 <script id="confirmationTemplateDelete" type="text/x-kendo-tmpl">
410  <div id="confirmationStatus"></div>
411  <div id="responseDiv">
412  <div class="local-transfer-msg">
413  <?php echo $MC->msg('Payee Deleted', HCU_DISPLAY_AS_JS); ?>
414  </div>
415  </div>
416 </script>
417 <script type="text/javascript">
418 
419 var windowStack = [];
420 var dsCUAccounts = [];
421 var dataPayFrom = [];
422 var payeeType = "";
423 var payeeWindow;
424 var mpType = "";
425 var dsPayees;
426 var dsPayeeMod;
427 var stateList = <?php echo HCU_JsonEncode( GetBPStateList() ); ?>;
428 var accountTypes = <?php echo HCU_JsonEncode($accountTypes); ?>;
429 var p2pTypes = <?php echo HCU_JsonEncode($p2pTypes); ?>;
430 var subId = "<?php echo $subId; ?>";
431 
432 //edit dialog
433 function EditPayee(args){
434  var entityGrid = $("#grid").data("kendoGrid");
435  var tr = $(args).closest("tr");
436  currentSelectedRow = entityGrid.dataItem(tr);
437  //alert(JSON.stringify(currentSelectedRow));
438 
439  dsGetAccounts.read();
440 
441  payeeType = currentSelectedRow.Class;
442  payeeId = currentSelectedRow.Id;
443  ShowHideFields();
444  var request = { mp_type: "GetPayee", vPayeeId: payeeId };
445  dsPayeeMod.read(request);
446 
447  kendo.bind($("#detailPayeeTemplate"), payeeModel);
448  var window = $("#detailPayeeTemplate").data("kendoWindow");
449  window.setOptions({
450  title: "<?php echo $MC->msg('Edit Payee', HCU_DISPLAY_AS_JS); ?>",
451  });
452  $("#btnAddPayee").hide();
453  $("#btnEditPayee").show();
454  payeeWindow.open().toFront().center();
455 }
456 
457 //delete dialog
458 function DeletePayee(args){
459  var entityGrid = $("#grid").data("kendoGrid");
460  var tr = $(args).closest("tr");
461  currentSelectedRow = entityGrid.dataItem(tr);
462  dsGetAccounts.read();
463 
464  payeeType = currentSelectedRow.Class;
465  payeeId = currentSelectedRow.Id;
466  var payeeName = currentSelectedRow.Name;
467  var nickname = currentSelectedRow.Nickname;
468 
469  //pull payee info and bind to model
470  var request = { mp_type: "GetPayee", vPayeeId: payeeId };
471  dsPayeeMod.read(request);
472  kendo.bind($("#detailPayeeTemplate"), payeeModel);
473  //no need to open edit window
474 
475  //Confirmation delete dialog
476  var confirmDeleteDialog = $("#confirmationDeleteTemplate").kendoDialog({
477  title: "<?php echo $MC->msg('Delete', HCU_DISPLAY_AS_JS); ?>",
478  width: "55%",
479  maxWidth: "500px",
480  minWidth: "300px",
481  modal: true,
482  closable: false,
483  visible: false,
484  resizable: false,
485  content: "<?php echo $MC->msg('Delete Payee', HCU_DISPLAY_AS_JS); ?>: " + payeeName + " (" + nickname + ") ?",
486  actions: [
487  {
488  text: "<?php echo $MC->msg('Cancel', HCU_DISPLAY_AS_JS); ?>",
489  },
490  {
491  text: "<?php echo $MC->msg('Delete', HCU_DISPLAY_AS_JS); ?>",
492  primary: true,
493  action: function(e) {
494  mpType = "DeletePayee";
495 
496  //after reading data, if we should delete, then save with delete
497  payeeModel.set("delete", "true");
498  payeeModel.Save();
499 
500  }
501  }
502  ],
503  open: function(e){
504  //disable delete button until all payee data is loaded
505  var buttons = $('.k-dialog button.k-button');
506  $(buttons).addClass('k-state-disabled');
507  },
508  show: function(e) {
509  // add the close function to the window stack
510  windowStack.push(function(e) {
511  confirmDeleteDialog.close(e);
512  });
513  },
514  close: function(e) {
515  windowStack.pop();
516 
517  }
518  }).data("kendoDialog");
519  //open delete dialog
520  confirmDeleteDialog.open();
521 }
522 
523 //add dialog
524 function AddPayee (){
525  payeeModel.ResetModel();
526  dsGetAccounts.read();
527  kendo.bind($("#detailPayeeTemplate"), payeeModel);
528  var window = $("#detailPayeeTemplate").data("kendoWindow");
529  window.setOptions({
530  title: "<?php echo $MC->msg('Add Payee', HCU_DISPLAY_AS_JS); ?>",
531  });
532  $("#btnAddPayee").show();
533  $("#btnEditPayee").hide();
534  buttonWindow.open().toFront().center();
535 
536 }
537 
538 function ShowHideFields(){
539  //show/hide fields in form based on payee type
540  if(payeeType === 'Comp'){
541  $(".indv").hide();
542  $(".fininst").hide();
543  $(".comp").show();
544 
545  //taking off requirements
546  $("#routingNum").attr('required', false);
547  $("#accountType").attr('required', false);
548  $("#secret").attr('required', false);
549  $("#nickName").attr('required', false);
550  $("#nickSpan").hide();
551  $("#email").attr('required', false);
552  $("#p2pType").attr('required', false);
553 
554  //adding phone requirements
555  $("#phone").attr('required', true);
556 
557  } else if(payeeType === 'FinInst'){
558  $(".comp").hide();
559  $(".indv").hide();
560  $(".fininst").show();
561 
562  //taking off requirements
563  $("#addr1").attr('required', false);
564  $("#city").attr('required', false);
565  $("#state").attr('required', false);
566  $("#zip").attr('required', false);
567  $("#phone").attr('required', false);
568  $("#subName").attr('required', false);
569  $("#payeeName").attr('required', false);
570  $("#secret").attr('required', false);
571  $("#email").attr('required', false);
572  $("#p2pType").attr('required', false);
573 
574  } else if(payeeType === 'Indv'){
575  $(".comp").hide();
576  $(".fininst").hide();
577  $(".indv").show();
578 
579  ///taking off requirements
580  $("#accountNum").attr('required', false);
581  $("#routingNum").attr('required', false);
582  $("#accountType").attr('required', false);
583  $("#subName").attr('required', false);
584  }
585 }
586 
587 // masked zip code (just US for now)
588 $("#zip").kendoMaskedTextBox({
589  mask: "00000-9999",
590  clearPromptChar: true
591 });
592 
593 // masked phone number
594 $("#phone").kendoMaskedTextBox({
595  mask: "(000)000-0000",
596  clearPromptChar: true
597 });
598 
599 homecuTooltip.bind({
600  subNameTip:
601  "<?php echo $MC->msg("Name On Account Tip", HCU_DISPLAY_AS_HTML)?>" ,
602  secretTip:
603  "<?php echo $MC->msg("Shared Secret Tip", HCU_DISPLAY_AS_HTML)?>" ,
604  p2pTip:
605  "<?php echo $MC->msg("P2P Type Tip", HCU_DISPLAY_AS_HTML)?>",
606  emailTip:
607  "<?php echo $MC->msg("Email Tip", HCU_DISPLAY_AS_HTML)?>"
608 });
609 
610 function InitDataSources(){
611 
612  //adding datasource to states field
613  $("#state").kendoDropDownList({
614  dataTextField: "name",
615  dataValueField: "value",
616  dataSource: stateList,
617  optionLabel: {value: "", name: "<?php echo $MC->msg("ACH Select State", HCU_DISPLAY_AS_JS) ?>"},
618  });
619 
620  //adding datasource to account types field
621  $("#accountType").kendoDropDownList({
622  dataTextField: "name",
623  dataValueField: "value",
624  dataSource: accountTypes,
625  optionLabel: {value: "", name: "<?php echo $MC->msg("ACH Need remote account type", HCU_DISPLAY_AS_JS) ?>"},
626  });
627 
628  //adding datasource to account types field
629  $("#p2pType").kendoDropDownList({
630  dataTextField: "name",
631  dataValueField: "value",
632  dataSource: p2pTypes,
633  change: function(e) {
634  var dropdown = this;
635  var dropdownValue = dropdown.value();
636  //Phone Type
637  if ( dropdownValue == "SMS" ) {
638  $("#email").attr("disabled", true);
639  $("#phone").attr("disabled", false);
640  $("#phone").attr("required", true);
641  $("#phoneSpan").show();
642  $("#emailSpan").hide();
643  //set email to empty
644  //payeeModel.set("email", "");
645  } else {
646  //Email Type
647  $("#phone").attr("disabled", true);
648  $("#email").attr("disabled", false);
649  $("#email").attr("required", true);
650  $("#emailSpan").show();
651  $("#phoneSpan").hide();
652  //set phone to empty
653  //payeeModel.set("phone", "");
654  }
655  },
656  optionLabel: {value: "", name: "<?php echo $MC->msg("P2P Select", HCU_DISPLAY_AS_JS) ?>"},
657 });
658 
659  dsCUAccounts = new kendo.data.DataSource ({
660  data: dataPayFrom
661  });
662 
663  var accountURL = "hcuMobilePay.data?cu=<?php echo $HB_ENV['cu']; ?>&mp_token=<?php echo $encodedToken ?>&mp_type=SrcAccounts&<?php echo $HB_ENV['cuquery'] ?>"
664 
665  //pulling user account information
666  dsGetAccounts = new kendo.data.DataSource ({
667  transport: {
668  read: {
669  url: accountURL,
670  contentType: 'application/x-www-form-urlencoded',
671  type: 'POST',
672  data: {},
673  pageable: true,
674  cache: false
675  }
676  },
677  requestStart: function( e ) {
678  ShowWaitWindow();
679  },
680  requestEnd: function( e ) {
681  CloseWaitWindow();
682  var error = null;
683  // see if there is an error
684  if ( e.response && e.response.homecuErrors )
685  error = e.response.homecuErrors;
686  if ( error && error.length > 0 ) {
687  e.preventDefault();
688  $.homecuValidator.displayMessage(error, $.homecuValidator.settings.statusError);
689  } else {
690  // not sure
691  }
692  },
693  // code to run if the request fails; the raw request and
694  // status codes are passed to the function
695  error: function( e ) {
696  alert( "Transport error: " + e.errorThrown);
697  },
698  schema: {
699  data: function (response) {
700  /* PARSE RESPONSE DATA */
701  var returnData = Array();
702  try {
703  if (response.homecuData) {
704  dataPayFrom = (response.homecuData.source ? response.homecuData.source : []);
705  dsCUAccounts.data(dataPayFrom);
706  returnData = response.homecuData;
707  } else if (response.homecuErrors) {
708  //error has been handled
709  } else {
710  throw "Error Parsing Result From Server";
711  }
712  } catch (err) {
713  // ** Need to report the message to the main screen
714  /* *** REPORT THE ERROR *** */
715  alert(err);
716  returnData = [];
717  }
718  return [response];
719  },
720  }
721  });
722 
723  $("#payFrom").kendoDropDownList({
724  optionLabel: {FromId: "", Name: "<?php echo $MC->msg("Select Pay From", HCU_DISPLAY_AS_JS) ?>"},
725  dataSource: dsCUAccounts,
726  dataTextField: 'Name',
727  dataValueField: "FromId",
728  valueTemplate: '#= Name #',
729  template: '#= Name #',
730  change: function(e){
731  var dropdown = this;
732  var dropdownValue = dropdown.value();
733  var dropdownText = dropdown.text();
734  payeeModel.set("accountId", dropdownValue);
735  payeeModel.set("accountName", dropdownText);
736  },
737  });
738 
739  var crudServiceBaseUrl = "hcuMobilePay.data?cu=<?php echo $HB_ENV['cu']; ?>&mp_token=<?php echo $encodedToken ?>";
740 
741  //datasource for payee list
742  dsPayees = new kendo.data.DataSource({
743  transport: {
744  read: {
745  url: "hcuMobilePay.data?cu=<?php echo $HB_ENV['cu']; ?>&mp_token=<?php echo $encodedToken ?>&mp_type=<?php echo $mpType; ?>&<?php echo $HB_ENV['cuquery'] ?>",
746  contentType: 'application/x-www-form-urlencoded',
747  type: 'POST',
748  data: function() {
749  return {
750  };
751  },
752  pageable: true,
753  cache: false
754  }
755  },
756  pageSize: 10,
757  requestStart: function( e ) {
758  ShowWaitWindow();
759  },
760  requestEnd: function( e ) {
761  CloseWaitWindow();
762  var error = null;
763  // see if there is an error
764  if ( e.response && e.response.homecuErrors )
765  error = e.response.homecuErrors;
766  if ( error && error.length > 0 ) {
767  e.preventDefault();
768  $.homecuValidator.settings.formErrorTitle = "Error";
769  $.homecuValidator.settings.formStatusField = "formStatusMain";
770  $.homecuValidator.displayMessage(error, $.homecuValidator.settings.statusError);
771  } else {
772  // not sure
773  }
774  },
775  // code to run if the request fails; the raw request and
776  // status codes are passed to the function
777  error: function( e ) {
778  alert( "<?php echo $MC->msg("Transport error", HCU_DISPLAY_AS_JS); ?>: " + e.status );
779  },
780  schema: {
781  data: "homecuData.data",
782  total: function(response) {
783  return $(response.homecuData.data).length;
784  }
785  }
786  });
787 
788  //datasource for adding and editing payees
789  dsPayeeMod = new kendo.data.DataSource({
790  autoSync: false,
791  batch: false,
792  transport: {
793  read: {
794  url: crudServiceBaseUrl,
795  dataType: "json",
796  contentType: "application/x-www-form-urlencoded",
797  type: "POST",
798  cache: false
799  },
800  },
801  schema: {
802  parse: function(response) {
803  // not showing data, so return empty array
804  var display = [];
805  return display;
806  }
807  },
808  requestStart: function( e ) {
809  ShowWaitWindow();
810  },
811  requestEnd: function(e) {
812  var error = null;
813  var results = null;
814  CloseWaitWindow();
815  if ( e.response && e.response.homecuErrors ){
816  error = e.response.homecuErrors;
817  // alert(JSON.stringify(error));
818  if ( error && error.length > 0 ) {
819  e.preventDefault();
820  $.homecuValidator.settings.formErrorTitle = "Error";
821  if ( mpType == "DeletePayee" ) {
822  $.homecuValidator.settings.formStatusField = "formStatusMain";
823  } else {
824  $.homecuValidator.settings.formStatusField = "detailPayeeFormStatus";
825  }
826  $.homecuValidator.displayMessage(error, $.homecuValidator.settings.statusError);
827  }
828  } else if ( e.response && e.response.homecuData ) {
829  var results = e.response.homecuData;
830  if ( results.data ) {
831  var payeeInfo = results.data;
832  //alert(JSON.stringify(payeeInfo));
833  payeeModel.set( "payeeId", payeeInfo[0].payeeId );
834  payeeModel.set( "payeeName", payeeInfo[0].payeeName );
835  payeeModel.set( "nickName", payeeInfo[0].nickName );
836  payeeModel.set( "addr1", payeeInfo[0].addr1 );
837  payeeModel.set( "addr2", payeeInfo[0].addr2 );
838  payeeModel.set( "city", payeeInfo[0].city );
839  payeeModel.set( "state", payeeInfo[0].state );
840  payeeModel.set( "zip", payeeInfo[0].zip );
841  payeeModel.set( "phone", payeeInfo[0].phone );
842  payeeModel.set( "email", payeeInfo[0].email );
843  payeeModel.set( "routingNum", payeeInfo[0].routingNum );
844  payeeModel.set( "accountNum", payeeInfo[0].accountNum );
845  payeeModel.set( "accountType", payeeInfo[0].accountType );
846  payeeModel.set( "accountId", payeeInfo[0].accountId );
847  payeeModel.set( "subName", payeeInfo[0].subName );
848  payeeModel.set( "secret", payeeInfo[0].secret );
849  payeeModel.set( "payeeType", payeeInfo[0].payeeType );
850  payeeModel.set( "p2pType", payeeInfo[0].p2pType );
851  //disabling fields that arent necessary
852  if ( payeeInfo[0].p2pType == "SMS" ) {
853  $("#email").attr("disabled", true);
854  $("#phoneSpan").show();
855  $("#emailSpan").hide();
856  payeeModel.set("email", "");
857  } else if ( payeeInfo[0].p2pType == "Email" ) {
858  $("#phone").attr("disabled", true);
859  $("#phoneSpan").hide();
860  $("#emailSpan").show();
861  payeeModel.set("phone", "");
862  }
863  //passing SubId along with Payee Info
864  payeeModel.set( "subId", subId);
865  //enable delete button after data has loaded
866  var buttons = $('.k-dialog button.k-button');
867  $(buttons).removeClass('k-state-disabled');
868  //alert(JSON.stringify(payeeModel));
869 
870  } else {
871  ShowSuccess();
872  //record saved, refresh grid data
873  var grid = $("#grid").data("kendoGrid");
874  grid.refresh();
875  }
876  }
877  },
878  error: function( e ) {
879  alert( "<?php echo $MC->msg("Transport error", HCU_DISPLAY_AS_JS); ?>: " + e.status );
880  },
881  });
882 }
883 
884 function InitDataView(){
885  //setting up for editing payees
886  payeeModel = kendo.observable({
887  payeeId: "",
888  payeeType: "",
889  mp_type: "",
890  firstName: "",
891  lastName: "",
892  payeeName: "",
893  accountNum: "",
894  addr1: "",
895  addr2: "",
896  city: "",
897  state: "",
898  zip: "",
899  phone: "",
900  subName: "",
901  accountName: "",
902  accountId: "",
903  nickName: "",
904  subId: "",
905  routingNum: "",
906  accountType: "",
907  secret: "",
908  p2pType: "",
909  email: "",
910  delete: "false",
911  Save: function() {
912  //create request
913  if ( mpType == "DeletePayee" ) {
914  //no extra validation needed
915  var request = {
916  payeeType: this.payeeType,
917  mp_type: mpType,
918  payeeId: this.payeeId,
919  firstName: this.firstName,
920  lastName: this.lastName,
921  payeeName: this.payeeName,
922  accountNum: this.accountNum,
923  addr1: this.addr1,
924  addr2: this.addr2,
925  city: this.city,
926  state: this.state,
927  zip: this.zip,
928  phone: this.phone,
929  subName: this.subName,
930  accountName: this.accountName,
931  accountId: this.accountId,
932  nickName: this.nickName,
933  subId: this.subId,
934  routingNum: this.routingNum,
935  accountType: this.accountType,
936  secret: this.secret,
937  p2pType: this.p2pType,
938  email: this.email,
939  delete: this.delete,
940  }
941  dsPayeeMod.read(request);
942  } else {
943  if ( ExtraValidation() ) {
944  var request = {
945  payeeType: this.payeeType,
946  mp_type: mpType,
947  payeeId: this.payeeId,
948  firstName: this.firstName,
949  lastName: this.lastName,
950  payeeName: this.payeeName,
951  accountNum: this.accountNum,
952  addr1: this.addr1,
953  addr2: this.addr2,
954  city: this.city,
955  state: this.state,
956  zip: this.zip,
957  phone: this.phone,
958  subName: this.subName,
959  accountName: this.accountName,
960  accountId: this.accountId,
961  nickName: this.nickName,
962  subId: this.subId,
963  routingNum: this.routingNum,
964  accountType: this.accountType,
965  secret: this.secret,
966  p2pType: this.p2pType,
967  email: this.email,
968  delete: this.delete,
969  }
970  dsPayeeMod.read(request);
971  }
972  }
973  },
974  ResetModel: function() {
975  this.set( "payeeId", "" );
976  this.set( "payeeType", "" );
977  this.set( "mp_type", "" );
978  this.set( "firstName", "" );
979  this.set( "lastName", "" );
980  this.set( "payeeName", "" );
981  this.set( "accountNum", "" );
982  this.set( "addr1", "" );
983  this.set( "addr2", "" );
984  this.set( "city", "" );
985  this.set( "state", "" );
986  this.set( "zip", "" );
987  this.set( "phone", "" );
988  this.set( "subName", "" );
989  this.set( "accountName", "" );
990  this.set( "accountId", "" );
991  this.set( "nickName", "" );
992  this.set( "subId", "" );
993  this.set( "routingNum", "" );
994  this.set( "accountType", "" );
995  this.set( "secret", "" );
996  this.set( "p2pType", "" );
997  this.set( "email", "" );
998  this.set( "delete", "false" );
999  // reset the selected account
1000  var dropdownlist = $("#payFrom").data("kendoDropDownList");
1001  dropdownlist.select(0);
1002  },
1003  });
1004 
1005  kendo.bind($("#detailPayeeTemplate"), payeeModel);
1006 
1007  // Confirmation dialog
1008  $("#confirmationWindow").kendoDialog({
1009  title: "<?php echo $MC->msg('Success', HCU_DISPLAY_AS_JS); ?>",
1010  width: "75%",
1011  maxWidth: "768px",
1012  minWidth: "300px",
1013  modal: true,
1014  closable: false,
1015  visible: false,
1016  resizable: false,
1017  actions: [
1018  {
1019  text: "<?php echo $MC->msg('Close', HCU_DISPLAY_AS_JS); ?>",
1020  primary: true
1021  }
1022  ],
1023  show: function(e) {
1024  windowStack.pop();
1025  },
1026  close: function(e) {
1027  windowStack.pop();
1028 
1029  // Reset validator to use page status field.
1030  $.homecuValidator.settings.formStatusField = "formStatus";
1031  $.homecuValidator.settings.formInfoTitle = "";
1032 
1033  //redirect back to menu page
1034  window.location = 'hcuMobilePayPayees.prg?mp_token=<?php echo $encodedToken ?>&mp_type=Payees&<?php echo $HB_ENV['cuquery'] ?>';
1035  }
1036  });
1037 }
1038 
1039 function ShowSuccess(){
1040  var confirmationTemplate;
1041  if ( mpType == "AddPayee" ){
1042  confirmationTemplate = kendo.template($("#confirmationTemplateAdd").html());
1043  } else if ( mpType == "EditPayee" ) {
1044  confirmationTemplate = kendo.template($("#confirmationTemplateEdit").html());
1045  } else if ( mpType == "DeletePayee" ) {
1046  confirmationTemplate = kendo.template($("#confirmationTemplateDelete").html());
1047  }
1048  var confirmationDisplay = confirmationTemplate;
1049  $("#confirmationWindow").data("kendoDialog").content(confirmationDisplay);
1050  $("#confirmationWindow").data("kendoDialog").open().toFront().center();
1051  // .open().toFront().center();
1052  payeeModel.ResetModel();
1053 }
1054 
1055 function ExtraValidation(){
1056  var otherErrors = Array();
1057  //zipcode validator
1058  if (payeeModel.zip != "") {
1059  // must validate zip code
1060  var zipcode = payeeModel.zip;
1061  var zipReplace = zipcode.replace(/_/g, "");
1062  var zipSplit = zipReplace.split("-");
1063  var zipConstruct = "";
1064 
1065  // validate section 1, must be 5 digits
1066  if (zipSplit[0].length < 5) {
1067  $.homecuValidator.displayMessage("<?php echo $MC->msg("Zip Code Invalid", HCU_DISPLAY_AS_JS) ?>", $.homecuValidator.settings.statusError);
1068  otherErrors.push("<?php echo $MC->msg("Zip Code Invalid", HCU_DISPLAY_AS_JS) ?>");
1069  } else if (zipSplit[1]) {
1070  if (zipSplit[1].length > 0 && zipSplit[1].length < 4) {
1071  $.homecuValidator.displayMessage("<?php echo $MC->msg("Zip Code Invalid", HCU_DISPLAY_AS_JS) ?>", $.homecuValidator.settings.statusError);
1072  otherErrors.push("<?php echo $MC->msg("Zip Code Invalid", HCU_DISPLAY_AS_JS) ?>");
1073  }
1074  }
1075 
1076  // reconstruct zip code
1077  if (zipSplit[1]) {
1078  zipConstruct += zipSplit[0] + "-" + zipSplit[1];
1079  } else {
1080  zipConstruct += zipSplit[0];
1081  }
1082  payeeModel.set("zip", zipConstruct);
1083  }
1084 
1085  //phone validator
1086  if (payeeModel.phone != "") {
1087  // must validate
1088  var phoneNumber = payeeModel.phone;
1089  var phoneReplace = phoneNumber.replace(/\(|\)|-|_/g, "");
1090  if ( phoneReplace.length < 10 ) {
1091  otherErrors.push("<?php echo $MC->msg("Phone Invalid", HCU_DISPLAY_AS_JS) ?>");
1092  }
1093 
1094  payeeModel.set("phone", phoneReplace);
1095  }
1096 
1097  $.homecuValidator.validate();
1098  var totalErrors = $.homecuValidator.homecuKendoValidator.errors();
1099 
1100  // cannot concat errors together because there may be duplicate errors
1101  for (var i = 0; i < otherErrors.length; i++) {
1102  if ($.inArray(otherErrors[i], totalErrors) == -1) {
1103  totalErrors.push(otherErrors[i]);
1104  }
1105  }
1106 
1107  if (totalErrors.length > 0) {
1108  $.homecuValidator.displayMessage(totalErrors, $.homecuValidator.settings.statusError);
1109  $.homecuValidator.homecuValidate = false;
1110  } else {
1111  $.homecuValidator.homecuValidate = true;
1112  }
1113 
1114  return ( $.homecuValidator.homecuValidate );
1115 }
1116 
1117 
1118 buttonWindow = $("#buttonWindow").kendoWindow({
1119  width: "80%",
1120  maxWidth: "768px",
1121  title: "<?php echo $MC->msg('Add Payee', HCU_DISPLAY_AS_JS); ?>",
1122  visible: false,
1123  modal: true,
1124  scrollable: true,
1125  activate: function(e) {
1126  windowStack.push(function(e) {
1127  buttonWindow.close(e);
1128  });
1129  $("#btnDetailClose").click( function() {
1130  detailWindow.close();
1131  });
1132  },
1133  close: function(e) {
1134  windowStack.pop();
1135  }
1136  }).data("kendoWindow");
1137 
1138 payeeWindow = $("#detailPayeeTemplate").kendoWindow({
1139  width: "80%",
1140  height: "80%",
1141  title: "",
1142  visible: false,
1143  modal: true,
1144  scrollable: true,
1145  actions: [
1146  "close"
1147  ],
1148  activate: function(e) {
1149  windowStack.push(function(e) {
1150  payeeWindow.close(e);
1151  });
1152  $.homecuValidator.setup({formValidate: "detailPayeeTemplate",
1153  formErrorTitle: "<?php echo $MC->msg("Error Occurred", HCU_DISPLAY_AS_JS) ?>",
1154  formStatusField: "detailPayeeFormStatus"});
1155 
1156  },
1157  close: function(e) {
1158  windowStack.pop();
1159  }
1160  }).data("kendoWindow");
1161 
1162 var billPayButton = $("#billPayBtn"),
1163 extTransButton = $("#extTransBtn"),
1164 indPayButton = $("#indPayBtn");
1165 
1166 billPayButton.click(function() {
1167  //Company
1168  payeeType = "Comp";
1169  payeeModel.set("payeeType", payeeType);
1170  ShowHideFields();
1171  buttonWindow.close();
1172  payeeWindow.open().toFront().center();
1173 });
1174 
1175 extTransButton.click(function() {
1176  //Financial Institution
1177  payeeType = "FinInst";
1178  payeeModel.set("payeeType", payeeType);
1179  ShowHideFields();
1180  buttonWindow.close();
1181  payeeWindow.open().toFront().center();
1182 });
1183 
1184 indPayButton.click(function() {
1185  //Individual
1186  payeeType = "Indv";
1187  payeeModel.set("payeeType", payeeType);
1188  ShowHideFields();
1189  buttonWindow.close();
1190  payeeWindow.open().toFront().center();
1191 });
1192 
1193 $(".btn-group > .btn").click(function(e){
1194  $(this).addClass("active").siblings().removeClass("active");
1195  var grid = $("#grid").data("kendoGrid");
1196  var dataSource = grid.dataSource;
1197  switch($('.btn-group > .btn.active').text()) {
1198  case "<?php echo $MC->msg('Payments', HCU_DISPLAY_AS_JS); ?>":
1199  dataSource.filter ({
1200  "field": "Type",
1201  "operator": "eq",
1202  "value": "Payment"
1203  });
1204  break;
1205  case "<?php echo $MC->msg('Transfers', HCU_DISPLAY_AS_JS); ?>":
1206  dataSource.filter ({
1207  "field": "Type",
1208  "operator": "eq",
1209  "value": "Transfer"
1210  });
1211  break;
1212  default:
1213  dataSource.filter ({
1214  });
1215  }
1216 
1217 });
1218 
1219 $(document).on("click", ".k-overlay", function (e) {
1220  if(windowStack.length > 0) {
1221  // get the close function from the stack, without poping it (the close will pop it)
1222  var fn = windowStack[windowStack.length - 1];
1223  var ret = fn(e);
1224  }
1225 });
1226 
1227 $(document).ready(function () {
1228  $.homecuValidator.setup({formErrorTitle: "<?php echo $MC->msg("Error Occurred", HCU_DISPLAY_AS_JS) ?>"});
1229 
1230  InitDataSources();
1231  InitDataView();
1232 
1233  var grid = $("#grid").kendoGrid({
1234  dataSource: dsPayees,
1235  toolbar: kendo.template($("#addPayee").html()),
1236  rowTemplate: kendo.template($("#payeeRow").html()),
1237  pageable: {
1238  refresh: true,
1239  alwaysVisible: false,
1240  buttonCount: 5,
1241  pageSizes: [5, 10, 15, 20]
1242  },
1243  selectable: true,
1244  visible: true,
1245  columns: [ {headerAttributes: {style: "display: none"},attributes:{style:"border-left-width: 0;"}},
1246  {width: "100px", headerAttributes: {style: "display: none"},attributes:{style:"border-left-width: 0;"}}],
1247  noRecords: {template: "<?php echo $MC->msg('No Payees Found', HCU_DISPLAY_AS_JS); ?>"},
1248  });
1249 
1250  //on click of Add Payee icon
1251  grid.find(".k-grid-toolbar").on("click", ".k-i-plus", function (e) {
1252  e.preventDefault();
1253  AddPayee();
1254  });
1255 
1256  grid.find(".k-grid-toolbar").on("click", ".add", function (e) {
1257  e.preventDefault();
1258  AddPayee();
1259  });
1260 
1261  $("#btnAddPayee").on('click', function (event) {
1262  //change mptype for editing
1263  mpType = "AddPayee";
1264  payeeModel.set("subId", subId);
1265  payeeModel.Save();
1266  });
1267 
1268  $("#btnEditPayee").on('click', function (event) {
1269  //change mptype for editing
1270  mpType = "EditPayee";
1271  payeeModel.Save();
1272  });
1273 
1274 });
1275 
1276 </script>
1277 <?php
1278  /*
1279  * ** END CONTENT
1280  */
1281 
1282 
1283  // ** INCLUDE POST CONTENT SCRIPT
1284  require_once(dirname(__FILE__) . '/../includes/hcuPostContent.i');