Odyssey
hcuMRDCHistory.prg
1 <?php
2  /*
3  * File: hcuMRDCHistory.prg
4  *
5  * Purpose: This script will show the user the recent history of RDC activity.
6  * Older history is removed so only about 30 days worth are saved.
7  *
8  * This script is part of Pegasus and is intended to be invoked by the app.
9  *
10  */
11 
12  // ** SET SCRIPT LEVEL VARIABLES
13  $serviceShowInfo = true;
14  $serviceLiveCheck = true;
15  // ** INCLUDE MAIN GLOBAL SCRIPT -- Handles security / global variable values
16  require_once(dirname(__FILE__) . '/../library/hcuService.i');
17 
18  require_once(dirname(__FILE__) . '../../../shared/library/cutrusted.i');
19  /*
20  * ** CHECK USER FEATURE PERMISSIONS **
21  * NOTE: DOES NOT RETURN ON FAILURE
22  */
23 
24  PermCheckFeatureScreen($dbh, $HB_ENV, $MC, FEATURE_MOBILE_RDC);
25 
26  // ** INSERT BUSINESS LOGIC FOR THIS FORM
27  $inputVars = array();
28  $varOk = array("rdc_token"=>"string");
29  HCU_ImportVars( $inputVars, "", $varOk );
30 
31  // extract the encrypted stuff
32  if ( strpos( $inputVars['rdc_token'], "=" ) !== false ||
33  strpos( $inputVars['rdc_token'], "+" ) !== false ) {
34  // already decoded
35  $decodedToken = $inputVars['rdc_token'];
36  $encodedToken = urlencode( $inputVars['rdc_token'] );
37  } else {
38  $encodedToken = $inputVars['rdc_token'];
39  $decodedToken = urldecode( $inputVars['rdc_token'] );
40  }
41 
42  $commonString = hcu_decrypturl( $decodedToken, $HB_ENV['2factorkey']);
43 
44  parse_str( $commonString, $commonParms );
45 
46  $rdcVendorKey = $commonParms["rdcVendor"];
47  $rdcAccount = $commonParms["rdcAccount"];
48  $rdcDepositId = $commonParms["rdcDepositId"];
49  $rdcEndorse = $commonParms["rdcEndorse"];
50 
51  // make sure got required inputs
52  if ( (strlen($rdcVendorKey) == 0) || (strlen($rdcAccount) == 0) || (strlen($rdcDepositId) == 0) ) {
53  // no token or bad token
54  // show error message
55  $serviceErrorMsg = $MC->msg('Feature Not Set', HCU_DISPLAY_AS_HTML);
56  $serviceErrorCode = '915';
57  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
58  // ** DO NOT CONTINUE
59  exit;
60  }
61 
62 
63 
64  //this is the header and side menu
65  // ** INCLUDE PRE CONTENT SCRIPT
66  require_once(dirname(__FILE__) . '/../includes/hcuPreContent.i');
67 ?>
68 <!-- kendo mobile -->
69 <style>
70  .btn-group-wrap {
71  text-align: center;
72  }
73 
74  .btn-group {
75  text-align: center;
76  }
77 
78  .k-grid .history-view {
79  border-left-width: 0;
80  }
81 
82  .history-status {
83  font-weight: bold;
84  }
85  .detail-description {
86  font-weight: bold;
87  text-align: left;
88  }
89  .detail-value {
90  text-align: left;
91  }
92  .payee-amount {
93  text-align: right;
94  color: darkblue;
95  }
96 
97  .history-date {
98  font-size: .8em;
99  }
100 
101  .k-radio-label {
102  padding-bottom: .5em;
103  font-weight: normal;
104  }
105 
106  h6 {
107  font-weight: bold;
108  padding-bottom: .5em;
109  }
110 
111  #payNum {
112  padding-bottom: .5em;
113  }
114 
115  .k-window-titlebar .k-window-actions {
116  display: none;
117  }
118 
119 </style>
120 <!-- template for scheduled/history grid -->
121 <script id="historyRow" type="text/x-kendo-template">
122  <tr>
123  <td class="history-view">
124  <div class="col-xs-12 history-date">#: lastUpdate #</div>
125  <div class="col-xs-12 history-status">#: status#</div>
126  </td>
127  <td class="history-view">
128  <div class="col-xs-12 payee-amount">#: kendo.toString(amountDisplay, 'C')#</div>
129  </td>
130  </tr>
131 </script>
132 <!-- template for detail -->
133 <script id="detailHistoryRow" type="text/x-kendo-template">
134  <tr>
135  <td class="history-view">
136  <div class="col-xs-12 col-sm-6 detail-description" n>#: description#</div>
137  <div class="col-xs-12 col-sm-6 detail-value" >#: dvalue#</div>
138  </td>
139  </tr>
140 </script>
141  <div id="confirmTemplate"></div>
142  <div id="confirmationWindow"></div>
143  <div id="discardDialog"></div>
144  <div id="formStatusMain" class="homecu-formStatus k-block k-error-colored" style="display:none; margin: 10px;"></div>
145  <div id="detailTemplate" class="k-content" hidden>
146  <!-- Payment Detail Window -->
147  <div class="container-fluid hcu-scrolling-dialog">
148  <div class="k-content col-xs-12 ">
149  <div id="detailPaymentFormStatus" class="homecu-formStatus k-block k-error-colored" style="display:none; margin-bottom:10px;max-width:800px;"></div>
150  </div>
151  <div class="row">
152  <div class="col-xs-12">
153  <div id="detailGrid"></div>
154  </div>
155  </div>
156  <div class="row">
157  <div class="col-xs-12 col-sm-4 col-md-4 col-lg-4">
158  <button id="btnDetailClose" name="btnDetailClose" type="submit" class="k-button k-primary hcu-all-100 hcu-xs-btn-margin-top hcu-xs-btn-pad"><?php echo $MC->msg("Close", HCU_DISPLAY_AS_HTML)?></button>
159  </div>
160  </div>
161  </div>
162  </div>
163 </div>
164  <!-- Grid to show payment list -->
165  <div class="historyC">
166  <div class="container-fluid">
167  <div class="row">
168  <div class='col-xs-12' style="margin: 10px 0px 10px 0px;" >
169  <span class="hcu-breadcrumbs"><a href='hcuMRDC.prg?rdc_token=<?php echo $encodedToken ?>&<?php echo $HB_ENV['cuquery'] ?>' class="tabReturnBtn"><?php echo $MC->msg("Menu", HCU_DISPLAY_AS_HTML) ?></a> / <span class="realname"><?php echo $MC->msg("History", HCU_DISPLAY_AS_HTML) ?></span></span>
170  </div>
171  </div>
172  <div class="row">
173  <div class="col-xs-12" style="max-width:800px;">
174  <div id="grid" class="hcu-xs-btn-margin-top">
175  </div>
176  </div>
177  </div>
178  </div>
179 </div>
180 <script type="text/javascript">
181 
182  var windowStack = [];
183  var dsHistory = [];
184 
185  var detailWindow;
186  var currentSelectedRow;
187 
188  dsHistory = new kendo.data.DataSource({
189  transport: {
190  read: {
191  url: "hcuMRDC.data?cu=<?php echo $HB_ENV['cu']; ?>&rdc_token=<?php echo $encodedToken ?>&rdc_type=History&<?php echo $HB_ENV['cuquery'] ?>",
192  contentType: 'application/x-www-form-urlencoded',
193  type: 'POST',
194  data: function() {
195  return {};
196  },
197  pageable: true,
198  cache: false
199  }
200  },
201  requestStart: function( e ) {
202  ShowWaitWindow();
203  },
204  requestEnd: function( e ) {
205  CloseWaitWindow();
206  var error = null;
207  // see if there is an error
208  if ( e.response && e.response.homecuErrors )
209  error = e.response.homecuErrors;
210 
211  if ( error && error.length > 0 ) {
212  e.preventDefault();
213  $.homecuValidator.displayMessage(error, $.homecuValidator.settings.statusError);
214  } else {
215  // should be showing data automatically
216  }
217  },
218  // code to run if the request fails; the raw request and
219  // status codes are passed to the function
220  error: function( e ) {
221  alert( "Transport error" );
222  },
223  schema: {
224  model: {
225  id: "depositId",
226  fields: {
227  depositId: { type: "number" },
228  acctId: { type: "number" },
229  amount: { type: "string" },
230  amountDisplay: { type: "string" },
231  hcuStatus: { type: "string" },
232  rdcStatus: { type: "string" },
233  lastUpdate: { type: "date" },
234  status: { type: "string" }
235  }
236  },
237  data: "homecuData"
238  },
239  });
240 
241  // detail dialog
242  detailWindow = $("#detailTemplate").kendoWindow({
243  width: "85%",
244  height: "85%",
245  title: "",
246  visible: false,
247  modal: true,
248  scrollable: true,
249  maxWidth: 600,
250  position: { top: 100, left: "10%" , right: "10%"},
251  activate: function(e) {
252  windowStack.push(function(e) {
253  detailWindow.close(e);
254  });
255  $.homecuValidator.setup({formValidate: "detailTemplate",
256  formErrorTitle: "<?php echo $MC->msg("Error Occurred", HCU_DISPLAY_AS_JS) ?>",
257  formStatusField: "detailPaymentFormStatus"});
258 
259  // add the close function to the window stack
260  $("#btnDetailClose").click( function() {
261  detailWindow.close();
262  });
263 
264  $("#btnPayment").click( function() {
265  detailWindow.close();
266  EditPayment();
267  });
268 
269  $("#btnStopPayment").click( function() {
270  StopPayment();
271  });
272  },
273  close: function(e) {
274  // now remove the close function call
275  windowStack.pop();
276  $('#btnDetailClose').off();
277  $('#btnPayment').off();
278  $('#btnStopPayment').off();
279  },
280  }).data('kendoWindow');
281 
282  // This will open the detailed transaction window
283  function showDetailWindow() {
284 
285  detailWindow.title(currentSelectedRow.Type + " <?php echo $MC->msg("Detail", HCU_DISPLAY_AS_HTML)?>");
286 /*
287  acctId: { type: "number" },
288  amount: { type: "string" },
289  amountDisplay: { type: "string" },
290  hcuStatus: { type: "string" },
291  rdcStatus: { type: "string" },
292  lastUpdate: { type: "date" },
293  status: { type: "string" }
294 */
295  var dataSource = new kendo.data.DataSource;
296  var txnId = currentSelectedRow.TxnId;
297  dataSource.add({ description: "<?php echo $MC->msg("ACH Deposit Account", HCU_DISPLAY_AS_JS) ?>", dvalue: currentSelectedRow.acctId});
298  dataSource.add({ description: "<?php echo $MC->msg("Amount", HCU_DISPLAY_AS_JS) ?>", dvalue: kendo.toString(currentSelectedRow.amountDisplay, "c")});
299  dataSource.add({ description: "<?php echo $MC->msg("Date", HCU_DISPLAY_AS_JS) ?>", dvalue: kendo.toString(kendo.parseDate(currentSelectedRow.lastUpdate), "MM/dd/yyyy")});
300  dataSource.add({ description: "<?php echo $MC->msg("Status", HCU_DISPLAY_AS_JS) ?>", dvalue: currentSelectedRow.hcuStatus});
301 
302  myDetailGrid = $("#detailGrid");
303  myDetailGrid.kendoGrid({
304  dataSource: dataSource,
305  rowTemplate: kendo.template($("#detailHistoryRow").html()),
306  selectable: true,
307  visible: true,
308  columns: [ { headerAttributes: {style: "display: none"}}],
309  noRecords: {template: "<?php echo $MC->msg('No Scheduled Found', HCU_DISPLAY_AS_JS); ?>"},
310  }).data('kendoWindow');
311 
312  detailWindow.open().toFront().center();
313  }
314 
315 
316  function onChange(arg) {
317  var selected = $.map(this.select(), function(item) {
318  return $(item).text();
319  });
320 
321  var entityGrid = $("#grid").data("kendoGrid");
322  currentSelectedRow = entityGrid.dataItem(entityGrid.select());
323 
324  showDetailWindow();
325 
326  }
327 
328  $(document).on("click", ".k-overlay", function (e) {
329  if(windowStack.length > 0) {
330  // get the close function from the stack, without poping it (the close will pop it)
331  var fn = windowStack[windowStack.length - 1];
332  var ret = fn(e);
333  }
334  });
335 
336  $(document).ready(function () {
337  $.homecuValidator.setup({formErrorTitle: "<?php echo $MC->msg("Error Occurred", HCU_DISPLAY_AS_JS) ?>"});
338 
339  $("#grid").kendoGrid({
340  dataSource: dsHistory,
341 // dataSource: [{amountDisplay: "$1.23", status: "Open", lastUpdate: "01/01/2013 12:34p"}, {amountDisplay: "$1.23", status: "Cancelled", lastUpdate: "11/26/2014 09:34a"}],
342  rowTemplate: kendo.template($("#historyRow").html()),
343  change: onChange,
344  selectable: true,
345  visible: false,
346  columns: [ {headerAttributes: {style: "display: none"},attributes:{style:"border-left-width: 0;"}},
347  {width: "100px", headerAttributes: {style: "display: none"},attributes:{style:"border-left-width: 0;"}}],
348  noRecords: {template: "<?php echo $MC->msg('No Records Found', HCU_DISPLAY_AS_JS); ?>"},
349  });
350 
351  });
352 
353 </script>
354 <?php
355  /*
356  * ** END CONTENT
357  */
358 
359 
360  // ** INCLUDE POST CONTENT SCRIPT
361  require_once(dirname(__FILE__) . '/../includes/hcuPostContent.i');
362 ?>