Odyssey
hcuUserActivity.prg
1 <?php
2  /**
3  * @package hcuUserActivity.prg
4  *
5  * This script is for approving transhdr and cu_scheduledtxn. Each feature has its own row and detail template.
6  * User can only approve if they have the permission for "confirm" in the user rights for that feature.
7  */
8  require_once(dirname(__FILE__) . '/../library/permissions.i');
9  require_once(dirname(__FILE__) . '/../library/hcuACH.i');
10  require_once(dirname(__FILE__) . "/../../shared/library/commonJsFunctions.i");
11  require_once(dirname(__FILE__) . "/../library/hcuUserActivity.i");
12 
13  // ** SET SCRIPT LEVEL VARIABLES
14  $serviceShowInfo = true;
15  $serviceLoadMenu = true;
16  $serviceShowMenu = true;
17 
18  // ** INCLUDE MAIN GLOBAL SCRIPT -- Handles security / global variable values
19  require_once(dirname(__FILE__) . '/../library/hcuService.i');
20 
21  /*
22  * ** CHECK USER FEATURE PERMISSIONS **
23  * NOTE: DOES NOT RETURN ON FAILURE
24  */
25  PermCheckFeatureScreen($dbh, $HB_ENV, $MC, FEATURE_BASIC);
26 
27  try {
28 
29  $Cu = $HB_ENV["Cu"];
30  $Uid = $HB_ENV["Uid"];
31  $Cn = $HB_ENV["Cn"];
32 
33  // Step 1: get the confirm permissions for the features that we care about. If there are no confirm permissions and there are multiple users in the group, then redirect.
34  $permissions = privPermGetAllFeatureRights($HB_ENV["dbh"], $HB_ENV, array("Uid" => $HB_ENV["Uid"]));
35  if (!intval($permissions["status"]["code"]) == 0) {
36  throw new exception($permissions["status"]["error"], $permissions["status"]["code"]);
37  }
38  $permissions = $permissions["data"][$HB_ENV["Uid"]];
39 
40  // Prevent the page from being accessible when the user doesn't have approve access to at least one feature.
41  $approvalFeatureList = getApprovalList();
42  $approvalFound = false;
43  foreach($permissions as $featureCode => $featureRecord) {
44  if (!in_array($featureCode, $approvalFeatureList)) {
45  continue; // Feature is irrelevant to this script.
46  }
47  if ($featureRecord["confirm"]) { // Found approval permission so don't care about the rest of the permissions.
48  $approvalFound = true;
49  break;
50  }
51  }
52 
53  if (!$approvalFound) {
54 
55 
56  $sql = "select 'FOUND' from ${Cu}user a inner join ${Cu}user b on a.user_id = $Uid and a.group_id = b.group_id and a.user_id <> b.user_id";
57  $sth = db_query($sql, $HB_ENV["dbh"]);
58  if (!$sth) {
59  throw new exception("Check if multiple users found failed.", 5);
60  }
61  if (db_num_rows($sth) > 0) { // We care if there are multiple users. If it is one user, then user has the permissions to view the page.
62  header ("Location: hcuPermNotice.prg?" . $HB_ENV["cuquery"]);
63  exit;
64  }
65  }
66 
67  try {
68  $showPendingApprovalGrid = getValidUserIds($dbh, $Cu, $Cn, $sqls)["showPendingApprovalGrid"];
69  $featureDDL = getFeatures($dbh, $Cu, $sqls, $MC, $Uid);
70  $statusApprovalDDL = getApprovalStatuses($MC);
71  $statusActiveDDL = getActiveStatuses($MC);
72  $actionDDL = getActions($MC);
73  } catch(exception $e) {
74  $showPendingApprovalGrid = false;
75  $featureDDL = array();
76  $statusApprovalDDL = array();
77  $statusActiveDDL = array();
78  $actionDDL = array();
79  }
80 
81  // ** INCLUDE PRE CONTENT SCRIPT
82  require_once(dirname(__FILE__) . '/../includes/hcuPreContent.i');
83 
84  printPage($HB_ENV, $showPendingApprovalGrid, $featureDDL, $statusApprovalDDL, $statusActiveDDL, $actionDDL);
85  } catch (Exception $ex) {
86  // * Include the Error page and then end the content
87  // NOTE: this is for when the page is first loading
88  $serviceErrorMsg = HCU_JsonDecode($ex->getMessage());
89 
90  $serviceErrorCode = $ex->getCode(); // this chooses which error page to show
91 
92  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
93  }
94 
95  // ** INCLUDE POST CONTENT SCRIPT
96  require_once(dirname(__FILE__) . '/../includes/hcuPostContent.i');
97 
98 // End outline for page
99 // ******************************
100 
101 /**
102  * function printPage($HB_ENV)
103  * Prints out the javascript and HTML necessary for the page.
104  * @param $HB_ENV -- the whole shebang.
105  */
106 function printPage($HB_ENV, $showPendingApprovalGrid, $featureDDL, $statusApprovalDDL, $statusActiveDDL, $actionDDL) {
107  // Extract important values.
108  $dataURL = "hcuUserActivity.data?" . $HB_ENV["cuquery"];
109  $presURL = "hcuUserActivity.prg?" . $HB_ENV["cuquery"];
110  $logger = $HB_ENV["SYSENV"]["logger"];
111  $MC = $HB_ENV["MC"];
112  $Uid = $HB_ENV["Uid"];
113 
114  // Included scripts
115  ?>
116 
117  <?php // Page Javascript ?>
118  <script type="text/javascript">
119  var rowId = 0;
120  var actionData = [];
121 
122  <?php
123  /**
124  * function init()
125  * The whole shebang on the javascript side.
126  */
127  ?>
128  function init()
129  {
130  <?php IEFixStartsWith();
131  printExtendShowOverflown();
132  ?>
133  $.homecuValidator.setup({formValidate:'mainForm', formStatusField: 'formStatus'});
134 
135  defineGrids();
136  defineFilters();
137 
138  var toolTipProps = homecuTooltip.defaults;
139  toolTipProps.filter = ".showEllipsis:visible:overflown";
140  toolTipProps.content = function(e) {
141  return $(e.target).text().trim();
142  };
143 
144  $(".userActivityDiv").kendoTooltip(toolTipProps);
145  }
146 
147  <?php
148  /**
149  * function defineGrids()
150  * This sets up the three grids. The definition of them is mostly the same. The rowTemplate is varied a little bit.
151  */
152  ?>
153  function defineGrids() {
154  ShowWaitWindow();
155 
156  var modelDefinition = {
157  id: "kendoId",
158  fields: {
159  kendoId: {type: "number"}, <?php // Need to uniquely identify record in the kendo grid. ?>
160  type: {type: "string"}, <?php // Used to get the right template ?>
161  data_id: {type: "number"}, <?php // Refers to the number in the database for the id. ?>
162 
163  displayDateFull: {type: "string"},
164  displayDateMonth: {type: "string"},
165  displayDateYear: {type: "string"},
166  displayDateDay: {type: "string"},
167  area4Text: {type: "string"},
168 
169  area1Label: {type: "string"},
170  area1Text: {type: "string"},
171  area2Label: {type: "string"},
172  area2Text: {type: "string"},
173  area3: {type: "string"},
174  interval: {type: "string"},
175  area4Label: {type: "string"},
176 
177  feature_code: {type: "string"}, <?php // Needed for client-side filtering on the prior activity grid. ?>
178  feature: {type: "string"},
179  approved_status: {type: "number"},
180  approvedDescription: {type: "string"},
181  details: {type: "odata"},
182  canApprove: {type: "string"},
183  infoClass: {type: "string"},
184  type: {type: "string"}
185  }
186  };
187 
188  var gridDefinition = {
189  dataSource: {
190  transport: {
191  read: null
192  },
193  schema: null
194  },
195  autoBind: false,
196  columns: [{width: 5}, {hidden: true}, {title: "date", width: 50}, {title: "other"}],
197  <?php // Dictionary not needed. Columns titles are not displayed. ?>
198  dataBound: function() {
199 
200  <?php // hide vertical date column on mobile size ?>
201  $(this.wrapper).find("colgroup").each(function() {
202  $(this).find("col:eq(1)").addClass("hidden-xs");
203  });
204  },
205  noRecords: {
206  template: '<tr><td><span class="hcu-secondary-text"><?php echo $MC->msg("No Records Found", HCU_DISPLAY_AS_JS); ?></span></td></tr>'
207  },
208  rowTemplate: $("#rowTemplate").html()
209  };
210 
211  var headerTemplateTemplate = kendo.template($("#headerTemplateTemplate").html());
212 
213  window.rowId = 0;
214 
215  var doneness = [false, false, false], populated = false, showPendingApprovalGrid = <?php echo $showPendingApprovalGrid ? "true" : "false" ?>,
216  ddls = <?php echo HCU_JsonEncode(array("featureDDL" => $featureDDL, "statusApprovalDDL" => $statusApprovalDDL, "statusActiveDDL" => $statusActiveDDL)); ?>, isFilter=false;
217 
218  var pendingApprovalGrid = null, scheduledTransactionsGrid = null, priorActivityGrid = null;
219 
220  var gridId = "";
221  <?php if ($showPendingApprovalGrid) { ?>
222  gridId = "pendingApproval";
223  gridDefinition.toolbar = [{template: headerTemplateTemplate({grid: gridId})}];
224  gridDefinition.dataSource.transport.read = {url: "<?php echo $dataURL; ?>&grid=" + gridId, dataType: "json", type: "POST"};
225  gridDefinition.dataSource.schema = {model: modelDefinition, parse: function (data) {
226  var pendingApprovalGrid = $("#pendingApprovalGrid").data("kendoGrid");
227  var data = data.results; <?php // Results are always returned. ?>
228  if (data.homecuErrors.length > 0) {
229  $.homecuValidator.displayMessage(data.homecuErrors, $.homecuValidator.settings.statusError);
230  CloseWaitWindow();
231 
232  return pendingApprovalGrid.dataSource.data();
233  } else {
234  if (data.homecuInfo.length > 0) {
235  $.homecuValidator.settings.formInfoTitle = "";
236  $.homecuValidator.displayMessage(data.homecuInfo);
237  }
238  }
239 
240  switch(data.mode) {
241  case "local":
242  return window.homecuData;
243  break;
244  case "setStatus":
245 
246  <?php // refresh the priorActivity to show the new record. ?>
247  window.homecuData = data.homecuData;
248  $("#priorActivityGrid").data("kendoGrid").dataSource.read({operation: "local"});
249  CloseWaitWindow();
250  var gridData = pendingApprovalGrid.dataSource.data();
251 
252  if (data.transferData) {
253  openTransferConfirmWindow(data.transferData);
254  }
255 
256  // notify the apps that a pending status was changed (appInfo doesn't matter)
257  var appInfo = JSON.stringify( { status: true } );
258 
259  <?php if ( $HB_ENV["platform"] == "ADA" ) : ?>
260  AndroidController.notifyCommand("CHANGED_PENDING_ACTIVITY", appInfo);
261  <?php elseif ( $HB_ENV["platform"] == "APP" ) : ?>
262  var postObject = {
263  body: {
264  cmd: "CHANGED_PENDING_ACTIVITY",
265  params: appInfo
266  }
267  };
268  window.webkit.messageHandlers.interOp.postMessage(postObject);
269  <?php endif ?>
270 
271  return $.grep(gridData, function(n,i) { return n.kendoId != data.kendoId; });
272  break;
273  case "read":
274  doneness[0] = true;
275  rowId = 0;
276 
277  if (!populated && doneness.indexOf(false) == -1)
278  {
279  populated = true;
280  isFilter = true;
281  populateFilters(ddls, showPendingApprovalGrid);
282  CloseWaitWindow();
283  }
284 
285  return data.homecuData;
286  break;
287  }
288  }};
289  pendingApprovalGrid = $("#pendingApprovalGrid").kendoGrid(gridDefinition).data("kendoGrid");
290  <?php } ?>
291 
292  gridId = "scheduledTransactions";
293  gridDefinition.toolbar = [{template: headerTemplateTemplate({grid: gridId})}];
294  gridDefinition.dataSource.transport.read = {url: "<?php echo $dataURL; ?>&grid="+gridId, dataType: "json", type: "POST"};
295  gridDefinition.dataSource.schema = {model: modelDefinition, parse: function (data) {
296  var gridId = "scheduledTransactions";
297  var data = data.results; <?php // Results are always returned. ?>
298  var scheduledTransactionsGrid = $("#scheduledTransactionsGrid").data("kendoGrid");
299  if (data.homecuErrors.length > 0) {
300  $.homecuValidator.displayMessage(data.homecuErrors, $.homecuValidator.settings.statusError);
301  CloseWaitWindow();
302 
303  return scheduledTransactionsGrid.dataSource.data();
304  } else {
305  if (data.homecuInfo.length > 0) {
306  $.homecuValidator.settings.formInfoTitle = "";
307  $.homecuValidator.displayMessage(data.homecuInfo);
308  }
309  CloseWaitWindow();
310  }
311 
312  switch(data.mode)
313  {
314  case "local":
315  return window.homecuData;
316  break;
317  case "skipTransactions":
318  window.homecuData = data.homecuData;
319  $("#scheduledTransactionsGrid").data("kendoGrid").dataSource.read({operation: "local"});
320  CloseWaitWindow();
321  var gridData = scheduledTransactionsGrid.dataSource.data();
322  return $.grep(gridData, function(n,i) { return n.data_id != data.dataId; });
323  break;
324  case "setStatus":
325 
326  <?php // refresh the priorActivity to show the new record. ?>
327  window.homecuData = data.homecuData;
328  $(data.grid == "scheduledTransactions" ? "#scheduledTransactionsGrid" : "#priorActivityGrid").data("kendoGrid").dataSource.read({operation: "local"});
329  CloseWaitWindow();
330  var gridData = scheduledTransactionsGrid.dataSource.data();
331 
332  if (data.transferData) {
333  openTransferConfirmWindow(data.transferData);
334  }
335  return $.grep(gridData, function(n,i) { return n.data_id != data.dataId; });
336  break;
337  case "filter":
338  CloseWaitWindow();
339  break;
340  case "clearFilter":
341  $("#filterTypeDDL" + gridId).data("kendoDropDownList").value("");
342  $("#statusActiveDDL" + gridId).data("kendoDropDownList").value("");
343  $("#filterFrom" + gridId).data("kendoDatePicker").value(null);
344  $("#filterTo" + gridId).data("kendoDatePicker").value(null);
345  CloseWaitWindow();
346  break;
347  case "read":
348  doneness[1] = true;
349  rowId = 0;
350 
351  if (!populated && doneness.indexOf(false) == -1) {
352  populated = true;
353  isFilter = true;
354  populateFilters(ddls, showPendingApprovalGrid);
355  CloseWaitWindow();
356  }
357  break;
358  }
359 
360  return data.homecuData;
361  }};
362  scheduledTransactionsGrid = $("#scheduledTransactionsGrid").kendoGrid(gridDefinition).data("kendoGrid");
363 
364  gridId= "priorActivity";
365  gridDefinition.toolbar = [{template: headerTemplateTemplate({grid: gridId})}];
366  <?php // If you go up a level, it forces it to create a new array. Just setting the URL is going to do a shallow copy so there are three of the same data call. ?>
367  gridDefinition.dataSource.transport.read = {url: "<?php echo $dataURL; ?>&grid=" + gridId, dataType: "json", type: "POST"};
368  delete gridDefinition.dataSource.transport.destroy;
369  gridDefinition.dataSource.schema = {model: modelDefinition, parse: function (data) {
370  var gridId= "priorActivity";
371  var priorActivityGrid = $("#priorActivityGrid").data("kendoGrid");
372  var data = data.results; <?php // Results are always returned. ?>
373  if (data.homecuErrors.length > 0) {
374  $.homecuValidator.displayMessage(data.homecuErrors, $.homecuValidator.settings.statusError);
375  CloseWaitWindow();
376 
377  return priorActivityGrid.dataSource.data();
378  } else {
379  if (data.homecuInfo.length > 0) {
380  $.homecuValidator.settings.formInfoTitle = "";
381  $.homecuValidator.displayMessage(data.homecuInfo);
382  }
383  }
384 
385  switch(data.mode) {
386  case "local":
387  return window.homecuData;
388  break;
389  case "filter":
390  CloseWaitWindow();
391  break;
392  case "clearFilter":
393  $("#filterTypeDDL"+gridId).data("kendoDropDownList").value("");
394  $("#statusApprovalDDL"+gridId).data("kendoDropDownList").value("");
395  $("#filterFrom"+gridId).data("kendoDatePicker").value(null);
396  $("#filterTo"+gridId).data("kendoDatePicker").value(null);
397  CloseWaitWindow();
398  break;
399  case "read":
400  doneness[2] = true;
401  rowId = 0;
402 
403  if (!populated && doneness.indexOf(false) == -1) {
404  populated = true;
405  isFilter = true;
406  populateFilters(ddls, showPendingApprovalGrid);
407  CloseWaitWindow();
408  }
409  break;
410  }
411 
412  return data.homecuData;
413  }};
414  priorActivityGrid = $("#priorActivityGrid").kendoGrid(gridDefinition).data("kendoGrid");
415 
416  <?php if ($showPendingApprovalGrid) { ?>
417  pendingApprovalGrid.dataSource.read({operation: "read"});
418  <?php } else { ?>
419  doneness[0] = true;
420  <?php } ?>
421  scheduledTransactionsGrid.dataSource.read({operation: "read"});
422  priorActivityGrid.dataSource.read({operation: "read"});
423 
424  defineActions();
425  }
426 
427  <?php
428  /**
429  * function defineFilters()
430  * This sets up the controls needed for the filters.
431  */
432  ?>
433  function defineFilters() {
434  <?php if ($showPendingApprovalGrid) { ?>
435  var featureDDL = $("#featureDDL").kendoDropDownList({
436  dataSource: {
437  data: []
438  },
439  dataTextField: "text",
440  dataValueField: "value",
441  select: function(e) {
442  var value = e.dataItem.value;
443  var filter = value == "" ? [] : {field: "feature_code", operator: "eq", value: value};
444  var grid = $("#pendingApprovalGrid").data("kendoGrid");
445  if (grid.dataSource.data().length > 0) { <?php // There seems to be a slight kill everything bug that happens when you filter on this empty grid for whatever reason. ?>
446  grid.dataSource.filter(filter);
447  }
448  },
449  open: function(e) {
450  $(this.wrapper).find(".fa.fa-caret-down").removeClass("fa-caret-down").addClass("fa-caret-up");
451  },
452  close: function(e) {
453  $(this.wrapper).find(".fa.fa-caret-up").removeClass("fa-caret-up").addClass("fa-caret-down");
454  },
455  valueTemplate: "<a href='\\#' class='hcu-align-right'>#= text # &nbsp;<i class='fa fa-caret-down'></i></a>",
456  template: "#= text #"
457  }).data("kendoDropDownList");
458 
459  $(featureDDL.wrapper).addClass("hcu-dropdownlist");
460  <?php } ?>
461 
462  <?php // From is limited to be before the To. ?>
463  $("[id^='filterTo'], [id^='filterFrom']").each(function() {
464  $(this).kendoDatePicker({
465  change: function() {
466  var value = this.value();
467  var isFrom = $(this.element).hasClass("filterFrom");
468  var grid = $(this.wrapper).closest(".activityGridDiv").data("grid");
469  var toDatePicker = $("#filterTo"+grid).data("kendoDatePicker");
470  if (value == null) {
471  this.value(null); <?php // Clear invalid input. ?>
472  if (isFrom) {
473  toDatePicker.min(null);
474  }
475  } else {
476  if (isFrom) {
477  toDatePicker.min(this.value());
478  if (toDatePicker.value() < this.value()) { <?php // Clear To if From is changed to a date after the To. ?>
479  toDatePicker.value(null);
480  }
481  }
482 
483  }
484  }
485  }).data("kendoDatePicker");
486 
487  if ($(this).attr("id").startsWith("filterFrom")) {
488  $(this).addClass("filterFrom");
489  }
490  });
491 
492  $("[id^='filterTo'].k-input, [id^='filterFrom'].k-input").blur(function() {
493  $(this).data("kendoDatePicker").trigger("change");
494  return false;
495  });
496 
497  $("[id^='filterTypeDDL'], [id^='statusApprovalDDL'], [id^='statusActiveDDL']").each(function() {
498  var ddl = $(this).kendoDropDownList({
499  dataSource: {
500  data: []
501  },
502  dataTextField: "text",
503  dataValueField: "value"
504  }).data("kendoDropDownList");
505  });
506 
507  $(".showFilterBtn").click(function() {
508  if ($(this).data("isshow")) {
509  $(this).closest(".activityGridDiv").find(".filterDiv").show();
510  $(this).html('<?php echo $MC->msg("Hide Filter", HCU_DISPLAY_AS_HTML); ?> <i class="fa fa-caret-up"></i>');
511  $(this).data("isshow", false);
512  } else {
513  $(this).closest(".activityGridDiv").find(".filterDiv").hide();
514  $(this).html('<?php echo $MC->msg("Show Filter", HCU_DISPLAY_AS_HTML); ?> <i class="fa fa-caret-down"></i>');
515  $(this).data("isshow", true);
516  }
517  return false;
518  });
519 
520  $(".filterApplyBtn, .filterClearBtn").click(function() {
521  var grid = $(this).closest(".activityGridDiv").data("grid");
522  var isClear = $(this).hasClass("filterClearBtn");
523  var from = $("#filterFrom"+grid).data("kendoDatePicker").value();
524  var to = $("#filterTo"+grid).data("kendoDatePicker").value();
525  from = from == null ? "" : kendo.toString(from, "yyyy-MM-dd");
526  to = to == null ? "" : kendo.toString(to, "yyyy-MM-dd");
527 
528  var parameters = isClear ? {operation: "clearFilter"} : {operation: "filter", filterFeature: $("#filterTypeDDL"+grid).data("kendoDropDownList").value(), filterFrom: from, filterTo: to };
529 
530  if (grid == "scheduledTransactions") {
531  parameters.filterStatus = $("#statusActiveDDL" + grid).data("kendoDropDownList").value();
532  } else {
533  parameters.filterStatus = $("#statusApprovalDDL" + grid).data("kendoDropDownList").value();
534  }
535 
536  var gridId = parameters.grid == "scheduledTransactions" ? "#scheduledTransactionsGrid" : "#priorActivityGrid";
537 
538  ShowWaitWindow();
539  $("#" + grid + "Grid").data("kendoGrid").dataSource.read(parameters);
540  return false;
541  });
542  }
543 
544  <?php
545  /**
546  * function populateFilters(thyDDLs, showPendingApprovalGrid)
547  * This function happens after the data is returned for the first read call.
548  *
549  * @param [] thyDDLs -- the list of the features and status filters.
550  * @param boolean showPendingApprovalGrid -- if the pending approval grid isn't available, then don't try to populate the filter inside that DIV.
551  */
552  ?>
553  function populateFilters(thyDDLs, showPendingApprovalGrid) {
554  if (showPendingApprovalGrid) {
555  $("#featureDDL").data("kendoDropDownList").dataSource.data(thyDDLs.featureDDL);
556  }
557  $("[id^='filterTypeDDL'][data-role='dropdownlist']").each(function() {
558  $(this).data("kendoDropDownList").dataSource.data(thyDDLs.featureDDL);
559  });
560  $("[id^='statusActiveDDL'][data-role='dropdownlist']").data("kendoDropDownList").dataSource.data(thyDDLs.statusActiveDDL);
561  $("[id^='statusApprovalDDL'][data-role='dropdownlist']").data("kendoDropDownList").dataSource.data(thyDDLs.statusApprovalDDL);
562  }
563 
564  <?php
565  /**
566  * function defineActions()
567  * This defines the links for the activity options.
568  */
569  ?>
570  function defineActions() {
571  $(".userActivityDiv").on("click", ".activityLink", function() {
572  var tr = $(this).closest("tr");
573  var grid = $(tr).closest(".userActivityGrid").data("kendoGrid");
574  var gridId = $(grid.element).attr("id");
575  var dataItem = grid.dataItem(tr);
576  switch($(this).data("action")) {
577  case "viewDetails": viewDetails(dataItem, gridId); break;
578  case "approve": changeStatus(dataItem, gridId, 10); break;
579  case "decline": changeStatus(dataItem, gridId, 90); break;
580  case "cancel": changeStatus(dataItem, gridId, 99); break;
581  case "skip": changeStatus(dataItem, gridId, 0); break;
582  }
583 
584  return false;
585  });
586  }
587 
588  <?php
589  /**
590  * function viewDetails(gridDataItem, gridId)
591  * This views the details of a particular record and whatnot.
592  *
593  * @param {} gridDataItem -- the dataItem of the grid.
594  * @param string gridId -- the id of the grid.
595  */
596  ?>
597  function viewDetails(gridDataItem, gridId) {
598  var detailDialog = $("#detailDialog").data("kendoDialog");
599  if (detailDialog == null) {
600  detailDialog = $("<div id='detailDialog'></div>").appendTo("body").kendoDialog({
601  title: '<?php echo $MC->msg("View Details", HCU_DISPLAY_AS_HTML); ?>',
602  visible: false,
603  open: function() {
604  if (window.activeWindows != null) {
605  window.activeWindows.push(this);
606  }
607  var maxHeight1 = 600;
608  var maxHeight2 = $(window).height() - 150;
609  var maxHeight = maxHeight2 >= maxHeight1 ? maxHeight1 : maxHeight2;
610  $("#detailDialog").css({maxHeight: maxHeight});
611  },
612  close: function() {
613  if (window.activeWindows != null) {
614  window.activeWindows.pop();
615  }
616  },
617  width: 400,
618  modal: true,
619  actions: [
620  {text: '<?php echo $MC->msg("Okay", HCU_DISPLAY_AS_HTML); ?>', primary: true}
621  ]
622  }).data("kendoDialog");
623  }
624  var template = kendo.template($("#detailTemplate").html());
625  gridDataItem.grid = gridId;
626  detailDialog.content(template(gridDataItem)).open();
627  }
628 
629  <?php
630  /**
631  * function changeStatus(gridDataItem, gridId, status)
632  * This changes the status of a record.
633  *
634  * @param {} gridDataItem -- the dataItem of the grid.
635  * @param string gridId -- the id of the grid.
636  * @param number status -- 0,10,90,99
637  */
638  ?>
639  function changeStatus(gridDataItem, gridId, status) {
640  var confirmWindow = $("#confirmWindow").data("kendoDialog");
641  if (confirmWindow == null) {
642  confirmWindow = $("<div id='confirmWindow'></div>").appendTo("body").kendoDialog({
643  title: '<?php echo $MC->msg("Confirmation"); ?>',
644  visible: false,
645  open: function() {
646  if (window.activeWindows != null) {
647  window.activeWindows.push(this);
648  }
649  var maxHeight1 = 600;
650  var maxHeight2 = $(window).height() - 150;
651  var maxHeight = maxHeight2 >= maxHeight1 ? maxHeight1 : maxHeight2;
652  $("#confirmWindow").css({maxHeight: maxHeight});
653  },
654  close: function() {
655  if (window.activeWindows != null) {
656  window.activeWindows.pop();
657  }
658  },
659  width: 400,
660  modal: true,
661  actions: [
662  {text: '<?php echo $MC->msg("Cancel", HCU_DISPLAY_AS_HTML); ?>'},
663  {text: '<?php echo $MC->msg("Okay", HCU_DISPLAY_AS_HTML); ?>', primary: true, action: function() {
664  var status = $("#confirmWindow").data("status");
665  var gridDataItem = $("#confirmWindow").data("gridDataItem");
666  var gridId = $("#confirmWindow").data("gridId");
667  <?php // Need to get the filter options set for the prior activity so that that grid can be refreshed once a record moves to it through status change. ?>
668  var grid = gridDataItem.type == "scheduled" && (status == 10 || status == 99) ? "scheduledTransactions" : "priorActivity";
669  var isClear = $(this).hasClass("filterClearBtn");
670  var from = $("#filterFrom" + grid).data("kendoDatePicker").value();
671  var to = $("#filterTo" + grid).data("kendoDatePicker").value();
672  from = from == null ? "" : kendo.toString(from, "yyyy-MM-dd");
673  to = to == null ? "" : kendo.toString(to, "yyyy-MM-dd");
674  var dataId = gridDataItem.data_id;
675 
676  var operation = status == 0 ? "skipTransaction" : "setStatus";
677 
678  var parameters = {operation: operation, status: status, type: gridDataItem.type, dataId: dataId, filterFeature: $("#filterTypeDDL" + grid).data("kendoDropDownList").value(), filterFrom: from, filterTo: to, grid: grid, kendoId: gridDataItem.kendoId};
679 
680  if (grid == "scheduledTransactions") {
681  parameters.filterStatus = $("#statusActiveDDL" + grid).data("kendoDropDownList").value();
682  } else {
683  parameters.filterStatus = $("#statusApprovalDDL" + grid).data("kendoDropDownList").value();
684  }
685 
686  ShowWaitWindow();
687  $("#"+gridId).data("kendoGrid").dataSource.read(parameters);
688  }}
689  ]
690  }).data("kendoDialog");
691  }
692 
693  $("#confirmWindow").data({status: status, gridDataItem: gridDataItem, gridId: gridId});
694  var skip = '<?php echo $MC->msg("Skip Transaction Msg"); ?><br><br>' +
695  '<?php echo $MC->msg("Skip Transaction Confirm"); ?>';
696  var cancel = '<?php echo $MC->msg("Confirm Cancel"); ?>';
697  var decline = '<?php echo $MC->msg("Confirm Decline"); ?>';
698  var approve = '<?php echo $MC->msg("Confirm Approve"); ?>';
699 
700  if (status == 0) { confirmWindow.content(skip); }
701  else if (status == 10) { confirmWindow.content(approve); }
702  else if (status == 99) { confirmWindow.content(cancel); }
703  else { confirmWindow.content(decline); }
704 
705  confirmWindow.open();
706  }
707 
708  <?php
709  /**
710  * function processResults(data, doFunction)
711  * This shows an error message if one exists. Otherwise it shows a status message if one exists and does some stuff maybe of the homecuData.
712  *
713  * @param [] data -- the data to process from the datacall.
714  * @param function doFunction -- the function to do when there are no errors.
715  */
716  ?>
717  function processResults(data, doFunction) {
718  var data = data.results; <?php // Results are always returned. ?>
719  if (data.homecuErrors.length > 0) {
720  $.homecuValidator.displayMessage(data.homecuErrors, $.homecuValidator.settings.statusError);
721  CloseWaitWindow();
722  } else {
723  if (data.homecuInfo.length > 0) {
724  $.homecuValidator.settings.formInfoTitle = "";
725  $.homecuValidator.displayMessage(data.homecuInfo);
726  }
727 
728  if (typeof doFunction == "function") {
729  (doFunction)(data.homecuData);
730  }
731  }
732  }
733 
734  function openTransferConfirmWindow(transferData) {
735  var transferConfirmWindow = $("#transferConfirmWindow").data("kendoDialog");
736  if (transferConfirmWindow == null) {
737  transferConfirmWindow = $("<div id='transferConfirmWindow'></div>").appendTo("body").kendoDialog({
738  width: "85%",
739  maxWidth: "768px",
740  minWidth: "300px",
741  title: '<?php echo $MC->msg('Transfer Confirmation', HCU_DISPLAY_AS_JS); ?>',
742  modal: true,
743  visible: false,
744  resizable: false,
745  actions: [ {text: "Close", primary: true} ],
746  open: function() {
747  if (window.activeWindows != null) {
748  window.activeWindows.push(this);
749  }
750  },
751  close: function() {
752  if (window.activeWindows != null) {
753  window.activeWindows.pop();
754  }
755  }
756  }).data("kendoDialog");
757  }
758 
759  var template = kendo.template($("#confirmationTemplate").html());
760  transferConfirmWindow.content(template(transferData)).open();
761  }
762 
763  var activeWindows = [];
764  $(document).ready(function() { init();
765  $("body").on("click", ".k-overlay", function() { if (activeWindows.length > 0) activeWindows[activeWindows.length - 1].close(); return false; });
766  });
767  </script>
768 
769  <?php
770  // ****************************************
771  // Page Kendo Templates ?>
772 
773  <script id="confirmationTemplate" type="text/x-kendo-template">
774  <div id="responseDiv">
775  <div class="local-transfer-msg">
776  <?php echo $MC->msg('Transfer posted', HCU_DISPLAY_AS_JS); ?>
777  </div>
778 
779  # for (i = 0; i < data.length; i++ ) { #
780  <div class="col-xs-6 text-right">
781  <span class="response-label">#= data[i]['label'] #:</span>
782  </div>
783  <div class="col-xs-6">
784  <span class="response-field">#= data[i]['caption'] #</span>
785  </div>
786  # } #
787  <div>&emsp;</div>
788  <div>&emsp;</div>
789  </div>
790  </script>
791 
792  <?php
793  /**
794  * <script type="text/x-kendo-template" id="detailTemplate">
795  * This displays the details of the transaction. It expects an array in the detail column of the grid row.
796  * Each row in the detail array has a "type" that determines the template.
797  */
798  ?>
799  <script type="text/x-kendo-template" id="detailTemplate">
800  # var addressOffset = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; var groupAltI = 0;#
801  <div class="container hcu-all-100">
802  # for (var i = 0; i != details.length; i++) { var item = details[i]; #
803  # if (item.type == "normalRow") { #
804  <div class="row"><div class="col-xs-12 showEllipsis"><label>#= item.label #</label> # if (item.text == "") { # &nbsp; # } else { # #= item.text # # } #</div></div>
805  # } else if (item.type == "header") { #
806  <div class="row"><div class="col-xs-12 h4 showEllipsis"># if (item.text == "") { # &nbsp; # } else { # #: item.text # # } #</div></div>
807  # } else if (item.type == "address") { #
808  <div class="row"><div class="col-xs-12 showEllipsis"><label>#: item.label #</label>&nbsp; # if (item.addresses.length > 0) { # #: item.addresses[0] # # } #</div></div>
809  # for (var j = 1, len = item.addresses.length; j != len; j++) { var addr = item.addresses[j]; if (addr == "") continue; #
810  <div class="row"><div class="col-xs-12 showEllipsis">#= addressOffset # #: addr #</div></div>
811  # } #
812  # } else if (item.type == "altGroupStart") { #
813  <div class="row # if (groupAltI++ % 2 == 1) { # hcu-alt # } #">
814  # } else if (item.type == "altGroupEnd" || item.type == "wellEnd") { #
815  </div>
816  # } else if (item.type == "wellStart") { #
817  <div class="well well-sm row">
818  # } #
819  # } #
820  </div>
821  </script>
822 
823  <?php
824  /**
825  * <script type="text/x-kendo-template" id="rowTemplate">
826  * This displays the row template of the transaction.
827  */
828  ?>
829  <script type="text/x-kendo-template" id="rowTemplate">
830  <tr data-uid="#=uid#">
831  <td class="hcu-activity-bg-#:infoClass#">&nbsp;</td><td style="display:none;">#: canApprove #</td>
832 
833  <td class="hidden-xs"># if (displayDateFull != null) { # <center>#: displayDateMonth #<br><b>#: displayDateDay #</b><br><span class="hcu-smallerYear hcu-secondary-text">
834  #: displayDateYear #</span># } else { # &nbsp; # } #</td>
835 
836  <td>
837  <div class="container hcu-all-100 hcu-bs-no-padding">
838  <div class="row hidden-sm hidden-md hidden-lg hcuSpacer titleRow">
839  <div class="col-xs-6"><span class="floatLeft">#: displayDateFull #</span></div>
840  <div class="col-xs-6"><span class="floatRight">#: feature #</span></div>
841  </div>
842  <div class="row">
843  <div class="col-xs-12 col-sm-4">
844  <div class="col-xs-12 area1 showEllipsis"># if (area1Label != "") { #<label>#= area1Label #</label> # } # #= area1Text # &nbsp;</div>
845  <div class="col-xs-12 area2 showEllipsis"># if (area2Label != "") { #<label>#= area2Label #</label> # } # #= area2Text # &nbsp;</div>
846  </div>
847  <div class="col-xs-12 col-sm-4">
848  <div class="col-xs-12 area3 showEllipsis">#: area3 # &nbsp;</div>
849  <div class="col-xs-12 area4 showEllipsis"># if (area4Label != "") { #<label>#= area4Label #</label> # } # #: area4Text # &nbsp;</div>
850  </div>
851  <div class="col-xs-12 col-sm-4">
852  <div class="hidden-xs col-sm-6 featureDiv showEllipsis">#: feature #</div>
853  <div class="col-xs-12 col-sm-6"><a href="\\#" class="activityLink" data-action="viewDetails">
854  <?php echo $MC->msg("View Details", HCU_DISPLAY_AS_JS); ?></a></div>
855  <div class="col-xs-12 col-sm-6 actionDiv">
856 
857  # if ((approved_status == 0) || (approved_status == 10 && type == 'scheduled' && active_status == 'A' && infoClass != 'completed')) { #
858  <div class="dropdown">
859  <a href="\\#" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><?php echo $MC->msg("Action", HCU_DISPLAY_AS_JS); ?>
860  <span class="caret"></span>
861  <ul class="dropdown-menu" aria-labelledby="actionMenu">
862 
863  # if (approved_status == 0) { #
864  # if (canApprove) { #
865  <li><a href="\\#" class="activityLink" data-action="approve"><?php echo $MC->msg("Approve", HCU_DISPLAY_AS_JS); ?></a></li>
866  <li><a href="\\#" class="activityLink" data-action="decline"><?php echo $MC->msg("Decline", HCU_DISPLAY_AS_JS); ?></a></li>
867  # } else { #
868  <li><a href="\\#" class="activityLink" data-action="cancel"><?php echo $MC->msg("Cancel", HCU_DISPLAY_AS_JS); ?></a></li>
869  # } #
870  # } else if (type == 'scheduled' && active_status == 'A' && interval == 'One Time') { #
871  <li><a href="\\#" class="activityLink" data-action="cancel"><?php echo $MC->msg("Cancel", HCU_DISPLAY_AS_JS); ?></a></li>
872  # } else if (type == 'scheduled' && active_status == 'A' && !canApprove) { #
873  <li><a href="\\#" class="activityLink" data-action="skip"><?php echo $MC->msg("Skip", HCU_DISPLAY_AS_JS); ?></a></li>
874  # } #
875 
876  </ul>
877  </div>
878  # } #
879  </div>
880 
881  # if (approvedDescription != "") { # <?php // On pending approval, set this to empty string. ?>
882  <div class="hidden-xs col-sm-6 showEllipsis">
883  <span class="hcu-activity-fg-#:infoClass#"><span class="control-label"> #: approvedDescription # </span></span>
884  </div>
885  # } #
886 
887  </div>
888  </div>
889  </div>
890  </td>
891 
892  </tr>
893 
894  </script>
895 
896  <?php // ******************
897  // END OF ROW TEMPLATE TEMPLATE ?>
898 
899  <?php
900  /**
901  * id="headerTemplateTemplate"
902  * This is the template for the top of the grid. It replaces the filter template because now that is defined here.
903  */
904  ?>
905  <script type="text/x-kendo-template" id="headerTemplateTemplate">
906  <div class="container hcu-all-100">
907  # if (grid == "pendingApproval") { #
908  <div class="row hcuSpacer">
909  <div class="col-xs-12">
910  <div class="floatLeft h4"><?php echo $MC->msg("Pending Approval", HCU_DISPLAY_AS_JS); ?></div>
911  <div class="floatRight"><div id="featureDDL" class="hcu-all-100 showEllipsis"></div></div>
912  </div>
913  </div>
914  # } else { #
915  <div class="row hcuSpacer">
916  <div class="col-xs-6"><div class="h4">
917  # if (grid == "scheduledTransactions") { # <?php echo $MC->msg("Scheduled Transactions", HCU_DISPLAY_AS_JS); ?>
918  # } else { # <?php echo $MC->msg("Prior Activity", HCU_DISPLAY_AS_JS); ?> # } #</div></div>
919  <div class="col-xs-6"><div class="floatRight"><a class="showFilterBtn" href="\\\\#" data-isshow="true">
920  <?php echo $MC->msg("Show Filter", HCU_DISPLAY_AS_JS); ?>
921  <i class='fa fa-caret-down'></i></a></div></div>
922  </div>
923  <div class="row hcuSpacer filterDiv" style="display:none;">
924  <div class="container hcu-all-100 hcu-nopadding">
925  <div class="mainDiv"><div>
926  <div class="row hcuSpacer">
927  <div class="col-xs-12 col-md-8 col-lg-6 hcuSpacer">
928  <div class="col-xs-12 col-sm-6 col-lg-6"><label><?php echo $MC->msg("Feature Transfer Type", HCU_DISPLAY_AS_JS); ?></label></div>
929  <div class="col-xs-12 col-sm-6 col-lg-6"><div id="filterTypeDDL#:grid#" class="hcu-all-100"></div></div>
930  </div>
931  <div class="col-xs-12 col-md-4 col-lg-4 hcuSpacer">
932  <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4"><label><?php echo $MC->msg("Status", HCU_DISPLAY_AS_JS); ?></label></div>
933  # if (grid == "scheduledTransactions") { #
934  <div class="col-xs-12 col-sm-6 col-md-8 col-lg-8"><div id="statusActiveDDL#:grid#" class="hcu-all-100"></div></div>
935  # } else { #
936  <div class="col-xs-12 col-sm-6 col-md-8 col-lg-8"><div id="statusApprovalDDL#:grid#" class="hcu-all-100"></div></div>
937  # } #
938  </div>
939  </div>
940  <div class="row hcuSpacer">
941  <div class="col-xs-12 col-md-8 col-lg-6 hcuSpacer">
942  <div class="col-xs-12 col-sm-6 col-lg-6"><label><?php echo $MC->msg("From", HCU_DISPLAY_AS_JS); ?></label></div>
943  <div class="col-xs-12 col-sm-6 col-lg-6"><input id="filterFrom#:grid#" class="hcu-all-100"></div>
944  </div>
945  <div class="col-xs-12 col-md-4 col-lg-4 hcuSpacer">
946  <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4"><label><?php echo $MC->msg("To", HCU_DISPLAY_AS_JS); ?></label></div>
947  <div class="col-xs-12 col-sm-6 col-md-8 col-lg-8"><input id="filterTo#:grid#" class="hcu-all-100"></div>
948  </div>
949  </div>
950  </div></div>
951  <div class="hcu-edit-buttons k-state-default">
952  <a class="filterClearBtn" href="\\\\#"><?php echo $MC->msg("Clear Filter", HCU_DISPLAY_AS_JS); ?></a>
953  &nbsp;&nbsp;&nbsp;
954  <a class="filterApplyBtn k-button k-primary" href="\\\\#"><?php echo $MC->msg("Apply", HCU_DISPLAY_AS_JS); ?></a>
955  </div>
956  </div>
957  </div>
958  # } #
959  </div>
960  </script>
961  <?php // **********************
962  // END OF HEADER TEMPLATE TEMPLATE
963  ?>
964 
965  <style>
966  <?php // Needed here because the dropdownlist lists are global inside a k-animation-container. The only trace back to the dropdownlist is the id has _listbox appended to it. ?>
967  #featureDDL-list .k-item {
968  overflow: hidden;
969  white-space: nowrap;
970  text-overflow: ellipsis !important;
971  }
972  .response-label {
973  font-weight: bold;
974  }
975 
976  .local-transfer-msg {
977  padding: 1em;
978  }
979  </style>
980 
981  <?php // Page HTML ?>
982  <div class="container-fluid userActivityDiv hcu-all-100 hcu-template vsgPrimary">
983  <form id="mainForm">
984  <div class="row hcuSpacer">
985  <h3 class="col-xs-12"><?php echo $MC->msg("User Activity", HCU_DISPLAY_AS_HTML); ?></h3>
986  </div>
987  <div class="row hcuSpacer">
988  <div id="formStatus" class="k-block k-error-colored col-xs-12" style="display:none"></div>
989  </div>
990  <?php if ($showPendingApprovalGrid) { ?>
991  <div class="pendingApprovalDiv activityGridDiv" data-grid="pendingApproval">
992  <div class="row hcuSpacer">
993  <div class="col-xs-12"><div class="hcu-all-100 headlessGrid table userActivityGrid" id="pendingApprovalGrid"></div></div>
994  </div>
995  </div>
996  <?php } ?>
997  <div class="scheduledTransactionsDiv activityGridDiv" data-grid="scheduledTransactions">
998  <div class="row hcuSpacer">
999  <div class="col-xs-12"><div class="hcu-all-100 headlessGrid table userActivityGrid" id="scheduledTransactionsGrid"></div></div>
1000  </div>
1001  </div>
1002  <div class="priorActivityDiv activityGridDiv" data-grid="priorActivity">
1003  <div class="row hcuSpacer">
1004  <div class="col-xs-12"><div class="hcu-all-100 headlessGrid table userActivityGrid" id="priorActivityGrid"></div></div>
1005  </div>
1006  </div>
1007  </form>
1008  </div>
1009 <?php } // END OF PRINT PAGE