Odyssey
hcuTestValidatorStrings.prg
1 <?php
2 /*
3  * File: hcuTransfer
4  *
5  * Purpose: To allow the member to transfer money from one account to another. If
6  * the member chooses, they can set up recurring transfers, an immediate transfer,
7  * and/or a transfer on a future date.
8  *
9  *
10  * Form Validation:
11  *
12  * From Account - Required, FROM LIST PROVIDED
13  * may not match TO Account
14  * TO Account - Required, FROM List Provided
15  * Amount - Required, Less than the available balance of the From Account
16  * Comment - Optional, must be trimmed to specific length
17  */
18 require_once(dirname(__FILE__) . '/../library/permissions.i');
19 
20 // ** SET SCRIPT LEVEL VARIABLES
21 $serviceShowInfo = true;
22 $serviceLoadMenu = true;
23 $serviceShowMenu = true;
24 $serviceLiveCheck = true;
25 
26 // ** INCLUDE MAIN GLOBAL SCRIPT -- Handles security / global variable values
27 require_once(dirname(__FILE__) . '/../library/hcuService.i');
28 
29 // ** INCLUDE to access scheduled transfer functions
30 require_once(dirname(__FILE__) . '/../library/hcuTransferScheduled.i');
31 
32 $string= array("filter" => FILTER_SANITIZE_STRING);
33 
34 // ** INSERT BUSINESS LOGIC FOR THIS FORM
35 $dms_ok = array("security_email"=>$string, "btnSubmit"=>$string,
36  "security_egenl"=>$string, "security_valid"=>$string);
37 
38 HCU_ImportVars($HB_ENV, 'HCUPOST', $dms_ok);
39 
40 /*
41  * ** CHECK USER FEATURE PERMISSIONS **
42  * NOTE: DOES NOT RETURN ON FAILURE
43  * ** CUSTOM FOR TRANSFER -- THEY MUST HAVE CREATE ABILITY TO USE THIS SCREEN **
44  */
45 PermCheckFeatureScreen($dbh, $HB_ENV, $MC, FEATURE_TRANSFERS, 'create');
46 
47 
48 // get some allowed amounts for client-side validation
49 $permissionInputs = array( "feature" => FEATURE_TRANSFERS );
50 $limits = Perm_GetValidationLimits( $dbh, $HB_ENV, $permissionInputs );
51 
52 if ( $limits === false ) {
53  // error occurred - assume count of zero
54  $allowedAmount = 0;
55 } else {
56  $allowedAmount = floatval( $limits["amount_per_transaction"] );
57 }
58 
59 // ** SET VARIABLES FOR WEBSITE FLAGS
60 /*
61  * SET LOGIC FOR SCHEDULED TRANSFER
62  * DEPENDENT ON CU SETTINGS AND USER PERMS
63  */
64 
65 $allowScheduled = (($HB_ENV['flagset2'] & $GLOBALS['CU2_PROCRECUR']) && PermCheckFeatureScreen($dbh, $HB_ENV, $MC, FEATURE_SCHEDULED_TRANSFERS, '', false));
66 
67 $transferFrequencyList = TxIntervalList($HB_ENV["MC"]);
68 $transferContinueList = Array(
69  Array("value" => "continuous", "text" => $MC->msg('Transfer Continue Until', HCU_DISPLAY_AS_RAW) . ' ' .$MC->msg('Transfer Further Notice', HCU_DISPLAY_AS_RAW)),
70  Array("value" => "continueuntil", "text" => $MC->msg('Transfer Continue Until', HCU_DISPLAY_AS_RAW))
71 );
72 
73 // ** get member to member/external account permissions
74 $permissionInputs = array( "feature" => FEATURE_M2M_TRANSFERS );
75 $permissionM2M = Perm_AccessRights( $dbh, $HB_ENV, $permissionInputs );
76 
77 /*
78  * FETCH ACCOUNT LIST
79  */
80 
81 $Transfer_List_ary = TX_list($dbh, $HB_ENV);
82 
83 setFmsgTxCookie($HB_ENV, $Transfer_List_ary);
84 
85 // ** Create an empty row
86 $acctFromListAry[] = Array("acctText" => '', "acctValue" => '', "acctAvail" => '', 'acctClass' => '', 'acctGroup' => '');
87 $acctToListAry[] = Array("acctText" => '', "acctValue" => '', "acctAvail" => '', 'acctClass' => '', 'acctGroup' => '');
88 $acctFromListAry = Array();
89 $acctToListAry = Array();
90 
91 /**
92  * Set default values for the terms/notice url and description
93  * the implementation is poor as it always prints the information to the html buffer
94  * instead of relying on some logic in php on when to write.
95  * Setting the values will remove the "noise" from the console.log until better implementation is done
96  * mws 11/2/17 - remove this comment at that time
97  */
98 $termsLinkDisplay = '';
99 $noticeURL = '';
100 $noticeLinkDisplay = '';
101 $termsURL = '';
102 
103 $fromAccountCount = 0;
104 $toAccountCount = 0;
105 if (count($Transfer_List_ary['acctlist']) > 0) {
106  foreach ($Transfer_List_ary['acctlist'] as $acct_key => $acct_values) {
107 
108  /* BUILD FROM ACCOUNT */
109  $acctInfo = Array();
110  if ($acct_values['from'] == 'Y' && !$acct_values['out_of_sync']) {
111  $acctInfo = Array();
112  $historyAcct = explode('|', $acct_key);
113  switch ($historyAcct[0]) {
114  case "X":
115  // not doing anything
116  break;
117  default:
118  $acctInfo = Array(
119  Array("desc" => $MC->msg('Available', HCU_DISPLAY_AS_RAW), "value" => $acct_values['available']),
120  Array("desc" => $MC->msg('Balance', HCU_DISPLAY_AS_RAW), "value" => $acct_values['balance'])
121  );
122  break;
123  }
124 
125  // ** Decode the values so kendo can properly display any encoded characters. This seems to work for at least single quote
126  $acctFromListAry[] = Array("acctText" => htmlspecialchars_decode(mobile_displayhtml($acct_values['description']), ENT_QUOTES), "acctValue" => mobile_displayhtml($acct_key), "acctAvail" => $acct_values['available'],
127  "acctInfo" => $acctInfo, 'acctClass' => $acct_values['acctclass'], 'acctGroup' => $acct_values['item-group']);
128  }
129 
130  /* BUILD TO ACCOUNT */
131 
132  if ($acct_values['to'] == 'Y' && !$acct_values['out_of_sync']) {
133  $acctInfo = Array();
134  $historyAcct = explode('|', $acct_key);
135 
136  /**
137  * When 'trust' is transfer, this is a Cross-Account, there is no information to specify, the values would be empty
138  */
139  if ($acct_values['trust'] != 'transfer'){
140  switch ($historyAcct[0]) {
141  case "D":
142  $acctInfo = Array(
143  Array("desc" => $MC->msg('Balance', HCU_DISPLAY_AS_RAW), "value" => $acct_values['balance'])
144  );
145  break;
146  case "L":
147  $acctInfo = Array(
148  Array("desc" => $MC->msg('Payoff', HCU_DISPLAY_AS_RAW), "value" => $acct_values['payoff']),
149  Array("desc" => $MC->msg('Balance', HCU_DISPLAY_AS_RAW), "value" => $acct_values['balance']),
150  Array("desc" => $MC->msg('Payment', HCU_DISPLAY_AS_RAW), "value" => $acct_values['paymentdue'])
151  );
152  break;
153  case "C":
154  $acctInfo = Array(
155  Array("desc" => $MC->msg('Payoff', HCU_DISPLAY_AS_RAW), "value" => $acct_values['payoff']),
156  Array("desc" => $MC->msg('Balance', HCU_DISPLAY_AS_RAW), "value" => $acct_values['balance']),
157  Array("desc" => $MC->msg('Payment', HCU_DISPLAY_AS_RAW), "value" => $acct_values['paymentdue'])
158  );
159  break;
160  }
161  }
162  $acctToListAry[] = Array("acctText" => htmlspecialchars_decode($acct_values['description'], ENT_QUOTES), "acctValue" => mobile_displayhtml($acct_key), "acctInfo" => $acctInfo, 'acctClass' => $acct_values['acctclass'], 'acctGroup' => $acct_values['item-group']);
163  }
164  }
165 
166  // only add new if member to member is allowed
167  if ($permissionM2M['access']) {
168  $acctToListAry[] = array("acctText" => $MC->msg("Transfer to another member", HCU_DISPLAY_AS_RAW), "acctValue" => "M|" . $HB_ENV['Uid'] . "|0", "acctInfo" => array(),
169  "acctClass" => "M", "acctGroup" => "6 - " . $MC->msg("Other Member Accounts", HCU_DISPLAY_AS_RAW));
170  }
171 }
172 
173 // list the account types for remote account (for ach) - used in dropdown list
174 $accountTypes = array(
175  array( "type" => 10, "display" => $MC->msg("ACH Checking", HCU_DISPLAY_AS_HTML) ),
176  array( "type" => 20, "display" => $MC->msg("ACH Savings", HCU_DISPLAY_AS_HTML) ));
177 
178 
179 
180 /*
181  * PERFORM SANITY CHECKS TO ENSURE GOOD DATA
182  */
183 
184 // ** INSERT BUSINESS LOGIC FOR THIS FORM
185 // ** Verify the feature is enabled for the Credit Union.
186 // * this is done by check the role 'transfernotify'
187 $sql = "SELECT email
188  FROM cuadmnotify
189  WHERE cu = '{$HB_ENV['Cu']}' AND role = 'transfernotify'";
190 $em_rs = db_query($sql, $dbh);
191 list($notifyemail) = db_fetch_array($em_rs, 0);
192 db_free_result($em_rs);
193 
194 /*
195  * Put the retrieval of the Available Trans Types higher in the code, this way
196  * I can check the CU has Cross-accounts enabled.
197  * They Fmsg_tx will never get set to a successful 32 , if Cross Accoutns
198  * are not enabled
199  */
200 $cuTransTypesAllowed = Get_HaveTrans($dbh, $HB_ENV);
201 
202 if (($HB_ENV['Fset'] & $CU_MAILTXNS) && trim($notifyemail) == "") {
203  // * Feature NOT set
204  // * Include the Error page and exit
205  $serviceErrorMsg = $MC->msg('Option not set', HCU_DISPLAY_AS_HTML);
206  $serviceErrorCode = '915';
207 
208  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
209  // ** DO NOT CONTINUE
210  exit;
211 } elseif ($HB_ENV['live'] && (($HB_ENV['Fset3'] & GetFlagsetValue('CU3_API_XAC')) && ($HB_ENV['Fmsg_tx'] & GetMsgTxValue('MSGTX_TMP_XAX_LD')) == 0)) {
212  // ** Current Cross Account Data Not Retrieved
213  $serviceErrorCode = '911';
214 
215  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
216  // ** DO NOT CONTINUE
217  exit;
218 } elseif (count($acctFromListAry) < 1 || count($acctToListAry) <= 1) {
219  // ** NO VALID ACOUNTS FOR TRANSFER
220  $serviceErrorMsg = $MC->msg("No valid accounts transfer", HCU_DISPLAY_AS_HTML);
221  $serviceErrorCode = '915';
222 
223  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
224  // ** DO NOT CONTINUE
225  exit;
226 }
227 /*
228  * RETRIEVE the Transfer Notice
229  *
230  */
231 $noticesAry = Get_NoticeInfo($dbh, $HB_ENV, $MC, "D", "transferNotice", true);
232 $hasNotice = false;
233 $hasNoticePopup = false;
234 
235 if ( $noticesAry["status"]["code"] == "000" && HCU_array_key_exists('0', $noticesAry['notice'])) {
236  if ($noticesAry["notice"][0]["notice_id"] ) {
237 
238  $hasNotice = true;
239  $noticeOption = $noticesAry['notice'][0];
240 
241  $noticeOptions = Array (
242  'docsid' => $noticeOption['notice_id'],
243  'docstype' => $noticeOption['notice_type'],
244  'device' => 'D',
245  'noticeOnly' => '0',
246  'expireTime' => mktime() + 86400
247  );
248 
249  $encryptedDocDetails= HCU_PayloadEncode($HB_ENV['Cu'], $noticeOptions);
250 
251  $noticeOptions['noticeOnly'] = 1;
252 
253  $encryptedDocDetailsNoticeOnly= HCU_PayloadEncode($HB_ENV['Cu'], $noticeOptions);
254 
255  // build the url encoded string
256  // * For the Popup
257  if ($noticeOption['notice_popup'] > 0) {
258  $hasNoticePopup = true;
259  $noticeURL = $HB_ENV['homebankingpath'] . '/hcuViewNotice.prg?cu=' . $HB_ENV['cu'] . '&x=' . urlencode($encryptedDocDetails);
260  }
261  // * For the regular Button
262  $noticeURLNoticeOnly = $HB_ENV['homebankingpath'] . '/hcuViewNotice.prg?cu=' . $HB_ENV['cu'] . '&x=' . urlencode($encryptedDocDetailsNoticeOnly);
263  }
264 }
265 
266 // ** Retrieve the Terms of Use for SCHEDULED TRANSACTIONS
267 // ** the user needs to accept these in order to make a
268 // ** scheduled transaction from this screen.
269 $noticesAry = Get_NoticeInfo($dbh, $HB_ENV, $MC, "D", "rptTransferTerms", true);
270 
271 $hasTerms = false;
272 $hasTermsPopup = false;
273 
274 if ( $noticesAry["status"]["code"] == "000" && HCU_array_key_exists('0', $noticesAry['notice'])) {
275  if ($noticesAry["notice"][0]["notice_id"] ) {
276  $hasTerms = true;
277  $noticeOption = $noticesAry['notice'][0];
278 
279  $noticeOptions = Array (
280  'docsid' => $noticeOption['notice_id'],
281  'docstype' => $noticeOption['notice_type'],
282  'device' => 'D',
283  'noticeOnly' => '0',
284  'expireTime' => mktime() + 86400
285  );
286 
287  $encryptedDocDetails= HCU_PayloadEncode($HB_ENV['Cu'], $noticeOptions);
288 
289  $noticeOptions['noticeOnly'] = 1;
290 
291  $encryptedDocDetailsNoticeOnly= HCU_PayloadEncode($HB_ENV['Cu'], $noticeOptions);
292 
293  // build the url encoded string
294  // * For the popup terms
295  $termsURL = $HB_ENV['homebankingpath'] . '/hcuViewNotice.prg?cu=' . $HB_ENV['cu'] . '&x=' . urlencode($encryptedDocDetails);
296 
297  // * For the regular Button
298  $termsURLNoticeOnly = $HB_ENV['homebankingpath'] . '/hcuViewNotice.prg?cu=' . $HB_ENV['cu'] . '&x=' . urlencode($encryptedDocDetailsNoticeOnly);
299 
300  // see if there is a popup notice
301  $hasTermsPopup = $noticeOption["notice_popup"] ? true : false;
302 
303  $termsButtonText = $noticeOption["notice_linkdisplay"];
304  }
305 }
306 
307 // ** INCLUDE PRE CONTENT SCRIPT
308 require_once(dirname(__FILE__) . '/../includes/hcuPreContent.i');
309 
310 /*
311  * ** START CONTENT
312  */
313 ?>
314 <script type="text/javascript">
315 
316 $(document).ready(function() {
317  $.homecuValidator.setup({formValidate: "validateForm", formStatusField: "validateStatusDiv"});
318 
319  $("#validate").click(function() {
320  $.homecuValidator.validate();
321  });
322 });
323 
324 </script>
325 
326 <div id="validateForm" class="container-fluid">
327 
328  <div id="validateStatusDiv"></div>
329 
330  <div class="row">
331  <div class="col-xs-6">This is required</div>
332  <div class="col-xs-6"><input name='a' type='text' required></div>
333  </div>
334 
335  <div class="row">
336  <div class="col-xs-6">Email check</div>
337  <div class="col-xs-6"><input name="b" type='email' value="invalid email"></div>
338  </div>
339 
340  <div class="row">
341  <div class="col-xs-6">Max check</div>
342  <div class="col-xs-6"><input name="c" type='text' max="1" value="over max"></div>
343  </div>
344 
345  <div class="row">
346  <div class="col-xs-6">Max Length</div>
347  <div class="col-xs-6"><input name="d" homecu-maxlen="1" value="over max"></div>
348  </div>
349 
350  <div class="row">
351  <div class="col-xs-6">Min Length</div>
352  <div class="col-xs-6"><input name="e" homecu-minlen="10" value="under"></div>
353  </div>
354 
355  <div class="row">
356  <div class="col-xs-6">Pattern Matching A</div>
357  <div class="col-xs-6"><input name="f" homecu-match="integer" value="doesn't match"></div>
358  </div>
359 
360 
361  <div class="row">
362  <div class="col-xs-6">Pattern Matching B</div>
363  <div class="col-xs-6"><input name="g" homecu-match="dateYY" value="doesn't match"></div>
364  </div>
365 
366  <div class="row">
367  <div class="col-xs-6">Distinct Values A</div>
368  <div class="col-xs-6"><input name="h" class="unique_select" homecu-distinct="unique_select" value="same"></div>
369  </div>
370 
371  <div class="row">
372  <div class="col-xs-6">Distinct Values B</div>
373  <div class="col-xs-6"><input name="i" class="unique_select" homecu-distinct="unique_select" value="same"></div>
374  </div>
375 
376  <div class="row">
377  <div class="col-xs-6">Match Values A</div>
378  <div class="col-xs-6"><input name="j" class="matchPasswords" homecu-equals="matchPasswords" value="different A"></div>
379  </div>
380 
381  <div class="row">
382  <div class="col-xs-6">Match Values B</div>
383  <div class="col-xs-6"><input name="k" class="matchPasswords" homecu-equals="matchPasswords" value="different B"></div>
384  </div>
385 
386  <div class="row">
387  <div class="col-xs-6">Date Greater Than 01/01/2017</div>
388  <div class="col-xs-6"><input name="l" homecu-dategtvalue="01/01/2017" homecu-dategttype="string" value="01/01/1500"></div>
389  </div>
390 
391  <div class="row">
392  <div class="col-xs-6">Date Greater Than Next Control</div>
393  <div class="col-xs-6"><input name="m" homecu-dategtvalue="fieldz" homecu-dategttype="field" value="01/01/1500"></div>
394  </div>
395 
396  <div class="row">
397  <div class="col-xs-6">Set for Next Test</div>
398  <div class="col-xs-6"><input name="n" id="fieldz" value="01/01/2017"></div>
399  </div>
400 
401  <div class="row">
402  <div class="col-xs-12"><a href="#" id="validate" class="k-button k-primary">Validate</a></div>
403  </div>
404 
405 </div>
406 <?php
407  /*
408  * ** END CONTENT
409  */
410 
411 
412  // ** INCLUDE POST CONTENT SCRIPT
413  require_once(dirname(__FILE__) . '/../includes/hcuPostContent.i');