Odyssey
lnappMaint.prg
1 <?php
2 
3  /* - Purpose of this script is evolving..
4  2/9/2012 - I am starting this form. At first it will be merely devloping the maintenance
5  of the lnappschemadetail table.
6  Next will be to Maintain the lnappschemamaster, disclosure fragements need to be somewhere,
7  and the portal script maintenance.
8 
9 
10 
11  ** NOTES:
12  SAVING -- Probably will have to start with a DELETE ALL for the loan, but I can then reinsert
13  the detailid if I know it, and any new records would get the default value from the sequence.
14 
15  */
16 
17  // ** DECLARE SCRIPT CONSTANTS
18 
19  // ** Declare http path to the lnapp includes
20  $http_script_path = "https://www4.homecu.net/lnapp_include/";
21 
22  // ** INCLUDE THE COMMON CU SCRIPTS
23 
24  // ** INCLUDE SCRIPT FOR HOMECU SECURITY
25  // require("ck_hticket.i"); ** REMOVED DURING DEVELOPMENT
26 
27  $monLibrary= dirname(__FILE__) . "/../library";
28  require_once("$monLibrary/cu_top.i");
29 
30  $LN_CUR_ID = 9;
31  // * GET THE RECORDS FROM THE lnappschemadetail for this loan
32  $sql = "SELECT *
33  FROM lnappschemadetail
34  WHERE loanid = " . intval($LN_CUR_ID) . "
35  ORDER BY loanid, pageid, groupid, lineid ";
36 
37  // ** This should NOW be in the correct Loan ORDER which may NOT coincide wth the detailid order
38  $detail_rs = db_query($sql, $link);
39 
40 
41  // ** START THE TOP OF THE STANDARD HTML PAGE HERE -- INCLUDE THE INFO FOR ANY JQUERY INCLUDES -- get these from /hcubin/lnapp
42  // this url is https: and AWS is NOT https. So point to local copy
43 
44 ?>
45 <html>
46  <head>
47  <title>HomeCU Loan Application Maintenance</title>
48 
49  <link type="text/css" href="<?php echo $http_script_path; ?>lnapp.css" rel="stylesheet" media="all"/>
50  <link type="text/css" href="<?php echo $http_script_path; ?>lnapp_style.css" rel="stylesheet" media="screen"/>
51  <link type="text/css" href="<?php echo $http_script_path; ?>css/jquery-ui-1.8.17.custom.css" rel="stylesheet" media="all"/>
52  <script type="text/javascript" src="<?php echo $http_script_path; ?>js/jquery/jquery-1.7.1.min.js"></script>
53  <script type="text/javascript" src="<?php echo $http_script_path; ?>js/jquery/jquery.ui.core.js"></script>
54  <script type="text/javascript" src="<?php echo $http_script_path; ?>js/jquery/jquery.populate.js"></script>
55  <script type="text/javascript" src="<?php echo $http_script_path; ?>js/jquery/jquery.validity.js"></script>
56  <script type="text/javascript" src="<?php echo $http_script_path; ?>js/jquery/jquery.qtip-1.0.0-rc3.min.js"></script>
57  <script type="text/javascript" src="<?php echo $http_script_path; ?>js/jquery/jquery.tablednd.0.6.min.js"></script>
58  <script type="text/javascript" src="<?php echo $http_script_path; ?>js/jquery/jquery.ui.widget.js"></script>
59  <script type="text/javascript" src="<?php echo $http_script_path; ?>js/jquery/jquery.ui.button.js"></script>
60  <script type="text/javascript" src="<?php echo $http_script_path; ?>js/jquery/jquery.ui.tabs.js"></script>
61 
62  </head>
63 
64  <body>
65 
66  <style>
67  #toolbar {
68  padding: 10px 4px;
69  }
70  </style>
71  <script>
72 
73  var GLOBAL_ROWID = -1;
74  var GLOBAL_SUSPEND = 0;
75 
76  $('#lnapp-detail').tableDnD({
77  onDrop: function(table, row) {
78  alert($('#lnapp-detail').tableDnDSerialize());
79  },
80  dragHandle: "dragHandle"
81  });
82 
83  function SetRowProperty(rowid) {
84  // rowid should be the ID value of the row
85  // Trim 'detail_' from beginning of string?
86 
87 
88  if (GLOBAL_ROWID != rowid) {
89  GLOBAL_SUSPEND = 1;
90  var FieldAttr = $('#fieldattr_' + rowid);
91 
92 
93  try {
94  var field_attr = JSON.parse(FieldAttr.val());
95  } catch(parseException) {
96  field_attr = JSON.parse("{}");
97  }
98  $('#form_attr').populate(field_attr,{resetForm:true,debug:false});
99 
100  GLOBAL_ROWID = rowid;
101  GLOBAL_SUSPEND = 0;
102  }
103  }
104 
105 
106  $(document).ready(function() {
107 
108  $("tr[id^='detail_']").click(function() {
109  // window.alert ('click the row' + $(this).attr('id'));
110  SetRowProperty($(this).attr('id').replace(/detail_/i, ''));
111  });
112 
113 
114 
115  $('#form_attr').change(function() {
116  if (GLOBAL_SUSPEND == 0) {
117  var new_attr= {'fieldcorearrayindex':$("#fieldcorearrayindex").val(), 'fieldcorename':$("#fieldcorename").val(), 'fieldansid':'', 'hidden':'', 'maxlength':'', 'size':'', 'default_val':'', 'print_summary':'', 'validation_require':'', 'validation_match':'', 'validation_custom':'', 'validation_desc':'', 'validation_range':'', 'validation_conditionname':'', 'validation_require_conditional[field]':'', 'validation_require_conditional[val]':'', 'helpurl':'', 'egtext':'', 'append_class':'', 'appendnextfield':'', 'localfieldonly':''}
118 
119  // window.alert('change value ' + JSON.stringify(new_attr));
120  console.log(new_attr);
121  }
122  });
123 
124 
125  // Initialise the first table (as before)
126  $("#lnapp-detail").tableDnD();
127  // Make a nice striped effect on the table
128  // $("#lnapp-detail tr:even').addClass('alt')");
129  /*
130 
131  // Initialise the second table specifying a dragClass and an onDrop function that will display an alert
132  $("#lnapp-detail").tableDnD({
133  onDragClass: "myDragClass",
134  onDrop: function(table, row) {
135  var rows = table.tBodies[0].rows;
136  var debugStr = "Row dropped was "+row.id+". New order: ";
137  for (var i=0; i<rows.length; i++) {
138  debugStr += rows[i].id+" ";
139  }
140  $(#debugArea).html(debugStr);
141  },
142  onDragStart: function(table, row) {
143  $(#debugArea).html("Started dragging row "+row.id);
144  }
145  });
146  */
147  });
148 
149 
150  $(function() {
151  $( "#new" ).button({
152  text: false,
153  icons: {
154  primary: "ui-icon-plusthick"
155  }
156  });
157  $( "#preview" ).button({
158  text: false,
159  icons: {
160  primary: "ui-icon-print"
161  }
162  });
163  $( "#save" ).button({
164  text: false,
165  icons: {
166  primary: "ui-icon-pencil"
167  }
168  })
169 /*
170  .click(function() {
171  var options;
172  if ( $( this ).text() === "new" ) {
173  options = {
174  label: "pause",
175  icons: {
176  primary: "ui-icon-pause"
177  }
178  };
179  } else {
180  options = {
181  label: "play",
182  icons: {
183  primary: "ui-icon-play"
184  }
185  };
186  }
187  $( this ).button( "option", options );
188  });
189  .click(function() {
190  $( "#play" ).button( "option", {
191  label: "play",
192  icons: {
193  primary: "ui-icon-play"
194  }
195  });
196  });
197 */
198  $( "#showprop" ).button({
199  text: false,
200  icons: {
201  primary: "ui-icon-note"
202  }
203 
204  });
205  });
206 
207  </script>
208 
209 <div id="page">
210 <div id="allcontent">
211  <form>
212  <div id='toolbar' class='ui-widget-header ui-corner-all'>
213  <button id='new'>Append</button>
214  <button id='preview'>Preview</button>
215  <button id='save'>Save</button>
216  <input type='checkbox' id='showprop'/><label for='showprop'>Display Properties</label>
217  </div>
218  <div id="content">
219  <table id='lnapp-detail' cellspacing='0' cellpadding='2'>
220  <tr id='0.0' class='nodrop nodrag'>
221  <th class='col_action'>Action</th>
222  <th>Page<br>Order</th>
223  <th>Group<br>Order</th>
224  <th>Line<br>Order</th>
225  <th>Field Type</th>
226  <th>Field Value</th>
227  </tr>
228 <?php
229  $detail_ctr = 0;
230 
231 
232  $select_fieldtype_keys = Array ("P", "H", "L", "GT", "YNR", "YNR01", "YNS", "YNS01", "AR", "AS");
233  while ($detail_row = db_fetch_assoc($detail_rs, $detail_ctr)) {
234  // ** Now Looping through each detail record
235 
236  $select_ary = array_fill_keys($select_fieldtype_keys, "");
237 
238  $select_ary[$detail_row['fieldtype']] = " SELECTED ";
239 
240  $fieldtype_select = "<option value='P' {$select_ary['P']}>Page Header</option><option value='H' {$select_ary['H']}>Section Header</option><option value='L' {$select_ary['L']}>Label</option><option value='GT' {$select_ary['GT']}>General Entry</option><option value='YNR' {$select_ary['YNR']}>Radio - Yes / No</option><option value='YNR01' {$select_ary['YNR01']}>Radio - Yes / No {0,1}</option><option value='YNS' {$select_ary['YNS']}>Select - Yes / No</option><option value='YNS01' {$select_ary['YNS01']}>Select - Yes / No {0,1}</option><option value='AR' {$select_ary['AR']}>Radio - List</option><option value='AS' {$select_ary['AS']}>Select - List</option>";
241  // $tr_even = ($detail_ctr % 2 == 0 ? " alt " : " ");
242  $tr_even = "";
243 
244  $action_link = "<a style='cursor: move' href='#' class='row_grip'/><a href='' class='row_new'/><a href='' class='row_insert'/><a href='' class='row_copy'/><a href='' class='row_delete'/>";
245 
246  print <<< table_row
247  <tr id='detail_{$detail_row['detailid']}' style='cursor: move; ' class='$tr_even'>
248  <td>$action_link</td>
249  <td class='ordercolumn'><input type='text' name='groupid_{$detail_row['detailid']}' class='order' value='{$detail_row['groupid']}'></td>
250  <td class='ordercolumn'><input type='text' name='pageid_{$detail_row['detailid']}' class='order' value='{$detail_row['pageid']}'></td>
251  <td class='ordercolumn'><input type='text' name='lineid_{$detail_row['detailid']}' class='order' value='{$detail_row['lineid']}'></td>
252  <td><select name='fieldtype_{$detail_row['detailid']}'>$fieldtype_select</select></td>
253  <td class='ordercolumn'><input type='text' name='fieldvalue_{$detail_row['detailid']}'class='fieldvalue' value='{$detail_row['fieldvalue']}'></td>
254  </tr>
255  <input type='hidden' id='detailid_{$detail_row['detailid']}' name='detailid_{$detail_row['detailid']}' value='{$detail_row['detailid']}'>
256  <input type='hidden' id='fieldattr_{$detail_row['detailid']}' name='fieldattr_{$detail_row['detailid']}' value='{$detail_row['fieldattr']}'>
257 table_row;
258  $detail_ctr++;
259  }
260 ?>
261  </table>
262  </div>
263  </form>
264  <div id='contentproperty'>
265 
266  <script>
267  $(function() {
268  $("#tabs").tabs();
269  });
270  </script>
271  <div id='item_attr'>
272  <form name='form_attr' id='form_attr'>
273  <div id="tabs">
274  <ul>
275  <li><a href="#tabs-1">Core</a></li>
276  <li><a href="#tabs-2">Attributes</a></li>
277  <li><a href="#tabs-3">Validation</a></li>
278  <li><a href="#tabs-4">Extra</a></li>
279  </ul>
280  <div id="tabs-1">
281  <p>
282  Core Record Index <input type='text' id='fieldcorearrayindex' name='fieldcorearrayindex' value=''><br>
283  Core Field Name <input type='text' id='fieldcorename' name='fieldcorename' value=''><br>
284  Select List <select id='fieldansid' name='fieldansid'><option value=''>NOT SET</option><option value='1'>US States</option><option value='3'>Marital Status</option><option value='4'>Salary Frequency</option><option value='5'>Generation Code</option><option value='2'>Auto Make (NEW)</option><option value='6'>Auto Make (USED)</option><option value='7'>Payment Frequency</option><option value='8'>Stark CU Branches</option><option value='11'>Own / Rent</option></select>
285  Response Core Table Field<input type='text' id='responsetablefield' name='responsetablefield' value=''><br>
286  </p>
287  </div>
288  <div id="tabs-2">
289  <p>
290  <input type='checkbox' name='hidden' value='1'> Field Hidden <br>
291  Max Length <input type='text' name='maxlength' value=''>##<br>
292  Field Size <input type='text' name='size' value=''>##<br>
293  Default Value <input type='text' name='defaultval' value=''><br>
294  <input type='checkbox' name='print_summary' value='1'> Print Summary<br>
295  Print Mask <input type='text' name='print_mask' value=''><br>
296  </p>
297  </div>
298  <div id="tabs-3">
299  <p>
300  Validation Required <select name='validation_require'><option value=''>NOT SET</option><option value='1'>On Submit ONLY</option><option value='2'>On Save AND Submit</option></select><br>
301  Validation Type <select name='validation_match'><option value='date'>Date</option><option value='ssn'>SSN</option><option value='phone'>Phone</option><option value='url'>URL</option><option value='usd'>Dollar</option><option value='integer'>Integer</option><option value='number'>Number</option><option value='zip'>Zip Code</option></select><br>
302  Custom Validation Regex <input type='text' name='validation_custom' value=''> FUTURE DEVELOPMENT<br>
303  Custom Validation Message <input type='text' name='validation_desc' value=''> FUTURE DEVELOPMENT<br>
304  Validation Range <input type='text' name='validation_range' value=''> FUTURE DEVELOPMENT<br>
305  Custom Validation Field Name <input type='text' name='validation_conditionname' value=''><br>
306  Require Conditional Field: <input type='text' name='validation_require_conditional[field]' value=''> Value: <input type='text' name='validation_require_conditional[value]' value=''><br>
307  </p>
308  </div>
309  <div id="tabs-4">
310  <p>
311  Help URL Link href: <input type='text' name='helpurl[href]' value=''> Display: <input type='text' name='helpurl[display]' value=''><br>
312  .eg Text <input type='text' name='egtext' value=''><br>
313  Append Class <input type='text' name='append_class' value=''><br>
314  <input type='checkbox' name='appendnextfield' value=''> Append Next Row? In development<br>
315  <input type='checkbox' name='localfieldonly' value=''> Local Field Only?<br>
316  Regex (USED?)<input type='text' name='regex' value=''><br>
317  </p>
318  </div>
319  </div>
320  </form>
321  </div>
322  </div>
323 </div>
324 </div>
325  </body>
326 </html>