Odyssey
lnappview.i
1 <?php
2 /*
3  * File: lnappview
4  * Purpose: This form will perform the function of creating a VIEW ONLY
5  * representation of the application.
6  * This form may also be what I call from HomeCU admin to show the application
7  * as well. Not sure..
8  *
9  * Paramters: viewapp -- this will be on the URL and will be the respid for the
10  * application to view
11 */
12  $App_Confirm = false;
13  $Form_LoadRespID = 0; // * this is the respid to load for the user
14  if (isset($_GET['viewapp']) || intval($Admin_View_App) > 0) {
15  // * there is an ID being passed.
16  // * try to load the application here
17  if (intval($Admin_View_App) > 0) {
18  $Form_LoadRespID = intval($Admin_View_App);
19  } else {
20  $Form_LoadRespID = intval($_GET['viewapp']);
21  }
22 
23  $sql = "SELECT loanschemadetail.*, loanschemamaster.*
24  FROM {$DB_TABLE_PREFIX}userresponse as userresponse
25  JOIN {$DB_TABLE_PREFIX}user as lnappuser
26  on lnappuser.userid = userresponse.userid
27  JOIN {$DB_TABLE_PREFIX}schemadetail as loanschemadetail
28  on loanschemadetail.loanid = userresponse.loanid
29  JOIN {$DB_TABLE_PREFIX}schemamaster as loanschemamaster
30  on loanschemamaster.loanid = loanschemadetail.loanid
31  WHERE userresponse.respid = {$Form_LoadRespID}
32  AND userresponse.userid = " . intval($DMSAPP_CURRENTUSERID) . "
33  AND lnappuser.cu = '" . $DMSAPP_CURRENTCUCODE . "'
34  ORDER BY loanschemadetail.loanid, loanschemadetail.pageid, loanschemadetail.groupid, loanschemadetail.lineid
35  ";
36 
37  $App_SchemaDetail = Array();
38  $App_SchemaFields = Array();
39  $App_AnswerDetail = Array();
40 
41  $loan_idx = 0;
42  if ($loan_rs = db_query($sql, $dbh)) {
43  // ** LOAN WAS FOUND
44  // ** Load the code to actually view the application
45  // ** LOAD THE USER RESPONSE
46 
47  $sql = "SELECT *
48  FROM {$DB_TABLE_PREFIX}userresponse
49  WHERE respid = {$Form_LoadRespID}
50  AND userid = " . intval($DMSAPP_CURRENTUSERID) . " ";
51  $app_rs = db_query($sql, $dbh);
52  $app_row = db_fetch_assoc($app_rs);
53 
54 
55  // * Create the value to check
56  if (!(intval($Admin_View_App) > 0)) {
57  if (isset($_GET['confid'])) {
58  $l_cookiename = ReturnDeviceCookieName($DMSAPP_CURRENTCUCODE, $DMSAPP_LOGINTYPE, $DMSAPP_CURRENTEMAIL, $DMSAPP_CURRENTUSERID);
59  // ** Get Cookie Contents and include it with the value being crypted
60  $l_cookieval = $_COOKIE[$l_cookiename];
61 
62  // $RecordVal = sha1($DMSAPP_SECRET_KEY . strtolower(trim($app_row['respfname'])) . strtolower(trim($app_row['resplname'])) . trim($app_row['respssn']) . date('mdY', strtotime($app_row['respdob'])) . $l_cookieval);
63  $RecordVal = sha1($DMSAPP_SECRET_KEY . trim($app_row['respssn']) . date('mdY', strtotime($app_row['respdob'])) . $l_cookieval);
64  /*
65  print "RecordVal - $RecordVal<Br>";
66  print "confid - " . $_GET['confid'] . "<Br>";
67  print "cookie - " . $l_cookieval . "<br>";
68  print "crypt - " . crypt($RecordVal, $_GET['confid']);
69 
70  print_r($_GET);
71  exit;
72  */
73 
74  if (crypt($RecordVal, $_GET['confid']) == $_GET['confid']) {
75  $App_Confirm = true;
76  // ** Allow them to Load
77  } else {
78  // ** they failed credential check
79  $FORM_VALIDATION_ERROR = "<li>The answers you provided did not match with what we have on file for this loan. Please try again.</li>";
80  }
81  }
82  } else {
83  // ** FOR ADMIN VIEW -- SET TO CONFIRMED
84  $App_Confirm = true;
85  }
86 
87  if (!$App_Confirm) {
88  //** Application confirm FAILED
89  // ** Either Include Script or redirect
90 
91  // ** Create redirect option
92  $lnapp_security_return_form_code = $form_code;
93  $lnapp_security_params = "viewapp=" . $_GET['viewapp'];
94  $lnapp_security_respid = "";
95  // ** Either case --
96 
97  include_once($inc_path . "lnappsecurity.i");
98  exit;
99  }
100 
101  // ** Load data from user application
102  $JSON_FormPopulate = $app_row['respapplication'];
103  $JSON_FormValues = json_decode($app_row['respapplication']);
104 
105  print "</div>
106  </form>
107  <div id='printoption'>
108  <p><a href='javascript: window.print();'><i class='fa fa-print'></i> Print Page</a>&nbsp;&nbsp;&nbsp; <a href='javascript: window.close();'><i class='fa fa-window-close-o'></i> Close Window</a></p>
109  </div>
110  ";
111 
112  while ($loan_row = db_fetch_assoc($loan_rs, $loan_idx++)) {
113  // ** Need to create the Loan Master Schema Array
114  // ** Make the detailid the key so I can look it up quickly
115  $App_SchemaDetail[$loan_row['detailid']] = $loan_row;
116 
117  if (strpos(":" . trim($loan_row['fieldtype']) . ":", ":YNR:YNR01:YNS:YNS01:GN:GA:GT:AS:AR:") >= 0) {
118  // * This appears to be a valid type... This is a field that should be saved
119  // to the database field response
120  // ** All fields save will be the field name "formfield_{detailid}"
121  $fieldname = "formfield_" . $loan_row['detailid'];
122  $App_SchemaFields[$fieldname] = "";
123 
124  }
125  }
126 
127  // ** Retrieve loan records - In order.. Now start displaying
128  // * information
129 
130 
131  // * some thoughts. If I can truly create the <div> tags how I envision,
132  // Then i should be able to create the menu div section as I go, then the
133  // style sheet can decide where to place this information
134  $PageTagOpen = False;
135  $GroupTagOpen = False;
136  $LineTagOpen = False;
137  $HoldLineOpen = False;
138 
139  $LAYOUT_PAGE = 1;
140  $LAYOUT_GROUP = 2;
141  $LAYOUT_LINE = 3;
142 
143  $CURRENT_LAYOUT = 0;
144  $PAGE_COUNT = 0;
145  $GROUP_COUNT = 0;
146 
147  // * This will be the left menu built on the left side for navigatino
148  $Build_CSS_Menu = "";
149 
150  // ** Loan Information
151 
152 
153  print "
154  <form id='appview' name='appview' method='post' action='#'>
155  <div class='container-fluid' id='appsolecontent'>";
156  // while ($loan_row = db_fetch_array($loan_rs, $loan_idx++))
157  $form_build_required_list = ""; // * this is the required list that will be included on teh form for whent eh user SUBMITS to the core
158  foreach ($App_SchemaDetail as $Detail_key => $Detail_value) {
159 
160  // $fieldtype = $loan_row['fieldtype'];
161  // $fieldvalue = disp_text($loan_row['fieldvalue']);
162  // // ** LOAD ThE JSON Object
163  // $fieldattr = json_decode($loan_row['fieldattr']);
164  //
165  // $formfieldname = "formfield_" . $loan_row['detailid'];
166 
167  $fieldtype = $Detail_value['fieldtype'];
168  $fieldvalue = disp_text($Detail_value['fieldvalue']);
169  // ** LOAD ThE JSON Object
170  $fieldattr = json_decode($Detail_value['fieldattr']);
171 
172  $formfieldname = "formfield_" . $Detail_key;
173  $defaultval = '';
174 
175  $formfieldrequired = (GetClassPropertyVal($fieldattr, 'validation_require') == 1 ? "<em>*</em>" : "");
176  // // ** Based on the Field type we will do differen things..
177  // if ($loan_row['fieldtype'] == "P") {
178  // // ** PAGE HEADER
179  // } elseif ($loan_row['fieldtype'] == "H") {
180  // // ** Section Header
181  // } elseif ($loan_row['fieldtype']
182  //print "WHILE LOOP - $loan_idx";
183  $field_class = "";
184 
185  // ** FETCH THE USER RESPONSE VALUE
186  $response_user_value = GetClassPropertyVal($JSON_FormValues, $formfieldname);
187 
188  switch ($fieldtype) {
189  case "P":
190  // Page Header
191  // * Check to see if we need to Close any tags
192  $PAGE_COUNT++;
193  // print "NEW P";
194  StartDMSTag ($LAYOUT_PAGE, $PAGE_COUNT, $fieldvalue);
195  print "<h1>$fieldvalue</h1>";
196 
197  break;
198  case "H":
199  // Section Header
200  // print "New H";
201  $GROUP_COUNT++;
202  StartDMSTag($LAYOUT_GROUP, 0,$fieldvalue);
203  print "<legend>$fieldvalue</legend>";
204  break;
205  case "L":
206  // Label
207  print "<p id='' class=''>$fieldvalue</p>";
208  break;
209  case "YNR":
210  case "YNS":
211  // Yes/No OPTIONS
212  StartDMSTag($LAYOUT_LINE);
213  $defaultval = ($response_user_value == "Y" ? "Yes" : "No");
214 
215  break;
216  case "YNR01":
217  case "YNS01":
218  // Yes/No OPTIONS
219  StartDMSTag($LAYOUT_LINE);
220  $defaultval = ($response_user_value == "1" ? "Yes" : "No");
221 
222  break;
223  case "AS":
224  // Answer Lookup
225  case "AR":
226  StartDMSTag($LAYOUT_LINE);
227 
228  if ($response_user_value != '') {
229  $defaultval = Display_AnswerList($fieldattr->fieldansid, $formfieldname, "R", $fieldvalue, $response_user_value);
230  }
231  break;
232  case "GT":
233  // General Text (Reg Input)
234  // ** validate changes based on the type of information we want
235 
236 
237  if (isset($fieldattr->hidden) && $fieldattr->hidden == 1) {
238  // ** DO NOT PRINT HIDDEN FIELDS
239  // DO NOTHING
240  } else {
241  StartDMSTag($LAYOUT_LINE);
242  $defaultval = $response_user_value;
243  }
244  break;
245  default:
246  }
247  if ($defaultval != '') {
248  print "<label for='$formfieldname'>$fieldvalue $formfieldrequired</label><input readonly='readonly' type='text' id='$formfieldname' name='$formfieldname' class='readonly' value='$defaultval' title='$fieldvalue' >";
249  }
250  }
251  // ** -- Close the TAG??
252  StartDMSTag($LAYOUT_PAGE, -1); // * This should close all the tags left open
253 
254 
255  } else {
256  // * No ID found -- Report error to the screen
257  print <<< print_html
258 
259  <div class="col-lg-6">
260  <div class="alert alert-danger " role="alert">
261  <div>
262  A problem was encountered:
263  <ul>
264  Unable to find the loan you requested. <br>
265  Please make your selection again.
266  </ul>
267  </div>
268  </div>
269  <div >
270  <a href='javascript: window.close();'><i class='fa fa-window-close-o'></i> Close Window</a>
271  </div>
272  </div>
273 
274 print_html;
275  }
276  } else {
277  // * No ID found -- Report error to the screen
278  print <<< print_html
279 
280  <div class="col-lg-6">
281  <div class="alert alert-danger " role="alert">
282  <div>
283  A problem was encountered:
284  <ul>
285  Unable to find the loan you requested. <br>
286  Please make your selection again.
287  </ul>
288  </div>
289  </div>
290  <div >
291  <a href='javascript: window.close();'><i class='fa fa-window-close-o'></i> Close Window</a>
292  </div>
293  </div>
294 print_html;
295 
296  }
297 ?>
298  <style>
299  #printoption {
300  margin-left: 20px;
301  }
302  </style>