Odyssey
cEstmntMntc.prg
1 <?php
2 /*
3  * FILE: mEstmntMntc.prg
4  * This is a maintenance form for adding estatement files by CU.
5  */
6 
7  $monLibrary = dirname(__FILE__) . "/../library";
8  $monIncludes = dirname(__FILE__) . "/../includes";
9  require_once("$monLibrary/cu_top.i");
10  require_once("$monLibrary/ck_hticket.i");
11  require_once("./mcEstmntMntc.data");
12 
13  if (!CheckPerm($link, $Hu, basename($_SERVER['SCRIPT_NAME']), $_SERVER['REMOTE_ADDR'])) {
14  // ** Permissions failed
15  // ** redirect to new page
16  header("Location: /hcuadm/hcu_noperm.prg");
17  exit;
18  }
19 
20  $string = array("filter" => FILTER_SANITIZE_STRING);
21  $array = array("filter" => FILTER_DEFAULT);
22  $parameters = array();
23  HCU_ImportVars($parameters, "a", array("operation" => $string, "dataItem" => $array, "docid" => $string, "contents" => $array, "cu" => $string,
24  "section" => $string, "vendor" => $string, "keyword" => $string, "file" => $string, "selectedForm" => $string,
25  "period" => $string, "suboperation" => $string));
26  extract($parameters["a"]);
27 
28  $operation = isset($operation) ? trim($operation) : "";
29  $dataItem = isset($dataItem) ? trim($dataItem) : "";
30  $docid = isset($docid) ? trim($docid) : "";
31  $contents = isset($contents) ? trim($contents) : "";
32  $cu = isset($cu) ? trim($cu) : "";
33  $section = isset($section) ? trim($section) : "";
34  $vendor = isset($vendor) ? trim($vendor) : "";
35  $period = isset($period) ? trim($period) : "";
36  $suboperation = isset($suboperation) ? trim($suboperation) : "";
37 
38  if ($operation != "") {
39  $useJson = true;
40  if ($cu == "") {
41  $returnArray = array("status" => "002", "error" => "Credit Union is not specified.");
42  } else {
43 
44  switch ($operation) {
45  case "readEstmntDefinitions":
46  $returnArray = ReadEstmntDefinitions($dbh, $cu, $section);
47  break;
48  case "updateEstmntDefinitionsMntc":
49  $returnArray = UpdateEstmntCu ($dbh, $dataItem, $cu, $section);
50  break;
51  case "removeEstmntDefinitionsMntc":
52  $returnArray = RemoveEstmntDefinitionsMntc($dbh, $docid, $cu, $section);
53  break;
54  case "readEstmntFile":
55  $returnArray = ReadEstmntFileCu($dbh, $docid, $cu, $section);
56  break;
57  case "readDifferentVendor":
58  $returnArray = ReadEstmntFileGlobal($dbh, $docid, true, $cu, $vendor);
59  break;
60  case "revertEstmntFile":
61  $returnArray = RevertEstmntFile($dbh, $docid, $cu, $section);
62  break;
63  case "startNewConfig":
64  $returnArray = StartNewConfig($dbh, $cu, $vendor, $section);
65  break;
66  case "readBackupFiles":
67  $returnArray = ReadBackupFiles($dbh, $cu);
68  break;
69  case "makeBackup":
70  $returnArray = MakeBackup($dbh, $cu, $keyword);
71  break;
72  case "removeBackup":
73  $returnArray = RemoveBackup($dbh, $cu, $keyword);
74  break;
75  case "viewBackupFile":
76  $returnArray = ViewBackup($dbh, $cu, $file);
77  break;
78  case "testPdfDefs":
79  $returnArray = TestPdfDefs ($cu, $selectedForm);
80  break;
81  case "testPdfDisclosure":
82  $returnArray = TestPdfDisclosure ($dbh, $cu, $docid, $section);
83  break;
84  case "viewPdfTestOutput":
85  $useJson = false;
86  ViewPdfTestOutput($cu);
87  break;
88  case "executeManualOperations":
89  $returnArray = ExecuteManualOperations($dbh, $cu, $file, $period, $suboperation);
90  break;
91  case "retrieveStatusManualOperations":
92  $returnArray = RetrieveStatusManualOperations($dbh, $cu);
93  break;
94  default: // Won't get here
95  $returnArray = array("status" => "001", "error" => "Operation not specified: '$operation'", "data" => array());
96  break;
97  }
98  }
99 
100  if ($useJson) {
101  header('Content-type: application/json');
102  print HCU_JsonEncode($returnArray);
103  }
104  } else {
105 
106  if ($cu == "") {
107  PrintErrorPage("Credit Union is not specified.");
108  } else {
109  PrintCuPage($cu);
110  }
111  }
112 
113  /**
114  * function PrintCuPage($homecuKendoVersion, $cloudfrontDomainName, $bootstrapVersion, $fontawesomeVersion, $Cu)
115  * Prints out the cu page for the cu maintenance of the E-statement script.
116  *
117  * @param $cu -- the credit union
118  */
119  function PrintCuPage($cu) {
120  $pageTitle = GetEstatementText() . " Maintenance";
121  printMonitorPageTop($pageTitle, GetHomecuKendoVersion("monitor"), GetCloudFrontDomainName(), GetHomecuBootstrapVersion(), GetFontawesomeVersion(), true);
122  printMonitorPageMiddle($pageTitle, null); ?>
123 
124  <?php
125  /**
126  * The CSS part of the page.
127  */
128  ?>
129  <style>
130  .filecontents {
131  height: 400px !important;
132  }
133 
134  .k-grid tr td, #cuTabStrip > .k-content {
135  overflow: visible;
136  }
137 
138  .chooseFromLi > .k-animation-container {
139  height: 241px !important;
140  }
141 
142  .chooseFromLi > .k-animation-container > .k-menu-group {
143  max-height: 243px !important; <?php // So that there is not a huge list of vendors. ?>
144  }
145 
146  .overwrittenFiles ul {
147  list-style-position: inside;
148  list-style-type: square;
149  }
150 
151  .k-grid td .k-menu .k-item > .k-link {
152  line-height: initial;
153  padding-bottom: 0.5em; <?php // I know that some of the criticism will be that it takes up a lot of space. ?>
154  padding-top: 0.5em;
155  }
156 
157  #pdfEmbedParent {
158  padding-top: 77.27%; <?php // the PDF embed object's aspect ratio is controlled by the padding-top property. This is the aspect ratio for 8.5 by 11. ?>
159  }
160 
161  #ccperiodCheckbox {
162  margin-top: 0px;
163  }
164  </style>
165 
166  <?php
167  /**
168  * The Javascript part of the page.
169  */
170  ?>
171  <script type="text/javascript">
172  var self = "<?php echo $_SERVER['PHP_SELF']; ?>";
173  var cu = "<?php echo $cu; ?>";
174  var estatementPluralText = "<?php echo GetEstatementText(); ?>s";
175 
176  <?php
177  /**
178  * function InitMainTabStrip()
179  * This initialize the main tab strip and kendo grid therein.
180  */
181  ?>
182  function InitMainTabStrip() {
183  var cuTabStrip = $("#cuTabStrip").kendoTabStrip({
184  value: estatementPluralText,
185  select: function(e) {
186  switch($(e.item).text().trim()) {
187  case "Disclosure":
188  $("#extraGrid").data("kendoGrid").dataSource.fetch();
189  <?php // Only get the data once from the remote server and after that, gets locally. ?>
190  break;
191  case "Credit Card":
192  $("#ccGrid").data("kendoGrid").dataSource.fetch();
193  break;
194  }
195  }
196  }).data("kendoTabStrip");
197  }
198 
199  var extraDocumentData = [];
200  var extraVendorData = [];
201  var filesAffected = null;
202  var filesAffectedCC = null;
203  var estatementInitialized = false;
204  var extraInitialized = false;
205  var estatementIndex = 0;
206  var extraIndex = 0;
207  var currentVendor = null;
208  var currentVendorCC = null;
209  var pdfChoiceList = [];
210  var pdfTestDataSource = null;
211  var moData = null;
212 
213  <?php
214  /**
215  * function InitGrids()
216  * Sets up the grids on the tabs: Estatements and extra.
217  */
218  ?>
219  function InitGrids() {
220 
221  <?php
222  /**
223  * @var maintDataSourceDef
224  * This is the dataSource for the estatement and the extra grids. They are slightly different in that the section is added to the read data.
225  */
226  ?>
227  var maintDataSourceDef = {
228  batch: true,
229  transport: {
230  read: {
231  url: self,
232  dataType: "json",
233  type: "POST",
234  data: {
235  cu: cu,
236  operation: "readEstmntDefinitions"
237  }
238  },
239  create: {
240  url: self,
241  dataType: "json",
242  type: "POST",
243  data: {
244  cu: cu,
245  operation: "updateEstmntDefinitionsMntc"
246  }
247  },
248  update: {
249  url: self,
250  dataType: "json",
251  type: "POST",
252  data: {
253  cu: cu,
254  operation: "updateEstmntDefinitionsMntc"
255  }
256  },
257  destroy: {
258  url: self,
259  dataType: "json",
260  type: "POST",
261  data: {
262  cu: cu,
263  operation: "removeEstmntDefinitionsMntc"
264  }
265  }
266  },
267  schema: {
268  model: {
269  id: "docid",
270  fields: {
271  docid: {type: "number"},
272  docname: {type: "string"},
273  sort: {type: "number"},
274  descr: {type: "string"},
275  invalid: {type: "boolean"},
276  contents: {type: "string"}, <?php // This won't actually be retrieved until file is opened. ?>
277  allvendors: {type: "odata"}
278  }
279  }
280  },
281  filter: {field: "invalid", operator: "neq", value: true},
282  sort: {field: "sort", dir: "asc"}
283  };
284 
285  <?php
286  /**
287  * var parameterMap = function(data, type)
288  * Refers to the parameterMap function inside of the transport object. It is out here to be able to copy the definition.
289  */
290  ?>
291  var parameterMap = function(data, type) {
292  ShowWaitWindow();
293 
294  switch (type) {
295  case "create":
296  case "update":
297  data.dataItem = kendo.stringify(data.models[0]);
298  delete data.models;
299  break;
300  case "destroy":
301  data.docid = data.models[0].docid;
302  delete data.models;
303  break;
304  case "read": <?php // I have everything that I need. ?>
305  break;
306  default:
307  break;
308  }
309 
310  return data;
311  };
312 
313  <?php
314  /**
315  * var parse = function (data)
316  * Refers to the parse function inside of the schema object. It is out here to be able to copy the definition.
317  */
318  ?>
319  var parse = function (data) {
320  CloseWaitWindow();
321  if (data.status != "000") {
322  $.homecuValidator.displayMessage(data.error, $.homecuValidator.settings.statusError );
323 
324  if (data.operation == "create") {
325  return {docid: "", invalid: true};
326  }
327 
328  } else if (data.info != "") {
329  $.homecuValidator.displayMessage(data.info, $.homecuValidator.settings.statusInfo );
330  }
331 
332  if (data.data.formList) {
333  if (data.data.formList.length > 0) {
334  $("#testPDFBtn").removeClass("k-state-disabled");
335 
336  <?php // Apply list to the dropdownlist if it exists at this point. Otherwise, save it for later. ?>
337  var pdfChoiceDDL = $("#pdfChoiceDDL").data("kendoDropDownList");
338  if (pdfChoiceDDL == null) {
339  window.pdfChoiceList = data.data.formList;
340  } else {
341  pdfChoiceDDL.dataSource.data(data.data.formList);
342  window.pdfChoiceList = undefined;
343  }
344  } else {
345  $("#testPDFBtn").addClass("k-state-disabled");
346  }
347  }
348 
349  if (data.operation == "read" || data.operation == "readInit") {
350  if (data.section == estatementPluralText) {
351  if (data.operation == "readInit") {
352  configList = data.data.configList;
353  extraDocumentData = data.data.extraDocumentData;
354  extraVendorData = data.data.extraVendorData;
355  HandleAddButton("init", null);
356  }
357 
358  filesAffected = data.data.filesAffected;
359  currentVendor = data.data.currentVendor;
360 
361  if (currentVendor != null && currentVendor.trim() != "") {
362  $("#currentVendorLabel span").text(currentVendor);
363  $("#currentVendorLabel").show();
364  } else {
365  $("#currentVendorLabel").hide();
366  }
367 
368  moData = data.data.moData;
369 
370  } else if (data.section == "Credit Card") {
371  currentVendorCC = data.data.currentVendor;
372 
373  filesAffectedCC = data.data.filesAffected;
374 
375  if (currentVendorCC != null && currentVendorCC.trim() != "") {
376  $("#currentVendorLabelCC span").text(currentVendorCC);
377  $("#currentVendorLabelCC").show();
378  } else {
379  $("#currentVendorLabelCC").hide();
380  }
381  }
382 
383  return data.data.gridData;
384  } else {
385  var record = data.data.record;
386  if (data.section == "Disclosure") {
387  <?php // It is going to be opposite because when you delete a record, it is now available for the add. ?>
388  if (data.operation == "delete") {
389  HandleAddButton("add", record.docname);
390  } else {
391  HandleAddButton("delete", record.docname);
392  }
393  }
394  return record;
395  }
396 
397 
398  };
399 
400  <?php // The configurations are nearly the same.
401  // This is one of the few ways to ensure that changes to the extra configuration do not change the estatement configuration. ?>
402  var estatementDef = JSON.parse(JSON.stringify(maintDataSourceDef));
403  var extraDef = JSON.parse(JSON.stringify(maintDataSourceDef));
404  var ccDef = JSON.parse(JSON.stringify(maintDataSourceDef));
405  var utilityDef = JSON.parse(JSON.stringify(maintDataSourceDef));
406  estatementDef.transport.read.data.section = estatementPluralText;
407  estatementDef.transport.create.data.section = estatementPluralText;
408  estatementDef.transport.update.data.section = estatementPluralText;
409  estatementDef.transport.destroy.data.section = estatementPluralText;
410  estatementDef.transport.parameterMap = parameterMap;
411  estatementDef.schema.parse = parse;
412 
413  var label = "Disclosure";
414  extraDef.transport.read.data.section = label;
415  extraDef.transport.create.data.section = label;
416  extraDef.transport.update.data.section = label;
417  extraDef.transport.destroy.data.section = label;
418  extraDef.transport.parameterMap = parameterMap;
419  extraDef.schema.parse = parse;
420 
421  var ccLabel = "Credit Card";
422  ccDef.transport.read.data.section = ccLabel;
423  ccDef.transport.create.data.section = ccLabel;
424  ccDef.transport.update.data.section = ccLabel;
425  ccDef.transport.destroy.data.section = ccLabel;
426  ccDef.transport.parameterMap = parameterMap;
427  ccDef.schema.parse = parse;
428 
429  var utilityLabel = "Utility";
430  utilityDef.transport.read.data.section = utilityLabel;
431  delete utilityDef.transport.create;
432  delete utilityDef.transport.update;
433  delete utilityDef.transport.destroy;
434  utilityDef.transport.parameterMap = parameterMap;
435  utilityDef.schema.parse = parse;
436 
437  <?php
438  /**
439  * @var menuDef -- The KendoMenu definition used by the menus in the grids.
440  */
441  ?>
442  var menuDef = {
443  orientation: "vertical",
444  direction: "bottom left",
445  select: function(e) {
446  var selectedTab = $("#cuTabStrip").data("kendoTabStrip").value();
447  var grid = null;
448  var dataItem = null;
449  var tr = $(e.item).closest("tr");
450  switch (selectedTab) {
451  case estatementPluralText:
452  grid = $("#estatementGrid").data("kendoGrid");
453  dataItem = grid.dataItem(tr);
454  break;
455  case "Disclosure":
456  grid = $("#extraGrid").data("kendoGrid");
457  dataItem = grid.dataItem(tr);
458  break;
459  case "Credit Card":
460  grid = $("#ccGrid").data("kendoGrid");
461  dataItem = grid.dataItem(tr);
462  break;
463  case "Utility":
464  grid = $("#utilityGrid").data("kendoGrid");
465  dataItem = grid.dataItem(tr);
466  break;
467  }
468  switch ($(e.item).text().trim()) {
469  case "Action...":
470  case "Choose From...":
471  break; <?php // Nothing to do. ?>
472  case "Edit File":
473  $("body").data("dataItem", dataItem);
474  fileDataSource.read({docid: dataItem.docid, section: selectedTab});
475  break;
476  case "Refresh":
477  revertFunc(dataItem.docid);
478  break;
479  case "Delete":
480  deleteFunc(dataItem);
481  break;
482  case "Test Disclosure":
483  pdfTestDataSource.read({operation: "testPdfDisclosure", docid: dataItem.docid, section: selectedTab});
484  break;
485  case "View Form":
486  pdfTestDataSource.read({operation: "testPdfDisclosure", docid: dataItem.docid, section: selectedTab});
487  break;
488  case "View Text":
489  $("body").data("dataItem", dataItem);
490  fileDataSource.read({docid: dataItem.docid, section: selectedTab});
491  break;
492  default:
493  <?php // File changes to version for Vendor. ?>
494  if ($(e.item).closest(".chooseFromLi").length > 0) {
495  var vendor = $(e.item).text().trim();
496  $("body").data("dataItem", dataItem);
497  fileDataSource.read({docid: dataItem.docid, operation: "readDifferentVendor", vendor: vendor});
498  }
499  break;
500  }
501  }
502  }
503 
504  <?php
505  /**
506  * @var estatementGrid
507  * This shows all custom content with the estatement section specified.
508  * It has an main option to create a configuration based on a vendor.
509  */
510  ?>
511  var estatementGrid = $("#estatementGrid").kendoGrid({
512  dataSource: estatementDef,
513  toolbar: $("#estatementToolbarTemplate").html(),
514  columns: [
515  {title: "Doc Name", field: "docname"},
516  {title: "Description", field: "descr"},
517  {title: "", width: 150}
518  ],
519  editable: "inline",
520  noRecords: {
521  template: "<tr><td>No records were found</td></tr>"
522  },
523  rowTemplate: $("#estatementTemplate").html(),
524  scrollable: false,
525  dataBinding: function (e) {
526  if (e.action == "add" || e.action == "remove" || e.action == "itemchange") {
527  <?php // Do not fire. I will have to set the "dirty" flag and sync which will fire the bind. ?>
528  e.preventDefault();
529  } else {
530 
531  $("#estatementGrid [id^='actionMenu_']").each(function() { <?php // Destroy all custom DDLs that are created on the grid. ?>
532  var ddl = $(this).data("kendoMenu");
533  if (ddl != null) {
534  ddl.destroy();
535  }
536  });
537  }
538 
539  estatementIndex = 0;
540  },
541  dataBound: function (e) {
542  $("#estatementGrid [id^='actionMenu_']").each(function() {
543  dmenu = $(this).kendoMenu(menuDef).data("kendoMenu");
544  });
545  }
546  }).data("kendoGrid");
547 
548  <?php
549  /**
550  * @var ccGrid
551  * This shows all custom content with the estatement section specified.
552  * It has an main option to create a configuration based on a vendor.
553  */
554  ?>
555  var ccGrid = $("#ccGrid").kendoGrid({
556  autoBind: false,
557  dataSource: ccDef,
558  toolbar: $("#ccToolbarTemplate").html(),
559  columns: [
560  {title: "Doc Name", field: "docname"},
561  {title: "Description", field: "descr"},
562  {title: "", width: 150}
563  ],
564  editable: "inline",
565  noRecords: {
566  template: "<tr><td>No records were found</td></tr>"
567  },
568  rowTemplate: $("#ccRowTemplate").html(),
569  scrollable: false,
570  dataBinding: function (e) {
571  if (e.action == "add" || e.action == "remove" || e.action == "itemchange") {
572  <?php // Do not fire. I will have to set the "dirty" flag and sync which will fire the bind. ?>
573  e.preventDefault();
574  } else {
575 
576  $("#ccGrid [id^='actionMenuCC_']").each(function() { <?php // Destroy all custom DDLs that are created on the grid. ?>
577  var ddl = $(this).data("kendoMenu");
578  if (ddl != null) {
579  ddl.destroy();
580  }
581  });
582  }
583 
584  estatementIndex = 0;
585  },
586  dataBound: function (e) {
587  $("#ccGrid [id^='actionMenuCC_']").each(function() {
588  dmenu = $(this).kendoMenu(menuDef).data("kendoMenu");
589  });
590  }
591  }).data("kendoGrid");
592 
593  <?php
594  /**
595  * @var extraGrid
596  * This shows all custom content that is not in any of the other categories.
597  * It allows adding records adhoc.
598  */
599  ?>
600  var extraGrid = $("#extraGrid").kendoGrid({
601  autoBind: false,
602  dataSource: extraDef,
603  toolbar: $("#extraToolbarTemplate").html(),
604  columns: [
605  {title: "Doc Name", field: "docname"},
606  {title: "Vendor", field: "vendor"},
607  {title: "Description", field: "descr"},
608  {title: "", width: 150}
609  ],
610  editable: "inline",
611  noRecords: {
612  template: "<tr><td>No records were found</td></tr>"
613  },
614  rowTemplate: $("#extraRowTemplate").html(),
615  scrollable: false,
616  dataBinding: function (e) {
617  if (e.action == "add" || e.action == "remove" || e.action == "itemchange") {
618  <?php // Do not fire. I will have to set the "dirty" flag and sync which will fire the bind. ?>
619  e.preventDefault();
620  } else {
621  $("#extraGrid [id^='actionMenu_']").each(function() { <?php // Destroy all custom DDLs that are created on the grid. ?>
622  var ddl = $(this).data("kendoMenu");
623  if (ddl != null) {
624  ddl.destroy();
625  }
626  });
627  }
628 
629  extraIndex = 0;
630  },
631  dataBound: function (e) {
632  $("#extraGrid [id^='actionMenu_']").each(function() {
633  dmenu = $(this).kendoMenu(menuDef).data("kendoMenu");
634  });
635  }
636  }).data("kendoGrid");
637 
638  var utilityGrid = $("#utilityGrid").kendoGrid({
639  dataSource: utilityDef,
640  columns: [
641  {title: "Doc Name", field: "docname"},
642  {title: "Description", field: "descr"},
643  {title: "", width: 150}
644  ],
645  editable: "inline",
646  noRecords: {
647  template: "<tr><td>No records were found</td></tr>"
648  },
649  rowTemplate: $("#utilityTemplate").html(),
650  scrollable: false,
651  dataBinding: function (e) {
652  if (e.action == "add" || e.action == "remove" || e.action == "itemchange") {
653  <?php // Do not fire. I will have to set the "dirty" flag and sync which will fire the bind. ?>
654  e.preventDefault();
655  } else {
656 
657  $("#utilityGrid [id^='actionMenuUT_']").each(function() { <?php // Destroy all custom DDLs that are created on the grid. ?>
658  var ddl = $(this).data("kendoMenu");
659  if (ddl != null) {
660  ddl.destroy();
661  }
662  });
663  }
664 
665  estatementIndex = 0;
666  },
667  dataBound: function (e) {
668  $("#utilityGrid [id^='actionMenuUT_']").each(function() {
669  dmenu = $(this).kendoMenu(menuDef).data("kendoMenu");
670  });
671  }
672  }).data("kendoGrid");
673 
674  $("#addBtn").kendoButton({
675  click: function() {
676  addWindowFunc ({}, "Disclosure", false);
677  }
678  }).data("kendoButton");
679  }
680 
681  <?php
682  /**
683  * @var addBackupViewFunc -- the window for choosing the backup options.
684  */
685  ?>
686  var addBackupViewFunc = function(dataItem) {
687  var backupViewDialog = $("#backupViewDialog").data("kendoDialog");
688  if (backupViewDialog == null) {
689  backupViewDialog = $("<div id='backupViewDialog'></div>").appendTo("body").kendoDialog({
690  visible: false,
691  content: $("#backupViewTemplate").html(),
692  actions: [
693  {text: "Okay", primary: true}
694  ],
695  open: function () {
696  if (window.activeWindows != null) {
697  window.activeWindows.push(this);
698  }
699 
700  var kWindow = $(backupViewDialog.wrapper);
701  var maxWidth = $(window).width() - 50;
702  var width = 700 > maxWidth ? maxWidth : 700;
703  $(kWindow).css({width: width});
704  },
705  close: function () {
706  if (window.activeWindows != null) {
707  window.activeWindows.pop();
708  }
709  }
710  }).data("kendoDialog");
711  }
712 
713  $("#backupViewDialog .filecontents").val(dataItem.contents);
714  backupViewDialog.title("View \"" + dataItem.file + "\"").open().center();
715  }
716 
717  var ReadOnlyDocFunc = function(dataItem) {
718  var readOnlyWindow = $("#readOnlyWindow").data("kendoWindow");
719  if (readOnlyWindow == null) {
720  readOnlyWindow = $("<div id='readOnlyWindow'></div>").appendTo("body").kendoWindow({
721  modal: true,
722  visible: false,
723  content: {
724  template: $("#readOnlyWindowTemplate").html()
725  },
726  open: function() {
727  if (window.activeWindows != null) {
728  window.activeWindows.push(this);
729  }
730 
731  var kWindow = $(readOnlyWindow.wrapper);
732  var maxWidth = $(window).width() - 50;
733  var width = 700 > maxWidth ? maxWidth : 700;
734  $(kWindow).css({width: width});
735  },
736  close: function() {
737  if (window.activeWindows != null) {
738  window.activeWindows.pop();
739  }
740  }
741  }).data("kendoWindow");
742 
743  <?php
744  /**
745  * Anonymous function
746  * Closes the window with a click on the "okay button."
747  */
748  ?>
749  $("#readOnlyWindow").on("click", ".okayBtn", function() {
750  readOnlyWindow.close();
751  });
752 
753  }
754 
755  <?php // Get file contents. ?>
756  $("#readOnlyWindow .filecontents").val(dataItem.contents);
757  readOnlyWindow.center().open();
758  }
759 
760  <?php
761  /**
762  * @var addWindowFunc
763  * This is the function to add or edit a record.
764  *
765  * @param dataItem -- the dataItem of the grid row.
766  * @param selectedTab -- if it on the estatement tab or the extra tab (or any tabs in the future).
767  * @param isEdit -- true if editing, false if adding
768  */
769  ?>
770  var addWindowFunc = function(dataItem, selectedTab, isEdit) {
771  var addWindow = $("#addWindow").data("kendoWindow");
772  var documentDDL = $("#documentDDL").data("kendoDropDownList");
773  var documentVendorDDL = $("#documentVendorDDL").data("kendoDropDownList");
774  if (addWindow == null) {
775 
776  <?php
777  /**
778  * @var addWindow -- the definition of the kendoWindow for adding.
779  */
780  ?>
781  addWindow = $("<div id='addWindow'></div>").appendTo("body").kendoWindow({
782  modal: true,
783  visible: false,
784  content: {
785  template: $("#addWindowTemplate").html()
786  },
787  open: function() {
788  if (window.activeWindows != null) {
789  window.activeWindows.push(this);
790  }
791 
792  $.homecuValidator.setup({formValidate:'addWindowForm', formStatusField: 'addWindowErrorDiv'});
793 
794  var kWindow = $(addWindow.wrapper);
795  var maxWidth = $(window).width() - 50;
796  var width = 700 > maxWidth ? maxWidth : 700;
797  $(kWindow).css({width: width});
798  },
799  close: function() {
800  $.homecuValidator.setup({formValidate:'estmntForm', formStatusField: 'estmntErrorDiv'});
801  if (window.activeWindows != null) {
802  window.activeWindows.pop();
803  }
804 
805  $("body").data("dataItem", null);
806  $("#addWindow").data("isEdit", null);
807  }
808  }).data("kendoWindow");
809 
810  <?php // Initialize all controls or give handles. ?>
811  <?php
812  /**
813  * @var documentDDL
814  * The drop down list to select the document (name + vendor name)
815  */
816  ?>
817  documentDDL = $("#documentDDL").kendoDropDownList({
818  dataSource: extraDocumentData,
819  dataTextField: "docname",
820  dataValueField: "docname"
821  }).data("kendoDropDownList");
822  $("#addWindow").data("documentData", null);
823 
824  <?php
825  /**
826  * @var documentVendorDDL
827  * The drop down list to select the document (name + vendor name)
828  */
829  ?>
830  documentVendorDDL = $("#documentVendorDDL").kendoDropDownList({
831  dataSource: {
832  data: extraVendorData,
833  schema: {
834  model: {
835  id: "docid",
836  fields: {
837  docid: {type: "number"},
838  docname: {type: "string"},
839  vendor: {type: "string"}
840  }
841  }
842  }
843  },
844  dataTextField: "vendor",
845  dataValueField: "docid",
846  cascadeFrom: "documentDDL",
847  change: function(e) { <?php // Changed to "change." "Change" includes cascadeFrom. "Select" does not. ?>
848 
849  if ($("#addWindow").data("isEdit") === false) {
850  fileDataSource.read({operation: "readDifferentVendor", docid: this.value()});
851  }
852  }
853  }).data("kendoDropDownList");
854 
855  $(documentDDL.wrapper).css({maxWidth: 300, minWidth: 176, width: "100%"});
856  $(documentVendorDDL.wrapper).css({maxWidth: 300, minWidth: 176, width: "100%"});
857 
858  <?php
859  /**
860  * Anonymous function
861  * Closes the window with a click on the "cancel button."
862  */
863  ?>
864  $("#addWindow").on("click", ".cancelBtn", function() {
865  addWindow.close();
866  });
867 
868  <?php
869  /**
870  * Anonymous function
871  * Updates the record and then closes the window with a click on the "update button."
872  */
873  ?>
874  $("#addWindow").on("click", ".updateBtn", function() {
875  if ($.homecuValidator.validate()) {
876 
877  var isEdit = $("#addWindow").data("isEdit");
878  var selectedTab = $("#addWindow").data("selectedTab");
879  var dataItem = $("body").data("dataItem");
880 
881  if (dataItem == null) {
882  dataItem = {};
883  }
884 
885  if (!isEdit && selectedTab == "Disclosure") {
886  dataItem.docid = $("#documentVendorDDL").data("kendoDropDownList").value();
887  }
888 
889  dataItem.contents = $("#addWindow .filecontents").val();
890  dataItem.dirty = true;
891 
892  <?php // Then: add it to the grid. dataSource.sync() should apply the correct CRUD operation. ?>
893  var dataSource = null;
894  switch (selectedTab) {
895  case estatementPluralText:
896  dataSource = $("#estatementGrid").data("kendoGrid").dataSource;
897  break;
898  case "Disclosure":
899  dataSource = $("#extraGrid").data("kendoGrid").dataSource;
900  break;
901  case "Credit Card":
902  dataSource = $("#ccGrid").data("kendoGrid").dataSource;
903  break;
904  }
905  var gridData = dataSource.data();
906  var indexToUpdate = -1;
907 
908  if (!isEdit) {
909  gridData.push(dataItem);
910  indexToUpdate = gridData.length - 1;
911  } else {
912  for(var i = 0; i != gridData.length; i++) {
913  if (gridData[i].docid == dataItem.docid) {
914  indexToUpdate = i;
915  gridData[i] = dataItem;
916  break;
917  }
918  }
919  }
920 
921  gridData[indexToUpdate].dirty = true;
922  dataSource.sync();
923 
924  addWindow.close();
925  }
926  });
927  }
928 
929  if (dataItem == null) {
930  dataItem = $("body").data("dataItem");
931  }
932 
933  if (dataItem != null && !$.isEmptyObject(dataItem)) {
934  $("#documentRow").hide();
935  if (selectedTab == "Disclosure") {
936  documentDDL.value(dataItem.docname);
937  } else {
938  documentDDL.select(0); <?php // Select the first one: default. ?>
939  }
940 
941  <?php // Get file contents. ?>
942  $("#addWindow .filecontents").val(dataItem.contents);
943  } else {
944  if (selectedTab == "Disclosure") {
945  $("#documentRow").show();
946  }
947  <?php // Clear ?>
948  $("#addWindow .filecontents").val(null);
949  documentDDL.select(0); <?php // Select the first one: default. ?>
950  }
951 
952  $("body").data("dataItem", dataItem);
953  $("#addWindow").data("isEdit", isEdit);
954  $("#addWindow").data("selectedTab", selectedTab);
955 
956  var title = isEdit ? "Edit Document" : "Add Document";
957 
958  if (!isEdit) {
959  fileDataSource.read({operation: "readDifferentVendor", docid: documentVendorDDL.value()});
960  }
961  $("#addWindow").data("isEdit", isEdit);
962 
963  addWindow.title(title).open().center();
964  }
965 
966  <?php
967  /**
968  * HandleAddButton(mode, docid, docname, vendor)
969  * Modifies addList to add or remove items. Then it checks the length to see if the add button is disabled or not.
970  *
971  * @param mode -- the mode: either "init", "add", or "delete"
972  * @param docname -- the docname of the dataItem for adding or removing.
973  */
974  ?>
975  function HandleAddButton(mode, docname) {
976  var documentData = [];
977  var documentDDL = $("#documentDDL").data("kendoDropDownList");
978  var documentVendorDDL = $("#documentVendorDDL").data("kendoDropDownList");
979 
980  if (mode == "init" || documentDDL == null) {
981  documentData = window.extraDocumentData;
982  } else {
983  documentData = documentDDL.dataSource.data();
984  }
985 
986  if (mode != "init") {
987 
988  if (mode == "add") {
989  documentData.push({docname: docname});
990  documentData.sort();
991  } else if (mode == "delete") {
992  documentData = $.grep(documentData, function(n,i) { return n.docname.trim() != docname.trim(); });
993  }
994 
995  if (documentDDL != null) {
996  $("#documentDDL").data("kendoDropDownList").dataSource.data(documentData);
997  documentDDL.select(0);
998  documentVendorDDL.select(0);
999  }
1000  }
1001 
1002  addBtn = $("#addBtn").data("kendoButton");
1003  if (documentData.length == 0) {
1004  $("#noAddLabel").show();
1005  addBtn.enable(false);
1006  } else {
1007  $("#noAddLabel").hide();
1008  addBtn.enable(true);
1009  }
1010  }
1011 
1012  <?php
1013  /**
1014  * @var revertFunc
1015  * This creates and shows a dialog to confirm updating file to default.
1016  *
1017  * @param docid -- the docid of the file to update.
1018  */
1019  ?>
1020  var revertFunc = function(docid) {
1021  var defaultDialog = $("#defaultDialog").data("kendoDialog");
1022  if (defaultDialog == null) {
1023 
1024  <?php
1025  /**
1026  * @var defaultDialog -- this is the kendoDialog control for confirming overwriting file to the default file.
1027  */
1028  ?>
1029  defaultDialog = $("<div id='defaultDialog'></div>").appendTo("body").kendoDialog({
1030  title: "Confirm Reset",
1031  content: "This will overwrite the file to the default file. Are you sure you want to do this?",
1032  visible: false,
1033  actions: [
1034  {text: "No"},
1035  {text: "Yes", primary: true, action: function() {
1036  var docid = $("#defaultDialog").data("docid");
1037  fileDataSource.read({operation: "revertEstmntFile", docid: docid});
1038  fileDataSource.sync();
1039  }}
1040  ],
1041  open: function () {
1042  if (window.activeWindows != null) {
1043  window.activeWindows.push(this);
1044  }
1045  },
1046  close: function () {
1047  if (window.activeWindows != null) {
1048  window.activeWindows.pop();
1049  }
1050  }
1051  }).data("kendoDialog");
1052  }
1053 
1054  $("#defaultDialog").data("docid", docid);
1055  defaultDialog.open().center();
1056  }
1057 
1058  <?php
1059  /**
1060  * function InitDeleteDialog()
1061  * Initializes the delete dialog.
1062  *
1063  * @param dataItem -- the dataItem of the record in the grid.
1064  */
1065  ?>
1066  var deleteFunc = function (dataItem) {
1067  var deleteDialog = $("#deleteDialog").data("kendoDialog");
1068  if (deleteDialog == null) {
1069 
1070  <?php
1071  /**
1072  * @var deleteDialog -- The kendoDialog for confirming deletion of the record.
1073  */
1074  ?>
1075  deleteDialog = $("<div id='deleteDialog'></div>").appendTo("body").kendoDialog({
1076  title: "Confirm Delete",
1077  content: "Are you sure you want to delete this custom content?",
1078  visible: false,
1079  actions: [
1080  {text: "No"},
1081  {text: "Yes", primary: true, action: function() {
1082  var dataItem = $("#deleteDialog").data("dataItem");
1083  var selectedTab = $("#cuTabStrip").data("kendoTabStrip").value();
1084  var dataSource = null;
1085  switch (selectedTab) {
1086  case estatementPluralText:
1087  dataSource = $("#estatementGrid").data("kendoGrid").dataSource;
1088  break;
1089  case "Disclosure":
1090  dataSource = $("#extraGrid").data("kendoGrid").dataSource;
1091  break;
1092  case "Credit Card":
1093  dataSource = $("#ccGrid").data("kendoGrid").dataSource;
1094  break;
1095  }
1096  dataSource.remove(dataItem);
1097  dataSource.sync();
1098  }}
1099  ],
1100  open: function () {
1101  if (window.activeWindows != null) {
1102  window.activeWindows.push(this);
1103  }
1104  },
1105  close: function () {
1106  if (window.activeWindows != null) {
1107  window.activeWindows.pop();
1108  }
1109  }
1110  }).data("kendoDialog");
1111  }
1112 
1113  $("#deleteDialog").data("dataItem", dataItem);
1114  deleteDialog.open().center();
1115  }
1116 
1117  <?php
1118  /**
1119  * function InitWindows()
1120  * Initializes the windows needed.
1121  */
1122  ?>
1123  function InitWindows() {
1124 
1125  var moStatusDialog = $("<div id='moStatusDialog'></div>").appendTo("body").kendoDialog({
1126  visible: false,
1127  modal: true,
1128  title: "Manual Operation Status",
1129  width: 350,
1130  actions: [
1131  {text: "Close", primary: true}
1132  ],
1133  open: function () {
1134  if (window.activeWindows != null) {
1135  window.activeWindows.push(this);
1136  }
1137  },
1138  close: function () {
1139  if (window.activeWindows != null) {
1140  window.activeWindows.pop();
1141  }
1142 
1143  clearInterval(moStatusFunc);
1144  }
1145  }).data("kendoDialog");
1146 
1147  <?php
1148  /**
1149  * Anonymous function
1150  * When the test pdf button is clicked, open a window with the possible forms to choose from.
1151  * Once selected and continued, run the pdf file generator and open file.
1152  */
1153  ?>
1154  $("#estatementGrid").on("click", "#testPDFBtn", function () {
1155  if (!$(this).hasClass("k-state-disabled")) {
1156  var pdfChoiceWindow = $("#pdfChoiceWindow").data("kendoWindow");
1157  var pdfChoiceDDL = $("#pdfChoiceDDL").data("kendoDropDownList");
1158  if (pdfChoiceWindow == null) {
1159 
1160  <?php
1161  /**
1162  * @var pdfChoiceWindow
1163  * Displays a window with a single dropdownlist. This dropdownlist contains all the form options.
1164  */
1165  ?>
1166  pdfChoiceWindow = $("<div id='pdfChoiceWindow'></div>").appendTo("body").kendoWindow({
1167  title: "Test Pdfdefs",
1168  modal: true,
1169  maxWidth: 350,
1170  content: {
1171  template: $("#pdfChoiceTemplate").html()
1172  },
1173  visible: false,
1174  open: function() {
1175  if (window.activeWindows != null) {
1176  window.activeWindows.push(this);
1177  }
1178  },
1179  close: function() {
1180  if (window.activeWindows != null) {
1181  window.activeWindows.pop();
1182  }
1183  }
1184  }).data("kendoWindow");
1185 
1186  <?php
1187  /**
1188  * @var pdfChoiceDDL
1189  * Contains all the form options for the pdfdefs file.
1190  */
1191  ?>
1192  pdfChoiceDDL = $("#pdfChoiceDDL").kendoDropDownList({
1193  dataSource: window.pdfChoiceList
1194  }).data("kendoDropDownList");
1195 
1196  $("#pdfChoiceWindow .cancelBtn").click(function() {
1197  pdfChoiceWindow.close();
1198  });
1199 
1200  $("#pdfChoiceWindow .updateBtn").click(function() {
1201  pdfChoiceWindow.close();
1202 
1203  pdfTestDataSource.read();
1204  });
1205  }
1206 
1207  pdfChoiceWindow.open().center();
1208  pdfChoiceDDL.select(0); <?php // Ensure that dropdownlist always has a value. ?>
1209  }
1210  });
1211 
1212  <?php
1213  /**
1214  * Anonymous function
1215  * When the backup button is clicked, create and show the backup window.
1216  */
1217  ?>
1218  $("#backupBtn").on("click", function() {
1219  var backupWindow = $("#backupWindow").data("kendoWindow");
1220  var backupGrid = $("#backupGrid").data("kendoGrid");
1221  if (backupWindow == null) {
1222 
1223  <?php
1224  /**
1225  * @var backupWindow -- the kendoWindow for selecting backup options.
1226  */
1227  ?>
1228  backupWindow = $("<div id='backupWindow'></div>").appendTo("body").kendoWindow({
1229  title: "Backup",
1230  modal: true,
1231  maxWidth: 350,
1232  content: {
1233  template: $("#backupTemplate").html()
1234  },
1235  visible: false,
1236  open: function() {
1237  if (window.activeWindows != null) {
1238  window.activeWindows.push(this);
1239  }
1240 
1241  $.homecuValidator.setup({formValidate:'backupForm', formStatusField: 'backupErrorDiv', homecuCustomRules: {
1242  keywordRequired: function(input) {
1243  if (!$(input).is("[name='keyword']")) {
1244  return true;
1245  }
1246 
1247  if ($(input).val().trim() != "") {
1248  return true;
1249  }
1250 
1251  var grid = $("#backupGrid").data("kendoGrid");
1252  if (grid == null) {
1253  return true;
1254  }
1255 
1256  var dataItem = grid.dataItem(grid.select());
1257  if (dataItem == null) {
1258  return true;
1259  }
1260 
1261  if (dataItem.mainAction == "Make Backup" || dataItem.mainAction == "Remove Backup") {
1262  $(input).attr("data-keywordRequired-msg", "Keyword is required.");
1263  return false;
1264  }
1265 
1266  return true;
1267  }
1268  }});
1269  },
1270  close: function() {
1271  $.homecuValidator.setup({formValidate:'estmntForm', formStatusField: 'estmntErrorDiv'});
1272  if (window.activeWindows != null) {
1273  window.activeWindows.pop();
1274  }
1275  }
1276  }).data("kendoWindow");
1277 
1278  <?php
1279  /**
1280  * @var first -- if first, it hasn't been initialized and the logic to select the first one will not be called.
1281  * So put that in the dataBound if first.
1282  */
1283  ?>
1284  var first = true;
1285 
1286  <?php
1287  /**
1288  * @var backupGrid -- The kendoGrid for showing all the backup options that can be selected.
1289  */
1290  ?>
1291  backupGrid = $("#backupGrid").kendoGrid({
1292  autoBind: false,
1293  dataSource: {
1294  transport: {
1295  read: {
1296  url: self,
1297  dataType: "json",
1298  type: "POST",
1299  data: {
1300  cu: cu,
1301  operation: "readBackupFiles"
1302  }
1303  },
1304  parameterMap: function (data, type) {
1305  ShowWaitWindow();
1306  return data;
1307  }
1308  },
1309  schema: {
1310  model: {
1311  id: "kendoId",
1312  fields: {
1313  kendoId: {type: "string"},
1314  sort: {type: "number"},
1315  mainAction: {type: "string"},
1316  file: {type: "string"},
1317  keyword: {type: "string"}
1318  }
1319  },
1320  parse: function (data) {
1321  CloseWaitWindow();
1322 
1323  var gridData = [
1324  {kendoId: 1, sort: 1, mainAction: "Make Backup"},
1325  {kendoId: 2, sort: 2, mainAction: "Remove Backup"}
1326  ];
1327 
1328  if (data.status !== "000") {
1329  $.homecuValidator.displayMessage(data.error, $.homecuValidator.settings.statusError );
1330  } else {
1331  if (data.info != "") {
1332  $.homecuValidator.displayMessage(data.info, $.homecuValidator.settings.statusInfo );
1333  }
1334 
1335  var returnedData = data.data; <?php // Only return data for the backed up files. ?>
1336  var kendoId = 3;
1337 
1338  for (var i = 0; i!= returnedData.length; i++) {
1339  var row = returnedData[i];
1340  gridData.push({kendoId: kendoId++, sort: 4, mainAction: "View Backup", file: row.file, keyword: row.keyword});
1341  }
1342  }
1343 
1344  return gridData;
1345  }
1346  },
1347  sort: [{field: "sort", dir: "asc"}, {field: "keyword", dir: "asc"}, {field: "file", dir: "asc"}]
1348  },
1349  columns: [
1350  {field: "mainAction", template: "# if (kendoId < 3) { # #: mainAction # # } else { # <b>View:</b> #: file # # } #"}
1351  ],
1352  selectable: "row",
1353  dataBound: function(e) {
1354  if (first) {
1355  first = false;
1356  this.select("tr:eq(0)");
1357  }
1358  }
1359  }).data("kendoGrid");
1360 
1361  <?php // Looks better without a header. ?>
1362  $("#backupGrid .k-header").remove();
1363 
1364  <?php
1365  /**
1366  * Anonymous function
1367  * When "cancel button" is clicked, close the window.
1368  */
1369  ?>
1370  $("#backupWindow").on("click", ".cancelBtn", function() {
1371  backupWindow.close();
1372  });
1373 
1374  <?php
1375  /**
1376  * Anonymous function
1377  * When "update button" is clicked, do the selected action and close window.
1378  */
1379  ?>
1380  $("#backupWindow").on("click", ".updateBtn", function() {
1381  if ($.homecuValidator.validate()) {
1382  var dataItem = backupGrid.dataItem(backupGrid.select());
1383  var parameters = {keyword: $("#keywordInput").val().trim()};
1384  var dataSource = null;
1385  switch (dataItem.mainAction) {
1386  case "Make Backup":
1387  parameters.operation = "makeBackup";
1388  dataSource = backupGrid.dataSource;
1389  break;
1390  case "Remove Backup":
1391  parameters.operation = "removeBackup";
1392  dataSource = backupGrid.dataSource;
1393  break;
1394  case "View Backup":
1395  parameters.operation = "viewBackupFile";
1396  parameters.file = dataItem.file;
1397  parameters.keyword = dataItem.keyword;
1398  dataSource = fileDataSource;
1399  break;
1400  }
1401 
1402  dataSource.read(parameters);
1403  }
1404  });
1405 
1406  <?php // Filter based on keyword. ?>
1407  $("#keywordInput").blur(function() {
1408  var value = $(this).val().trim();
1409  var filter = value == "" ? {} : {logic: "or", filters: [
1410  {field: "mainAction", operator: "neq", value: "View Backup"},
1411  {field: "keyword", operator: "eq", value: value}
1412  ]};
1413  backupGrid.dataSource.filter(filter);
1414  backupGrid.select("tr:eq(0)");
1415  });
1416  }
1417 
1418  backupGrid.dataSource.fetch();
1419  backupGrid.select("tr:eq(0)");
1420  backupWindow.open().center();
1421  });
1422 
1423  <?php
1424  /**
1425  * Anonymous function
1426  * When "new config button" is clicked, create and show dialog confirming.
1427  */
1428  ?>
1429  $("#estatementGrid, #ccGrid").on("click", ".newConfigBtn", function () {
1430  var confirmBackupDialog = $("#confirmBackupDialog").data("kendoDialog");
1431  if (confirmBackupDialog == null) {
1432 
1433  <?php
1434  /**
1435  * @var confirmBackupDialog
1436  * This is a simple dialog to ensure that they backed up first.
1437  */
1438  ?>
1439  confirmBackupDialog = $("<div id='confirmBackupDialog'></div>").appendTo("body").kendoDialog({
1440  title: "Confirm Backup",
1441  content: $("#confirmBackupTemplate").html(),
1442  visible: false,
1443  actions: [
1444  {text: "Cancel"},
1445  {text: "Continue", primary: true, action: function() {
1446  $("#confirmBackupDialog").data("kendoDialog").close();
1447  $("#selectVersionDialog").data("kendoDialog").open().center();
1448  return false;
1449  }}
1450  ],
1451  open: function () {
1452  if (window.activeWindows != null) {
1453  window.activeWindows.push(this);
1454  }
1455  },
1456  close: function () {
1457  if (window.activeWindows != null) {
1458  window.activeWindows.pop();
1459  }
1460  }
1461  }).data("kendoDialog");
1462 
1463  <?php
1464  /**
1465  * @var selectVersionDialog
1466  * This is a simple dialog to select the version (vendor) to configure for.
1467  */
1468  ?>
1469  var selectVersionDialog = $("<div id='selectVersionDialog'></div>").appendTo("body").kendoDialog({
1470  title: "Select Version",
1471  content: $("#selectVersionTemplate").html(),
1472  visible: false,
1473  maxWidth: 350,
1474  maxHeight: 300,
1475  actions: [
1476  {text: "Cancel"},
1477  {text: "Save", primary: true, action: function() {
1478  var grid = $("#selectGrid").data("kendoGrid");
1479  var dataItem = grid.dataItem(grid.select());
1480  var tabStrip = $("#cuTabStrip").data("kendoTabStrip");
1481  var dataSource = null;
1482 
1483  switch(tabStrip.value()) {
1484  case "Disclosure":
1485  dataSource = $("#extraGrid").data("kendoGrid").dataSource;
1486  break;
1487  case estatementPluralText:
1488  dataSource = $("#estatementGrid").data("kendoGrid").dataSource;
1489  break;
1490  case "Credit Card":
1491  dataSource = $("#ccGrid").data("kendoGrid").dataSource;
1492  break;
1493  }
1494  var data = {vendor: dataItem.value, operation: "startNewConfig"};
1495  dataSource.read(data);
1496  }}
1497  ],
1498  open: function () {
1499  if (window.activeWindows != null) {
1500  window.activeWindows.push(this);
1501  }
1502  },
1503  close: function () {
1504  if (window.activeWindows != null) {
1505  window.activeWindows.pop();
1506  }
1507  }
1508  }).data("kendoDialog");
1509 
1510  <?php
1511  /**
1512  * @var selectGrid
1513  * This is the simple grid in the dialog that gives a list of vendors to select. The default (the vendor that the CU is set to) is at the top.
1514  */
1515  ?>
1516  var selectGrid = $("#selectGrid").kendoGrid({
1517  dataSource: {
1518  data: configList,
1519  sort: [
1520  {field: "default", dir: "desc"},
1521  {field: "value", dir: "asc"}
1522  ],
1523  schema: {
1524  model: {
1525  id: "value",
1526  fields: {
1527  value: {type: "text"},
1528  text: {type: "text"},
1529  default: {type: "boolean"},
1530  section: {type: "string"}
1531  }
1532  }
1533  }
1534  },
1535  selectable: "row",
1536  columns: [
1537  {field: "text"}
1538  ]
1539  }).data("kendoGrid");
1540 
1541  $("#selectGrid .k-grid-header").remove();
1542  }
1543 
1544  var top = $("#confirmBackupDialog .overwrittenFiles");
1545  var none = $("#confirmBackupDialog .noFiles");
1546  var tabStrip = $("#cuTabStrip").data("kendoTabStrip");
1547  var selectGrid = $("#selectGrid").data("kendoGrid");
1548 
1549  var localFilesAffected = null;
1550  switch(tabStrip.value()) {
1551  case "Credit Card":
1552  localFilesAffected = filesAffectedCC;
1553  break;
1554  default:
1555  localFilesAffected = filesAffected;
1556  break;
1557  }
1558 
1559  if (localFilesAffected.length > 0) {
1560 
1561  var ul = $("#confirmBackupDialog .overwrittenFiles ul");
1562 
1563  var toAppend = "";
1564  for (var i = 0; i != localFilesAffected.length; i++) {
1565  toAppend += "<li>" + localFilesAffected[i] + "</li>";
1566  }
1567  $(ul).html(toAppend);
1568  $(top).show();
1569  $(none).hide();
1570  } else {
1571  $(top).hide();
1572  $(none).show();
1573  }
1574 
1575  <?php // Now that the config list is for estatements and also credit cards, filter. ?>
1576 
1577  selectGrid.dataSource.filter({field: "section", operator: "eq", value: tabStrip.value()});
1578  var selectData = selectGrid.dataSource.view();
1579  var searchValue = null;
1580  switch(tabStrip.value()) {
1581  case "Credit Card":
1582  searchValue = currentVendorCC;
1583  break;
1584  default:
1585  searchValue = currentVendor;
1586  break;
1587  }
1588  for(var i = 0; i != selectData.length; i++) {
1589  if (selectData[i].value == searchValue) {
1590  break;
1591  }
1592  }
1593  selectGrid.select("tr:eq(" + i + ")");
1594 
1595  confirmBackupDialog.open().center();
1596  });
1597 
1598  <?php
1599  /**
1600  * $(".manualBtn").on("click"
1601  * This sets up the manual operation window.
1602  */
1603  ?>
1604  $(".manualBtn").on("click", function () {
1605  var manualWindow = $("#manualWindow").data("kendoWindow");
1606  var statementFileDDL = $("#statementFileDDL").data("kendoDropDownList");
1607  var tabStrip = $("#cuTabStrip").data("kendoTabStrip");
1608  if (manualWindow == null) {
1609 
1610  <?php
1611  /**
1612  * @var manualWindow
1613  * This is the actual KendoWindow object for the manual operation window.
1614  */
1615  ?>
1616  manualWindow = $("<div id='manualWindow'></div>").appendTo("body").kendoWindow({
1617  title: "Manual Operations",
1618  content: {
1619  template: $("#manualTemplate").html()
1620  },
1621  visible: false,
1622  modal: true,
1623  width: "90%",
1624  minWidth: 350,
1625  maxWidth: 500,
1626  open: function () {
1627  $.homecuValidator.setup({formValidate:'manualForm', formStatusField: 'manualErrorDiv', homecuCustomRules: {
1628  validateperiod: function(input) {
1629  if (!$(input).is("[name='reportingPeriodText']")) {
1630  return true;
1631  }
1632 
1633  var text = $(input).val().trim();
1634  var pattern = <?php echo GetPeriodPattern(); ?>;
1635  if (!text.match(pattern)) {
1636  $(input).attr("data-validateperiod-msg", "Period is invalid");
1637  return false;
1638  }
1639  return true;
1640  }
1641  }});
1642  if (window.activeWindows != null) {
1643  window.activeWindows.push(this);
1644  }
1645  },
1646  close: function () {
1647  $.homecuValidator.setup({formValidate:'estmntForm', formStatusField: 'estmntErrorDiv'});
1648  if (window.activeWindows != null) {
1649  window.activeWindows.pop();
1650  }
1651  }
1652  }).data("kendoWindow");
1653 
1654  var moActions = moData == null ? [] : moData.moActions;
1655  var moAllFiles = moData == null ? [] : moData.moAllFiles;
1656  var moPeriods = moData == null ? [] : moData.moPeriods;
1657 
1658  <?php
1659  /**
1660  * @var manualActionDDL
1661  * Either "Reload" or "Undo." (It's required.)
1662  */
1663  ?>
1664  $("#manualActionDDL").kendoDropDownList({
1665  dataSource: moActions,
1666  dataTextField: "text",
1667  dataValueField: "value",
1668  optionLabel: "Action...",
1669  change: function() {
1670  var value = this.value();
1671  switch(value) {
1672  case "reload":
1673  $(".statementFileDiv").show();
1674  break;
1675  default:
1676  $(".statementFileDiv").hide();
1677  break;
1678  }
1679  }
1680  }).data("kendoDropDownList");
1681 
1682  <?php
1683  /**
1684  * @var statementFileDDL
1685  * This KendoDropDownList control contains all the valid files to choose.
1686  */
1687  ?>
1688  statementFileDDL = $("#statementFileDDL").kendoDropDownList({
1689  dataSource: {
1690  data: moAllFiles,
1691  schema: {
1692  model: {
1693  id: "filename",
1694  fields: {
1695  filename: {type: "string"},
1696  date: {type: "string"},
1697  type: {type: "string"}
1698  }
1699  }
1700  }
1701  },
1702  dataTextField: "filename",
1703  dataValueField: "filename",
1704  template: $("#manualFileOptionTemplate").html(),
1705  change: function(e) {
1706  if (this.dataItem() != null) {
1707  $("#fileDateText").text(this.dataItem().date);
1708  }
1709  }
1710  }).data("kendoDropDownList");
1711 
1712  var dataItem = statementFileDDL.dataItem();
1713  if (dataItem != null) {
1714  $("#fileDateText").text(dataItem.date);
1715  } else {
1716  $("#fileDateText").text("&nbsp;");
1717  }
1718 
1719 
1720  $("#manualWindow").on("click", ".cancelBtn", function() {
1721  $("#manualWindow").data("kendoWindow").close();
1722  return false;
1723  });
1724 
1725  $("#manualWindow").on("click", ".updateBtn", function() {
1726  if ($.homecuValidator.validate()) {
1727  var manualWindowConfirmation = $("#manualWindowConfirmation").data("kendoDialog");
1728  if (manualWindowConfirmation == null) {
1729 
1730  <?php
1731  /**
1732  * @var manualWindowConfirmation
1733  * An extra dialog to confirm the reload or undo operation
1734  */
1735  ?>
1736  manualWindowConfirmation = $("<div id='manualWindowConfirmation'></div>").appendTo("body").kendoDialog({
1737  title: "Confirm Manual Operation",
1738  visible: false,
1739  open: function() {
1740  if (window.activeWindows != null) {
1741  window.activeWindows.push(this);
1742  }
1743  },
1744  close: function() {
1745  if (window.activeWindows != null) {
1746  window.activeWindows.pop();
1747  }
1748  },
1749  actions: [
1750  {text: "No"},
1751  {text: "Yes", primary: true, action: function() {
1752  $("#manualWindowConfirmation").data("kendoDialog").close();
1753  $("#manualWindow").data("kendoWindow").close();
1754 
1755  var parameters = {operation: "executeManualOperations"};
1756  parameters.period = $("#reportingPeriodText").val().trim();
1757  parameters.suboperation = $("#manualActionDDL").data("kendoDropDownList").value();
1758  parameters.file = $("#statementFileDDL").data("kendoDropDownList").value();
1759  fileDataSource.read(parameters);
1760 
1761  return false;
1762  }}
1763  ]
1764  }).data("kendoDialog");
1765  }
1766 
1767  var parameters = {};
1768  parameters.period = $("#reportingPeriodText").val().trim();
1769  parameters.suboperation = $("#manualActionDDL").data("kendoDropDownList").value();
1770  parameters.file = $("#statementFileDDL").data("kendoDropDownList").value();
1771  parameters.filedate = $("#fileDateText").text().trim();
1772 
1773  var template = kendo.template($("#manualWindowConfirmationTemplate").html());
1774  manualWindowConfirmation.content(template(parameters)).open();
1775  }
1776  });
1777 
1778  var height = 170; <?php // the calculated height when X is 5. ?>
1779  <?php
1780  /**
1781  * @var lastPeriodGrid
1782  * This is info-only KendoGrid showing the last X periods in the summary log file.
1783  */
1784  ?>
1785  $("#lastPeriodGrid").kendoGrid({
1786  dataSource: moPeriods,
1787  columns: [
1788  {title: "Period", field: "period"},
1789  {title: "Action", field: "action"},
1790  {title: "Date", field: "date"}
1791  ],
1792  noRecords: {
1793  template: "<span class='hcu-secondary'><span class='vsgSecondary'>No Periods Found</span></span>"
1794  },
1795  height: height
1796  }).data("kendoGrid");
1797 
1798 
1799 
1800  <?php
1801  /**
1802  * @var ccperiodCheckbox
1803  * This prepend the words CREDIT CARD to the period text field.
1804  */
1805  ?>
1806  $("#ccperiodCheckbox").click(function() {
1807  var ccname = "<?php echo GetCCName(); ?>";
1808  var text = $("#reportingPeriodText").val().trim();
1809  if (!$(this).prop("checked")) {
1810  text = text.replace(ccname, "");
1811  } else if (text.lastIndexOf(ccname) === -1) {
1812  text = ccname + " " + text;
1813  }
1814  $("#reportingPeriodText").val(text);
1815  });
1816  }
1817  manualWindow.center().open();
1818  });
1819  }
1820 
1821  <?php
1822  /**
1823  * @var fileDataSource -- Since the dataSource is used in multiple places, put it in global scope.
1824  */
1825  ?>
1826  var fileDataSource = null;
1827  var moStatusDataSource = null;
1828  var moStatusFunc = null;
1829 
1830  <?php
1831  /**
1832  * function InitFileOperations()
1833  * This function initializes the dataSource for reading/editing files and the window to edit the file.
1834  */
1835  ?>
1836  function InitFileOperations() {
1837 
1838  <?php
1839  /**
1840  * @var fileDataSource -- Set up a dataSource to read and update files which do not change the record in the database.
1841  */
1842  ?>
1843  fileDataSource = new kendo.data.DataSource({
1844  batch: true,
1845  transport: {
1846  read: {
1847  url: self,
1848  dataType: "json",
1849  type: "POST",
1850  data: {
1851  cu: cu,
1852  operation: "readEstmntFile"
1853  }
1854  },
1855  parameterMap: function(data, type) {
1856  ShowWaitWindow();
1857 
1858  if (data.section == "Utility") {
1859  data.operation = "readDifferentVendor";
1860  }
1861  return data;
1862  }
1863  },
1864  schema: {
1865  parse: function (data) {
1866  CloseWaitWindow();
1867  if (data.status !== "000") {
1868  $.homecuValidator.displayMessage(data.error, $.homecuValidator.settings.statusError );
1869  } else {
1870  if (data.info != "") {
1871  $.homecuValidator.displayMessage(data.info, $.homecuValidator.settings.statusInfo );
1872  }
1873 
1874  if (data.data && data.data.formList) {
1875  if (data.data.formList.length > 0) {
1876  $("#testPDFBtn").removeClass("k-state-disabled");
1877 
1878  <?php // Apply list to the dropdownlist if it exists at this point. Otherwise, save it for later. ?>
1879  var pdfChoiceDDL = $("#pdfChoiceDDL").data("kendoDropDownList");
1880  if (pdfChoiceDDL == null) {
1881  window.pdfChoiceList = data.data.formList;
1882  } else {
1883  pdfChoiceDDL.dataSource.data(data.data.formList);
1884  window.pdfChoiceList = undefined;
1885  }
1886  } else {
1887  $("#testPDFBtn").addClass("k-state-disabled");
1888  }
1889  }
1890 
1891  if (data.operation == "read") {
1892  var dataItem = data.data[0];
1893  var contents = dataItem.contents;
1894 
1895  if ($("#addWindow:visible").length > 0) {
1896  $("#addWindow .filecontents").val(contents);
1897  } else {
1898  dataItem = $("body").data("dataItem");
1899  dataItem.contents = contents;
1900 
1901  var currentTab = $("#cuTabStrip").data("kendoTabStrip").value();
1902 
1903  if (currentTab == "Utility") {
1904  ReadOnlyDocFunc(dataItem);
1905  } else {
1906  addWindowFunc(dataItem, currentTab, true);
1907  }
1908  }
1909  } else if (data.operation == "backup") {
1910  addBackupViewFunc(data.data);
1911  } else if (data.operation == "exec") {
1912  <?php // Open the window and assume that it hasn't completed that fast. ?>
1913  $("#moStatusDialog").data("kendoDialog").content("<?php echo GetRunningMOInfo(); ?>").open();
1914  <?php // Set up to check every so many seconds. ?>
1915  moStatusFunc = setInterval(function() {
1916  moStatusDataSource.read();
1917  }, <?php echo GetCheckMORunningSecs() * 1000; ?>);
1918 
1919  }
1920  }
1921 
1922  return [];
1923  }
1924  }
1925  });
1926 
1927  <?php
1928  /**
1929  * @var pdfTestDataSource
1930  * This is a dataSource to handle the two test operations: "testPdfDefs" and "testPdfDisclosure."
1931  */
1932  ?>
1933  pdfTestDataSource = new kendo.data.DataSource({
1934  transport: {
1935  read: {
1936  url: self,
1937  dataType: "json",
1938  type: "POST",
1939  data: {
1940  cu: cu,
1941  operation: "testPdfDefs"
1942  }
1943  },
1944  parameterMap: function(data, type) {
1945  ShowWaitWindow();
1946 
1947  switch (data.operation) {
1948  case "testPdfDefs":
1949  data.selectedForm = $("#pdfChoiceDDL").data("kendoDropDownList").value();
1950  break;
1951  default:
1952  break;
1953  }
1954 
1955  return data;
1956  }
1957  },
1958  schema: {
1959  parse: function (data) {
1960  CloseWaitWindow();
1961  if (data.status !== "000") {
1962  $.homecuValidator.displayMessage(data.error, $.homecuValidator.settings.statusError );
1963  } else {
1964  if (data.info != "") {
1965  $.homecuValidator.displayMessage(data.info, $.homecuValidator.settings.statusInfo );
1966  }
1967 
1968  <?php // Need to destroy and recreate window because the content is changed. ?>
1969  var pdfViewWindow = $("#pdfViewWindow").data("kendoWindow");
1970  if (pdfViewWindow == null) {
1971 
1972  <?php
1973  /**
1974  * @var pdfViewWindow
1975  * This is a window to handle showing the test pdf.
1976  */
1977  ?>
1978  pdfViewWindow = $("<div id='pdfViewWindow'></div>").appendTo("body").kendoWindow({
1979  title: "View Window",
1980  modal: true,
1981  width: 600,
1982  height: 400,
1983  visible: false,
1984  content: {
1985  template: $("#pdfViewTemplate").html()
1986  },
1987  open: function() {
1988  if (window.activeWindows != null) {
1989  window.activeWindows.push(this);
1990  }
1991  },
1992  close: function() {
1993  if (window.activeWindows != null) {
1994  window.activeWindows.pop();
1995  }
1996  }
1997  }).data("kendoWindow");
1998 
1999  $("#pdfViewWindow .closeBtn").click(function() {
2000  pdfViewWindow.close();
2001  });
2002  }
2003 
2004  $("#viewIframe").attr("src", null);
2005  $("#pdfEmbedParent").empty();
2006  pdfViewWindow.open().center();
2007 
2008  var src = self + "?operation=viewPdfTestOutput&cu=" + cu + "&time=" + new Date().getTime();
2009  <?php // Need the time or Safari will not refresh. ?>
2010  $("#pdfEmbedParent").append('<embed class="embed-responsive-item" id="viewIframe" src="' + src + '" type="application/pdf">');
2011  <?php // Safari does not update always when the "src" attribute is updated. Therefore, need to recreate the entire embed object. ?>
2012  }
2013 
2014  return [];
2015  }
2016  }
2017  });
2018 
2019  moStatusDataSource = new kendo.data.DataSource({
2020  transport: {
2021  read: {
2022  url: self,
2023  dataType: "json",
2024  type: "POST",
2025  data: {
2026  cu: cu,
2027  operation: "retrieveStatusManualOperations"
2028  }
2029  },
2030  parameterMap: function(data, type) {
2031  return data;
2032  }
2033  },
2034  schema: {
2035  parse: function(data) {
2036  var moStatusDialog = $("#moStatusDialog").data("kendoDialog");
2037 
2038  var isHidden = $(moStatusDialog.element).is(":hidden");
2039 
2040  switch (data.infoCode) {
2041  case 1: <?php // Failed ?>
2042  if (!isHidden) {
2043  clearInterval(moStatusFunc);
2044  }
2045  moStatusDialog.content(data.infoMessage).open();
2046  break;
2047  case 2: <?php // Running ?>
2048  if (isHidden) {
2049  <?php // Set up to check every so many seconds. ?>
2050  moStatusFunc = setInterval(function() {
2051  moStatusDataSource.read();
2052  }, <?php echo GetCheckMORunningSecs() * 1000; ?>);
2053  }
2054  moStatusDialog.content(data.infoMessage).open();
2055  break;
2056  default:
2057  moStatusDialog.close();
2058  break;
2059  }
2060 
2061  return [];
2062  }
2063  }
2064  });
2065 
2066  <?php // Initial read for the page to see if there is a process running. ?>
2067  moStatusDataSource.read();
2068  }
2069 
2070  <?php
2071  /**
2072  * @var activeWindows -- needed to reference current windows when the background is clicked.
2073  */
2074  ?>
2075  var activeWindows = [];
2076 
2077  <?php
2078  /**
2079  * Anonymous function
2080  * Run everything when the document is ready.
2081  */
2082  ?>
2083  $(document).ready(function() {
2084  $.homecuValidator.setup({formValidate:'estmntForm', formStatusField: 'estmntErrorDiv'});
2085  InitMainTabStrip();
2086  InitGrids();
2087  InitWindows();
2088  InitFileOperations();
2089 
2090  <?php
2091  /**
2092  * Anonymous function
2093  * Be sure and close the window when the background is clicked.
2094  */
2095  ?>
2096  $("body").on("click", ".k-overlay", function() {
2097  if (activeWindows.length > 0) {
2098  activeWindows [activeWindows.length - 1].close();
2099  return false;
2100  }
2101  });
2102  });
2103  </script>
2104 
2105  <script type="text/x-kendo-template" id="extraToolbarTemplate">
2106  <div style="display: none;" id="noAddLabel" class="hcu-secondary"><div class="vsgSecondary">
2107  There are no more extra documents to add.
2108  </div></div>
2109  <a href='\\#' id='addBtn' class='k-button'><i class='fa fa-plus'></i>Add</a>
2110  </script>
2111 
2112  <?php
2113  /**
2114  * @var estatementToolbarTemplate
2115  * Contents of the toolbar for the estatement grid.
2116  */
2117  ?>
2118  <script type="text/x-kendo-template" id="estatementToolbarTemplate">
2119  <div style="display: none;" id="currentVendorLabel" class="hcu-secondary"><div class="vsgSecondary">
2120  The current configuration is <span></span>.
2121  </div></div>
2122  <a href='\\#' class='k-button newConfigBtn'>Start New Config</a>
2123  <a href='\\#' id='testPDFBtn' class='k-button'>Test Pdfdefs</a>
2124  </script>
2125 
2126  <?php
2127  /**
2128  * @var estatementToolbarTemplate
2129  * Contents of the toolbar for the cc grid.
2130  */
2131  ?>
2132  <script type="text/x-kendo-template" id="ccToolbarTemplate">
2133  <div style="display: none;" id="currentVendorLabelCC" class="hcu-secondary"><div class="vsgSecondary">
2134  The current configuration is <span></span>.
2135  </div></div>
2136  <a href='\\#' class='k-button newConfigBtn'>Start New Config</a>
2137  </script>
2138 
2139  <?php
2140  /**
2141  * @var backupViewTemplate
2142  * Contents of the backup view dialog/window. This has a textarea that is disabled.
2143  */
2144  ?>
2145  <script type="text/x-kendo-template" id="backupViewTemplate">
2146  <div class="container-fluid">
2147  <div class="row hcuSpacer">
2148  <textarea class="col-xs-12 k-textbox hcu-all-100 filecontents k-state-disabled" readonly></textarea>
2149  </div>
2150  </div>
2151  </script>
2152 
2153  <?php
2154  /**
2155  * @var backupTemplate
2156  * Contents of the backup dialog/window.
2157  */
2158  ?>
2159  <script type="text/x-kendo-template" id="backupTemplate">
2160  <div class="container-fluid hcu-template" id="backupForm">
2161  <div id='backupErrorDiv'></div>
2162  <div class="row hcuSpacer hcu-secondary"><div class="vsgSecondary col-xs-12">
2163  Adding a keyword will also restrict the grid results.
2164  </div></div>
2165  <div class="row hcuSpacer">
2166  <div class="col-xs-4"><label>Keyword</label></div>
2167  <div class="col-xs-8"><input id="keywordInput" name="keyword" type="text" class="k-textbox hcu-all-100"></div>
2168  </div>
2169  <div class="row hcuSpacer">
2170  <div class="col-xs-12">
2171  <div id="backupGrid"></div>
2172  </div>
2173  </div>
2174  <div class="hcu-edit-buttons k-state-default">
2175  <a class="cancelBtn" href="\\#">Cancel</a>
2176  &nbsp;&nbsp;&nbsp;
2177  <a class="updateBtn k-button k-primary" href="\\#"><i class="fa fa-check"></i>Okay</a>
2178  </div>
2179  </div>
2180  </script>
2181 
2182  <?php
2183  /**
2184  * @var selectVersionTemplate
2185  * The template for the select version popup.
2186  */
2187  ?>
2188  <script type="text/x-kendo-template" id="selectVersionTemplate">
2189  <div class="container-fluid">
2190  <div class="row hcuSpacer">
2191  <div id="selectGrid"></div>
2192  </div>
2193  </div>
2194  </script>
2195 
2196  <?php
2197  /**
2198  * @var confirmBackupTemplate
2199  * The template for the confirm backup popup.
2200  */
2201  ?>
2202  <script type="text/x-kendo-template" id="confirmBackupTemplate">
2203  <div class='container-fluid'>
2204  <div class='row hcuSpacer'>
2205  This action will overwrite files to bring in new configuration. Please backup if you haven't already.
2206  </div>
2207  <div class='row hcuSpacer overwrittenFiles' style='display:none;'>
2208  These files will be overwritten:
2209  <ul></ul>
2210  </div>
2211  <div class='row hcuSpacer noFiles' style='display:none;'>
2212  There are no files to overwrite.
2213  </div>
2214  </div>
2215  </script>
2216 
2217  <?php
2218  /**
2219  * @var extraRowTemplate
2220  * The row template for the extra grid.
2221  */
2222  ?>
2223  <script type="text/x-kendo-template" id="extraRowTemplate">
2224  <tr data-uid="#= uid #">
2225  <td>#: docname #</td>
2226  <td>#: vendor #</td>
2227  <td>#: descr #</td>
2228  <td>
2229  <ul id='actionMenu_#: window.extraIndex #'>
2230  <li>Action...
2231  <ul>
2232  <li>Edit File</li>
2233  <li>Refresh</li>
2234  <li>Delete</li>
2235  <li class="chooseFromLi">Choose From...
2236  <ul>
2237  # for(var i = 0; i != allvendors.length; i++) { #
2238  <li>#: allvendors[i] #</li>
2239  # } #
2240  </ul>
2241  </li>
2242  <li>Test Disclosure</li>
2243  </ul>
2244  </li>
2245  </ul>
2246  </td>
2247  </tr>
2248  # window.extraIndex++; #
2249  </script>
2250 
2251  <?php
2252  /**
2253  * @var estatementTemplate
2254  * The row template for the estatement grid.
2255  */
2256  ?>
2257  <script type="text/x-kendo-template" id="estatementTemplate">
2258  <tr data-uid="#= uid #">
2259  <td>#: docname #</td>
2260  <td>#: descr #</td>
2261  <td>
2262  <ul id='actionMenu_#: window.estatementIndex #'>
2263  <li>Action...
2264  <ul>
2265  <li>Edit File</li>
2266  <li>Refresh</li>
2267  <li>Delete</li>
2268  <li class="chooseFromLi">Choose From...
2269  <ul>
2270  # for(var i = 0; i != allvendors.length; i++) { #
2271  <li>#: allvendors[i] #</li>
2272  # } #
2273  </ul>
2274  </li>
2275  </ul>
2276  </li>
2277  </ul>
2278  </td>
2279  </tr>
2280  # window.estatementIndex++; #
2281  </script>
2282 
2283  <?php
2284  /**
2285  * @var ccTemplate
2286  * The row template for the cc grid.
2287  */
2288  ?>
2289  <script type="text/x-kendo-template" id="ccRowTemplate">
2290  <tr data-uid="#= uid #">
2291  <td>#: docname #</td>
2292  <td>#: descr #</td>
2293  <td>
2294  <ul id='actionMenuCC_#: window.estatementIndex #'>
2295  <li>Action...
2296  <ul>
2297  <li>Edit File</li>
2298  <li>Refresh</li>
2299  <li>Delete</li>
2300  <li class="chooseFromLi">Choose From...
2301  <ul>
2302  # for(var i = 0; i != allvendors.length; i++) { #
2303  <li>#: allvendors[i] #</li>
2304  # } #
2305  </ul>
2306  </li>
2307  </ul>
2308  </li>
2309  </ul>
2310  </td>
2311  </tr>
2312  # window.estatementIndex++; #
2313  </script>
2314 
2315  <?php
2316  /**
2317  * @var estatementTemplate
2318  * The row template for the estatement grid.
2319  */
2320  ?>
2321  <script type="text/x-kendo-template" id="utilityTemplate">
2322  <tr data-uid="#= uid #">
2323  <td>#: docname #</td>
2324  <td>#: descr #</td>
2325  <td>
2326  <ul id='actionMenuUT_#: window.estatementIndex #'>
2327  <li>Action...
2328  <ul>
2329  <li>View Form</li>
2330  <li>View Text</li>
2331  </ul>
2332  </li>
2333  </ul>
2334  </td>
2335  </tr>
2336  # window.estatementIndex++; #
2337  </script>
2338 
2339  <?php
2340  /**
2341  * @var addWindowTemplate
2342  * The template for the add/edit window popup.
2343  */
2344  ?>
2345  <script type="text/x-kendo-template" id="addWindowTemplate">
2346  <div class="container-fluid hcu-template" id="addWindowForm">
2347  <div id='addWindowErrorDiv'></div>
2348  <div id="documentRow">
2349  <div class="row hcuSpacer">
2350  <div class="col-xs-12"><div id="documentDDL"></div></div>
2351  </div>
2352  <div class="row hcuSpacer">
2353  <div class="col-xs-12"><div id="documentVendorDDL"></div></div>
2354  </div>
2355  </div>
2356  <div class="row hcuSpacer">
2357  <div class="col-xs-12">
2358  <textarea class="hcu-all-100 filecontents"></textarea>
2359  </div>
2360 
2361  </div>
2362  <div class="hcu-edit-buttons k-state-default">
2363  <a class="cancelBtn" href="\\#">Cancel</a>
2364  &nbsp;&nbsp;&nbsp;
2365  <a class="updateBtn k-button k-primary" href="\\#"><i class="fa fa-check"></i>Update</a>
2366  </div>
2367  </div>
2368  </script>
2369 
2370  <?php
2371  /**
2372  * @var readOnlyTemplate
2373  * The template for the view popup for the Utility tab.
2374  */
2375  ?>
2376  <script type="text/x-kendo-template" id="readOnlyWindowTemplate">
2377  <div class="container-fluid hcu-template">
2378  <div class="row hcuSpacer">
2379  <div class="col-xs-12">
2380  <textarea class="hcu-all-100 filecontents" readonly></textarea>
2381  </div>
2382 
2383  </div>
2384  <div class="hcu-edit-buttons k-state-default">
2385  <a class="okayBtn k-button k-primary" href="\\#"><i class="fa fa-check"></i>Okay</a>
2386  </div>
2387  </div>
2388  </script>
2389 
2390  <?php
2391  /**
2392  * @var pdfChoiceTemplate
2393  * This is a template for the window to select the form to show for pdfdefs.
2394  */
2395  ?>
2396  <script type="text/x-kendo-template" id="pdfChoiceTemplate">
2397  <div class="container-fluid hcu-template">
2398  <div class="row hcuSpacer">
2399  <div class="col-xs-12"><div id="pdfChoiceDDL"></div></div>
2400  </div>
2401  <div class="hcu-edit-buttons k-state-default">
2402  <a class="cancelBtn" href="\\#">Cancel</a>
2403  &nbsp;&nbsp;&nbsp;
2404  <a class="updateBtn k-button k-primary" href="\\#"><i class="fa fa-check"></i>Okay</a>
2405  </div>
2406  </div>
2407  </script>
2408 
2409  <?php
2410  /**
2411  * @var pdfViewTemplate
2412  * This is a template for the window that shows the created pdf.
2413  */
2414  ?>
2415  <script type="text/x-kendo-template" id="pdfViewTemplate">
2416  <div id="pdfEmbedParent" class="embed-responsive"></div>
2417  </script>
2418 
2419  <?php
2420  /**
2421  * @var manualTemplate
2422  * This is the HTML template for the manual operation window.
2423  */
2424  ?>
2425  <script type="text/x-kendo-template" id="manualTemplate">
2426  <div id="manualErrorDiv"></div>
2427  <div class="container-fluid hcu-template" id="manualForm">
2428  <div class="row hcuSpacer hcu-secondary">
2429  <div class="col-xs-12 vsgSecondary">
2430  This list does not update automatically. <br>Please refresh to see the latest information.
2431  </div>
2432  </div>
2433  <div class="row hcuSpacer">
2434  <div class="col-xs-12">
2435  <label>Last <?php echo GetMOLastXPeriods(); ?> Periods</label>
2436  </div>
2437  <div class="col-xs-12">
2438  <div id="lastPeriodGrid" class="hcu-all-100"></div>
2439  </div>
2440  </div>
2441  <div class="row hcuSpacer">
2442  <hr class="col-xs-12">
2443  </div>
2444  <div class="row hcuSpacer hcu-secondary">
2445  <div class="col-xs-12 vsgSecondary">
2446  Enter reporting period as Month, Quarter, etc. and reporting year.<br>
2447  Use checkbox to set 'CREDIT CARD' prefix when reloading / unloading Credit Card files.
2448  </div>
2449  </div>
2450  <div class="row hcuSpacer">
2451  <div class="col-xs-5">
2452  <label>Statement Period</label>
2453  </div>
2454  <div class="col-xs-7">
2455  <input type="text" id="reportingPeriodText" name='reportingPeriodText' class="hcu-all-100 k-input k-textbox">
2456  </div>
2457  </div>
2458  <div class="row hcuSpacer">
2459  <div class="col-xs-5">&nbsp;</div>
2460  <div class="col-xs-7 checkbox">
2461  <label><input type="checkbox" id="ccperiodCheckbox"> Credit Card Period</label>
2462  </div>
2463  </div>
2464 
2465  <div class="row hcuSpacer">
2466  <div class="col-xs-5">
2467  <label>Reload/Undo</label>
2468  </div>
2469  <div class="col-xs-7">
2470  <input id="manualActionDDL" name="manualAction" class="hcu-all-100"
2471  required data-required-msg="Action is required">
2472  </div>
2473  </div>
2474  <div class="row hcuSpacer statementFileDiv" style="display:none;">
2475  <div class="col-xs-5">
2476  <label>File</label>
2477  </div>
2478  <div class="col-xs-7">
2479  <div id="statementFileDDL" class="hcu-all-100"></div>
2480  </div>
2481  </div>
2482  <div class="row hcuSpacer statementFileDiv" style="display:none;">
2483  <div class="col-xs-5">
2484  <label>File Date</label>
2485  </div>
2486  <div class="col-xs-7" id="fileDateText">
2487  </div>
2488  </div>
2489  <div class="hcu-edit-buttons k-state-default">
2490  <a class="cancelBtn" href="\\#">Cancel</a>
2491  &nbsp;&nbsp;&nbsp;
2492  <a class="updateBtn k-button k-primary" href="\\#"><i class="fa fa-check"></i>Okay</a>
2493  </div>
2494  </div>
2495  </script>
2496 
2497  <?php
2498  /**
2499  * This is the HTML for inside the file dropdownlist. It shows the dates for the files.
2500  */
2501  ?>
2502  <script type="text/x-kendo-template" id="manualFileOptionTemplate">
2503  <span>#: filename # <br> <label>Date:</label> #: date #</span>
2504  </script>
2505 
2506  <?php
2507  /**
2508  * This is the template to confirm the manual operation.
2509  */
2510  ?>
2511  <script type="text/x-kendo-template" id="manualWindowConfirmationTemplate">
2512  <p>You are about to #: suboperation # eStatements for <b>#: period #</b>.</p>
2513  # if (suboperation == "reload") { #
2514  <p>This uses the file <b>#: file #</b>.</p>
2515  <p>File was last modified on <b>#: filedate #</b>.</p>
2516  # } #
2517  <p>Is this correct?</p>
2518  </script>
2519 
2520  <?php
2521  /**
2522  * This is the HTML that is outside of a template. It shows up directly on load on the page.
2523  */
2524  ?>
2525  <div id='hideSubmitWait' style='position:relative; left:-2000px;top:-2000px;'>
2526  <div id='homecuSubmitWait' class='k-block' >
2527  <div class='k-loading-image'></div>
2528  </div>
2529  </div>
2530  <div class="container-fluid" id="estmntForm">
2531  <div id="estmntErrorDiv"></div>
2532  <div class="row hcuSpacer">
2533  &nbsp;
2534  </div>
2535  <div class="row hcuSpacer">
2536  <div class="col-xs-12">
2537  <a href="#" id="backupBtn" class="k-button">Backup</a>
2538  <a href='#' class='k-button manualBtn'>Manual Operations</a>
2539  </div>
2540  </div>
2541  <div class="row hcuSpacer">
2542  <div class="col-xs-12">
2543  <div id="cuTabStrip">
2544  <ul>
2545  <li><?php echo GetEstatementText() . "s"; ?></li>
2546  <li>Credit Card</li>
2547  <li>Disclosure</li>
2548  <li>Utility</li>
2549  </ul>
2550  <div id="tabContentsEstatement">
2551  <div class="container-fluid">
2552  <div class="row hcuSpacer">
2553  <div id="estatementGrid" class="hcu-no-td-border"></div>
2554  </div>
2555  </div>
2556  </div>
2557  <div id="tabContentsCC">
2558  <div class="container-fluid">
2559  <div class="row hcuSpacer">
2560  <div id="ccGrid" class="hcu-no-td-border"></div>
2561  </div>
2562  </div>
2563  </div>
2564  <div id="tabContentsExtra">
2565  <div class="container-fluid">
2566  <div class="row hcuSpacer">
2567  <div id="extraGrid" class="hcu-no-td-border"></div>
2568  </div>
2569  </div>
2570  </div>
2571  <div id="tabContentsUT">
2572  <div class="container-fluid">
2573  <div class="row hcuSpacer">
2574  <div id="utilityGrid" class="hcu-no-td-border"></div>
2575  </div>
2576  </div>
2577  </div>
2578  </div>
2579  </div>
2580  </div>
2581  </div>
2582  <?php
2583  printMonitorPageBottom();
2584  }
2585 
2586  /**
2587  * function PrintErrorPage($msg)
2588  * Prints the page if there is an error.
2589  *
2590  * @param $msg -- the error message to display.
2591  */
2592  function PrintErrorPage($msg) {
2593  $errorTitle = GetEstatementText() . " Maintenance";
2594  printMonitorPageTop($errorTitle, GetHomecuKendoVersion("monitor"), GetCloudFrontDomainName(), GetHomecuBootstrapVersion(), GetFontawesomeVersion(), true);
2595  printMonitorPageMiddle($errorTitle, null, true); ?>
2596 
2597  <?php
2598  /**
2599  * The CSS part of the page.
2600  */
2601  ?>
2602  <style>
2603  .k-block.k-error-colored {
2604  margin: 0 auto;
2605  width: 300px;
2606  padding: 20px;
2607  }
2608  </style>
2609 
2610  <?php
2611  /**
2612  * The HTML part of the page.
2613  */
2614  ?>
2615  <div class='k-block k-error-colored container-fluid'>
2616  <div class="row hcuSpacer">
2617  <div class="col-xs-12">
2618  <?php echo $msg; ?>
2619  </div>
2620  </div>
2621  </div>
2622  <?php
2623  printMonitorPageBottom();
2624  }