Odyssey
hcuAlerts.prg
1 <?php
2  /*
3  * File: hcuAlerts.prg
4  *
5  * Purpose: To show the alerts for the member. They can add new ones or edit
6  * existing alerts.
7  *
8  */
9 
10  // ** SET SCRIPT LEVEL VARIABLES
11  $serviceShowInfo = true;
12  $serviceLoadMenu = true;
13  $serviceShowMenu = true;
14 
15  // ** INCLUDE MAIN GLOBAL SCRIPT -- Handles security / global variable values
16  require_once(dirname(__FILE__) . '/../library/hcuService.i');
17 
18 
19  /*
20  * ** CHECK USER FEATURE PERMISSIONS **
21  * NOTE: DOES NOT RETURN ON FAILURE
22  */
23  PermCheckFeatureScreen($dbh, $HB_ENV, $MC, FEATURE_ALERTS);
24 
25  // ** INSERT BUSINESS LOGIC FOR THIS FORM
26  $Cu = $HB_ENV["Cu"];
27  $Cn = $HB_ENV["Cn"];
28  $chome = $HB_ENV["chome"];
29  $Flang = $HB_ENV["Flang"];
30 
31  // ** SET VARIABLES FOR WEBSITE FLAGS
32  $alertsCalcRunBal = ($HB_ENV['Fset'] & GetFlagsetValue("CU_CALCRUNBAL")) == GetFlagsetValue("CU_CALCRUNBAL");
33 
34  // ** INCLUDE PRE CONTENT SCRIPT
35  require_once(dirname(__FILE__) . '/../includes/hcuPreContent.i');
36 
37  // ** Verify the feature is enabled for the Credit Union.
38  $alertsEnabled = Check_AlertsEnabled( $dbh, $HB_ENV );
39  if ( $alertsEnabled === false ) {
40  // * Feature NOT set
41  // * Include the Error page and exit
42  $serviceErrorMsg = $MC->msg('Option not set', HCU_DISPLAY_AS_HTML);
43  $serviceErrorCode = '915';
44 
45  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
46  // ** DO NOT CONTINUE
47  exit;
48  }
49 
50  // ** Retrieve the notice for alerts
51  $noticesAry = Get_NoticeInfo($dbh, $HB_ENV, $MC, "D", "alertNotice", true);
52 
53  $hasNoticeALT = false;
54  $hasNoticePopupALT = false;
55  $noticeURLALT = "";
56  $noticeLinkDisplayALT = "";
57 
58  if ( $noticesAry["status"]["code"] == "000" && HCU_array_key_exists('0', $noticesAry['notice'])) {
59  if ($noticesAry["notice"][0]["notice_id"] ) {
60  $hasNoticeALT = true;
61  $noticeLinkDisplayALT = $noticesAry["notice"][0]["notice_linkdisplay"];
62 
63  $noticeOption = $noticesAry['notice'][0];
64 
65  $noticeOptions = Array (
66  'docsid' => $noticeOption['notice_id'],
67  'docstype' => $noticeOption['notice_type'],
68  'device' => 'D',
69  'noticeOnly' => '0',
70  'expireTime' => mktime() + 86400
71  );
72 
73  $encryptedDocDetails= HCU_PayloadEncode($HB_ENV['Cu'], $noticeOptions);
74 
75  $noticeOptions['noticeOnly'] = 1;
76 
77  $encryptedDocDetailsNoticeOnly= HCU_PayloadEncode($HB_ENV['Cu'], $noticeOptions);
78 
79  // build the url encoded string
80  // * For the popup terms
81  $noticeURLALT = $HB_ENV['homebankingpath'] . '/hcuViewNotice.prg?cu=' . $HB_ENV['cu'] . '&x=' . urlencode($encryptedDocDetails);
82 
83  // * For the regular Button
84  $noticeURLNoticeOnly = $HB_ENV['homebankingpath'] . '/hcuViewNotice.prg?cu=' . $HB_ENV['cu'] . '&x=' . urlencode($encryptedDocDetailsNoticeOnly);
85 
86  // see if there is a popup notice
87  $hasNoticePopupALT = $noticeOption["notice_popup"] ? true : false;
88  }
89  }
90 
91  // ** Retrieve the Terms of Use for Alerts
92  $noticesAry = Get_NoticeInfo($dbh, $HB_ENV, $MC, "D", "alertTerms", true);
93 
94  $hasTermsALT = false;
95  $hasTermsPopupALT = false;
96  $termsURLALT = "";
97  $termsLinkDisplayALT = "";
98 
99  if ( $noticesAry["status"]["code"] == "000" && HCU_array_key_exists('0', $noticesAry['notice'])) {
100  if ($noticesAry["notice"][0]["notice_id"] ) {
101  $hasTermsALT = true;
102  $noticeOption = $noticesAry['notice'][0];
103 
104  $noticeOptions = Array (
105  'docsid' => $noticeOption['notice_id'],
106  'docstype' => $noticeOption['notice_type'],
107  'device' => 'D',
108  'noticeOnly' => '0',
109  'expireTime' => mktime() + 86400
110  );
111 
112  $encryptedDocDetails= HCU_PayloadEncode($HB_ENV['Cu'], $noticeOptions);
113 
114  $noticeOptions['noticeOnly'] = 1;
115 
116  $encryptedDocDetailsNoticeOnly= HCU_PayloadEncode($HB_ENV['Cu'], $noticeOptions);
117 
118  // build the url encoded string
119  // * For the popup terms
120  $termsURLALT = $HB_ENV['homebankingpath'] . '/hcuViewNotice.prg?cu=' . $HB_ENV['cu'] . '&x=' . urlencode($encryptedDocDetails);
121 
122  // * For the regular Button
123  $termsURLNoticeOnly = $HB_ENV['homebankingpath'] . '/hcuViewNotice.prg?cu=' . $HB_ENV['cu'] . '&x=' . urlencode($encryptedDocDetailsNoticeOnly);
124 
125  // see if there is a popup notice
126  $hasTermsPopupALT = $noticeOption["notice_popup"] ? true : false;
127 
128  $termsButtonText = $noticeOption["notice_linkdisplay"];
129  }
130  }
131 
132  // include common functions
133 
134  /********* functions ************/
135  /********* end functions ********/
136 
137  /*
138  * ** START ALERT GRID CONTENT
139  */
140 
141  /*
142  * Get the default email and cell number
143  */
144  $return = Get_AlertDefaultEmail( $dbh, $HB_ENV );
145  $defaultEmail = $return["data"];
146 
147  // Get the cell phone defaults -- get this from a union of all the different types of alerts
148  // table -- use the cell phone used most often
149  $return = Get_AlertDefaultCell( $dbh, $HB_ENV );
150 
151  $defaultCell = $return["data"]["cell_number"];
152 
153  $overdueList = array( array("text" => $MC->msg('Is Due', HCU_DISPLAY_AS_RAW), "daysPrior" => "0"),
154  array("text" => $MC->msg('5 Days Prior', HCU_DISPLAY_AS_RAW), "daysPrior" => "5"),
155  array("text" => $MC->msg('10 Days Prior', HCU_DISPLAY_AS_RAW), "daysPrior" => "10"),
156  );
157 
158  // List the choices for transactions
159  $transList = array( array("text" => $MC->msg('both types of transactions', HCU_DISPLAY_AS_RAW), "value" => "B"),
160  array("text" => $MC->msg('deposits only', HCU_DISPLAY_AS_RAW), "value" => "D"),
161  array("text" => $MC->msg('withdrawals only', HCU_DISPLAY_AS_RAW), "value" => "W"),
162  );
163 
164  /*
165  * List the headers for use by the grid (with necessary translation).
166  *
167  */
168  $gridHeaders = array( $MC->msg('Member Number', HCU_DISPLAY_AS_RAW),
169  $MC->msg('Account', HCU_DISPLAY_AS_RAW),
170  $MC->msg('Alert Type', HCU_DISPLAY_AS_RAW),
171  $MC->msg('Send', HCU_DISPLAY_AS_RAW),
172  $MC->msg('Alert Message', HCU_DISPLAY_AS_RAW),
173  $MC->msg('Alerted On', HCU_DISPLAY_AS_RAW) );
174 
175  // get the type (names) of alerts
176  $return = Get_AlertTypes( $MC );
177  $alertTypes = $return["data"];
178 
179  $alertAccounts = array();
180  $alertAccounts[] = array(
181  "description" => $MC->msg('Select account', HCU_DISPLAY_AS_RAW),
182  "acct_ident" => "",
183  "bal_allowed" => true,
184  "trans_allowed" => true,
185  "check_allowed" => true,
186  "loan_allowed" => true
187  );
188 
189  $accts = Get_AlertAccountList( $dbh, $HB_ENV );
190  for ($i = 0; $i < count($accts['data']); $i++) {
191  $alertAccounts[] = $accts['data'][$i];
192  }
193 ?>
194 
195 <script type="text/javascript">
196  var hcuGridHeaders = <?php echo HCU_JsonEncode($gridHeaders); ?>;
197  var hcuOverdueChoices = <?php echo HCU_JsonEncode($overdueList); ?>;
198  var hcuTransChoices = <?php echo HCU_JsonEncode($transList); ?>;
199  var hcuAlertTypes = <?php echo HCU_JsonEncode( $alertTypes ); ?>;
200  var hcuAlertAccounts = <?php echo HCU_JsonEncode( $alertAccounts ); ?>;
201  var hcuCalcRunBal = <?php echo HCU_JsonEncode( $alertsCalcRunBal ); ?>;
202 
203  var window_stack = [];
204 
205  // populated dynamically
206  var hcuNewAlertList = [];
207  var hcuBalanceAccounts = [];
208  var hcuTransAccounts = [];
209  var hcuCheckAccounts = [];
210  var hcuLoanAccounts = [];
211  var hcuSelAcctList = [];
212  var hcuAlertScreenCreated = false;
213 
214  // save member's alert accounts as we get them
215  var savedMemberAccounts = [];
216  var savedAlertRow = null;
217 
218  var wnd, wndDelete;
219  var alertData;
220  var alertTypeForCallback;
221 
222  var dsAlerts = null;
223  var dsOneAlert = null;
224  var alertTemplate = null;
225  var alertViewModel = null;
226 
227  // check for notices
228  var terms = <?php echo HCU_JsonEncode($hasTermsALT && $hasTermsPopupALT); ?>;
229  var notice = <?php echo HCU_JsonEncode($hasNoticeALT && $hasNoticePopupALT); ?>;
230 
231  // status will be shown in the default info location
232  function ShowStatus( statusMessage ) {
233  $.homecuValidator.settings.formStatusField = "formStatus";
234  $.homecuValidator.settings.formInfoTitle = "";
235  $.homecuValidator.displayMessage(statusMessage);
236  }
237 
238  function ClearStatus( ) {
239  $.homecuValidator.settings.formInfoTitle = "";
240  $.homecuValidator.displayMessage(null);
241  }
242 
243  function ResetAlertScreen(alertId) {
244  var screenTitle = null;
245  // reset screen
246  if (alertId === 0) {
247  screenTitle = "<?php echo $MC->msg('Add Alert', HCU_DISPLAY_AS_JS) ?>";
248  } else {
249  screenTitle = "<?php echo $MC->msg('Edit Alert', HCU_DISPLAY_AS_JS) ?>";
250  }
251 
252  $("#hcuEditAlerts").empty();
253  $("#hcuEditAlerts").html(alertTemplate({ screen: screenTitle }));
254  kendo.bind($("#hcuEditAlerts"), alertViewModel);
255 
256  // set up some validation
257  $.homecuValidator.setup({
258  formValidate: "hcuEditAlerts",
259  formStatusField: "formStatus",
260  formErrorTitle: "<?php echo $MC->msg("Error Occurred", HCU_DISPLAY_AS_JS) ?>",
261  });
262  }
263 
264  // Call this function when the type of alert is known
265  function StartAlert( initialData ) {
266  // Clear out any old message
267  ClearStatus();
268 
269  var subAccountList;
270  // set up an empty data set
271  if ( initialData.type === "bal" ) {
272  alertViewModel.set( "notifyAmt", initialData.notifyamt );
273  alertViewModel.set( "cbIncBal", initialData.incbal === "1" );
274  alertViewModel.set( "cbUseAvailBal", initialData.useavailbal === "1" );
275  alertViewModel.set( "typeName", "<?php echo Get_AlertDesc( "bal", $MC )["data"] ?>" );
276  } else if ( initialData.type === "trans" ) {
277  alertViewModel.set( "notifyDesc", initialData.notifydesc );
278  alertViewModel.set( "cbIncBal", initialData.incbal === "1" );
279  alertViewModel.set( "cbIncAmt", initialData.incamt === "1" );
280  alertViewModel.set( "cbUseRange", initialData.notifyrange === "1" );
281  alertViewModel.set( "transAmtMin", initialData.notifyamtmin );
282  alertViewModel.set( "transAmtMax", initialData.notifyamtmax );
283  alertViewModel.set( "transType", initialData.notifytranstype );
284  alertViewModel.set( "typeName", "<?php echo Get_AlertDesc( "trans", $MC )["data"] ?>" );
285  alertViewModel.set( "inctransdesc", initialData.inctransdesc === "" ? "0" : initialData.inctransdesc );
286  } else if ( initialData.type === "check" ) {
287  alertViewModel.set( "chkNum", initialData.notifychknum );
288  alertViewModel.set( "cbIncAmt", initialData.incamt === "1" );
289  alertViewModel.set( "typeName", "<?php echo Get_AlertDesc( "check", $MC )["data"] ?>" );
290  } else if ( initialData.type === "loan" ) {
291  alertViewModel.set( "selectedOverdue", initialData.alert_days_prior );
292  alertViewModel.set( "typeName", "<?php echo Get_AlertDesc( "loan", $MC )["data"] ?>" );
293  } else {
294  alertViewModel.set( "typeName", "" );
295  }
296 
297  // set up the common values
298  alertViewModel.set( "alertType", initialData.type );
299  alertViewModel.set( "alertId", initialData.id );
300  alertViewModel.set( "notifyMsg.value", initialData.notifymsg );
301 
302  // default to e-mail to start
303  alertViewModel.set( "weType", initialData.emailtype );
304  alertViewModel.set( "notifyTo", initialData.notifyto );
305 
306  // disable some buttons
307  alertViewModel.set( "alertBack", "<?php echo $MC->msg('Delete Alert', HCU_DISPLAY_AS_JS) ?>" );
308  alertViewModel.set( "showDeleteIcon", alertViewModel.alertBack === "<?php echo $MC->msg('Delete Alert', HCU_DISPLAY_AS_JS) ?>" );
309  alertViewModel.set( "showBackIcon", alertViewModel.alertBack !== "<?php echo $MC->msg('Delete Alert', HCU_DISPLAY_AS_JS) ?>" );
310  alertViewModel.set( "alertAction", "<?php echo $MC->msg('Next', HCU_DISPLAY_AS_JS) ?>" );
311  alertViewModel.set( "showSaveIcon", alertViewModel.alertAction === "<?php echo $MC->msg('Save', HCU_DISPLAY_AS_JS) ?>" );
312  alertViewModel.set( "showNextIcon", alertViewModel.alertAction !== "<?php echo $MC->msg('Save', HCU_DISPLAY_AS_JS) ?>" );
313 
314  if ( hcuNewAlertList.length < 2 ) {
315  // set up an array with no choices as a default
316  var ary = {};
317  ary["name"] = "<?php echo $MC->msg('Select New Alert', HCU_DISPLAY_AS_JS) ?>";
318  ary["value"] = "";
319  hcuNewAlertList.push(ary);
320  for(var i = 0; i < hcuAlertTypes.length; i++) {
321  hcuNewAlertList.push(hcuAlertTypes[i]);
322  }
323  alertViewModel.set( "alertChoice", new kendo.data.ObservableArray(hcuNewAlertList) );
324  }
325 
326  alertViewModel.set( "selectedAlert", initialData.type );
327 
328  if ( initialData.id > 0 ) {
329  // editing
330  alertViewModel.set( "alertEditAccount", initialData.accountnumber );
331  alertViewModel.set( "alertShowEdit", true );
332  alertViewModel.set( "alertShowNew", false );
333  alertViewModel.set( "selectedAcct", initialData.selacct);
334  } else {
335  // adding
336  // set up the notify to the default email choice
337  alertViewModel.set( "notifyTo", "<?php echo trim( $defaultEmail ) ?>" );
338 
339  alertViewModel.set( "alertShowEdit", false );
340  alertViewModel.set( "alertShowNew", true );
341  alertViewModel.set( "selectedAcct", "");
342  }
343 
344  if ( alertViewModel.weType === "E" ) {
345  alertViewModel.set( "notifyToEmail", alertViewModel.notifyTo );
346  // set up the default cell choice
347  alertViewModel.set( "notifyToCell", "<?php echo trim( $defaultCell ) ?>" );
348  } else {
349  alertViewModel.set( "notifyToCell", alertViewModel.notifyTo );
350  // set up the default email choice
351  alertViewModel.set( "notifyToEmail", "<?php echo trim( $defaultEmail ) ?>" );
352  }
353 
354  if ( !hcuAlertScreenCreated ) {
355 
356  ShowAlertBody();
357  $("#tabGrid").hide();
358  $("#tabEdit").show();
359 
360  $("#noticeButton").hide();
361  $("#termsButton").hide();
362  } else {
363  // start at first step
364  ShowAlertBody();
365  $("#tabGrid").hide();
366  $("#tabEdit").show();
367 
368  $("#noticeButton").hide();
369  $("#termsButton").hide();
370 
371  // set screen title
372  if (initialData.id === 0) {
373  $("#tabEdit h3").text("<?php echo $MC->msg('Add Alert', HCU_DISPLAY_AS_JS) ?>");
374  } else {
375  $("#tabEdit h3").text("<?php echo $MC->msg('Edit Alert', HCU_DISPLAY_AS_JS) ?>");
376  }
377  }
378  }
379 
380  function ShowAlertBody() {
381  // change which alert type screen is shown
382  alertViewModel.set( "progressAccount", true );
383  alertViewModel.set( "progressMsg", true );
384  alertViewModel.set( "progressNotify", true );
385 
386  // set required attribtues based on alert type selection
387  // if not alert type (typically new alert) is selected
388  // remove all required attribtues until one is selected.
389  // if one is selected, set appropriate required fields.
390  $("*[required]").removeAttr("required");
391  $("#alertChoice").attr("required", "required");
392  if ( alertViewModel.selectedAlert === "bal" ) {
393  alertViewModel.set( "isBalAlertVisible", true );
394  alertViewModel.set( "isTransAlertVisible", false );
395  alertViewModel.set( "isCheckAlertVisible", false );
396  alertViewModel.set( "isLoanAlertVisible", false );
397  alertViewModel.set( "showCustomMsg", false );
398 
399  $("#accountChoice").attr("required", "required");
400  $("#notifyamt").attr("required", "required");
401  $("#notifymsg").attr("required", "required");
402  $("#inctransdesc0").prop("checked", "checked");
403  changeDesc();
404  toggleNotify();
405  } else if ( alertViewModel.selectedAlert === "trans" ) {
406  alertViewModel.set( "isBalAlertVisible", false );
407  alertViewModel.set( "isTransAlertVisible", true );
408  alertViewModel.set( "isCheckAlertVisible", false );
409  alertViewModel.set( "isLoanAlertVisible", false );
410  alertViewModel.set( "showCustomMsg", true );
411 
412  $("#accountChoice").attr("required", "required");
413  $("#notifydesc").attr("required", "required");
414  $("#notifymsg").attr("required", "required");
415  if (alertViewModel.inctransdesc == "0") {
416  $("#inctransdesc0").prop("checked", "checked");
417  } else {
418  $("#inctransdesc1").prop("checked", "checked");
419  }
420  toggleTransCheck();
421  changeDesc();
422  toggleNotify();
423  } else if ( alertViewModel.selectedAlert === "check" ) {
424  alertViewModel.set( "isBalAlertVisible", false );
425  alertViewModel.set( "isTransAlertVisible", false );
426  alertViewModel.set( "isCheckAlertVisible", true );
427  alertViewModel.set( "isLoanAlertVisible", false );
428  alertViewModel.set( "showCustomMsg", false );
429 
430  $("#accountChoice").attr("required", "required");
431  $("#chknum").attr("required", "required");
432  $("#notifymsg").attr("required", "required");
433  $("#inctransdesc0").prop("checked", "checked");
434  changeDesc();
435  toggleNotify();
436  } else if ( alertViewModel.selectedAlert === "loan" ) {
437  alertViewModel.set( "isBalAlertVisible", false );
438  alertViewModel.set( "isTransAlertVisible", false );
439  alertViewModel.set( "isCheckAlertVisible", false );
440  alertViewModel.set( "isLoanAlertVisible", true );
441  alertViewModel.set( "showCustomMsg", false );
442 
443  $("#accountChoice").attr("required", "required");
444  $("#notifymsg").attr("required", "required");
445  $("#inctransdesc0").prop("checked", "checked");
446  changeDesc();
447  toggleNotify();
448  } else {
449  alertViewModel.set( "isBalAlertVisible", false );
450  alertViewModel.set( "isTransAlertVisible", false );
451  alertViewModel.set( "isCheckAlertVisible", false );
452  alertViewModel.set( "isLoanAlertVisible", false );
453  alertViewModel.set( "progressAccount", false );
454  alertViewModel.set( "progressMsg", false );
455  alertViewModel.set( "progressNotify", false );
456  }
457 
458  // now figure out some things to show based on alert type
459  if ( alertViewModel.selectedAlert === "loan" ) {
460  alertViewModel.set( "showAdditionalOptions", false );
461  } else {
462  alertViewModel.set( "showAdditionalOptions", true );
463  }
464 
465 
466  if ( alertViewModel.selectedAlert == "bal" || (alertViewModel.selectedAlert == "trans" && !hcuCalcRunBal) ) {
467  alertViewModel.set( "showIncludeBalance", true );
468  } else {
469  alertViewModel.set( "showIncludeBalance", false );
470  }
471  if ( alertViewModel.selectedAlert === "bal" ) {
472  alertViewModel.set( "showUseAvailBal", true );
473  alertViewModel.set( "showIncAmt", false ); // don't show for balance
474  } else {
475  alertViewModel.set( "showUseAvailBal", false );
476  alertViewModel.set( "showIncAmt", true );
477  // these only show if showIncAmt is set to true
478  if ( alertViewModel.selectedAlert === "check" ) {
479  alertViewModel.set( "showIncCheckAmt", true );
480  alertViewModel.set( "showIncTransAmt", false );
481  } else {
482  alertViewModel.set( "showIncCheckAmt", false );
483  alertViewModel.set( "showIncTransAmt", true );
484  }
485  }
486 
487  alertViewModel.set( "disableBackButton", false );
488  alertViewModel.set( "disableSaveButton", false );
489 
490 
491  var subAcctList = [];
492  var subAcctFilter = {};
493  if ( alertViewModel.selectedAlert === "bal" ) {
494  subAcctList = hcuBalanceAccounts;
495  subAcctFilter = { field: "bal_allowed", operator: "eq", value: true };
496  } else if ( alertViewModel.selectedAlert === "trans" ) {
497  subAcctList = hcuTransAccounts;
498  subAcctFilter = { field: "trans_allowed", operator: "eq", value: true };
499  } else if ( alertViewModel.selectedAlert === "check" ) {
500  subAcctList = hcuCheckAccounts;
501  subAcctFilter = { field: "check_allowed", operator: "eq", value: true };
502  } else if ( alertViewModel.selectedAlert === "loan" ) {
503  subAcctList = hcuLoanAccounts;
504  subAcctFilter = { field: "loan_allowed", operator: "eq", value: true };
505  }
506 
507  // filter sub-accounts list here since the list can be null
508  // when checking in the StartAlert function
509  if ($("#accountChoice").data("kendoDropDownList")) {
510  $("#accountChoice").data("kendoDropDownList").dataSource.filter(subAcctFilter);
511  }
512  }
513 
514  // Initialize the data for a new alert.
515  // NOTE: This needs to look like the data structure in the dsAlerts data source;
516  // but just the necessary fields are initialized.
517  function InitDataForAlert( alertType ) {
518  alertData = new Object();
519  // initialize common values
520  alertData.alert_days_prior = 0; // loan
521  // default to e-mail to start
522  alertData.emailtype = "E";
523  alertData.id = 0;
524  alertData.incamt = "0"; // check, trans
525  alertData.incbal = "0"; // bal, trans
526  alertData.notifyamt = ""; // bal
527  alertData.notifyamtmax = ""; // trans
528  alertData.notifyamtmin = ""; // trans
529  alertData.notifychknum = ""; // check
530  alertData.notifydesc = ""; // trans
531  alertData.notifymsg = "";
532  alertData.notifyrange = "0"; // trans
533  alertData.notifyto = "";
534  alertData.notifyToEmail = "<?php echo trim( $defaultEmail ) ?>";
535  alertData.notifyToCell = "<?php echo trim( $defaultCell ) ?>";
536  alertData.notifytranstype = "B"; // trans
537  alertData.selacct = "";
538  alertData.type = alertType;
539  alertData.type_name = "";
540  alertData.useavailbal = "1"; // bal - default checked
541  alertData.inctransdesc = "0"; // Notify Msg type (trans type only)
542  }
543 
544  // this is a callback to start the alert
545  function StartAlertFunction() {
546  InitDataForAlert( alertTypeForCallback );
547  StartAlert(alertData);
548  }
549 
550  function DeleteAlert(alertId) {
551 
552  wndDelete = $('#deleteWindow').kendoDialog({
553  modal: true,
554  iframe: true,
555  visible: false,
556  width: "300px",
557  show: function(e) {
558  // bind the Model View
559  window_stack.push(wndDelete);
560  },
561  close: function(e) {
562  window_stack.pop();
563  },
564  actions: [
565  { text: "No",
566  action: function() {
567  // no action
568  }
569  },
570  {
571  text: "Yes", primary: true,
572  action: function() {
573  var raw = dsAlerts.data();
574  var item = null;
575  for (var i = 0; i < raw.length; i++) {
576  item = raw[i];
577  if (item.id == alertId) {
578  dsAlerts.remove(item);
579  break;
580  }
581  }
582 
583  dsAlerts.sync();
584  }
585  }
586  ]
587  }).data('kendoDialog');
588 
589  wndDelete.title("<?php echo $MC->msg('Delete Alert', HCU_DISPLAY_AS_JS) ?>");
590  wndDelete.content("<?php echo $MC->msg('Delete Sure', HCU_DISPLAY_AS_JS) ?>?");
591  wndDelete.open();
592  }
593 
594  function lookupAccount( lookupList, lookupId ) {
595  for ( var i = 0; i < lookupList.length; i++ ) {
596  if ( lookupList[i].identifier == lookupId ) {
597  return lookupList[i];
598  }
599  }
600 
601  // didn't find it (probably something wrong) - return first occurance
602  return lookupList[0];
603  }
604 
605  // Note: hcuOverdueChoices needs to be set up before calling this
606  function lookupOverdue( lookupId ) {
607  for ( var i = 0; i < hcuOverdueChoices.length; i++ ) {
608  if ( hcuOverdueChoices[i].daysPrior == lookupId ) {
609  return hcuOverdueChoices[i];
610  }
611  }
612 
613  // didn't find it (probably something wrong) - return first occurance
614  return hcuOverdueChoices[0];
615  }
616 
617  function check_size() {
618  var msg_fld = $("#notifymsg");
619  var i=0;
620  var msg_len = 0;
621  var maxchar = 250;
622  var msg;
623 
624  msg_len = $(msg_fld).val().length;
625 
626  if (msg_len > maxchar) {
627  msg = '<?php echo $MC->msg('Exceeded Maximum', HCU_DISPLAY_AS_JS) ?>' + maxchar + ". ";
628  msg += '<?php echo $MC->msg('Characters not included', HCU_DISPLAY_AS_JS) ?>';
629  alert (msg);
630  var newString = $(msg_fld).val();
631  $(msg_fld).val( newString.substring(0, maxchar) );
632  msg_len = maxchar;
633  }
634  $("#size_msg").text( msg_len );
635  }
636 
637  function round_val(element) {
638  var field_val = 0;
639 
640  field_val = $(element).val();
641  if (isNaN(field_val))
642  field_val = 0
643 
644  field_val = Math.round(field_val * 100) / 100;
645 
646  $(element).val( field_val );
647  }
648 
649  function next_field() {
650  // This function is executed to set focus to skip the message counter
651  if (document.forms['alert'].incBal) {
652  document.forms['alert'].incBal.focus();
653  } else if (document.forms['alert'].incAmt) {
654  document.forms['alert'].incAmt.focus();
655  } else if (document.forms['alert'].we_type[0]) {
656  document.forms['alert'].we_type[0].focus();
657  }
658  }
659  // toggle used to add special (language) characters to end of text string when set > 0
660  function extchar(elementId, vchar) {
661  document.getElementById(elementId).focus();
662  document.getElementById(elementId).value+=vchar;
663  }
664 
665  function toggleNotify() {
666  // default to e-mail
667  if ( $("#radio_w").is(':checked') ) {
668  $("#showCell").css("display", "block");
669  $("#showEmail").css("display", "none");
670  $("#alert_cell").attr("required", "required");
671  $("#alert_email").removeAttr("required");
672  } else {
673  $("#showEmail").css("display", "block");
674  $("#showCell").css("display", "none");
675  $("#alert_email").attr("required", "required");
676  $("#alert_cell").removeAttr("required");
677  }
678  }
679 
680  function toggleTransCheck() {
681  if ( $("#userange").is(':checked') ) {
682  $("#desc_amtmin").attr("required", "required");
683  $("#desc_amtmax").attr("required", "required");
684  } else {
685  $("#desc_amtmin").removeAttr("required");
686  $("#desc_amtmax").removeAttr("required");
687  }
688  }
689 
690  function changeDesc() {
691  var radioOptValue = $("input[name=\"inctransdesc\"]:checked").val();
692  if (radioOptValue == "0") {
693  $("#notifymsg").prop("disabled", false);
694  $("#notifymsg").attr("required", "required");
695  } else {
696  $("#notifymsg").prop("disabled", true);
697  $("#notifymsg").removeAttr("required");
698  $("#notifymsg").val("");
699  check_size();
700  }
701  }
702 
703  function InitDataSources() {
704  dsAlerts = new kendo.data.DataSource({
705  autoSync: false,
706  batch: false,
707  transport: {
708  read: {
709  url: 'hcuAlerts.data?cu=<?php echo $HB_ENV['cu']; ?>',
710  dataType: "json",
711  contentType: "application/x-www-form-urlencoded",
712  data: {
713  action: "read"
714  },
715  type: "GET",
716  cache: false
717  },
718  destroy: {
719  url: 'hcuAlerts.data?cu=<?php echo $HB_ENV['cu']; ?>',
720  contentType: "application/x-www-form-urlencoded",
721  data: {
722  action: "destroy",
723  },
724  type: "POST",
725  cache: false
726  }
727  },
728  requestEnd: function( e ) {
729  var error = null;
730  // see if there is an error
731  if ( e.response && e.response.homecuErrors )
732  error = e.response.homecuErrors;
733 
734  if ( error && error.length > 0 ) {
735  e.preventDefault();
736  // make sure only old data
737  dsAlerts.cancelChanges();
738  // show the error information
739  $.homecuValidator.displayMessage(error, $.homecuValidator.settings.statusError);
740  } else {
741  if ( wnd ) {
742  wnd = null;
743  }
744 
745  if ( e.response && e.response.homecuInfo && (e.response.homecuInfo.length > 0) ) {
746  ShowStatus( e.response.homecuInfo );
747  }
748 
749  if ( e.type === "read" ||
750  e.type === "destroy" ) {
751  // get the alert info since it changed
752  $("#tabEdit").hide();
753  $("#tabGrid").show();
754 
755  // show notice links again
756  $("#noticeButton").show();
757  $("#termsButton").show();
758  }
759  }
760  },
761 
762  // code to run if the request fails; the raw request and
763  // status codes are passed to the function
764  error: function( e ) {
765  },
766  schema: {
767  model: {
768  id: "id",
769  fields: {
770  type: {type: "string"},
771  type_name: {type: "string"},
772  id: {type: "number"},
773  notifyto: {type: "string"},
774  description: {type: "string"},
775  notifymsg: {type: "string"},
776  lastalert: {type: "string"}
777  }
778  },
779  parse: function(response) {
780  var display = [];
781  if ( response.homecuData ) {
782  for (var i = 0; i < response.homecuData.length; i++) {
783  display.push(response.homecuData[i]);
784  }
785  }
786  return display;
787  },
788  errors: "Errors"
789  }
790  });
791 
792  dsOneAlert = new kendo.data.DataSource({
793  transport: {
794  create: {
795  url: 'hcuAlerts.data?cu=<?php echo $HB_ENV['cu']; ?>',
796  contentType: "application/x-www-form-urlencoded",
797  data: {
798  action: "create"
799  },
800  type: "POST",
801  cache: false
802  },
803  read: {
804  url: 'hcuAlerts.data?cu=<?php echo $HB_ENV['cu']; ?>',
805  dataType: "json",
806  contentType: "application/x-www-form-urlencoded",
807  type: "POST",
808  data: {
809  action: "thisshouldgetoverwritten"
810  },
811  cache: false
812  },
813  update: {
814  url: 'hcuAlerts.data?cu=<?php echo $HB_ENV['cu']; ?>',
815  contentType: "application/x-www-form-urlencoded",
816  data: {
817  action: "update",
818  },
819  type: "POST",
820  cache: false
821  }
822  },
823  schema: {
824  parse: function(response) {
825  var display = [];
826  if ( response.homecuData ) {
827  for (var i = 0; i < response.homecuData.length; i++) {
828  display.push(response.homecuData[i]);
829  }
830  }
831  return display;
832  },
833  },
834  requestEnd: function( e ) {
835  var error = null;
836  // see if there is an error
837  if ( e.response && e.response.homecuErrors )
838  error = e.response.homecuErrors;
839 
840  if ( error && error.length > 0 ) {
841  e.preventDefault();
842  // make sure only old data
843  dsOneAlert.cancelChanges();
844  // show the error information
845  $.homecuValidator.displayMessage(error, $.homecuValidator.settings.statusError);
846  } else {
847  $("#tabEdit").hide();
848  $("#tabGrid").show();
849 
850 
851  $("#noticeButton").show();
852  $("#termsButton").show();
853 
854  if ( e.response && e.response.homecuInfo && (e.response.homecuInfo.length > 0) ) {
855  ShowStatus( e.response.homecuInfo );
856  }
857 
858  // refresh the grid
859  dsAlerts.read();
860  }
861  },
862 
863  // code to run if the request fails; the raw request and
864  // status codes are passed to the function
865  error: function( e ) {
866  alert( "<?php echo $MC->msg("Transport error", HCU_DISPLAY_AS_JS); ?>: " + e.status );
867  }
868  });
869  }
870 
871  function InitDataViews() {
872  $('#hcuTableAlerts').kendoGrid({
873  dataSource: dsAlerts,
874  sortable: {
875  mode: "single",
876  allowUnsort: false
877  },
878  noRecords: {
879  template: "<span class=\"hcu-secondary\"><span class=\"vsgSecondary\"><?php echo $MC->msg('No Records Found', HCU_DISPLAY_AS_JS) ?></span></span>"
880  },
881  columns: [
882  { field: "description", title: hcuGridHeaders[1], width: "170px",
883  template: "#= description #" },
884  { field: "type_name", title: hcuGridHeaders[2], width: "90px",
885  template: "#= type_name #",
886  minScreenWidth: 425 },
887  { field: "notifyto", title: hcuGridHeaders[3], width: "150px",
888  template: "#= notifyto #",
889  minScreenWidth: 600 },
890  { field: "notifydisplaymsg", title: hcuGridHeaders[4],
891  template: "#: notifydisplaymsg #" }
892  ],
893  selectable: "row",
894  detailTemplate: function(e) {
895  var displayInfo = e;
896  var dTemplate;
897 
898  if ( e.type === "bal" ) {
899  displayInfo["criteria"] = "<?php echo $MC->msg('is less than', HCU_DISPLAY_AS_JS) ?> " + e.notifyamt;
900  displayInfo["additionalDesc"] = "";
901  var addMsg = "";
902  if ( e.incbal === "1" ) {
903  addMsg += "<li><?php echo $MC->msg('Include the account balance in the alert', HCU_DISPLAY_AS_JS) ?></li>";
904  }
905  if ( e.useavailbal === "1" ) {
906  addMsg += "<li><?php echo $MC->msg('Alert on available balance', HCU_DISPLAY_AS_JS) ?></li>";
907  }
908 
909  displayInfo["additionalMsg"] = addMsg;
910  } else if ( e.type === "trans" ) {
911  displayInfo["criteria"] = "<?php echo $MC->msg('has a transaction description starting with', HCU_DISPLAY_AS_JS) ?>: " + e.notifydesc;
912  var addDesc = "";
913  if ( e.notifyrange === "1" ) {
914  addDesc = "<li><?php echo $MC->msg('Only alert me when the amount is between', HCU_DISPLAY_AS_JS) ?> " + e.notifyamtmin + " <?php echo $MC->msg('and', HCU_DISPLAY_AS_JS) ?> " + e.notifyamtmax + "</li>";
915  }
916  for ( var i = 0; i < hcuTransChoices.length; i++ ) {
917  if ( hcuTransChoices[i]["value"] === e.notifytranstype ) {
918  addDesc += "<li>" + hcuTransChoices[i]["text"] + "</li>";
919  break;
920  }
921  }
922 
923  var addMsg = "";
924  if ( !hcuCalcRunBal ) {
925  if ( e.incbal === "1" ) {
926  addMsg += "<li><?php echo $MC->msg('Include the account balance in the alert', HCU_DISPLAY_AS_JS) ?></li>";
927  }
928  }
929  if ( e.incamt === "1" ) {
930  addMsg += "<li><?php echo $MC->msg('Include the transaction amount in the alert', HCU_DISPLAY_AS_JS) ?></li>";
931  }
932 
933  displayInfo["additionalDesc"] = addDesc;
934  displayInfo["additionalMsg"] = addMsg;
935  } else if ( e.type === "check" ) {
936  displayInfo["criteria"] = "<?php echo $MC->msg('Alert me when check number', HCU_DISPLAY_AS_JS) ?> " + e.notifychknum;
937  displayInfo["additionalDesc"] = "";
938 
939  var addMsg = "";
940  if ( e.incamt === "1" ) {
941  addMsg = "<li><?php echo $MC->msg('Include the check amount in the alert', HCU_DISPLAY_AS_JS) ?></li>";
942  }
943 
944  displayInfo["additionalMsg"] = addMsg;
945  } else if ( e.type === "loan" ) {
946  // find string based on daysPrior
947  var string = "";
948 
949  for ( var i = 0; i < hcuOverdueChoices.length; i++ ) {
950  if ( hcuOverdueChoices[i]["daysPrior"] === e.alert_days_prior ) {
951  string = hcuOverdueChoices[i]["text"];
952  break;
953  }
954  }
955  displayInfo["criteria"] = "<?php echo $MC->msg('When', HCU_DISPLAY_AS_JS) ?> " + string;
956  displayInfo["additionalDesc"] = "";
957  displayInfo["additionalMsg"] = "";
958  }
959 
960  if ( e.restrictions === "L" ) {
961  displayInfo["additionalDesc"] = displayInfo["additionalDesc"] + " <span class='local-locked'><?php echo $MC->msg('Account Locked', HCU_DISPLAY_AS_JS) ?></span>";
962  } else if ( e.restrictions === "R" ) {
963  displayInfo["additionalDesc"] = displayInfo["additionalDesc"] + " <span class='local-locked'><?php echo $MC->msg('Account Readonly', HCU_DISPLAY_AS_JS) ?></span>";
964  }
965 
966  displayInfo["notifyLoc"] = ( e.emailtype === "E" ? "<?php echo $MC->msg('email', HCU_DISPLAY_AS_JS) ?>" : "<?php echo $MC->msg('cell phone', HCU_DISPLAY_AS_JS) ?>" );
967  dTemplate = kendo.template($("#templateDetail").html());
968  return dTemplate( displayInfo );
969 
970  },
971  change: function(e) {
972  this.select().removeClass("k-state-selected");
973  },
974  dataBound: function () {
975  $("table tbody tr").hover(
976  function() {
977  $(this).toggleClass("k-state-hover");
978  }
979  );
980 
981  var grid = $("#hcuTableAlerts").data("kendoGrid");
982  $(grid.tbody).off(); // remove any existing handlers
983  $(grid.tbody).on("click", "td", function(e) {
984  var testClass = $(this).attr("class");
985 
986  if ( testClass !== "k-detail-cell" ) {
987  var row = $(this).closest("tr");
988  var colIdx = $("td", row).index(this);
989  if ( colIdx >= 1 ) {
990  // just save the row info and
991  var selectedRow = grid.dataItem(row);
992 
993  ResetAlertScreen(selectedRow.id);
994  InitDataForAlert( selectedRow.type );
995  StartAlert( selectedRow );
996  ShowAlertBody();
997  }
998  }
999  });
1000  },
1001  create: function(e) {
1002  if (e.model.isNew()) {
1003  }
1004  }
1005  });
1006  alertTemplate = kendo.template($("#template").html());
1007  alertViewModel = kendo.observable({
1008  // common
1009  selectedMbr: 0,
1010  alertChoice: hcuAlertTypes,
1011  selectedAlert: null,
1012  alertChoiceDisabled: false,
1013  // these are for editing an existing alert
1014  alertShowEdit: false,
1015  alertShowNew: false,
1016  alertEditAccount: "",
1017  // these are for when the user has a single account or multiple
1018  alertShowSingle: false,
1019  alertShowMultiple: false,
1020  // these control what is shown for the alert body
1021  isBalAlertVisible: false,
1022  isTransAlertVisible: false,
1023  isCheckAlertVisible: false,
1024  isLoanAlertVisible: false,
1025  // these control which options are shown depending on type and settings
1026  showCustomMsg: false,
1027  showAdditionalOptions: false,
1028  showIncludeBalance: false,
1029  showUseAvailBal: false,
1030  showIncAmt: false,
1031  showIncCheckAmt: false,
1032  showIncTransAmt: false,
1033  //
1034  disableBackButton: true,
1035  disableSaveButton: true,
1036  subAccountSelList: hcuAlertAccounts,
1037  selectedAcct: null,
1038  alertType: "",
1039  alertId: 0,
1040  alertBack: "",
1041  alertAction: "",
1042  notifyMsg: {
1043  value: "",
1044  size: function () {
1045  var value = this.get("value");
1046  var retVal = ( value ) ? value.length : 0;
1047  return retVal;
1048  }
1049  },
1050  inctransdesc: "0",
1051  showDeleteIcon: false,
1052  showBackIcon: false,
1053  showSaveIcon: false,
1054  showNextIcon: false,
1055  weType: "",
1056  notifyToEmail: "",
1057  notifyToCell: "",
1058  selectedCell: null,
1059  // specific - balance
1060  notifyAmt: "0.00",
1061  cbIncBal: false,
1062  cbUseAvailBal: false,
1063  // specific - transaction
1064  notifyDesc: "0.00",
1065  cbUseRange: "",
1066  transAmtMin: "0.00",
1067  transAmtMax: "0.00",
1068  typeName: "", // This is the flag to know if alert is started!
1069  transType: "",
1070  transTypeList: hcuTransChoices,
1071  // specific - check number
1072  chkNum: "",
1073  cbIncAmt: false,
1074  // specific - loan
1075  overdueList: hcuOverdueChoices,
1076  selectedOverdue: 0,
1077  // used for showing pages
1078  progressAccount: false,
1079  progressMsg: false,
1080  progressNotify: false,
1081  alertSave: function(e) {
1082  e.preventDefault();
1083 
1084  if ($.homecuValidator.validate()) {
1085  var request;
1086 
1087  var notifyTo;
1088  if ( alertViewModel.weType === "E" ) {
1089  notifyTo = alertViewModel.notifyToEmail;
1090  } else if ( alertViewModel.weType === "W" ) {
1091  notifyTo = alertViewModel.notifyToCell;
1092  } else {
1093  notifyTo = "";
1094  }
1095  // set up the common fields
1096  request = {
1097  action: "update",
1098  type: alertViewModel.selectedAlert,
1099  id: alertViewModel.alertId,
1100  selacct: alertViewModel.selectedAcct,
1101  emailtype: alertViewModel.weType,
1102  notifyto: notifyTo,
1103  mbr_account: alertViewModel.selectedMbr,
1104  notifymsg: kendo.toString(alertViewModel.notifyMsg.value)
1105  };
1106  // set up the specific fields
1107  // NOTE: send flags as a 1/0
1108  if ( alertViewModel.alertType === "bal" ) {
1109  request["incbal"] = (alertViewModel.cbIncBal ? "1" : "0");
1110  request["notifyamt"] = alertViewModel.notifyAmt;
1111  request["useavailbal"] = (alertViewModel.cbUseAvailBal ? "1" : "0");
1112  } else if ( alertViewModel.alertType === "trans" ) {
1113  request["incbal"] = (alertViewModel.cbIncBal ? "1" : "0");
1114  request["userange"] = (alertViewModel.cbUseRange ? "1" : "0");
1115  request["desc_amtmin"] = alertViewModel.transAmtMin;
1116  request["desc_amtmax"] = alertViewModel.transAmtMax;
1117  request["notifydesc"] = alertViewModel.notifyDesc;
1118  request["transtype"] = alertViewModel.transType;
1119  request["incamt"] = (alertViewModel.cbIncAmt ? "1" : "0");
1120  request["inctransdesc"] = (alertViewModel.inctransdesc === "1" ? "1" : "0");
1121  } else if ( alertViewModel.alertType === "check" ) {
1122  request["incamt"] = (alertViewModel.cbIncAmt ? "1" : "0");
1123  request["chknum"] = alertViewModel.chkNum;
1124  } else if ( alertViewModel.alertType === "loan" ) {
1125  request["days_prior"] = alertViewModel.selectedOverdue;
1126  }
1127 
1128  // read the value directly in case there is a non-US character set in use
1129  request.notifymsg = $("#notifymsg").val();
1130 
1131  // need to smurf a read request because the data varies depending on the alert type
1132  dsOneAlert.transport.read.type = "POST";
1133  dsOneAlert.read( request );
1134  }
1135  },
1136  alertBackDelete: function(e) {
1137  e.preventDefault();
1138  DeleteAlert(this.alertId);
1139  },
1140  alertCancel: function(e) {
1141  e.preventDefault();
1142 
1143  $("#tabEdit").hide();
1144  $("#tabGrid").show();
1145 
1146  $("#noticeButton").show();
1147  $("#termsButton").show();
1148  },
1149  acctListener: function(e) {
1150  // get member number from selected account an set
1151  // to observable
1152  var selectedIndex = e.sender.selectedIndex;
1153  var selectedItem = e.sender.dataItem(selectedIndex);
1154  this.set("selectedAcct", selectedItem.acct_ident);
1155  this.set("selectedMbr", selectedItem.accountnumber);
1156  },
1157  alertListener: function(e) {
1158  // if someone changed the alert type we start over
1159  var selectedIndex = e.sender.selectedIndex;
1160  var selectedItem = e.sender.dataItem(selectedIndex);
1161  this.set("selectedAlert", selectedItem.value);
1162 
1163  InitDataForAlert(selectedItem.value);
1164  StartAlert(alertData);
1165  },
1166  emailListener: function(e) {
1167  var selectedIndex = e.sender.selectedIndex;
1168  var selectedItem = e.sender.dataItem(selectedIndex);
1169  }
1170  });
1171 
1172  // start a new alert
1173  $("#alertStart").kendoButton({
1174  click: function(e) {
1175  ResetAlertScreen(0);
1176  InitDataForAlert( "" );
1177  StartAlert( alertData );
1178  }
1179  });
1180  }
1181 
1182  function InitScreen() {
1183  InitDataSources();
1184  InitDataViews();
1185 
1186  // initialize then show
1187  $("#alertScreen").show();
1188  }
1189 
1190  $(document).on("click", ".k-overlay", function () {
1191  if(window_stack.length > 0) {
1192  open = window_stack[0];
1193  open.close();
1194  }
1195  });
1196 
1197  $(document).ready(function() {
1198 
1199  $("#alertScreen").on("click", "#btnExtraChars", function() {
1200  $("#extraCharSpace").hide();
1201  $("#extraChars").show();
1202  });
1203 
1204  if (terms) {
1205  ShowNotice('<?php echo $termsURLALT; ?>', "<?php echo $termsLinkDisplayALT ?>",
1206  function() {
1207  InitScreen();
1208  if (notice) {
1209  ShowNotice('<?php echo $noticeURLALT; ?>', "<?php echo $noticeLinkDisplayALT ?>");
1210  }
1211  },
1212  function() {
1213  // if they do not accept, send them to banking accounts screen
1214  ShowWaitWindow();
1215 
1216  var urlInit = window.location.href.substring(0, window.location.href.indexOf("hcu"));
1217  var urlCu = "<?php echo $Cu ?>";
1218  var urlPage = "hcuAccounts.prg";
1219  var urlRedirect = urlInit + urlPage + "?cu=" + urlCu;
1220 
1221  window.location.replace(urlRedirect);
1222  }
1223  );
1224  } else if (notice) {
1225  InitScreen();
1226  ShowNotice('<?php echo $noticeURLALT; ?>', "<?php echo $noticeLinkDisplayALT ?>");
1227  } else {
1228  InitScreen();
1229  }
1230  });
1231 </script>
1232 
1233 <div class="container-fluid" id="alertScreen" style="display: none;">
1234  <div id="tabGrid" class="well well-sm col-xs-12">
1235  <h3><?php echo $MC->msg('Alerts', HCU_DISPLAY_AS_JS) ?></h3>
1236  <div class="row">&nbsp;</div>
1237  <button type="button" id="alertStart"><span class="fa fa-plus">&nbsp;</span><?php echo $MC->msg('Add Alert', HCU_DISPLAY_AS_JS) ?></button>
1238  <div class="row">&nbsp;</div>
1239  <div id="hcuTableAlerts"></div>
1240  </div>
1241 
1242  <div id="tabEdit" style="display: none;">
1243  <div id="hcuEditAlerts"></div>
1244  </div>
1245 </div>
1246 <div id="alertWindow" name="alertWindow"></div>
1247 <div id="deleteWindow" name="deleteWindow"></div>
1248 <div id="disclosureWindow" name="disclosureWindow"></div>
1249 <style type="text/css">
1250  .e-initial {display: none;}
1251 
1252  #tabAlerts,
1253  #tabEdit {
1254  max-width: 750px;
1255  }
1256 
1257  #hcuTableAlerts .k-detail-row {
1258  background: transparent;
1259  }
1260 
1261  #gridDetail { margin-bottom: 5px;}
1262  #gridDetail ul { padding-left: 5px; }
1263  #gridDetail ul li { margin-left:15px; }
1264  .k-tooltip-content { text-align: left; max-width: 300px; }
1265 
1266  /* Default is extra small (mobile) */
1267  .alert-wiz-label {
1268  text-align:left;
1269  }
1270  .alert-label {
1271  font-size:larger;
1272  }
1273 
1274  .nopadding {
1275  padding: 0;
1276  }
1277 
1278  .local-spacing {
1279  margin-top: 7.5px;
1280  margin-bottom: 7.5px;
1281  }
1282 
1283  .k-grid td {
1284  border-width: 0;
1285  }
1286 
1287  input[type="radio"],
1288  input[type="checkbox"] {
1289  margin-top: -2px;
1290  }
1291 
1292  .local-locked {
1293  color: darkorange;
1294  }
1295 
1296  /* Small devices @screen-sm-min (tablets, 768px and up) */
1297  @media (min-width: 768px) {
1298  .sm-text-right {
1299  text-align: right;
1300  }
1301  }
1302 
1303  /* Small devices @screen-sm-min (tablets, 767px and lower) */
1304  @media (max-width: 768px) {
1305  .xs-text-left {
1306  text-align: left;
1307  }
1308  }
1309 
1310  /* Medium devices @screen-md-min (desktops, 992px and up) */
1311  @media (min-width: 992px) {
1312  }
1313 </style>
1314 
1315 <script type="text/x-kendo-template" id="templateDetail">
1316  <div class="well well-sm" id="gridDetail">
1317  <h4>#= type_name #</h4>
1318  <br>
1319 
1320  <span>#= description # #= criteria #</span>
1321  <ul>
1322  #if (additionalDesc.length > 0) {#
1323  #= additionalDesc #
1324  #}#
1325  </ul>
1326 
1327  <span>#: notifydisplaymsg #</span>
1328  <ul>
1329  #if (type !== "loan" && additionalMsg.length > 0) {#
1330  #= additionalMsg #
1331  #}#
1332  </ul>
1333 
1334  <p>#= notifyLoc #: #= notifyto #</p>
1335 
1336  <p><?php echo $MC->msg('Alerted On', HCU_DISPLAY_AS_JS); ?>: #= lastalert #</p>
1337  </div>
1338 </script>
1339 <script type="text/x-kendo-template" id="template">
1340  <div class="well well-sm col-xs-12" style="margin-bottom: 0;">
1341  <h3>#= screen #</h3>
1342  <div class="row">&nbsp;</div>
1343 
1344  <div data-bind="visible: alertShowNew" style="display:none;">
1345  <div class="row">
1346  <div class="col-xs-12 col-sm-6 sm-text-right xs-text-left">
1347  <label class="form-horizontal control-label"><?php echo $MC->msg('Select New Alert', HCU_DISPLAY_AS_JS) ?></label>
1348  </div>
1349  <div class="col-xs-12 col-sm-5">
1350  <input id="alertChoice" name="alertChoice" class="hcu-all-100"
1351  data-role="dropdownlist"
1352  data-text-field="name"
1353  data-value-field="value"
1354  data-bind="source: alertChoice, value: selectedAlert, events:{ change: alertListener }"
1355  data-required-msg="<?php echo $MC->msg('Invalid Alert Type', HCU_DISPLAY_AS_JS) ?>">
1356  </input>
1357  </div>
1358  </div>
1359 
1360  </div>
1361  <?php
1362  // Show for editing existing alerts
1363  ?>
1364  <div data-bind="visible: alertShowEdit" style="display:none;">
1365  <div class="row">
1366  <div class="col-xs-12 col-sm-6 sm-text-right xs-text-left">
1367  <label class="form-horizontal control-label"><?php echo $MC->msg('Alert Type', HCU_DISPLAY_AS_JS) ?></label>
1368  </div>
1369  <div class="col-xs-12 col-sm-5">
1370  <p data-bind="text: typeName"></p>
1371  </div>
1372  </div>
1373  </div>
1374 
1375  <div id='progressAccount' data-bind="visible: progressAccount" style='display:none;'>
1376  <div class="row local-spacing"></div>
1377  <div class="row">
1378  <div class="col-xs-12 col-sm-6 sm-text-right xs-text-left">
1379  <label class="form-horizontal control-label"><?php echo $MC->msg('Account', HCU_DISPLAY_AS_JS) ?></label>
1380  </div>
1381  <div class="col-xs-12 col-sm-5">
1382  <input id="accountChoice" name="accountChoice"
1383  class="hcu-all-100"
1384  data-role="dropdownlist"
1385  data-text-field="description"
1386  data-value-field="acct_ident"
1387  data-bind="source: subAccountSelList, value: selectedAcct, events: { change: acctListener }"
1388  data-required-msg="<?php echo $MC->msg('Please select an account', HCU_DISPLAY_AS_JS) ?>">
1389  </input>
1390  </div>
1391  </div>
1392  <?php
1393  // Balance Alert
1394  // If balance is less than nnn
1395  ?>
1396  <div id="progressAccount-bal" data-bind="visible: isBalAlertVisible">
1397  <div class="row local-spacing"></div>
1398  <div class="row">
1399  <div class="col-xs-12 col-sm-6 sm-text-right xs-text-left">
1400  <span><?php echo $MC->msg('is less than', HCU_DISPLAY_AS_JS) ?></span>
1401  </div>
1402  <div class="col-xs-12 col-sm-5">
1403  <input type='text' class="k-textbox hcu-all-100" name='notifyamt' id='notifyamt' maxlength='10' size='10'
1404  onfocus='JAVASCRIPT:{tname="notifyamt";this.select()}'
1405  onchange='round_val(this)'
1406  data-bind="value: notifyAmt"
1407  data-required-msg="<?php echo $MC->msg('Amount Missing', HCU_DISPLAY_AS_JS) ?>" />
1408  <span id="e-notifyamt" class="fa fa-question-circle-o e-initial"></span>
1409  </div>
1410  </div>
1411  </div>
1412 
1413  <?php
1414  // Transaction Alert
1415  // If transaction with Description like XYZ with amount between, could be withdrawal, deposit, or both
1416  ?>
1417  <div id="progressAccount-trans" data-bind="visible: isTransAlertVisible">
1418  <div class="row local-spacing"></div>
1419  <div class="row">
1420  <div class="col-xs-12 col-sm-6 sm-text-right xs-text-left">
1421  <span><?php echo $MC->msg('has a transaction description starting with', HCU_DISPLAY_AS_JS) ?></span>
1422  </div>
1423  <div class="col-xs-12 col-sm-5">
1424  <input type='text' class="k-textbox hcu-all-100" id="notifydesc" name='t_notifydesc' maxlength='40'
1425  data-bind="value: notifyDesc"
1426  onfocus='JAVASCRIPT:{this.select()}'
1427  homecu-minlen="3"
1428  data-homecuCustomMinLen-msg="<?php echo $MC->msg('Description Short', HCU_DISPLAY_AS_JS) ?>"
1429  data-required-msg="<?php echo $MC->msg('Description Missing', HCU_DISPLAY_AS_JS) ?>" />
1430  </div>
1431  </div>
1432  <div class="row local-spacing"></div>
1433  <div class="row">
1434  <div class="col-xs-12 col-sm-6 sm-text-right xs-text-left">
1435  <label for="userange">
1436  <input type='checkbox' name='userange' id="userange" value='Y' data-bind="checked: cbUseRange" onChange="toggleTransCheck()" />
1437  <?php echo $MC->msg('Only alert me when the amount is between', HCU_DISPLAY_AS_JS) ?>
1438  </label>
1439  </div>
1440  <div class="col-xs-12 col-sm-5 text-left">
1441  <input type='text' class="k-textbox hcu-all-100" name='desc_amtmin' id="desc_amtmin" max='10'
1442  data-bind="value: transAmtMin"
1443  onfocus='JAVASCRIPT:{this.select()}'
1444  onchange='round_val(this)'
1445  data-required-msg="<?php echo $MC->msg('Amount Minimum', HCU_DISPLAY_AS_JS) ?>" />
1446  <br>
1447  <span><?php echo $MC->msg('and', HCU_DISPLAY_AS_JS) ?></span>
1448  <br>
1449  <input type='text' class="k-textbox hcu-all-100" name='desc_amtmax' id="desc_amtmax" max='10'
1450  data-bind="value: transAmtMax"
1451  onfocus='JAVASCRIPT:{this.select()}'
1452  onchange='round_val(this)'
1453  data-required-msg="<?php echo $MC->msg('Amount Maximum', HCU_DISPLAY_AS_JS) ?>" />
1454  </div>
1455  </div>
1456  <div class="row local-spacing"></div>
1457  <div class="row">
1458  <div class="col-xs-12 col-sm-6 sm-text-right xs-text-left">
1459  <label class="form-horizontal control-label"><?php echo $MC->msg('Search', HCU_DISPLAY_AS_JS) ?></label>
1460  </div>
1461  <div class="col-xs-12 col-sm-5" style='text-align:left;'>
1462  <input class="hcu-all-100"
1463  data-role="dropdownlist"
1464  data-text-field="text"
1465  data-value-field="value"
1466  data-bind="source: transTypeList, value: transType">
1467  </input>
1468  </div>
1469  </div>
1470 
1471  </div>
1472 
1473  <?php
1474  // Check Number Alert
1475  // Description box is needed for the check number
1476  ?>
1477  <div id="progressAccount-check" data-bind="visible: isCheckAlertVisible">
1478  <div class="row local-spacing"></div>
1479  <div class="row">
1480  <div class="col-xs-12 col-sm-6 sm-text-right xs-text-left">
1481  <span><?php echo $MC->msg('Alert me when check number', HCU_DISPLAY_AS_JS) ?></span>
1482  </div>
1483  <div class="col-xs-12 col-sm-5">
1484  <input type='text' class="k-textbox hcu-all-100" name='t_chknum' id='chknum' size='10' maxlength='8'
1485  data-bind="value: chkNum"
1486  onfocus='JAVASCRIPT:{this.select()}'
1487  data-required-msg="<?php echo $MC->msg('Check Number Missing', HCU_DISPLAY_AS_JS) ?>" >
1488  </div>
1489  </div>
1490  </div>
1491 
1492  <?php
1493  // Missed Payment, check if a payment on a loan is overdue
1494  ?>
1495  <div id="progressAccount-loan" data-bind="visible: isLoanAlertVisible">
1496  <div class="row local-spacing"></div>
1497  <div class="row">
1498  <div class="col-xs-12 col-sm-6 sm-text-right xs-text-left">
1499  <label class="form-horizontal control-label"><?php echo $MC->msg('When', HCU_DISPLAY_AS_JS) ?></label>
1500  </div>
1501  <div class="col-xs-12 col-sm-5">
1502  <input class="hcu-all-100"
1503  data-role="dropdownlist"
1504  data-text-field="text"
1505  data-value-field="daysPrior"
1506  data-bind="source: overdueList, value: selectedOverdue"></input>
1507  </div>
1508  </div>
1509  </div>
1510  </div>
1511 
1512  <?php
1513  // all alerts have this portion
1514  ?>
1515  <div id='progressMsg' data-bind="visible: progressMsg" style="display:none;">
1516  <div class="row local-spacing"></div>
1517  <div class="row">
1518  <div class="col-xs-12 col-sm-6 sm-text-right xs-text-left">
1519  <span><?php echo $MC->msg('I want my alert to say', HCU_DISPLAY_AS_JS) ?></span>
1520  </div>
1521 
1522  <div class="col-xs-12 col-sm-5 text-left">
1523  <div data-bind="visible: showCustomMsg">
1524  <label class="form-horizontal control-label">
1525  <input type='radio' value='1' name='inctransdesc' id='inctransdesc1' onchange='changeDesc()'
1526  data-bind="checked: inctransdesc"/>
1527  <?php echo $MC->msg('the transaction description', HCU_DISPLAY_AS_JS) ?>
1528  </label>
1529  </div>
1530  <div data-bind="visible: showCustomMsg">
1531  <label class="form-horizontal control-label">
1532  <input type='radio' value='0' name='inctransdesc' id='inctransdesc0' onchange='changeDesc()'
1533  data-bind="checked: inctransdesc"/>
1534  <?php echo $MC->msg('A Custom Message', HCU_DISPLAY_AS_JS) ?>
1535  </label>
1536  </div>
1537  </div>
1538  </div>
1539  <div class="row local-spacing"></div>
1540  <div class="row">
1541  <div class="col-xs-12 col-sm-6">
1542  <div id="extraCharSpace">&nbsp;
1543  <?php if ( ($Flang == "es_US") || ($Flang == "pl_US") ): ?>
1544  <div id="btnExtraChars" class="k-button"><?php echo $MC->msg("Show Extended Characters", HCU_DISPLAY_AS_JS); ?></div>
1545  <?php endif; ?>
1546  </div>
1547  <div id="extraChars" style='display:none;'>
1548  <?php
1549  // non-English character sets have this set of helpers to get additional characters into the message
1550  if ($Flang == 'es_US') {
1551  # Spanish extended characters
1552  $charSet = array( '&\\\#225;', '&\\\#233;', '&\\\#237;', '&\\\#243;', '&\\\#250;', '&\\\#241;', '&\\\#191;', '&\\\#161;' );
1553  } else if ( $Flang == "pl_US" ) {
1554  $charSet = array( '&\\\#260;', '&\\\#261;', '&\\\#280;', '&\\\#281;', '&\\\#211;', '&\\\#243;', '&\\\#262;',
1555  '&\\\#263;', '&\\\#321;', '&\\\#322;', '&\\\#323;', '&\\\#324;', '&\\\#346;', '&\\\#347;',
1556  '&\\\#377;', '&\\\#378;', '&\\\#379;', '&\\\#380;' );
1557  } else {
1558  $charSet = array();
1559  }
1560 
1561  for ( $i = 0; $i < count( $charSet ); $i++ ) {
1562  print "<div style='float:left; margin-right:5px;'><a class='k-button' style='width:10mm' href='JAVASCRIPT:extchar(\"notifymsg\", \"{$charSet[$i]}\");'); return false;'>{$charSet[$i]}</a></div>";
1563  }
1564  if ( count( $charSet ) ) {
1565  print "<span class='fa fa-question-circle-o detailsTip' title='{$MC->msg('TXT character alert', HCU_DISPLAY_AS_JS)}'></span>";
1566  }
1567 
1568  ?>
1569  </div> <?php /* end div for id=etraChars */ ?>
1570  </div>
1571  <div class="col-xs-12 col-sm-5">
1572  <div id='containerDiv'>
1573  <textarea class="k-textbox hcu-all-100" name='notifymsg' id='notifymsg' rows='5' cols='90' wrap='physical'
1574  data-bind="value: notifyMsg.value"
1575  onKeyUp='check_size();'
1576  onKeyDown='check_size();'
1577  onBlur='check_size();'
1578  data-required-msg="<?php echo $MC->msg('Message Missing', HCU_DISPLAY_AS_JS) ?>"></textarea>
1579  <span id="e-notifymsg" class="fa fa-question-circle-o e-initial"></span>
1580  </div>
1581  </div>
1582 
1583  <div class="col-xs-12 col-sm-6">
1584  &nbsp;
1585  </div>
1586  <div class="col-xs-12 col-sm-5">
1587  <span id='size_msg' data-bind="text: notifyMsg.size">0</span> / 250
1588  <span class='fa fa-question-circle-o detailsTip' title='<?php echo $MC->msg('Length Note', HCU_DISPLAY_AS_JS) ?>.'></span>
1589  </div>
1590  </div>
1591 
1592  <div class="row local-spacing"></div>
1593  <div class="row">
1594  <div data-bind="visible: showAdditionalOptions">
1595  <div class="col-xs-12 col-sm-6 sm-text-right xs-text-left">
1596  <label class="form-horizontal control-label"><?php echo $MC->msg('Additional Options', HCU_DISPLAY_AS_JS); ?></label>
1597  </div>
1598  <div class="col-xs-12 col-sm-5 text-left">
1599  <div data-bind="visible: showIncludeBalance">
1600  <label class="form-horizontal control-label">
1601  <input type='checkbox' name='incBal' value='1' data-bind="checked: cbIncBal">
1602  <?php echo $MC->msg('Include the account balance in the alert', HCU_DISPLAY_AS_JS) ?>
1603  </label>
1604  </div>
1605  <div data-bind="visible: showUseAvailBal">
1606  <label class="form-horizontal control-label">
1607  <input type='checkbox' name='useAvailBal' value='Y' data-bind="checked: cbUseAvailBal">
1608  <?php echo $MC->msg('Alert on available balance', HCU_DISPLAY_AS_JS) ?>
1609  </label>
1610  </div>
1611  <div data-bind="visible: showIncAmt">
1612  <label class="form-horizontal control-label">
1613  <input type='checkbox' name='incAmt' value='1' data-bind="checked: cbIncAmt">
1614  <span data-bind="visible: showIncCheckAmt"><?php echo $MC->msg('Include the check amount in the alert', HCU_DISPLAY_AS_JS) ?></span>
1615  <span data-bind="visible: showIncTransAmt"><?php echo $MC->msg('Include the transaction amount in the alert', HCU_DISPLAY_AS_JS) ?></span>
1616  </label>
1617  </div>
1618  </div>
1619  </div>
1620  </div>
1621  </div>
1622 
1623  <?php
1624  // all alerts use this portion for where to send the alert
1625  ?>
1626  <div id='progressNotify' data-bind="visible: progressNotify" style="display:none;">
1627  <div class="row local-spacing"></div>
1628  <div class="row">
1629  <div class="col-xs-12 col-sm-6 sm-text-right xs-text-left">
1630  <label class="form-horizontal control-label"><?php echo $MC->msg('Send the alert to my', HCU_DISPLAY_AS_JS) ?></label>
1631  </div>
1632  <div class="col-xs-12 col-sm-5 text-left">
1633  <label class="form-horizontal control-label">
1634  <input type='radio' name='we_type' id='radio_e' value='E' data-bind="checked: weType" onChange='JAVASCRIPT:{toggleNotify();}'>
1635  <?php echo $MC->msg('email', HCU_DISPLAY_AS_JS) ?>
1636  </label>
1637  <span>&emsp;</span>
1638  <label class="form-horizontal control-label">
1639  <input type='radio' name='we_type' id='radio_w' value='W' data-bind="checked: weType" onChange='JAVASCRIPT:{toggleNotify();}'>
1640  <?php echo $MC->msg('cell phone', HCU_DISPLAY_AS_JS) ?>
1641  </label>
1642  </div>
1643  </div>
1644  <div class="row local-spacing"></div>
1645  <div class="row">
1646  <span id='showEmail' style="display: none;">
1647  <div class="col-xs-12 col-sm-6 sm-text-right xs-text-left">
1648  <label class="form-horizontal control-label"><?php echo trim( $MC->msg('email', HCU_DISPLAY_AS_JS) ) ?></label>
1649  </div>
1650  <div class="col-xs-12 col-sm-5">
1651  <input type='email' class="k-textbox hcu-all-100" name='alert_email' id="alert_email" maxlength='50'
1652  data-bind="value: notifyToEmail"
1653  onfocus='JAVASCRIPT:{this.select()}'
1654  data-required-msg="<?php echo $MC->msg('EMail Missing', HCU_DISPLAY_AS_JS) ?>" />
1655  </div>
1656  </span>
1657  </div>
1658  <div class="row">
1659  <span id='showCell' style="display: none;">
1660  <div class="col-xs-12 col-sm-6 sm-text-right xs-text-left">
1661  <label class="form-horizontal control-label"><?php echo trim( $MC->msg('cell phone', HCU_DISPLAY_AS_JS) ) ?></label> \\#
1662  </div>
1663  <div class="col-xs-12 col-sm-5">
1664  <input type='text'
1665  class="k-textbox hcu-all-100"
1666  name='alert_cell'
1667  id="alert_cell"
1668  data-bind="value: notifyToCell"
1669  maxlength='10'
1670  size='10'
1671  onfocus='JAVASCRIPT:{this.select()}'
1672  data-required-msg="<?php echo $MC->msg('Cell Number Missing', HCU_DISPLAY_AS_JS) ?>."
1673  homecu-minlen="10"
1674  data-homecuCustomMinLen-msg="<?php echo $MC->msg('Cell Number Length', HCU_DISPLAY_AS_JS) ?>."
1675  homecu-maxlen="10"
1676  data-homecuCustomMaxLen-msg="<?php echo $MC->msg('Cell Number Length', HCU_DISPLAY_AS_JS) ?>."
1677  homecu-match="number"
1678  data-homecuCustomMatch-msg="<?php echo $MC->msg('Cell Number Digits', HCU_DISPLAY_AS_JS) ?>."
1679  ><br />
1680  <span style='font-size: smaller;'>(ex. 2081234567)</span><br />
1681  </div>
1682  </span>
1683  </div>
1684  </div>
1685  </div>
1686 
1687  <div class="hcu-template">
1688  <div class="hcu-edit-buttons k-state-default">
1689  <span class="hcu-icon-delete">
1690  <a href="##" id="lnkDelete"
1691  data-bind="events: { click: alertBackDelete }, visible: alertShowEdit">
1692  <i class="fa fa-trash fa-lg"></i>
1693  </a>
1694  </span>
1695  <a href="##" id="lnkCancel" style=""
1696  data-bind="events: { click: alertCancel }"><?php echo $MC->msg("Cancel", HCU_DISPLAY_AS_HTML); ?></a>
1697  &emsp;
1698  <a href="##" id="btnUpdate" class="k-button k-primary"
1699  data-bind="events: { click: alertSave }">
1700  <i class="fa fa-check fa-lg"></i><?php echo $MC->msg("Update", HCU_DISPLAY_AS_HTML); ?>
1701  </a>
1702  </div>
1703  </div>
1704 </script>
1705 
1706 <?php
1707  /*
1708  * ** END CONTENT
1709  */
1710 
1711 
1712  // ** INCLUDE POST CONTENT SCRIPT
1713  require_once(dirname(__FILE__) . '/../includes/hcuPostContent.i');