Odyssey
MemCheck.prg
1 <?php
2 
3 $dms_ok=array('check_number'=>'digits','check_amount'=>'string',
4 'rt'=>'digits','check_date'=>'string','check_micr'=>'digits','mode'=>'string');
5 dms_import_v2($SYSENV, "MEM", $dms_ok);
6 extract($SYSENV["MEM"]);
7 
8  // Always perform the check to see if check images are available for this credit union
9  $sql = "SELECT img, flagset
10  FROM cuadmin
11  WHERE cu = '$Cu' ";
12 
13  $img_rs = db_query($sql, $dbh);
14 
15  list($img_vendor, $flagset) = db_fetch_row($img_rs, 0);
16  $img_vendor = trim($img_vendor);
17  db_free_result($img_rs);
18 
19  if ((trim($img_vendor) == '' || strtoupper(trim($img_vendor)) == 'NO') || (($flagset & $CU_SHOWIMAGES) != $CU_SHOWIMAGES)) {
20  print <<< print_html
21  <CENTER><TABLE WIDTH=95% BORDER=0 CELLPADDING=0 CELLSPACING=0>
22  <tr><td>&nbsp;</td></tr>
23  <tr class='hdrc'><td><DIV class='msg'>
24  Currently your credit union is not setup for on-line check images.
25  </DIV> </td></tr> </table>
26 print_html;
27 
28  // Check images unavailable for this vendor
29  } else {
30  if (!isset($mode))
31  $mode = "ENTER";
32 
33  $err_msg = "";
34  if ($mode == "VIEW") {
35  // Validate all information is correct and entered before trying to VIEW the image
36  if (trim($check_number) == '' || !is_numeric($check_number)) {
37  $err_msg .= "<li>Invalid information for check number. Be sure the check number is entered.</li><br>";
38  } else {
39  $check_number = trim($check_number);
40  }
41  if (trim($check_amount) == '' || !is_numeric($check_amount)) {
42  $err_msg .= "<li>Invalid information for check amount. Be sure the check amount is entered.</li><br>";
43  } else {
44  $check_amount = number_format($check_amount, 2, '.', '');
45  }
46  if (trim($rt) == '' || !is_numeric($rt)) {
47  $err_msg .= "<li>Invalid information for R&amp;T number. Be sure the R&amp;T number is selected.</li><br>";
48  } else {
49  $rt = trim($rt);
50  }
51 
52  list($mm,$dd,$yyyy) = explode("/",$check_date);
53  if (!validateDate("$mm", "$dd", "$yyyy")) {
54  $err_msg .= "<li>Invalid Check Date</li><br>";
55  } else {
56  $check_date = date('m/d/Y', strtotime($check_date));
57  }
58 
59  if (trim($check_micr) == '' || !is_numeric($check_micr)) {
60  $err_msg .= "<li>Invalid information for micr number. Be sure the micr number is entered.</li><br>";
61  } else {
62  $check_micr = trim($check_micr);
63  }
64 
65 
66  if ($err_msg != '') {
67  $err_msg = "Some information you entered was either incorrect or missing.<br>
68  Please examine the error(s) and fix them before continuing.<br>$err_msg";
69  $mode = "ENTER";
70  }
71  }
72 
73  if ($err_msg != '') {
74  $err_msg = "<tr><td colspan=\"2\" class=\"dtlc\"><span class=\"msg\">$err_msg</span>
75  </td></tr><tr><td colspan=\"2\" class=\"dtl\"><hr></td></tr>";
76  }
77  switch ($mode) {
78  case "VIEW":
79  // Now drop some code to allow the window to be loaded
80  // Start out by printing out the information they entered on the previous screen
81  // Get any needed information from the cuadmin table
82 
83 # pass micr as sortkey to ImageSRC program for MidAt clients using tracenumber
84 # and not micr to retrieve images
85 /*
86  * changed 12/19/12 if FEDIMAGE, send check_number; if MAC send check_micr; else send ''
87  * so old legacy hacks for FEDIMAGE and MAC still work without breaking new alternate MICR for
88  * WASATCH / ISUCU
89  */
90 
91 if ($img_vendor == 'FEDIMAGE') $sortkey = $check_number;
92 elseif ($img_vendor == 'MAC') $sortkey = $check_micr;
93 else $sortkey = '';
94 
95  $dmskey=sha1("${Cu}${img_vendor}${check_number}${check_amount}${check_date}${rt}${check_micr}${sortkey}${Cn}cierto");
96  $img_url = "https://{$_SERVER['SERVER_NAME']}" . ($Cl == "L" ? "/hculive7" : "/hcubin7") . "/ImageSRC"
97  . "?cu=$Cu&chome=$chome&img=$img_vendor&check={$check_number}&amount={$check_amount}"
98  . "&date={$check_date}&rt={$rt}&micr={$check_micr}&sk=$sortkey&adm=1&dmskey=${dmskey}";
99  case "ENTER":
100  // This allows the credit union to Enter in the information for the check
101  // image, then it validates all the neccessary information is entered
102  // before calling the imagesrc
103 
104 # Get any extra R/T numbers
105 
106  $sql = "SELECT trim(rt), 'P' as pri from cuadmin where cu='$Cu'
107  UNION ALL
108  SELECT trim(rt), 'X' as pri from cualtroute where cu='$Cu'
109  ORDER BY 2,1 ";
110 
111  $sql_rs = db_query($sql, $dbh);
112 
113  if (db_num_rows($sql_rs) == 1 ) {
114  $hide_rt=1;
115  list($key,$value) = db_fetch_array($sql_rs,0);
116  $rt_select = "<input type='hidden' name='rt' value='$key'>";
117  } else {
118  $hide_rt=0;
119  $rt_select = "<select name='rt' size=1>
120  <option value=''>Select R/T#</option>\n";
121  for ($row=0;list($key, $value) = db_fetch_array($sql_rs,$row); $row++) {
122  $rt_select .="<option value='$key'>$key</option>\n";
123  }
124  $rt_select .= "</select>";
125  }
126 
127  print <<< print_html
128  <form name="checkinfo" method="post" action="{$_SERVER['SCRIPT_NAME']}?ft={$ft}">
129  <input type="hidden" name="mode" value="VIEW">
130  <br>
131  <table width="90%" border=0 cellpadding=0 cellspacing=0>
132  <tr>
133  <td colspan="2" class="bar" align="center">
134  View Member's Check Image
135  </td>
136  </tr>
137  $err_msg
138  <tr>
139  <td colspan="2" class="hdrl">
140  Check Information
141  </td>
142  </td>
143  <tr>
144  <td class="dtlr" width="30%">
145  Check Number:
146  </td>
147  <td class="dtll" width="70%">
148  <input type="text" name="check_number" value="{$check_number}" size="15" maxlength="20">
149  <font color="green">###</font>
150  </td>
151  </tr>
152  <tr>
153  <td class="dtlr">
154  Check Amount:
155  </td>
156  <td class="dtll">
157  <input type="text" name="check_amount" value="{$check_amount}" size="15" maxlength="15">
158  <font color="green">####.##</font>
159  </td>
160  </tr>
161  <tr>
162  <td class="dtlr">
163  Check Date:
164  </td>
165  <td class="dtll">
166  <input type="text" name="check_date" value="{$check_date}" size="10" maxlength="10">
167  <font color="green">MM/DD/YYYY</font>
168  </td>
169  </tr>
170  <tr>
171  <td class="dtlr">
172  MICR Account Number:
173  </td>
174  <td class="dtll">
175  <input type="text" name="check_micr" value="{$check_micr}" size="20" maxlength="20">
176  <font color="green">###</font>
177  </td>
178  </tr>
179 print_html;
180  if ($hide_rt) {
181  print "$rt_select";
182  } else {
183  print <<< print_html
184  <tr>
185  <td class="dtlr">
186  Routing &amp; Transit Number:
187  </td>
188  <td class="dtll">
189  $rt_select
190  </td>
191  </tr>
192 print_html;
193 }
194  print <<< print_html
195  <tr>
196  <td colspan="2" class="dtl"><hr></td>
197  </tr>
198  <tr>
199  <td class="dtl">&nbsp;</td>
200  <td class="dtll">
201  <input type="submit" value="View Image&gt;&gt;" name="btnCheck">
202  </td>
203  </tr>
204  <tr>
205  <td colspan="2" class="dtl">&nbsp;</td>
206  </tr>
207 print_html;
208 
209  if ($img_url != '') {
210  print <<< print_html
211  <script language="javascript">
212  <!--
213  var url='$img_url';
214  window.open (url, "ViewCheck", "scrollbars=yes,resizable=yes");
215  // -->
216  </script>
217  <tr>
218  <td class="msg">&nbsp;</td>
219  <td colspan="1" class="msg">Check Image Loaded</td>
220  </tr>
221 print_html;
222  }
223 
224  print "</table></form>";
225  }
226  }
227 ?>