3 $HcuEZCARDi =
new class()
5 public function parms_parse($payload) {
11 list($card4, $cardsig, $cardtype) = explode(
',', $payload);
12 return array(
'card4' => $card4,
'cardsig' => $cardsig,
'cardtype' => $cardtype);
15 public function parms_validate($parms) {
16 $dms_ok = array(
'card4' =>
'string',
'cardsig' =>
'string',
17 'cardtype' =>
'string',);
18 dms_import_v2($parms,
"HCUPOST", $dms_ok);
24 if (empty($parms[
'HCUPOST'][
'card4'])) {
25 $errors[] =
'Card Last 4 Required';
27 if (preg_match(
"/\D/", $parms[
'HCUPOST'][
'card4']) || strlen($parms[
'HCUPOST'][
'card4']) <> 4) {
28 $errors[] =
"Card Last 4 must be 4 digits";
31 if (empty($parms[
'HCUPOST'][
'cardsig'])) {
32 $errors[] =
'Card Signature Required';
34 if (strlen($parms[
'HCUPOST'][
'cardsig']) <> 44) {
35 $errors[] =
"Card Signature must be 44 characters";
42 if (preg_match(
"/[+\/=]/", $parms[
'HCUPOST'][
'cardsig'])) {
43 $errors[] =
"Card Signature contains invalid characters";
45 $patterns = array(
"/-/",
"/_/",
"/\./");
46 $repl = array(
"+",
"/",
"=");
47 $b64str = preg_replace($patterns, $repl, $parms[
'HCUPOST'][
'cardsig']);
48 if (!base64_decode($b64str)) {
49 $errors[] =
"Card Signature contains invalid characters";
52 if (empty($parms[
'HCUPOST'][
'cardtype'])) {
54 $parms[
'HCUPOST'][
'cardtype'] =
'P';
56 if (preg_match(
"/[^PC123456789]/", $parms[
'HCUPOST'][
'cardtype'])) {
57 $errors[] =
"Invalid Card Type";
59 if (
sizeof($errors)) {
61 $payload[errors] = $errors;
63 $payload[data] =
"{$parms['HCUPOST']['card4']},{$parms['HCUPOST']['cardsig']},{$parms['HCUPOST']['cardtype']}";
68 public function printTemplate()
70 <span
id=
"popupNotification"></span>
71 <div
id=
'gridMsg' style=
"100%"></div>
72 <div
id=
"window"></div>
73 <div
id=
"winErr"></div>
76 public function printGlobals()
78 var tValues = [ {
'value':
'',
'text':
'...Choose...'}, {
'value':
'P',
'text':
'P'}, {
'value':
'1',
'text':
'1'}, {
'value':
'2',
'text':
'2'}, {
'value':
'3',
'text':
'3'}];
83 public function printInit($crudhost, $trustid, $fromUserHub=
false)
85 var windowTemplate=
'Delete card ending in <strong>#= card4 #</strong> for member <strong>#= accountnumber #</strong>? </p>\ 86 <button class="k-button" id="yesButton">Yes</button>\ 87 <button class="k-button" id="noButton"> No</button>';
89 var windowError=
'#= Message #</p>\ 90 <button class="k-button" id="errCloseButton">Close</button>';
92 windowTemplate = kendo.template(windowTemplate);
93 var windowT = $(
"#window").kendoWindow({
94 title:
"Please Confirm",
100 if (window.activeWindows !=
null)
101 window.activeWindows.pop();
105 if (window.activeWindows !=
null)
106 window.activeWindows.push(
this);
108 }).data(
"kendoWindow");
110 windowError = kendo.template(windowError);
111 var winErr = $(
"#winErr").kendoWindow({
119 if (window.activeWindows !=
null)
120 window.activeWindows.pop();
124 if (window.activeWindows !=
null)
125 window.activeWindows.push(
this);
127 }).data(
"kendoWindow");
129 var popupNotification = $(
"#popupNotification").kendoNotification().data(
"kendoNotification");
130 popupNotification.setOptions({
136 var crudServiceBaseUrl =
"<?php echo $crudhost; ?>?ft=534&trustid=<?php echo $trustid; ?>";
137 <?php
if ($fromUserHub) { ?>
138 crudServiceBaseUrl+=
"&userid=" + $(
"#selectedId").text();
140 var dataSource =
new kendo.data.DataSource({
143 serverFiltering:
false,
151 url: crudServiceBaseUrl +
"&action=read",
156 url: crudServiceBaseUrl +
"&action=update",
161 url: crudServiceBaseUrl +
"&action=delete",
166 url: crudServiceBaseUrl +
"&action=new",
169 parameterMap:
function(options, operation) {
170 if (operation !==
"read" && options.models) {
171 return {models: kendo.stringify(options.models)};
172 }
else if (operation ===
'create' || operation ===
'update' || operation ===
'destroy') {
179 total:
function(response)
181 return response.homecuData.length;
183 errors:
function(response)
185 return response.homecuErrors !=
null && response.homecuErrors.length > 0 ? response.homecuErrors :
null;
187 parse:
function(response)
189 var returnValue= response.Results[0];
190 if (returnValue.homecuInfo !=
null && returnValue.homecuInfo.length > 0)
191 popupNotification.show(returnValue.homecuInfo,
"info");
197 keyid: {type:
'number', editable:
false},
198 userid: {type:
"number", editable:
false},
199 accountnumber: { type:
'string', editable:
false},
200 parms: { type:
'string'},
201 card4: { type:
'string', validation: {required: { message:
"Card Last-4 Required" }} },
202 cardsig: { type:
'string', validation: {required: { message:
"Card Signature Required"}} },
203 cardtype: { type:
'string', validation: {required: { message:
"Card Type Required" }}, defaultValue:
'P' }
210 winErr.content(windowError({Message: e.errors.join(
"<br>")}));
211 $(
"#winErr").closest(
".k-window.k-widget").css({<?php printTopCenterCss(200,
"",
"jsGuts"); ?>});
216 var grid= $(
"#gridMsg").kendoGrid({
217 dataSource: dataSource,
218 <?php
if (!$fromUserHub) {
220 pageSizes: [10, 20, 50],
224 display:
"Showing {0}-{1} from {2} data items" 227 filterable: {extra:
false},
232 { field:
"userid", title:
"User", width:
"100px"},
233 { field:
"accountnumber", title:
"Member", width:
"120px"},
234 { field:
"card4", title:
"Last 4", width:
"100px", editor:
function(container, options) {
235 var input = $(
"<input class='k-input k-textbox' maxlength='4' name='" + options.field +
"'>").appendTo(container);
237 { field:
"cardsig", title:
"Signature", width:
"300px" },
238 { field:
"cardtype", title:
"Type", values: tValues, width:
"100px" },
239 { command: [{name:
"edit", text:
"Change"}, {name:
"Delete"}], title:
" ", width:
"200px" }],
240 <?php
if ($fromUserHub) { ?>
243 toolbar: [{name:
"customCreate", text:
"<span class='k-icon k-add'></span> Add New Record"}],
250 e.model.userid= $(
"#selectedAccntId").text();
251 e.model.accountnumber= $(
"#selectedAccnt").text();
253 <?php
if (!$fromUserHub) { ?>
254 e.container.find(
"td:eq(0)").text($(
"#selectedAccnt").text());
259 template:
"<tr><td colspan='<?php echo $fromUserHub ? 5 : 4; ?>'>No Records Found!</td></tr>" 261 }).data(
"kendoGrid");
263 <?php
if (!$fromUserHub) { ?>
264 $(
"#gridMsg").on(
"click",
".k-grid-customCreate",
function() {
265 searchUser(
function(dataItem) {
267 $(
".k-grid-edit-row .k-input:first").focus();
273 $(
"#winErr").on(
"click",
"#errCloseButton",
function() {
278 var deleteDataItem=
null;
279 $(
"#gridMsg").on(
"click",
".k-grid-Delete",
function(e) {
280 var tr = $(e.target).closest(
"tr");
281 deleteDataItem = grid.dataItem(tr);
282 windowT.content(windowTemplate(deleteDataItem));
283 $(
"#window").closest(
".k-window.k-widget").css({<?php printTopCenterCss(200,
"",
"jsGuts"); ?>});
288 $(
"#window").on(
"click",
"#yesButton",
function() {
289 dataSource.remove(deleteDataItem)
295 $(
"#window").on(
"click",
"#noButton",
function() {
301 public function parms_disp4edit($findTab, $searchTab, $crudhost, $Cu, $trustid) {
305 $this->printTemplate();
306 printSearchTemplates($searchTab, $findTab);
311 getShowWaitFunctions();
312 searchOutsideHub($searchTab, $findTab);
313 $this->printGlobals(); ?>
314 var activeWindows= [];
315 $(document).ready(
function() {
316 <?php $this->printInit($crudhost, $trustid);
317 printClickOverlayEvent();