Odyssey
aAdminSettings.prg
1 <?php
2 /**
3  * @author MGHandy: 7/28/17
4  * @package Banking Settings
5  *
6  * @uses display and edit credit union specific data
7  * display and edit credit union name for ach transactions
8  * display and edit ACH GL account number for ach transactions
9  * Allow an offsetting ach micro deposit entry to be made
10  * display and edit credit union routing number for ach transactions
11  * display and edit cutoff time for ach transactions
12  * display and edit default profile for auto enrollment
13  *
14  * @param operation string: database operation to perform
15  * operation: readSettings, updateSettings
16  *
17  * @return aryReply array: errors or information and settings data
18  */
19 
20 require_once("$admLibrary/aAdminSettings.i");
21 require_once("$sharedLibrary/sFeatureMnu.i");
22 
23 $tinymceVersion = GetTinyMCEVersion();
24 $cloudfrontDomainName = GetCloudFrontDomainName();
25 
26 try {
27  $admVars = array();
28 
29  $admOk = array(
30  "operation" => array("filter" => FILTER_SANITIZE_STRING),
31  "settings" => array("filter" => FILTER_DEFAULT) // Allows anything. JSON is validated below.
32  );
33  HCU_ImportVars($admVars, "SETTINGS", $admOk);
34 
35  $sOperation = isset($admVars["SETTINGS"]["operation"]) ? $admVars["SETTINGS"]["operation"] : null;
36  $sSettings = isset($admVars["SETTINGS"]["settings"]) ? $admVars["SETTINGS"]["settings"] : null;
37 
38  $aryResult = array();
39  $aryReply = array();
40 
41  // the admin should not have the ability to alter
42  // any email content if the admin notify email is
43  // not setup for achnotify on the CU Email Notifications screen
44  $sql = "SELECT email FROM cuadmnotify WHERE cu = '{$Cu}' AND role = 'achnotify'";
45  $sqlRs = db_query($sql, $dbh);
46  $sqlData = db_fetch_assoc($sqlRs);
47  // the admin should not havet he ability to alter
48  // any email content if the admin notify email is
49  // not setup for achnotify on the CU Email Notifications screen
50 
51  // this value wil have null or array since you cannot have empty
52  // values in the email. if there is an array there is an email.
53  $showEmailNotifyContent = is_array($sqlData) && strlen($sqlData['email']) > 0;
54 
55  // the new email notifications are for commercial use only so
56  // do not show email notification fields at all on the ach tab
57  // if the credit union doesn't have access.
58 
59  // use the feature menu to determine this fact.
60  $featureList = FetchMenuFeatureList( array("dbh" => $dbh), array("Cu"=>$Cu) );
61  $featureMenuHasACH = false;
62  $featureMenuHasCommercial = false;
63 
64  if (in_array("TRNEXT", $featureList['data'])) {
65  $featureMenuHasACH = true;
66  }
67 
68  if (in_array("ACHPMT", $featureList['data']) || in_array("ACHCOL", $featureList['data'])) {
69  $featureMenuHasACH = true;
70  $featureMenuHasCommercial = true;
71  }
72 
73  switch ($sOperation) {
74  case "":
75  printTabPlugin();
76  PrintAdminSettings($tinymceVersion, $cloudfrontDomainName, $featureMenuHasACH, $featureMenuHasCommercial, $showEmailNotifyContent);
77  break;
78  case "readAdminSettings":
79  $sProfiles = AdminReadProfiles($SYSENV, $dbh, $Cu);
80  $sSettings = AdminReadSettings($SYSENV, $dbh, $Cu);
81 
82  $aryResult['data']['settings'] = $sSettings['settings'];
83  $aryResult['data']['profiles'] = $sProfiles['profiles'];
84 
85  AdminSettingsReplay($aryResult, $aryReply, $sOperation);
86  break;
87  case "updateACHSettings":
88  $sValidate = ValidateACHSettings($SYSENV, $sSettings, true);
89  $sSettings = AdminUpdateSettings($SYSENV, $dbh, $Cu, $sValidate['validate']);
90 
91  $aryResult['info'] = $sSettings['message'];
92  $aryResult['data']['settings'] = $sSettings['settings'];
93 
94  AdminSettingsReplay($aryResult, $aryReply, $sOperation);
95  break;
96  case "updateAutoSettings":
97  $sValidate = ValidateAutoSettings($SYSENV, $sSettings, true);
98  $sSettings = AdminUpdateSettings($SYSENV, $dbh, $Cu, $sValidate['validate']);
99 
100  $aryResult['info'] = $sSettings['message'];
101  $aryResult['data']['settings'] = $sSettings['settings'];
102 
103  AdminSettingsReplay($aryResult, $aryReply, $sOperation);
104  break;
105  default:
106  throw new Exception("Unknown server request: " . $sOperation);
107  break;
108  }
109 } catch (Exception $e) {
110  $aryReply['error'][] = $e->getMessage();
111  $aryResult['data'] = array();
112  $aryResult['info'] = array();
113 
114  AdminSettingsReplay($aryResult, $aryReply, $sOperation);
115 }
116 
117 /**
118  * function PrintAdminSettings($tinyMceVersion, $cloudfrontDomainName, $hasACHFeature, $showEmailContent)
119  * Prints out the banking settings page.
120  *
121  * @param $tinyMceVersion -- the Tiny MCE version
122  * @param $cloudfrontDomainName -- the cloudfront domain name
123  * @param $hasACHFeature -- if the banking feature menu contains ACHCOL, ACHPMT, or TRNEXT than true
124  * @param $showEmailContent -- if to show email content. This is dependent on the CU Email Notifications being set up for "ACH Notifications."
125  */
126 function PrintAdminSettings($tinyMceVersion, $cloudfrontDomainName, $hasACHFeature, $hasCommercialFeature, $showEmailContent) { ?>
127 <script type="text/javascript" src="https://<?php echo $cloudfrontDomainName; ?>/homecu/js/tinymce/<?php echo $tinyMceVersion; ?>/tinymce.min.js"></script>
128 <script type="text/javascript" src="https://<?php echo $cloudfrontDomainName; ?>/homecu/js/tinymce/homecuchar.plugin.js"></script>
129 <script type="text/javascript">
130  <?php getShowWaitFunctions(); ?>
131 
132  var asDataSource = null;
133 
134  var asTabs = null;
135 
136  <?php if ($hasACHFeature) { ?>
137  var asTabACH = null;
138  var asDataACH = null;
139  var asObserveACH = null;
140  <?php } ?>
141 
142  var asTabAuto = null;
143  var asDataAuto = null;
144  var asObserveAuto = null;
145 
146  var asEmailNotifyDialog = null;
147  var asWindowStack = [];
148 
149  <?php
150  /**
151  * function ValidateFormSuccess()
152  * Contains what is run after the validation didn't return errors up to and including the data call to update.
153  */
154  ?>
155  function ValidateFormSuccess() {
156  var _tabUsed = $(".tabTitles .selected").data("name");
157  <?php if ($hasACHFeature) { ?> var _sourceACH = asObserveACH.source; <?php } ?>
158  var _sourceAuto = asObserveAuto.source;
159  var _settings = {};
160  var _request = {};
161 
162  if (_tabUsed == "Auto Enrollment" && asObserveAuto.dirty) {
163  var _profile = null;
164  if (_sourceAuto.profile_e) {
165  if (typeof _sourceAuto.profile_e === "string") {
166  _profile = _sourceAuto.profile_e;
167  } else {
168  _profile = _sourceAuto.profile_e.code;
169  }
170  } else {
171  _profile = "";
172  }
173  _settings.profile = _profile;
174 
175  _request = {
176  operation: "updateAutoSettings",
177  settings: JSON.stringify(_settings)
178  };
179  }
180 
181  <?php if ($hasACHFeature) { ?>
182  if (_tabUsed == "ACH" && asObserveACH.dirty) {
183  var _time =
184  _sourceACH.cutoff_e.getHours() +
185  (_sourceACH.cutoff_e.getMinutes() < 10 ? '0':'') +
186  _sourceACH.cutoff_e.getMinutes();
187  _settings.cutoff = _time;
188 
189  var _routing = _sourceACH.routing_e;
190  _routing = _routing.replace(/_/g, '');
191  _routing = _routing.trim();
192  _settings.routing = _routing;
193 
194  var _account = _sourceACH.account_e.replace(/_/g, '');
195  _account = _account.replace(/_/g, '');
196  _account = _account.trim();
197  _settings.account = _account;
198 
199  var _sub_account_mask = _sourceACH.sub_account_mask_e.replace(/_/g, '');
200  _sub_account_mask = _sub_account_mask.replace(/_/g, '');
201  _sub_account_mask = _sub_account_mask.trim();
202  _settings.sub_account_mask = _sub_account_mask;
203 
204  var _offsetting = _sourceACH.offsetting_e;
205  _settings.offsetting = _offsetting;
206 
207  var _name = _sourceACH.name_e;
208  _name = _name.trim();
209  _settings.name = _name;
210 
211  var _type = _sourceACH.type_e;
212  _settings.type = _type.substring(0,1);
213 
214  // only update if allowed to view/edit
215  <?php if ($hasCommercialFeature && $showEmailContent) { ?>
216  var _notify = tinymce.activeEditor.getContent();
217  _notify = _notify.replace(/[\n\r]+/g, '');
218  _notify = _notify.trim();
219  _settings.notify = _notify;
220  <?php } ?>
221 
222  _request = {
223  operation: "updateACHSettings",
224  settings: JSON.stringify(_settings)
225  };
226  }
227  <?php } ?>
228 
229  if (<?php if ($hasACHFeature) { ?> asObserveACH.dirty || <? } ?> asObserveAuto.dirty) {
230 
231  asDataSource.transport.options.read.type = "POST";
232  asDataSource.read(_request);
233  }
234  }
235 
236  <?php
237  /**
238  * function ValidateForm()
239  * This actually validates the form. The other functions starting with "validate" don't actually validate. Instead they return if the tab is dirty or not.
240  *
241  * @return true if validation works; false if there are errors to display.
242  */
243  ?>
244  function ValidateForm() {
245  var _tabUsed = $(".tabTitles .selected").data("name");
246  <?php if ($hasACHFeature) { ?> var _sourceACH = asObserveACH.source; <?php } ?>
247  var _sourceAuto = asObserveAuto.source;
248 
249  var _errors = [];
250  <?php if ($hasACHFeature) { ?> var _sourceACH = asObserveACH.source; <?php } ?>
251  var _sourceAuto = asObserveAuto.source;
252 
253  <?php if ($hasACHFeature) { ?>
254  if (_tabUsed == "ACH") {
255  // validate ach name
256  var _name = _sourceACH.name_e;
257  _name = _name.trim();
258  if (_name.length === 0) {
259  _errors.push("Credit union name is required");
260  }
261 
262  var _account = _sourceACH.account_e;
263  _account = _account.replace(/_/g, '');
264  _account = _account.trim();
265  if (_account.length === 0) {
266  _errors.push("ACH GL Account is required");
267  } else if (_account.match(/^\d{1,12}$/) === null) {
268  _errors.push("ACH GL Account can only contain up to 12 digits");
269  }
270 
271  var _sub_account_mask = _sourceACH.sub_account_mask_e;
272  _sub_account_mask = _sub_account_mask.replace(/_/g, '');
273  _sub_account_mask = _sub_account_mask.trim();
274  if (_sub_account_mask.length > 16) {
275  _errors.push("ACH Sub-Account Format can only contain up to 16 characters");
276  } else if (_sub_account_mask.match(/^0*$/) === null) {
277  _errors.push("ACH Sub-Account Format can only contain '0' characters");
278  }
279 
280  var _routing = _sourceACH.routing_e;
281  _routing = _routing.replace(/_/g, '');
282  _routing = _routing.trim();
283  if (_routing.length === 0) {
284  _errors.push("Routing number is required");
285  } else if (_routing.match(/\d{9}/) === null) {
286  _errors.push("Routing number must be 9 digits");
287  }
288 
289  var _cutoff = _sourceACH.cutoff_e;
290  if (_cutoff === null) {
291  _errors.push("Cutoff time is required");
292  }
293 
294  <?php if ($hasCommercialFeature && $showEmailContent) { // do not validate if not allowed to view/alter?>
295  var _notify = tinymce.activeEditor.getContent();
296  _notify = _notify.replace(/[\n\r]+/g, '');
297  _notify = _notify.trim();
298  if (_notify.length === 0) {
299  _errors.push("Email Notification is required");
300  }
301  <?php } ?>
302  }
303  <?php } ?>
304 
305  if (_tabUsed == "Auto") {
306  var _profile = _sourceAuto.profile_e;
307  if (_profile) {
308  if (typeof _profile === "string") {
309  _profile = _profile.trim();
310  } else {
311  _profile = _profile.code.trim();
312  }
313  } else {
314  _profile = "";
315  }
316 
317  if (_profile.length === 0) {
318  _errors.push("Default profile is required");
319  }
320  }
321 
322  // set up and display error messages
323  if (_errors.length > 0) {
324  $.homecuValidator.settings.formStatusField = "formStatus";
325  $.homecuValidator.displayMessage(_errors, $.homecuValidator.settings.statusError);
326  return false;
327  }
328 
329  return true;
330  }
331 
332  <?php if ($hasACHFeature) {
333 
334  /**
335  * validateTabACH
336  * This function does not actually validate the tab. Instead it determines if changes are made in the tab. For actually validating the tabs, @see ValidateForm().
337  *
338  * @return true if dirty; false if there are no changes.
339  */
340  ?>
341  function ValidateTabACH() {
342  var _observe = asObserveACH;
343  var _source = asObserveACH.source;
344 
345  var _label = null;
346  var _warning = null;
347 
348  // check for changes in cu name
349  _label = $("label[for=achName]");
350  _warning = $(_label.find("span")[1]);
351  var _name = _source.name_e;
352  _name = _name.trim();
353  _name !== _source.name ?
354  _warning.show() :
355  _warning.hide();
356 
357  // check for changes in micro account
358  _label = $("label[for=achAccount]");
359  _warning = $(_label.find("span")[1]);
360  var _account = _source.account_e;
361  _account = _account.replace(/_/g, '');
362  _account = _account.trim();
363  _account !== _source.account ?
364  _warning.show() :
365  _warning.hide();
366 
367  // check for changes in sub-account mask
368  _label = $("label[for=achSubAccountMask]");
369  _warning = $(_label.find("span")[1]);
370  var _sub_account_mask = _source.sub_account_mask_e;
371  _sub_account_mask = _sub_account_mask.replace(/_/g, '');
372  _sub_account_mask = _sub_account_mask.trim();
373  _sub_account_mask !== _source.sub_account_mask ?
374  _warning.show() :
375  _warning.hide();
376 
377  // check if micro deposit offsetting checkbox changed
378  _label = $("label[for=achMicroOffsetting]");
379  _warning = $(_label.find("span")[1]);
380  var _offsetting = _source.offsetting_e;
381  _offsetting != _source.offsetting ?
382  _warning.show() :
383  _warning.hide();
384 
385  // check for changes in routing number
386  _label = $("label[for=achRouting]");
387  _warning = $(_label.find("span")[1]);
388  var _routing = _source.routing_e;
389  _routing = _routing.replace(/_/g, '');
390  _routing = _routing.trim();
391  _routing !== _source.routing ?
392  _warning.show() :
393  _warning.hide();
394 
395  // check for changes in cutoff time
396  _label = $("label[for=achCutoff]");
397  _warning = $(_label.find("span")[1]);
398 
399 
400  // setting the dirty flag for the cutoff time is
401  // somewhat complicated because the widget holds null
402  // value if the format is not exactly HH:MM PM/AM
403 
404  // if the original cutoff time is null
405  // we must set to widget to 3 PM
406  // this value is not stored yet so we can't check it
407  // against the original value as we have the previous
408  // input fields.
409 
410  // dirty flag
411  // if the original time is not null
412  // if the current value is not null
413  // dirty is true if the times are different
414  // if the current time is null
415  // dirty is true because original is not null
416  // if the original time is null
417  // if the current time is not null
418  // dirty is true if the time is not 3 PM
419  // if the current time is null
420  // dirty is true because current time is not 3 PM
421  var _cutoff = _source.cutoff_e;
422  if (_source.cutoff) {
423  if (_cutoff) {
424  (_cutoff.getTime() !== _source.cutoff.getTime()) ?
425  _warning.show() :
426  _warning.hide();
427 
428  _observe.dirty =
429  (_cutoff.getTime() !== _source.cutoff.getTime());
430  } else {
431  _warning.show();
432 
433  _observe.dirty = true;
434  }
435  } else {
436  if (_cutoff) {
437  (_cutoff.getHours() !== 15 && _source.cutoff_e.getMinutes() !== 0) ?
438  _warning.show() :
439  _warning.hide();
440 
441  _observe.dirty =
442  (_cutoff.getHours() !== 15 && _source.cutoff_e.getMinutes() !== 0);
443  } else {
444  _warning.show();
445 
446  _observe.dirty = true;
447  }
448  }
449 
450  //do not validate if not allowed to view/alter
451  // if not allowed set both equal to avoid
452  // complicating the dirty check below
453  _notify = "";
454  _notify_e = "";
455  <?php if ($hasCommercialFeature && $showEmailContent) { ?>
456  // check for changes in email notification
457  // for this check we must trim all whitespace because
458  // tinymce formats the content differently.
459  _label = $("label[for=achEmailNotify]");
460  _warning = $(_label.find("span")[1]);
461 
462  var _notify = _source.notify;
463  _notify = _notify.replace(/[\s\n\t\r]+/g, '');
464  _notify = _notify.trim();
465 
466  var _notify_e = tinymce.activeEditor.getContent();
467  _notify_e = _notify_e.replace(/[\s\n\t\r]+/g, '');
468  _notify_e = _notify_e.trim();
469 
470  _notify_e !== _notify ?
471  _warning.show() :
472  _warning.hide();
473  <?php } ?>
474 
475  // Validate Company ID Type
476  // check for changes in routing number
477  _label = $("label[for=achType]");
478  _warning = $(_label.find("span")[2]);
479  var _type = _source.type_e.substring(0,1);
480  _type !== _source.type ?
481  _warning.show() :
482  _warning.hide();
483 
484  // checking cutoff time dirty state is the most complicated
485  // so we set the dirty flag during the cutoff time dirty check.
486  // first check the current dirty state, then the rest of the fields.
487  _observe.dirty =
488  (_observe.dirty) ||
489  (_name !== _source.name) ||
490  (_account !== _source.account) ||
491  (_sub_account_mask !== _source.sub_account_mask) ||
492  (_offsetting !== _source.offsetting) ||
493  (_routing !== _source.routing) ||
494  (_notify !== _notify_e) ||
495  (_type !== _source.type);
496 
497  return !_observe.dirty;
498  }
499  <?php } ?>
500 
501  <?php
502  /**
503  * validateTabACH
504  * This function does not actually validate the tab. Instead it determines if changes are made in the tab. For actually validating the tabs, @see ValidateForm().
505  *
506  * @return true if dirty; false if there are no changes.
507  */
508  ?>
509  function ValidateTabAuto() {
510  var _observe = asObserveAuto;
511  var _source = asObserveAuto.source;
512 
513  var _label = null;
514  var _warning = null;
515 
516  // check for changes in default profile
517  _label = $("label[for=autoProfile]");
518  _warning = $(_label.find("span")[1]);
519  _value = _source.profile;
520  _value_e = null;
521  if (_source.profile_e) {
522  if (typeof _source.profile_e === "string") {
523  _value_e = _source.profile_e;
524  } else {
525  _value_e = _source.profile_e.code;
526  }
527  } else {
528  _value_e = "";
529  }
530 
531  if (_value === null) {
532  _value_e !== "" ?
533  _warning.show() :
534  _warning.hide();
535 
536  _observe.dirty =
537  (_value === null && _value_e !== "");
538  } else {
539  _value_e !== _value ?
540  _warning.show() :
541  _warning.hide();
542 
543  _observe.dirty =
544  (_value_e !== _value);
545  }
546 
547  return !_observe.dirty;
548  }
549 
550  <?php
551  /**
552  * function InitDataSources()
553  * This function initializes the data source for both. This is used for reading and updating ACH and Auto tabs.
554  */
555  ?>
556  function InitDataSources() {
557  asDataSource = new kendo.data.DataSource({
558  transport: {
559  read: {
560  url: "main.prg",
561  dataType: "json",
562  contentType: "application/x-www-form-urlencoded",
563  type: "GET",
564  data: {
565  ft: "54"
566  },
567  cache: false
568  }
569  },
570  schema: {
571  parse: function(data) {
572  var results = null;
573  var resultData = null;
574  var resultOperation = null;
575 
576  if (data.hasOwnProperty("Results")) {
577  results = data.Results;
578  resultData = results.data;
579  resultOperation = results.operation;
580  }
581 
582  if (results.hasOwnProperty("error")) {
583  return [];
584  }
585 
586  if (resultData === null || resultData === undefined) {
587  return [];
588  }
589 
590  switch (resultOperation) {
591  <?php if ($hasACHFeature) { ?>
592  case "updateACHSettings":
593  asObserveACH.init(resultData);
594  asTabs.validate();
595  break;
596  <?php } ?>
597  case "updateAutoSettings":
598  asObserveAuto.init(resultData);
599  asTabs.validate();
600  break;
601  case "readAdminSettings":
602  asObserveAuto.init(resultData);
603  <?php if ($hasACHFeature) { ?> asObserveACH.init(resultData); <?php } ?>
604  break;
605  }
606 
607  return [];
608  }
609  },
610  requestStart: function(request) {
611  showWaitWindow();
612  },
613  requestEnd: function(response) {
614  hideWaitWindow();
615 
616  if (response.hasOwnProperty("response")) {
617  if (response.response.hasOwnProperty("Results")) {
618  var results = response.response.Results;
619 
620  if (results.hasOwnProperty("error")) {
621  $.homecuValidator.homecuResetMessage = true;
622  $.homecuValidator.displayMessage(results.error, $.homecuValidator.settings.statusError);
623  } else if (results.hasOwnProperty("info")) {
624  $.homecuValidator.homecuResetMessage = true;
625  $.homecuValidator.displayMessage(results.info, $.homecuValidator.settings.statusSuccess);
626  }
627  } else {
628  $.homecuValidator.displayMessage("Error Parsing Server", $.homecuValidator.settings.statusError);
629  }
630  } else {
631  $.homecuValidator.displayMessage("Error Parsing Server", $.homecuValidator.settings.statusError);
632  }
633  }
634  });
635  }
636 
637  function DiscardChangesOkayACH() {
638  asObserveACH.reset();
639  $("#tabAch .fa-asterisk").hide();
640  }
641 
642  function DiscardChangesOkayAuto() {
643  asObserveAuto.reset();
644  $("#tabAuto .fa-asterisk").hide();
645  }
646 
647  <?php
648  /**
649  * function InitDataViews()
650  * This function initializes the data views. This includes the observable objects for ACH and Auto, initializing kendo controls on those tabs, and click events for cancel and update buttons.
651  */
652  ?>
653  function InitDataViews() {
654  <?php if ($hasACHFeature) { ?> asTabACH = $("#tabAch"); <?php } ?>
655  asTabAuto = $("#tabAuto");
656  asTabs = $("#tabs").hcuTabs({
657  tabs: [
658  <?php if ($hasACHFeature) { ?>
659  { title: "ACH", text: "ACH", icon: "fa-money", selected: true, discardChangesText: "<p>Changes have been made to ACH settings.</p><p>Do you wish to discard your changes?</p>",
660  content: asTabACH, validate: ValidateTabACH, discardChangesOkay: DiscardChangesOkayACH
661  },
662  <?php } ?>
663  { title: "Auto Enrollment", text: "Auto Enrollment", icon: "fa-users", <?php if (!$hasACHFeature) { ?> selected: true, <?php } ?>
664  content: asTabAuto, validate: ValidateTabAuto, discardChangesOkay: DiscardChangesOkayAuto,
665  discardChangesText: "<p>Changes have been made to auto settings.</p><p>Do you wish to discard your changes?</p>"
666  }
667  ],
668  useDiscardChangesDialog: true,
669  discardChangesWindowStack: asWindowStack,
670  formValidate: ValidateForm
671  });
672 
673  <?php if ($hasACHFeature) { ?>
674  asObserveACH = new kendo.observable({
675  dirty: false,
676  source: null,
677  change: function(e) {
678  asTabs.validate();
679  },
680  init: function(data) {
681  var _source = {};
682  _source.name = data.settings.name ? data.settings.name : "";
683  _source.name_e = _source.name;
684  _source.account = data.settings.account ? data.settings.account : "";
685  _source.account_e = _source.account;
686  _source.sub_account_mask = data.settings.sub_account_mask ? data.settings.sub_account_mask : "";
687  _source.sub_account_mask_e = _source.sub_account_mask;
688  _source.offsetting = data.settings.offsetting > 0 ? 1 : 0;
689  _source.offsetting_e = _source.offsetting;
690  _source.routing = data.settings.routing ? data.settings.routing : "";
691  _source.routing_e = _source.routing;
692 
693  // Default value is 9 (Other)
694  _source.type = data.settings.type == 1 ? "1" : (data.settings.type == " " ? " " : "9");
695  _source.type_e = _source.type;
696 
697  <?php if ($hasCommercialFeature && $showEmailContent) { // only set these values if allowed ?>
698  // set the email notification default format
699  _source.notify_d = $("#emailNotifyDefault").html();
700  // set the emailnotification current format
701  // if not current format use default
702  _source.notify = data.settings.notify ? data.settings.notify : "";
703  _source.notify_e = data.settings.notify ? data.settings.notify : _source.notify_d;
704  <?php } ?>
705 
706  var _today = new Date();
707  var _timeHour = data.settings.cutoff ?
708  data.settings.cutoff.substring(0, 2) :
709  "15";
710  var _timeMinutes = data.settings.cutoff ?
711  data.settings.cutoff.substring(2, 4) :
712  "00";
713  var _timeValue = new Date(
714  _today.getFullYear(),
715  _today.getMonth(),
716  _today.getDate(),
717  _timeHour,
718  _timeMinutes
719  );
720 
721  _source.cutoff = data.settings.cutoff ? _timeValue : "";
722  _source.cutoff_e = _timeValue;
723 
724  this.set("source", _source);
725  },
726  reset: function(e) {
727  this.set("source.name_e", this.source.name);
728  this.set("source.account_e", this.source.account);
729  this.set("source.sub_account_mask_e", this.source.sub_account_mask);
730  this.set("source.offsetting_e", this.source.offsetting);
731  this.set("source.routing_e", this.source.routing);
732  this.set("source.type_e", this.source.type);
733 
734  <?php if ($hasCommercialFeature && $showEmailContent) { // only reset if allowed to view ?>
735  // on reset we must set the value of the textarea and tinymce
736  this.set("source.notify_e", this.source.notify);
737 
738  // here we do not reset to the default only reset the changes made.
739  tinymce.activeEditor.setContent(this.source.notify);
740  <?php } ?>
741 
742  if (this.source.cutoff === "") {
743  var _today = new Date();
744 
745  // cutoff date is null, reset to default 3 PM
746  this.set("source.cutoff_e", new Date(
747  _today.getFullYear(),
748  _today.getMonth(),
749  _today.getDate(),
750  "15",
751  "00"
752  ));
753  } else {
754  this.set("source.cutoff_e", this.source.cutoff);
755  }
756  },
757  resetNotify: function(e) {
758  e.preventDefault();
759  $("#emailNotifyConfirmDialog").data("kendoDialog").open();
760  }
761  });
762  <?php } ?>
763 
764  asObserveAuto = new kendo.observable({
765  dirty: false,
766  source: null,
767  profiles: [],
768  change: function(e) {
769  asTabs.validate();
770  },
771  init: function(data) {
772  var _source = {};
773  _source.profile = data.settings.profile;
774  _source.profile_e = data.settings.profile;
775 
776  this.set("source", _source);
777 
778  // only if reading do we update
779  // the profile dropdown list
780  if (data.profiles) {
781  var _profiles = data.profiles;
782  this.set("profiles", _profiles);
783  }
784  },
785  reset: function(e) {
786  this.set("source.profile_e", this.source.profile);
787  }
788  });
789 
790  <?php if ($hasACHFeature) { ?> kendo.bind(asTabACH, asObserveACH); <?php } ?>
791  kendo.bind(asTabAuto, asObserveAuto);
792 
793  <?php if ($hasACHFeature) { ?>
794  $("#achAccount").kendoMaskedTextBox({
795  mask: "000000000000",
796  clearPromptChar: true
797  });
798 
799  $("#achRouting").kendoMaskedTextBox({
800  mask: "000000000",
801  clearPromptChar: true
802  });
803 
804  $("#achEmailPlaceholders").on("click", function(e) {
805  $("#emailNotifyPlaceholderDialog").data("kendoDialog").open();
806  });
807  <?php } ?>
808 
809  $("#lnkCancel").on("click", function(e) {
810  e.preventDefault();
811  <?php if ($hasACHFeature) { ?> asObserveACH.reset(); <?php } ?>
812  asObserveAuto.reset();
813  asTabs.validate();
814  })
815 
816  $("#btnUpdate").on("click", function(e) {
817  e.preventDefault();
818  $.homecuValidator.hideMessage();
819 
820  if (ValidateForm()) {
821  ValidateFormSuccess();
822  }
823  });
824 
825  $.homecuValidator.setup({
826  formValidate: "bankingSettings"
827  });
828 
829  <?php if ($hasACHFeature && $showEmailContent) { ?>
830  $("#emailNotifyConfirmDialog").kendoDialog({
831  title: "Reset Email Message",
832  modal: true,
833  visible: false,
834  resizeable: false,
835  content: $("#emailNotifyConfirmTemplate").html(),
836  show: function() {
837  asWindowStack.push(this);
838  },
839  close: function() {
840  asWindowStack.pop(this);
841  },
842  actions: [
843  { text: "No",
844  action: function(e) {}
845  },
846  {
847  text: "Yes", primary: true,
848  action: function(e) {
849  // on reset we must set the value of the textarea and tinymce
850  asObserveACH.set("source.notify_e", asObserveACH.source.notify_d);
851 
852  // here we are resettings the value to the default format
853  // this is not the same as resetting any changes made
854  tinymce.activeEditor.setContent(asObserveACH.source.notify_d);
855 
856  // because this is a change we need to validate the tabs again
857  asTabs.validate();
858  }
859  }
860  ]
861  });
862 
863  $("#emailNotifyPlaceholderDialog").kendoDialog({
864  title: "ACH Email Notification Template",
865  modal: true,
866  visible: false,
867  resizeable: false,
868  maxWidth: 750,
869  content: $("#emailNotifyPlaceholderTemplate").html(),
870  show: function() {
871  asWindowStack.push(this);
872  },
873  close: function() {
874  asWindowStack.pop(this);
875  },
876  actions: [
877  { text: "Ok", primary: true,
878  action: function(e) {}
879  }
880  ]
881  });
882 
883  tinymce.init({
884  selector: "#achEmailNotify",
885  relative_urls: false,
886  remove_script_host : false,
887  plugins: [
888  "advlist autolink link image lists preview anchor pagebreak",
889  "searchreplace visualblocks visualchars code insertdatetime nonbreaking",
890  "table contextmenu directionality template textcolor homecuchar paste textcolor"
891  ],
892  toolbar1: "code newdocument | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | fontselect fontsizeselect | bullist numlist",
893  toolbar2: "outdent indent blockquote | undo redo | link unlink image | preview | forecolor backcolor | removeformat | homecuchar | nonbreaking",
894  menubar : false,
895  toolbar_items_size: "small",
896  valid_children : "+body[style]",
897  init_instance_callback: function(editor) {
898  editor.setContent(asObserveACH.source.notify_e);
899  asTabs.validate();
900  editor.on("change", function(e) {
901  asTabs.validate();
902  });
903  }
904  });
905  <?php } ?>
906 
907  // Tooltip for Company ID Type field
908  $("#tipCompanyIDType").kendoTooltip({
909  content: "This field is the Identification Code Designator for the Company ID field in the ACH file Company / Batch Header and Company / Batch Control records for Micro Deposits, Micro Deposit Offsets and External Transactions.<br><br>Identification Code Designator values:<br>EIN: 1<br>Other: 9<br>Blank: Legacy setting"
910  });
911 
912  // Tooltip for Sub-account mask field
913  $("#tipSubAccountMask").kendoTooltip({
914  content: "<p>Applies a format to the sub-account number in the ACH file. Example: a format of '000' when applied to a sub-account of '10' will result in '010'.</p><p>If the format is blank or is shorter than the sub-account number, just the sub-account number is used.</p>",
915  });
916  }
917 
918  $(document).ready(function() {
919  InitDataSources();
920  InitDataViews();
921 
922  // begin read
923  asDataSource.transport.options.read.type = "POST";
924  asDataSource.read({
925  operation: "readAdminSettings"
926  });
927  });
928 
929  $(document).on('click', '.k-overlay', function() {
930  if (asWindowStack.length > 0) {
931  asWindowStack[asWindowStack.length-1].close();
932  }
933  });
934 </script>
935 
936 <div id="emailNotifyConfirmDialog"></div>
937 <div id="emailNotifyPlaceholderDialog"></div>
938 <div id="bankingSettings">
939  <!--TABS: -->
940  <div class="container-fluid">
941  <br>
942  <div id="tabs"></div>
943  </div>
944 
945  <?php if ($hasACHFeature) { ?>
946  <!--TAB VIEW: ACH-->
947  <div class="well well-sm col-sm-12" id="tabAch">
948  <div class="row">
949  <div class="col-sm-3">
950  <label for="achName">
951  <span>Credit Union Name</span>
952  <span class="fa fa-asterisk" style="color: #f0ad4e;"
953  data-bind="visible: dirty"></span>
954  </label>
955  </div>
956  <div class="col-sm-4">
957  <input class="hcu-all-100 k-textbox" id="achName" name="achName"
958  maxlength="100"
959  minlength="5"
960  data-bind="
961  value: source.name_e,
962  events: { change: change }"
963  required>
964  </div>
965  </div>
966  &nbsp;
967  <div class="row">
968  <div class="col-sm-3">
969  <label for="achAccount">
970  <span>ACH GL Account</span>
971  <span class="fa fa-asterisk" style="color: #f0ad4e;"
972  data-bind="visible: dirty"></span>
973  </label>
974  </div>
975  <div class="col-sm-4">
976  <input class="hcu-all-100" id="achAccount" name="achAccount"
977  data-bind="
978  value: source.account_e,
979  events: { change: change }">
980  </div>
981  </div>
982  &nbsp;
983  <div class="row">
984  <div class="col-sm-3">
985  <label for="achSubAccountMask">
986  <span>ACH Sub-Account Format</span>
987  <span class="fa fa-question-circle-o" id="tipSubAccountMask"></span>
988  <span class="fa fa-asterisk" style="color: #f0ad4e;"
989  data-bind="visible: dirty"></span>
990  </label>
991  </div>
992  <div class="col-sm-4">
993  <input class="hcu-all-100 k-textbox" id="achSubAccountMask" name="achSubAccountMask"
994  maxlength="16"
995  data-bind="
996  value: source.sub_account_mask_e,
997  events: { change: change }">
998  </div>
999  </div>
1000  &nbsp;
1001  <div class="row">
1002  <div class="col-sm-3">
1003  <label for="achMicroOffsetting">
1004  <span>Create Offsetting Micro Deposit Entry</span>
1005  <span class="fa fa-asterisk" style="color: #f0ad4e;"
1006  data-bind="visible: dirty"></span>
1007  </label>
1008  </div>
1009  <div class="col-sm-4 checkbox">
1010  <label>
1011  <input type="checkbox" id="achMicroOffsetting" name="achMicroOffsetting"
1012  data-bind="
1013  checked: source.offsetting_e,
1014  events: { change: change }"> Yes
1015  </label>
1016  </div>
1017  </div>
1018  &nbsp;
1019  <div class="row">
1020  <div class="col-sm-3">
1021  <label for="achRouting">
1022  <span>Routing Number</span>
1023  <span class="fa fa-asterisk" style="color: #f0ad4e;"
1024  data-bind="visible: dirty"></span>
1025  </label>
1026  </div>
1027  <div class="col-sm-4">
1028  <input class="hcu-all-100" id="achRouting"
1029  data-bind="
1030  value: source.routing_e,
1031  events: { change: change }">
1032  </div>
1033  </div>
1034  &nbsp;
1035  <div class="row">
1036  <div class="col-sm-3">
1037  <label for="achType">
1038  <span>Company ID Type</span>
1039  <span class="fa fa-question-circle-o" id="tipCompanyIDType"></span>
1040  <span class="fa fa-asterisk" style="color: #f0ad4e;"
1041  data-bind="visible: dirty"></span>
1042  </label>
1043  </div>
1044  <div class="col-sm-4">
1045  <label for="achEIN" style="margin-top: 2px;">
1046  <input type="radio" name="achType" id="achEIN" value="1" style="margin-top: -2px;"
1047  data-bind="checked: source.type_e, events: { change: change }" required>
1048  <span>EIN</span>
1049  </label>
1050  &nbsp;
1051  <label for="achOther" style="margin-top: 2px;">
1052  <input type="radio" name="achType" id="achOther" value="9" style="margin-top: -2px;"
1053  data-bind="checked: source.type_e, events: { change: change }" required>
1054  <span>Other</span>
1055  </label>
1056  &nbsp;
1057  <label for="achBlank" style="margin-top: 2px;">
1058  <input type="radio" name="achType" id="achBlank" value=" " style="margin-top: -2px;"
1059  data-bind="checked: source.type_e, events: { change: change }" required>
1060  <span>Blank (Legacy Setting)</span>
1061  </label>
1062  </div>
1063  </div>
1064  &nbsp;
1065  <div class="row">
1066  <div class="col-sm-3">
1067  <label for="achCutoff">
1068  <span>Cutoff Time</span>
1069  <span class="fa fa-asterisk" style="color: #f0ad4e;"
1070  data-bind="visible: dirty"></span>
1071  </label>
1072  </div>
1073  <div class="col-sm-4">
1074  <input class="hcu-all-100" id="achCutoff"
1075  data-role="timepicker"
1076  data-bind="
1077  value: source.cutoff_e,
1078  events: { change: change }">
1079  </div>
1080  </div>
1081  <?php if($hasCommercialFeature) { ?>
1082  &nbsp;
1083  <div class="row">
1084  <div class="col-sm-3">
1085  <label for="achEmailNotify">
1086  <span>Email Notification</span>
1087  <span class="fa fa-asterisk" style="color: #f0ad4e;"
1088  data-bind="visible: dirty"></span>
1089  </label>
1090  </div>
1091  <?php if ($showEmailContent) { ?>
1092  <div class="col-sm-4 text-right">
1093  <a href="#" data-bind="events: {click: resetNotify}">Reset email message to default</a>
1094  </div>
1095  <?php } ?> <!-- end show content -->
1096  </div>
1097  <?php if($showEmailContent) { ?>
1098  <div class="row">
1099  <div class="col-sm-12">
1100  <a href="#" id="achEmailPlaceholders">Help</a>
1101  <textarea class="hcu-all-100" id="achEmailNotify"
1102  data-bind="value: source.notify_e"></textarea>
1103  </div>
1104  </div>
1105  <?php } else { ?>
1106  <div class="row">
1107  <div class="col-sm-12">
1108  <div class="hcu-secondary">
1109  <div class="small vsgSecondary">
1110  <span>This feature requires an "ACH Notifications" email on the <a href="main.prg?ft=46">CU Email Notifications</a> screen.</span>
1111  </div>
1112  </div>
1113  </div>
1114  </div>
1115  <?php } ?> <!-- end show content -->
1116  <?php } ?> <!-- end has feature -->
1117  </div>
1118  <?php } ?>
1119 
1120  <!--TAB VIEW: AUTO-ENROLLMENT-->
1121  <div class="well well-sm col-sm-12" id="tabAuto">
1122  <div class="row">
1123  <div class="col-sm-3">
1124  <label for="autoProfile">
1125  <span>Default Profile</span>
1126  <span class="fa fa-asterisk" style="color: #f0ad4e;"
1127  data-bind="visible: dirty"></span>
1128  </label>
1129  </div>
1130  <div class="col-sm-4">
1131  <input class="hcu-all-100" id="autoProfile"
1132  data-role="dropdownlist"
1133  data-value-field="code"
1134  data-text-field="description"
1135  data-option-label="Select profile"
1136  data-bind="
1137  value: source.profile_e,
1138  source: profiles,
1139  events: { change: change }">
1140  </div>
1141  </div>
1142  </div>
1143 
1144  <div class="hcu-template col-sm-12">
1145  <div class="hcu-edit-buttons k-state-default">
1146  <a href="##" id="lnkCancel">Cancel</a>
1147  &emsp;
1148  <a href="##" id="btnUpdate" class="k-button k-primary">
1149  <i class="fa fa-check fa-lg"></i>Update
1150  </a>
1151  </div>
1152  </div>
1153 </div>
1154 
1155 <?php if ($hasACHFeature) { ?>
1156 <script type="text/template" id="emailNotifyDefault">
1157  <div>
1158  <p><span style="font-size: 10pt;">{{company}} has initiated a {{transactiontype}} in the amount of: ${{amount}} on {{date}}</span></p>
1159  </div>
1160  <div>
1161  <p style="padding-left: 30px;"><span style="font-size: 10pt;"><strong>Name On Account:</strong> {{accountname}}</span></p>
1162  <p style="padding-left: 30px;"><span style="font-size: 10pt;"><strong>Routing Number:</strong> {{routing}}</span></p>
1163  <p style="padding-left: 30px;"><span style="font-size: 10pt;"><strong>Account Number:</strong> {{accountnumber}}</span></p>
1164  <p style="padding-left: 30px;"><span style="font-size: 10pt;">{{accounttype}}</span></p>
1165  </div>
1166  <div>
1167  <p>
1168  You are receiving this email as a courtesy notification that a funds transfer has been initiated. The actual transfer may not show in your online account for several days. This notification is not a guarantee that the transfer will actually occur.
1169  </p>
1170  <p>
1171  Do not reply to this email. This mailbox is not monitored and you will not receive a response. If you need any assistance or wish to stop receiving this type of notification please contact {{company}}.
1172  </p>
1173  </div>
1174 </script>
1175 
1176 <script type="text/template" id="emailNotifyConfirmTemplate">
1177  <div class="col-sm-12">
1178  <p><strong>Your are about to restore your email notification to the default format.</strong></p>
1179  <p>Do you wish to continue?</p>
1180  </div>
1181 </script>
1182 
1183 <script type="text/template" id="emailNotifyPlaceholderTemplate">
1184  <div class="col-sm-12">
1185  <p>Below is a list of replacement keywords which may be used when creating ACH notification emails. These keywords are not mandatory but must be used with surrounding double brackets for correct replacement.</p>
1186  <p>For example: "{{company}} has initiated a {{transactiontype}}..." will generate the following sentence: "ABC Company has initiated a withdrawal..."</p>
1187  <p></p>
1188  <p><strong>Keywords that can be used to display transaction data:</strong></p>
1189  <ul style="margin-left: 30px;">
1190  <li><label>{{company}}:</label> the Group Name</li>
1191  <li><label>{{transactiontype}}:</label> whether the transaction is "withdrawal" or "deposit"</li>
1192  <li><label>{{amount}}:</label> the transaction amount</li>
1193  <li><label>{{date}}:</label> the batch effective date</li>
1194  </ul>
1195  <p><strong>Keywords that can be used to display the remote account information:</strong></p>
1196  <ul style="margin-left: 30px;">
1197  <li><label>{{accountname}}:</label> the name on the remote account</li>
1198  <li><label>{{routing}}:</label> the remote account routing number</li>
1199  <li><label>{{accountnumber}}:</label> the last four digits of the remote account number</li>
1200  <li><label>{{accounttype}}:</label> whether the remote account is "checking" or "savings"</li>
1201  </ul>
1202  </div>
1203 </script>
1204 <?php } // End if ($hasACHFeature) ?>
1205 
1206 <?php }