Odyssey
hcuArchiveCheck.prg
1 <?php
2  /*
3  * File: hcuArchiveCheck
4  *
5  * Purpose: Let the user view older checkes obtained from the check image vendor (because core system
6  * doesn't keep enough history)
7  *
8  */
9 
10  // ** SET SCRIPT LEVEL VARIABLES
11  $serviceShowInfo = true;
12  $serviceLoadMenu = true;
13  $serviceShowMenu = true;
14 
15  // ** INCLUDE MAIN GLOBAL SCRIPT -- Handles security / global variable values
16  require_once(dirname(__FILE__) . '/../library/hcuService.i');
17 
18  /*
19  * ** CHECK USER FEATURE PERMISSIONS **
20  * NOTE: DOES NOT RETURN ON FAILURE
21  */
22  PermCheckFeatureScreen($dbh, $HB_ENV, $MC, FEATURE_BASIC);
23 
24 
25  // ** INSERT BUSINESS LOGIC FOR THIS FORM
26 
27 
28  // ** SET VARIABLES FOR WEBSITE FLAGS
29 
30  // ** INCLUDE PRE CONTENT SCRIPT
31  require_once(dirname(__FILE__) . '/../includes/hcuPreContent.i');
32 
33 try {
34  $Cu = $HB_ENV["Cu"];
35  $Cn = $HB_ENV["Cn"];
36 
37  /*
38  * ** START CONTENT
39  */
40  // Always perform the check to see if check images are available for this credit union
41 
42  $sql = "SELECT img, rt, flagset
43  FROM cuadmin
44  WHERE cu = '$Cu' ";
45 
46  $img_rs = db_query($sql, $dbh);
47 
48  list($img_vendor, $cu_rt, $flagset) = db_fetch_row($img_rs, 0);
49  $img_vendor = trim($img_vendor);
50  $cu_rt = trim($cu_rt);
51  db_free_result($img_rs);
52 
53  if ( (trim($img_vendor) == '' || strtoupper(trim($img_vendor)) == 'NO') || (($flagset & GetFlagsetValue("CU_SHOWIMAGES")) == 0)) {
54  // * Feature NOT set
55  // * Include the Error page and exit
56  $serviceErrorMsg = $MC->msg('Feature Not Set', HCU_DISPLAY_AS_HTML) . ".<BR>" . $MC->msg('Contact CU', HCU_DISPLAY_AS_HTML);
57  $serviceErrorCode = '915';
58 
59  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
60  // ** DO NOT CONTINUE
61  exit;
62  }
63 
64  # find out how many valid checking accounts the user can access:
65  $sql = "SELECT description, trim(display_name), trim(ab.accounttype), trim(micraccount), trim(ab.accountnumber)
66  FROM {$Cu}useraccounts ua
67  INNER JOIN {$Cu}accountbalance ab ON ab.accountnumber = ua.accountnumber
68  AND ab.accounttype = ua.accounttype
69  and ab.certnumber = ua.certnumber
70  AND upper(deposittype) = 'Y'
71  AND trim(micraccount) > ''
72  WHERE ua.user_id = {$HB_ENV["Uid"]}
73  AND ua.recordtype = 'D'";
74 
75  $acctRS = db_query($sql, $dbh);
76 
77  if (db_num_rows($acctRS) == 0) {
78  // * Include the Error page and exit
79  $serviceErrorMsg = $MC->msg('No Valid Accounts', HCU_DISPLAY_AS_HTML) . "<BR>" . $MC->msg('Contact CU', HCU_DISPLAY_AS_HTML);
80  $serviceErrorCode = '915';
81 
82  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
83  // ** DO NOT CONTINUE
84  exit;
85  }
86 
87 
88  $row = 0;
89  $accountList = array();
90  while ( list($desc, $display, $atype, $micr, $acct) = db_fetch_row($acctRS, $row++) ) {
91  $displayName = getAccountDescription($dbh, $HB_ENV["Cu"], $acct, $desc, $atype, $display, $HB_ENV["Fset3"]);
92  $accountList[] = array( "text" => $displayName, "value" => "$micr|$acct|$atype" );
93  }
94 
95  db_free_result($acctRS);
96 
97  ?>
98  <script type="text/javascript">
99  var windowStack = [];
100  var accountList = <?php echo HCU_JsonEncode( $accountList ) ?>;
101  $(document).ready(function() {
102  var dsGetArchive = new kendo.data.DataSource({
103  autoSync: false,
104  batch: false,
105  pageSize: 10,
106  error: function(e) {
107  // displays "error"
108  },
109  transport: {
110  read: {
111  url: "hcuArchiveCheck.data?cu=<?php echo $HB_ENV["cu"] ?>",
112  dataType: "json",
113  contentType: "application/json",
114  type: "GET",
115  data: {
116  action: "thisshouldgetoverwritten"
117  },
118  cache: false
119  }
120  },
121  schema: {
122  parse: function(response) {
123  // not showing data, so return empty array
124  var display = [];
125  return display;
126  }
127  },
128  requestStart: function(e) {
129  kendo.ui.progress($("#archive"), true);
130  },
131  requestEnd: function(e) {
132  var error = null;
133 
134  // stop the progress bar
135  kendo.ui.progress($("#archive"), false);
136 
137  // see if there is an error
138  if ( e.response && e.response.homecuErrors )
139  error = e.response.homecuErrors;
140 
141  if ( error && error.length > 0 ) {
142  e.preventDefault();
143  // make sure only old data
144  this.cancelChanges();
145  // show the error information
146  $.homecuValidator.displayMessage(error, $.homecuValidator.settings.statusError);
147  } else {
148  if ( e.response && e.response.homecuData && (e.response.homecuData.img_url.length > 0) ) {
149  CreateWindow(e.response.homecuData.img_url);
150  }
151  }
152  }
153 
154  });
155 
156  $('#dateCleared').kendoDatePicker({format: "MM/dd/yyyy"});
157  $('#dateCleared').data('kendoDatePicker').value(kendo.toString(new Date(), 'MM/dd/yyyy'));
158 
159  // create DropDownList from input HTML element
160  $("#accountChoice").kendoDropDownList({
161  dataTextField: "text",
162  dataValueField: "value",
163  dataSource: accountList
164  });
165 
166  var checkNumber = $("#checkNumber").kendoMaskedTextBox({
167  mask: "<?php echo str_repeat('0', 20); ?>",
168  placeholder: "<?php echo $MC->msg('Check Number', HCU_DISPLAY_AS_HTML); ?>"
169  }).data("kendoMaskedTextBox");
170 
171  var amount = $("#amount").kendoNumericTextBox({
172  placeholder: "####.##",
173  format: "$####.##",
174  decimals: 2,
175  spinners: false
176  }).data("kendoNumericTextBox");
177 
178  $("#viewCheck").click( function() {
179  if ( $.homecuValidator.validate() ) {
180  var request = { action: "create_url", check_number: checkNumber.raw(),
181  amount: $("#amount").val(), date_cleared: $("#dateCleared").val(),
182  account: $("#accountChoice").val() };
183 
184  dsGetArchive.transport.read.type = "POST";
185  dsGetArchive.read( request );
186  }
187  });
188 
189  // set up some validation, using the default error location
190  $.homecuValidator.setup({formValidate: "formArchive",
191  formErrorTitle: "<?php echo $MC->msg("Error Occurred", HCU_DISPLAY_AS_JS) ?>"});
192 
193  function CreateWindow(url) {
194  $('#checkWindow').kendoWindow({
195  visible: false,
196  actions: [ "Close" ],
197  iframe: true,
198  modal: true,
199  title: "<?php echo $MC->msg("View Check Image", HCU_DISPLAY_AS_JS) ?>",
200  resizable: true,
201  width: 700,
202  height: 650,
203  open: function(e) {
204  windowStack.push(this);
205  },
206  close: function(e) {
207  windowStack.pop();
208  this.content('');
209  this.refresh('');
210  },
211  content: url
212  });
213 
214  // doing it this way for IE8
215  var dialog = $("#checkWindow").data('kendoWindow');
216  dialog.center().open();
217  }
218 
219  });
220 
221  $(document).on("click", ".k-overlay", function () {
222  // close the currently open window
223  if ( windowStack.length > 0 ) {
224  windowStack[windowStack.length-1].close();
225  }
226  });
227 
228  </script>
229  <style>
230  #archive {
231  max-width: 600px;
232  margin-right: initial;
233  margin-left: initial;
234  }
235 
236  .hcu-edit-buttons {
237  bottom: -10px !important;
238  }
239  </style>
240  <div class="container" id="archive">
241 
242  <form class='formInputx well well-sm col-xs-12' id='formArchive' name='formArchive'>
243  <div class="row">
244  <div class="col-xs-12 hcuSpacer">
245  <h3><?php echo $MC->msg('View Check Image', HCU_DISPLAY_AS_HTML); ?> <span id="displayStatus"></span></h3>
246  </div>
247  </div>
248 
249  <div class="row">
250  <div class="col-xs-12 hcuSpacer">
251  <label for="checkNumber"><?php echo $MC->msg('Check Number', HCU_DISPLAY_AS_HTML); ?>: </label>
252  <div>
253  <input id="checkNumber"
254  name="checkNumber"
255  value=""
256  required
257  data-required-msg="<?php echo "'{$MC->msg('Check Number', HCU_DISPLAY_AS_HTML)}' {$MC->msg('is a Required Field', HCU_DISPLAY_AS_HTML)}" ?>"
258  class="hcu-all-100" />
259  </div>
260  </div>
261  </div>
262 
263  <div class="row">
264  <div class="col-xs-12 hcuSpacer">
265  <label for="amount"><?php echo $MC->msg('Amount', HCU_DISPLAY_AS_HTML); ?>: </label>
266  <div>
267  <input type="number"
268  id="amount"
269  name="amount"
270  value=""
271  required
272  data-required-msg="<?php echo "'{$MC->msg('Amount', HCU_DISPLAY_AS_HTML)}' {$MC->msg('is a Required Field', HCU_DISPLAY_AS_HTML)}" ?>"
273  class="hcu-all-100" />
274  </div>
275  </div>
276  </div>
277 
278  <div class="row">
279  <div class="col-xs-12 hcuSpacer">
280  <label for="dateCleared"><?php echo $MC->msg('Date Cleared', HCU_DISPLAY_AS_HTML); ?>: </label>
281  <div>
282  <input type="text" class="hcu-all-100" id='dateCleared' name='dateCleared' value='' homecu-match="date"
283  required data-required-msg="<?php echo "'{$MC->msg('Date Cleared', HCU_DISPLAY_AS_HTML)}' {$MC->msg('is a Required Field', HCU_DISPLAY_AS_HTML)}"; ?>"
284  data-homecuCustomMatch-msg="<?php echo "'{$MC->msg('Date Cleared', HCU_DISPLAY_AS_HTML)}' {$MC->msg('is not a valid date', HCU_DISPLAY_AS_HTML)}"; ?>" />
285  </div>
286  </div>
287  </div>
288 
289  <div class="row">
290  <div class="col-xs-12 hcuSpacer">
291  <label for="accountChoice"><?php echo $MC->msg('Account', HCU_DISPLAY_AS_HTML); ?>: </label>
292  <div>
293  <input class="hcu-all-100" id='accountChoice' />
294  </div>
295  </div>
296  </div>
297  </form>
298 
299  <div class="hcu-template">
300  <div class="hcu-edit-buttons k-state-default">
301  <a href="##" id="viewCheck" name="btnView" class="k-button k-primary">
302  <span class="fa fa-eye"></span>&nbsp;<?php print $MC->msg('View', HCU_DISPLAY_AS_HTML); ?>
303  </a>
304  </div>
305  </div>
306 
307 </div>
308 <div id="checkWindow"></div>
309 <?php
310 } catch (Exception $ex) {
311  //Return error message
312  $thisPageErrors = $ex->getMessage();
313  $errorObject = HCU_JsonDecode($thisPageErrors, true, false);
314  $serviceErrorMsg = strlen( $errorObject->content ) > 0 ? $errorObject->content : $thisPageErrors;
315 
316  $serviceErrorTitle = "";
317  if ( strlen( $errorObject->title ) ) {
318  $serviceErrorTitle = $errorObject->title;
319  }
320 
321  // * Include the Error page and finish
322  $serviceErrorCode = '916';
323 
324  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
325 }
326 
327  /*
328  * ** END CONTENT
329  */
330 
331  // ** INCLUDE POST CONTENT SCRIPT
332  require_once(dirname(__FILE__) . '/../includes/hcuPostContent.i');
333 
334 ?>