Odyssey
MbrExHcuMIR.i
1 <?php
2 require_once(dirname(__FILE__) . "/../../shared/library/statecountry.i");
3 
4 $HcuMIRi = new class()
5 {
6  public function parms_parse($payload) {
7  /*
8  * parms_parse - explode parms into component values
9  * called after reading record from database
10  */
11 
12  list($firstname,$middlename,$lastname,$email,$homephone,$workphone,$cellphone,$fax,$ssn,$address1,$address2,$city,$state,$zip,$cc,$dob) = explode("\t",$payload);
13  return array('firstname' => $firstname,
14  'middlename' => $middlename,
15  'lastname' => $lastname,
16  'email' => $email,
17  'homephone' => $homephone,
18  'workphone' => $workphone,
19  'cellphone' => $cellphone,
20  'fax' => $fax,
21  'ssn' => $ssn,
22  'address1' => $address1,
23  'address2' => $address2,
24  'city' => $city,
25  'state' => $state,
26  'zip' => $zip,
27  'cc' => $cc,
28  'dob' => $dob);
29  }
30 
31  public function parms_validate($parms) {
32  $dms_ok = array('accountnumber' => 'digits',
33  'firstname' => 'string',
34  'middlename' => 'string',
35  'lastname' => 'string',
36  'email' => 'string',
37  'homephone' => 'string',
38  'workphone' => 'string',
39  'cellphone' => 'string',
40  'fax' => 'string',
41  'ssn' => 'string',
42  'address1' => 'string',
43  'address2' => 'string',
44  'city' => 'string',
45  'state' => 'string',
46  'zip' => 'string',
47  'cc' => 'string',
48  'dob' => 'string');
49  dms_import_v2($parms, "HCUPOST", $dms_ok);
50  /*
51  * parms_validate - check entries before attemtping db update
52  * includes readying for db write
53  * called after form post, so import the needed form values
54  */
55 
56  /* strip slashes and dashes and non-digits from phone numbers
57  * and zip code and tax id;
58  * then check to see if we have valid data
59  */
60  $parms['HCUPOST']['accountnumber'] = preg_replace('/\D/', '', $parms['HCUPOST']['accountnumber']);
61  if (trim($parms['HCUPOST']['accountnumber']) == '') {
62  unset($parms['HCUPOST']['accountnumber']);
63  }
64  $parms['HCUPOST']['homephone'] = preg_replace('/\D/', '', $parms['HCUPOST']['homephone']);
65  if (trim($parms['HCUPOST']['homephone']) == '') {
66  unset($parms['HCUPOST']['homephone']);
67  }
68  $parms['HCUPOST']['cellphone'] = preg_replace('/\D/', '', $parms['HCUPOST']['cellphone']);
69  if (trim($parms['HCUPOST']['cellphone']) == '') {
70  unset($parms['HCUPOST']['cellphone']);
71  }
72  $parms['HCUPOST']['workphone'] = preg_replace('/\D/', '', $parms['HCUPOST']['workphone']);
73  if (trim($parms['HCUPOST']['workphone']) == '') {
74  unset($parms['HCUPOST']['workphone']);
75  }
76 
77  $parms['HCUPOST']['PHONE'] = (isset($parms['HCUPOST']['homephone']) ? $parms['HCUPOST']['homephone'] :
78  (isset($parms['HCUPOST']['cellphone']) ? $parms['HCUPOST']['cellphone'] : $parms['HCUPOST']['workphone']));
79 
80  try
81  {
82  if (trim($parms['HCUPOST']['dob']) != "")
83  {
84  $date= DateTime::createFromFormat("m/d/Y", $parms['HCUPOST']['dob']);
85  if (!$date)
86  throw new exception("DOB is invalid");
87  $parms['HCUPOST']['dob']= $date->format("Y-m-d");
88  }
89  else
90  unset($parms['HCUPOST']['dob']);
91 
92  }
93  catch(exception $e)
94  {
95  $errors[]= "DOB is invalid";
96  }
97 
98  $parms['HCUPOST']['ssn'] = str_replace('-', '', $parms['HCUPOST']['ssn']);
99  if (trim($parms['HCUPOST']['ssn']) == '') {
100  unset($parms['HCUPOST']['ssn']);
101  } else {
102  if (strlen($parms['HCUPOST']['ssn']) <> 9) {
103  $errors[] = "ssn must be 9 digits";
104  }
105  }
106 
107  $parms['HCUPOST']['zip'] = str_replace('-', '', $parms['HCUPOST']['zip']);
108  $parms['HCUPOST']['zip'] = str_replace(' ', '', $parms['HCUPOST']['zip']);
109  if (trim($parms['HCUPOST']['zip']) == '') {
110  unset($parms['HCUPOST']['zip']);
111  } else {
112  if (strlen($parms['HCUPOST']['zip']) <> 9 && strlen($parms['HCUPOST']['zip']) <> 5) {
113  $errors[] = "zip must be either 5 digits or 9 digits";
114  }
115  }
116 
117  $rmlist = array("#", "&", "/", "%", ",", ":", "=", "?", "'");
118 
119  $parms['HCUPOST']['email'] = str_replace($rmlist, "", $parms['HCUPOST']['email']);
120  if (trim($parms['HCUPOST']['email']) == '') {
121  unset($parms['HCUPOST']['email']);
122  }
123  $parms['HCUPOST']['firstname'] = str_replace($rmlist, "", $parms['HCUPOST']['firstname']);
124  if (trim($parms['HCUPOST']['firstname']) == '') {
125  unset($parms['HCUPOST']['firstname']);
126  }
127  $parms['HCUPOST']['middlename'] = str_replace($rmlist, "", $parms['HCUPOST']['middlename']);
128  $parms['HCUPOST']['lastname'] = str_replace($rmlist, "", $parms['HCUPOST']['lastname']);
129  if (trim($parms['HCUPOST']['lastname']) == '') {
130  unset($parms['HCUPOST']['lastname']);
131  }
132  $parms['HCUPOST']['address1'] = str_replace($rmlist, "", $parms['HCUPOST']['address1']);
133  if (trim($parms['HCUPOST']['address1']) == '') {
134  unset($parms['HCUPOST']['address1']);
135  }
136  $parms['HCUPOST']['address2'] = str_replace($rmlist, "", $parms['HCUPOST']['address2']);
137  $parms['HCUPOST']['city'] = str_replace($rmlist, "", $parms['HCUPOST']['city']);
138  if (trim($parms['HCUPOST']['city']) == '') {
139  unset($parms['HCUPOST']['city']);
140  }
141  $parms['HCUPOST']['state'] = str_replace($rmlist, "", $parms['HCUPOST']['state']);
142  if (trim($parms['HCUPOST']['state']) == '') {
143  unset($parms['HCUPOST']['state']);
144  }
145 
146  $reqMIR = array(
147  'accountnumber' => 1,
148  'firstname' => 1,
149  'lastname' => 1,
150  'email' => 1,
151  'PHONE' => 1,
152  'address1' => 1,
153  'city' => 1,
154  'state' => 1,
155  'zip' => 1
156  );
157  $missing = array_diff_key($reqMIR,$parms['HCUPOST']);
158  if (sizeof($missing)) {
159  $errors[] = "Missing Required Info (" . join(", ",array_keys($missing)) . ")";
160  }
161 
162 
163 
164  if (sizeof($errors)) {
165  $payload[data] = '';
166  $payload[errors] = $errors;
167  } else {
168 
169  $payload[data] = "{$parms['HCUPOST']['firstname']}\t{$parms['HCUPOST']['middlename']}\t{$parms['HCUPOST']['lastname']}\t{$parms['HCUPOST']['email']}\t{$parms['HCUPOST']['homephone']}\t{$parms['HCUPOST']['workphone']}\t{$parms['HCUPOST']['cellphone']}\t{$parms['HCUPOST']['fax']}\t{$parms['HCUPOST']['ssn']}\t{$parms['HCUPOST']['address1']}\t{$parms['HCUPOST']['address2']}\t{$parms['HCUPOST']['city']}\t{$parms['HCUPOST']['state']}\t{$parms['HCUPOST']['zip']}\t{$parms['HCUPOST']['cc']}\t{$parms['HCUPOST']['dob']}";
170  }
171  return $payload;
172  }
173 
174  public function printTemplate()
175  { ?>
176  <div id='gridMIR' style="width:100%"></div>
177  <div id="window"></div>
178  <?php }
179 
180  public function printGlobals()
181  { ?>
182  var tValuesMirrrrr = [ {'value':'', 'text':'...Choose...'}, {'value':'US', 'text':'United states'}, {'value':'BB', 'text':'Barbados'}, {'value': 'BS', 'text': 'Bahamas'},
183  {'value': 'PR', 'text': 'Puerto Rico'}, {'value': 'TC', 'text': 'Turks and Caicos'}, {'value': 'TT', 'text': 'Trinidad and Tobago'}, {'value': 'VI', 'text': 'Virgin Islands'}];
184  var isCreating;
185  <?php }
186 
187  public function printInit($crudhost, $trustid, $fromUserHub=false)
188  {
189  $stateDDL= getStateDDL();
190  $stateDDL= json_encode($stateDDL);
191  $countryDDL= getCountryDDL();
192  $countryDDL= json_encode($countryDDL);
193  ?>
194  var windowTemplate= 'Delete member info for member <strong>#= accountnumber #</strong>? </p>\
195  <button class="k-button" id="yesButton">Yes</button>\
196  <button class="k-button" id="noButton"> No</button>';
197 
198  var windowError= '#= Message #</p>\
199  <button class="k-button" id="errCloseButton">Close</button>';
200 
201  var popupMIR= '<form id="popupForm"><div id="mirPopupDiv" class="container">\
202  <div class="row col-md-12">\
203  <div id="formValidatePopupDiv" class="k-block k-error-colored formValidateDiv" style="display:none;"></div>\
204  </div>\
205  <div class="row col-md-12">\
206  <div class="col-md-2">Member:</div>\
207  <div class="col-md-7"><div class="accountnumber"></div></div>\
208  </div>\
209  <div class="row col-md-12">\
210  <div class="col-md-2">First, Middle Name:</div>\
211  <div class="col-md-7"><input class="k-input k-textbox" name="firstname" placeholder="First" required />&nbsp;<input class="k-input k-textbox" name="middlename" placeholder="Middle"/>\
212  </div><div class="col-md-1"><div class="k-invalid-msg" data-for="firstname"></div></div>\
213  </div>\
214  <div class="row col-md-12">\
215  <div class="col-md-2">Last Name:</div>\
216  <div class="col-md-7"><input class="k-input k-textbox" name="lastname" placeholder="Last" required /></div>\
217  <div class="col-md-1"><div class="k-invalid-msg" data-for="lastname"></div></div>\
218  </div>\
219  <div class="row col-md-12">\
220  <div class="col-md-2">Email:</div>\
221  <div class="col-md-7"><input type="email" class="k-input k-textbox" name="email" placeholder="Email" /></div>\
222  <div class="col-md-1"><div data-for="email" class="k-invalid-msg"></div></div>\
223  </div>\
224  <div class="row col-md-12">\
225  <div class="col-md-2">SSN:</div>\
226  <div class="col-md-7"><input name="ssn" placeholder="ssn" /></div>\
227  <div class="col-md-1"><div data-for="ssn" class="k-invalid-msg"></div></div>\
228  </div>\
229  <div class="row col-md-12">\
230  <div class="col-md-2">DOB:</div>\
231  <div class="col-md-7"><input name="dobInput" placeholder="DOB" /></div>\
232  <div class="col-md-1"><div data-for="dobInput" class="k-invalid-msg"></div></div>\
233  </div>\
234  <div class="row col-md-12">\
235  <div class="col-md-2">Home Phone:</div>\
236  <div class="col-md-7"><input class="k-input k-textbox homephoneInput validatePhone" name="homephone" placeholder="Home Phone" /></div>\
237  <div class="col-md-1"><div data-for="homephone" class="k-invalid-msg"></div></div>\
238  </div>\
239  <div class="row col-md-12">\
240  <div class="col-md-2">Cell Phone:</div>\
241  <div class="col-md-7"><input class="k-input k-textbox cellphoneInput validatePhone" name="cellphone" placeholder="Cell Phone" /></div>\
242  <div class="col-md-1"><div data-for="cellphone" class="k-invalid-msg"></div></div>\
243  </div>\
244  <div class="row col-md-12">\
245  <div class="col-md-2">Work Phone:</div>\
246  <div class="col-md-7"><input class="k-input k-textbox workphoneInput validatePhone" name="workphone" placeholder="Work Phone" /></div>\
247  <div class="col-md-1"><div data-for="workphone" class="k-invalid-msg"></div></div>\
248  </div>\
249  <div class="row col-md-12">\
250  <div class="col-md-2">Fax:</div>\
251  <div class="col-md-7"><input class="k-input k-textbox workphoneInput validatePhone" name="fax" placeholder="FAX" /></div>\
252  <div class="col-md-1"><div data-for="fax" class="k-invalid-msg"></div></div>\
253  </div>\
254  <div class="row col-md-12">\
255  <div class="col-md-2">Address Line 1:</div>\
256  <div class="col-md-7"><input class="k-input k-textbox" name="address1" placeholder="Address" required /></div>\
257  <div class="col-md-1"><div data-for="address1" class="k-invalid-msg"></div></div>\
258  </div>\
259  <div class="row col-md-12">\
260  <div class="col-md-2">Address Line 2:</div>\
261  <div class="col-md-7"><input class="k-input k-textbox" name="address2" placeholder="Line 2"/></div>\
262  </div>\
263  <div class="row col-md-12">\
264  <div class="col-md-2">City, State Zip:</div>\
265  <div class="col-md-7"><input class="k-input k-textbox" name="city" placeholder="City" required />, <div id="stateDDL" style="width:100px;"></div>\
266  <input type="hidden" name="state" required>\
267  &nbsp; <input class="k-input k-textbox zipInput" name="zip" placeholder="Zip" required homecu-match="zip" /></div> \
268  <div class="col-md-1"><div class="k-invalid-msg" data-for="state"></div><div class="k-invalid-msg" data-for="city"></div><div class="k-invalid-msg" data-for="zip"></div></div>\
269  </div>\
270  <div class="row col-md-12">\
271  <div class="col-md-2">Country:</div>\
272  <div class="col-md-7"><div id="countryDDL"></div> <input type="hidden" name="cc" required></div>\
273  </div></form>';
274 
275  var popupNotification = $("<div id='popupNotification'></div>").appendTo("body").kendoNotification().data("kendoNotification");
276  popupNotification.setOptions({
277  stacking: 'up',
278  autoHideAfter: 5000
279  });
280 
281  windowTemplate = kendo.template(windowTemplate);
282  var windowT = $("#window").kendoWindow({
283  title: "Please Confirm",
284  visible: false, //the window will not appear before its .open method is called
285  width: "400px",
286  modal: true,
287  open: function()
288  {
289  if (window.activeWindows != null)
290  window.activeWindows.push(this);
291  },
292  close: function()
293  {
294  if (window.activeWindows != null)
295  window.activeWindows.pop();
296  }
297  }).data("kendoWindow");
298 
299  windowError = kendo.template(windowError);
300  var winErr = $("<div id='winErr'></div>").appendTo("body").kendoWindow({
301  title: "Error",
302  visible: false, //the window will not appear before its .open method is called
303  actions: ["Close"],
304  modal: true,
305  width: "400px",
306  open: function()
307  {
308  if (window.activeWindows != null)
309  window.activeWindows.push(this);
310  },
311  close: function()
312  {
313  if (window.activeWindows != null)
314  window.activeWindows.pop();
315  }
316  }).data("kendoWindow");
317 
318  var crudServiceBaseUrl = "<?php echo $crudhost; ?>?ft=534&trustid=<?php echo $trustid; ?>";
319  <?php if ($fromUserHub) { ?>
320  crudServiceBaseUrl+= "&userid=" + $("#selectedId").text();
321  <?php } ?>
322  dataSource = new kendo.data.DataSource({
323  autoSync: false,
324  batch: false,
325  serverFiltering: false,
326  serverPaging: false,
327  page: 1,
328  pageSize: 15,
329  cache: false,
330  transport: {
331  read: {
332  type: "GET",
333  url: crudServiceBaseUrl + "&action=read",
334  dataType: "json"
335  },
336  update: {
337  type: "POST",
338  url: crudServiceBaseUrl + "&action=update",
339  dataType: "json"
340  },
341  destroy: {
342  type: "POST",
343  url: crudServiceBaseUrl + "&action=delete",
344  dataType: "json"
345  },
346  create: {
347  type: "POST",
348  url: crudServiceBaseUrl + "&action=new",
349  dataType: "json"
350  },
351  parameterMap: function(options, operation) {
352  if (operation !== "read" && options.models) {
353  return {models: kendo.stringify(options.models)};
354  } else if (operation === 'create' || operation === 'update' || operation === 'destroy') {
355  return options;
356  }
357  }
358  },
359  schema: {
360  data: "homecuData",
361  total: function(response)
362  {
363  return response.homecuData.length;
364  },
365  errors: function(response)
366  {
367  return response.homecuErrors != null && response.homecuErrors.length > 0 ? response.homecuErrors : null;
368  },
369  parse: function(response)
370  {
371  var returnValue= response.Results[0];
372  if (returnValue.homecuInfo != null && returnValue.homecuInfo.length > 0)
373  popupNotification.show(returnValue.homecuInfo, "info");
374  return returnValue;
375  },
376  model: {
377  id: "keyid",
378  fields: {
379  keyid: {type: 'number'},
380  accountnumber: { type: 'string'},
381  parms: { type: 'string'},
382  firstname: { type: 'string'},
383  middlename: { type: 'string'},
384  lastname: { type: "string"},
385  email: {type: "string"},
386  homephone: {type: "string"},
387  workphone: {type: "string"},
388  cellphone: {type: "string"},
389  fax: {type: "string"},
390  ssn: { type: "string"},
391  address1: {type: "string"},
392  address2: {type: "string"},
393  city: {type: "string"},
394  state: {type: "string"},
395  zip: {type: "string"},
396  cc: {type: "string", defaultValue: 'US'},
397  dob: { type: "string"},
398  userid: {type : "number"}
399  }
400  }
401  },
402  error: function(e)
403  {
404  grid.cancelRow();
405  winErr.content(windowError({Message: e.errors.join("<br>")})); //send the err data object to the template and render it
406  $("#winErr").closest(".k-window.k-widget").css({<?php printTopCenterCss(200, "", "jsGuts"); ?>});
407  winErr.open();
408  }
409  });
410  var grid= $("#gridMIR").kendoGrid({
411  dataSource: dataSource,
412  pageable: {
413  pageSizes: [2, 10, 20, 50],
414  info: true,
415  refresh: true,
416  messages: {
417  display: "Showing {0}-{1} from {2} data items"
418  }
419  },
420  filterable: true,
421  sortable: true,
422  batch: false,
423  columns: [
424  { field: "userid", title: "User", width: "100px"},
425  { field:"accountnumber", title: "Member", width: "120px"},
426  { field: "firstname", title:"First Name", width: "100px" },
427  { field: "middlename", title:"Middle", width: "100px" },
428  { field: "lastname", title:"Last Name", width: "100px" },
429  { command: [{name: "edit", text: "Change"}, {name: "Delete"}], title: "&nbsp;", width: "200px" }],
430  <?php if ($fromUserHub) { ?>
431  toolbar: ["create"],
432  <?php } else { ?>
433  toolbar: [{name: "customCreate", text: "<span class='k-icon k-add'></span> Add New Record"}],
434  <?php } ?>
435  editable: {
436  mode: "popup",
437  template: kendo.template(popupMIR),
438  window: {
439  width: 715,
440  open: function()
441  {
442  var thisWindow= this;
443  if (window.activeWindows != null)
444  {
445  thisWindow.grid= grid;
446  window.activeWindows.push(thisWindow);
447  }
448 
449  },
450  close: function()
451  {
452  if (window.activeWindows != null)
453  window.activeWindows.pop();
454  },
455  modal: true,
456  autoFocus: false
457  }
458  },
459  edit: function(e) {
460  $(e.container.element).closest(".k-window.k-widget").css({<?php printTopCenterCss(350, "", "jsGuts"); ?>});
461 
462  setupValidatorInGrid(e, false, {formValidate: "popupForm", formErrorTitle: 'The following errors were detected:', formStatusField: "formValidatePopupDiv",
463  homecuCustomRules: {
464  custZip: function(input)
465  {
466  if(input.is("[name='zip']"))
467  {
468  var value= $(input).val().trim();
469  if (value == "")
470  return true;
471  if (!value.match(/^\d{5}(-\_{4})?$/) && !value.match(/^\d{5}(-\d{4})?$/))
472  {
473  $(input).attr("data-custZip-msg", "Zip is invalid!");
474  return false;
475  }
476  }
477  return true;
478  },
479  custPhone: function(input)
480  {
481  if (input.is(".validatePhone"))
482  {
483  var value= $(input).val().trim();
484  if (value == "")
485  return true;
486  if (!value.match(/^\([2-9]\d{2}\) \d{3}-\d{4}$/))
487  {
488  $(input).attr("data-custPhone-msg", $(input).attr("name") + " is invalid!");
489  return false;
490  }
491  }
492  return true;
493  },
494  ssnCheck: function(input)
495  {
496  if (input.is("[name='ssn']"))
497  {
498  var value= $(input).val().trim();
499  if (value == "")
500  return true;
501  if (!value.match(/^\d{3}-\d{2}-\d{4}$/))
502  {
503  $(input).attr("data-ssnCheck-msg", "SSN is invalid!");
504  return false;
505  }
506  }
507  return true;
508  },
509  dobCheck: function(input)
510  {
511  if (input.is("[name='dobInput']"))
512  {
513  var value= $(input).val().trim();
514  if (value == "")
515  return true;
516  var matches= value.match(/(\d{1,2})\/(\d{1,2})\/(\d{4})/);
517  var newDate= new Date(value);
518  // These checks are for browsers that interpret 8/32/2016 as 9/1/2016. I would say that that is an invalid date
519  if (!matches || newDate == "Invalid Date" || Number(newDate.getMonth()) != Number(matches[1])-1
520  || Number(newDate.getDate()) != Number(matches[2]) || Number(newDate.getFullYear()) != Number(matches[3]))
521  {
522  $(input).attr("data-dobCheck-msg", "DOB is invalid!");
523  return false;
524  }
525  }
526  return true;
527  }
528  }}, true);
529 
530  var homephoneMTB= $(".homephoneInput").kendoMaskedTextBox({
531  mask: "(000) 000-0000",
532  change: function()
533  {
534  e.model.homephone= this.raw();
535  e.model.dirty= true;
536  }
537  }).data("kendoMaskedTextBox");
538 
539  homephoneMTB.value(e.model.homephone);
540 
541  var workphoneMTB= $(".workphoneInput").kendoMaskedTextBox({
542  mask: "(000) 000-0000",
543  change: function()
544  {
545  e.model.workphone= this.raw();
546  e.model.dirty= true;
547  }
548  }).data("kendoMaskedTextBox");
549 
550  workphoneMTB.value(e.model.workphone);
551 
552  var cellphoneMTB= $(".cellphoneInput").kendoMaskedTextBox({
553  mask: "(000) 000-0000",
554  change: function()
555  {
556  e.model.cellphone= this.raw();
557  e.model.dirty= true;
558  }
559  }).data("kendoMaskedTextBox");
560 
561  cellphoneMTB.value(e.model.cellphone);
562 
563  var zipMTB= $(".zipInput").kendoMaskedTextBox({
564  mask: "00000-0000",
565  change: function()
566  {
567  e.model.zip= this.raw();
568  e.model.dirty= true;
569  }
570  }).data("kendoMaskedTextBox");
571 
572  zipMTB.value(e.model.zip);
573 
574  var stateDDL= $("#stateDDL").kendoDropDownList({
575  dataSource: {
576  data: <?php echo $stateDDL; ?>
577  },
578  dataTextField: "text",
579  dataValueField: "value",
580  filter: "startswith",
581  change: function()
582  {
583  $("[name='state']").val(this.value());
584  e.model.state= this.value();
585  e.model.dirty= true;
586  $(this.wrapper).find(".k-dropdown-wrap.k-state-default .k-input").text(this.value());
587  }
588  }).data("kendoDropDownList");
589 
590  var countryDDL= $("#countryDDL").kendoDropDownList({
591  dataSource: {
592  data: <?php echo $countryDDL; ?>
593  },
594  dataTextField: "text",
595  dataValueField: "value",
596  filter: "startswith",
597  change: function()
598  {
599  $("[name='cc']").val(this.value());
600  e.model.cc= this.value();
601  e.model.dirty= true;
602  }
603  }).data("kendoDropDownList");
604 
605  var dobPicker= $("[name='dobInput']").kendoDatePicker({
606  change: function()
607  {
608  e.model.dob= $("[name='dobInput']").val();
609  }
610  }).data("kendoDatePicker");
611 
612  var ssnMTB= $("[name='ssn']").kendoMaskedTextBox({
613  mask: "000-00-0000"
614  }).data("kendoMaskedTextBox");
615 
616  if (e.model.isNew())
617  {
618  e.model.userid= $("#selectedAccntId").text();
619  e.model.accountnumber= $("#selectedAccnt").text();
620  $(".accountnumber").text($("#selectedAccnt").text());
621  e.model.cc= "US";
622  }
623  else
624  {
625  $(".accountnumber").text(e.model.accountnumber);
626  }
627 
628  stateDDL.value(e.model.state);
629  countryDDL.value(e.model.cc);
630  dobPicker.value(e.model.dob);
631 
632  $(stateDDL.wrapper).find(".k-dropdown-wrap.k-state-default .k-input").text(stateDDL.value());
633  },
634  save: function(e)
635  {
636  useValidatorInGrid(e, false);
637  },
638  noRecords: {
639  template: "<tr><td colspan='5'>No Records Found!</td></tr>"
640  }
641  }).data("kendoGrid");
642 
643  <?php if (!$fromUserHub) { ?>
644  $("#gridMIR").on("click", ".k-grid-customCreate", function() {
645  searchUser(function(dataItem) {
646  grid.addRow(); // Should have the selected accnt and primary user in the variables ready for the edit function.
647  $("[name='firstname']").focus();
648  });
649  return false;
650  });
651  <?php } ?>
652 
653  $("#winErr").on("click", "#errCloseButton", function() {
654  winErr.close();
655  return false;
656  });
657 
658  var deleteDataItem= null;
659  $("#gridMIR").on("click", ".k-grid-Delete", function(e) {
660  var tr = $(e.target).closest("tr"); //get the row for deletion
661  deleteDataItem = grid.dataItem(tr); //get the row data so it can be referred later
662  windowT.content(windowTemplate(deleteDataItem)); //send the row data object to the template and render it
663  $("#window").closest(".k-window.k-widget").css({<?php printTopCenterCss(200, "", "jsGuts"); ?>});
664  windowT.open();
665  return false;
666  });
667 
668  $("#window").on("click", "#yesButton", function() {
669  dataSource.remove(deleteDataItem) //prepare a "destroy" request
670  dataSource.sync() //actually send the request (might be omitted if the autoSync option is enabled in the dataSource)
671  windowT.close();
672  return false;
673  });
674 
675  $("#window").on("click", "#noButton", function() {
676  windowT.close();
677  return false;
678  });
679  <?php }
680 
681  public function parms_disp4edit($findTab, $searchTab, $crudhost, $Cu, $trustid) {
682  /*
683  * parms_disp4edit - layout screen for display / edit values
684  */
685  $this->printTemplate();
686  printSearchTemplates($searchTab, $findTab);
687  printExtKeyStyle();
688  ?>
689 
690  <script>
691  <?php // Library javascript functions
692  getShowWaitFunctions();
693  searchOutsideHub($searchTab, $findTab);
694  getUseValidatorInGridFunction();
695  getSetupValidatorInGridFunction();
696  $this->printGlobals(); ?>
697  var activeWindows= [];
698  $(document).ready(function() {
699  <?php $this->printInit($crudhost, $trustid);?>
700  $("body").on("click", ".k-overlay", function() {
701  if (activeWindows.length > 0)
702  {
703  var lastActive= activeWindows[activeWindows.length-1];
704  lastActive.grid != null ? lastActive.grid.cancelRow() : lastActive.close();
705  }
706 
707  return false;
708  });
709  });
710  </script>
711  <?php } // End parms_disp4edit
712 } // End class
713 ?>