10 $string = array(
"filter" => HCUFILTER_INPUT_STRING);
11 $parameters = array(
"a" => array(
"operation" =>
"",
"payload" =>
""));
12 HCU_ImportVars($parameters,
"a", array(
"operation" => $string,
"payload" => $string,
"changeList" => $string));
13 extract($parameters[
"a"]);
15 $operation = !isset($operation) ?
"" : trim($operation);
16 $payload = !isset($payload) ?
"" : trim($payload);
17 $changeList = !isset($changeList) ?
"" : trim($changeList);
20 require_once(
"$sharedLibrary/hcuTranslate.i");
21 require_once(
"$bankingLibrary/hcuTransferScheduled.i");
25 try { $userId = HCU_PayloadDecode($Cu, $payload); }
catch(exception $e) {}
26 $userId = isset($userId) ? $userId[
"user_id"] :
null;
28 if ($operation !=
"") {
32 $returnArray = SetStatusTrans($dbh, $Cu, $userId, $changeList, $MC,
true);
35 $returnArray = SetStatusTrans($dbh, $Cu, $userId, $changeList, $MC,
false);
38 $returnArray = SkipTrans($dbh, $Cu, $userId, $changeList, $MC);
41 $returnArray = array(
"error" => array(
"Operation not specified: '$operation'"),
"record" => array());
44 $returnArray = array(
"error" =>
"No User Found",
"record" => array(),
"sql" => array());
47 header(
'Content-type: application/json');
48 print HCU_JsonEncode($returnArray);
51 PrintPage(
"$menu_link?ft=$ft", ReadTrans($dbh, $Cu, $userId, $MC), $payload);
53 <div
class=
'noUserFound'><div>No
User Found</div></div>
73 function SetStatusTrans($dbh, $Cu, $userId, $changeList, $MC, $isCancel =
true) {
75 if ($changeList ==
"") {
76 throw new exception(
"Nothing to change.", 301);
78 $changeList = HCU_JsonDecode($changeList);
79 if (!is_array($changeList)) {
80 throw new exception(
"Change List is malformed.", 302);
82 if (count($changeList) == 0) {
83 throw new exception(
"Nothing to change.", 304);
85 foreach($changeList as $changeListId) {
86 if (!is_integer($changeListId)) {
87 throw new exception(
"Change List is malformed.", 303);
92 $sql =
"select id, approved_status, status from cu_scheduledtxn where cu = '$Cu' and user_id = $userId and id in (" . implode(
", ", $changeList) .
")";
93 $sth = db_query($sql, $dbh);
95 throw new exception(
"Select query failed.", 305);
97 $updateList = array();
98 for($i = 0; $row = db_fetch_assoc($sth, $i); $i++) {
99 if ($isCancel && $row[
"status"] !=
"A") {
100 throw new exception(
"Cancel can only happen on active records.", 306);
102 if (!$isCancel && $row[
"status"] ==
"A") {
103 throw new exception(
"Reactivate can only happen on inactive records.", 307);
105 if ($row[
"approved_status"] != 10) {
106 throw new exception(($isCancel ?
"Cancel" :
"Reactivate") .
" can only happen on approved records.", 308);
108 $updateList[] = $row[
"id"];
110 if (count($updateList) != count($changeList)) {
111 throw new exception(
"Some ids in the changeList are invalid.", 309);
115 $sql =
"update cu_scheduledtxn set status= '" . ($isCancel ?
"I" :
"A") .
"' where id in (" . implode(
", ", $updateList) .
") and cu = '$Cu' and user_id = $userId";
116 $sth = db_query($sql, $dbh);
118 throw new exception(
"Update query failed.", 310);
121 $readResults = ReadTrans($dbh, $Cu, $userId, $MC);
123 if ($readResults[
"status"] !=
"000") {
124 throw new exception($readResults[
"error"][0], $readResults[
"code"]);
126 $repeatingTransfers = $readResults[
"repeatingTransfers"];
129 $returnArray = array(
"status" =>
"000",
"error" =>
"",
"repeatingTransfers" => $repeatingTransfers,
130 "info" => (count($updateList) == 1 ?
"Transfer was " :
"Transfers were ") . ($isCancel ?
"cancelled" :
"reactivated") .
" successfully.");
131 }
catch(exception $e) {
132 $returnArray = array(
"status" => $e->getCode(),
"error" => $e->getMessage());
145 function PrintPage($self, $readData, $payload) { ?>
146 <script type=
"text/javascript">
156 $.homecuValidator.setup({formValidate:
"repeatingDiv", formStatusField:
"formValidateDiv"});
157 $(
"#externalTabWindow").data(
"preferredHeight",
"auto");
159 $(
".repeatingDiv").on(
"click",
".closeBtn",
function() {
164 var dateTemplateTemplate = kendo.template(
"\\# if (#: column # == null) { \\# \\# } else { \\# \\#= kendo.toString(#: column #, 'MM/dd/yyyy') \\# \\# } \\#");
166 window.repeatingTransfers = [];
167 var repeatingTransfersGrid = $(
"#repeatingTransfersGrid").kendoGrid({
170 read:
function(options) {
171 options.success(window.repeatingTransfers);
178 id: {type:
"number"},
179 feature_code: {type:
"string"},
180 feature: {type:
"string"},
181 create_date: {type:
"date"},
182 next_trigger_date: {type:
"date"},
183 start_date: {type:
"date"},
184 end_date: {type:
"date"},
185 status: {type:
"string"},
186 statusText: {type:
"string"},
187 interval: {type:
"string"},
188 intervalText: {type:
"string"},
189 details: {type:
"string"},
190 checked: {type:
"boolean", defaultValue:
false}
197 {headerTemplate:
"<input type='checkbox' class='allCheckbox'>", width: 40},
198 {field:
"feature", title:
"Feature", width: 200},
199 {field:
"details", title:
"Details", width: 300},
200 {field:
"create_date", title:
"Created", width: 50, headerAttributes: {
"class":
"hidden-xs hidden-sm"}},
201 {field:
"start_date", title:
"Range", width: 150, headerAttributes: {
"class":
"hidden-xs hidden-sm hidden-md"}},
202 {field:
"next_trigger_date", title:
"Next Trigger Date", width: 50},
203 {field:
"intervalText", title:
"Interval", width: 200, headerAttributes: {
"class":
"hidden-xs hidden-sm"}},
204 {field:
"statusText", title:
"Status", width: 100, attributes: {
"class":
"statusTD"}}
207 toolbar:
"<div id='actionDDL'></div>",
208 rowTemplate: $(
"#rowTemplate").html(),
210 }).data(
"kendoGrid");
212 var actionDDL = $(
"#actionDDL").kendoDropDownList({
214 data: [{value:
"", text:
"Action"}]
216 dataTextField:
"text",
217 dataValueField:
"value",
218 change:
function(e) {
219 var text = this.text();
221 OpenConfirm(text.toLowerCase(), this.value());
224 }).data(
"kendoDropDownList");
227 actionDDL.enable(
false);
229 var data = <?php echo HCU_JsonEncode($readData); ?>;
230 if (data.error.length > 0) {
231 $.homecuValidator.displayMessage(data.error, $.homecuValidator.settings.statusError );
233 window.repeatingTransfers =
new kendo.data.ObservableArray(data.repeatingTransfers);
234 repeatingTransfersGrid.dataSource.read();
237 <?php printCheckboxEvents(
"#repeatingTransfersGrid"); ?>
239 var inThisEvent =
false;
240 $(
"#repeatingTransfersGrid").on(
"click",
".allCheckbox, .rowCheckbox",
function() {
241 if (inThisEvent) { <?php
247 var checkedList = $(
"#repeatingTransfersGrid .rowCheckbox:checked");
249 if ($(
"#repeatingTransfersGrid .rowCheckbox:checked").length == 0) {
250 actionDDL.enable(
false);
252 var activate =
false;
257 $(checkedList).each(
function() {
259 var record = repeatingTransfersGrid.dataItem($(
this).closest(
"tr"));
261 activate = activate || record.status ==
"I";
262 cancel = cancel || record.status ==
"A";
263 skip = skip || record.status ==
"A";
264 hasNull = hasNull || record.next_trigger_date ==
null;
266 if (activate && cancel && skip && hasNull) {
272 if (activate && cancel) { <?php
273 actionDDL.enable(
false);
275 actionDDL.enable(
true);
276 var ddlData = [{value:
"", text:
"Action"}];
278 ddlData.push({value:
"activateTrans", text:
"Activate"});
281 ddlData.push({value:
"cancelTrans", text:
"Cancel"});
283 if (skip && !hasNull) {
284 ddlData.push({value:
"skipTrans", text:
"Skip"});
287 actionDDL.dataSource.data(ddlData);
295 $(
"#repeatingTransfersGrid").on(
"click",
"tbody tr",
function(e) {
296 if ($(e.target).is(
".rowCheckbox")) {
300 $(
this).find(
".rowCheckbox").click();
303 $(
"#repeatingTransfersGrid").find(
"colgroup").each(
function() {
304 $(
this).find(
"col:eq(4)").addClass(
"hidden-xs hidden-sm hidden-md");
305 $(
this).find(
"col:eq(3), col:eq(6)").addClass(
"hidden-xs hidden-sm"); <?php
308 $(
"#repeatingTransfersGrid thead tr").addClass(
"showClickable");
317 function postPostPostPost() {
318 $(
"#externalTabWindow").data(
"isClosing",
true);
319 $(
"#externalTabWindow").data(
"kendoWindow").close();
320 $(
"#externalTabWindow").data(
"isClosing",
false);
329 function OpenConfirm(actionText, actionValue) {
330 var confirmDialog = $(
"#confirmActionDialog").data(
"kendoDialog");
332 if (confirmDialog ==
null) {
333 var content =
"Do you wish to continue?";
334 confirmDialog = $(
"<div id='confirmActionDialog'></div>").appendTo(
"body").kendoDialog({
336 actions: [{text:
"No", action:
function() {
337 confirmDialog.close();
338 var actionDDL = $(
"#actionDDL").data(
"kendoDropDownList");
341 }}, {text:
"Yes", primary:
true, action:
function() {
342 confirmDialog.close();
344 var actionValue = $(
"#confirmActionDialog").data(
"actionValue");
345 var repeatingTransfersGrid = $(
"#repeatingTransfersGrid").data(
"kendoGrid");
346 var actionDDL = $(
"#actionDDL").data(
"kendoDropDownList");
348 var gridData = repeatingTransfersGrid.dataSource.data();
350 for(var i = 0, length = gridData.length; i != length; i++) {
351 var record = gridData[i];
352 if (record.checked) {
353 changeList.push(record.id);
356 var parameters = {changeList: kendo.stringify(changeList), payload:
"<?php echo $payload; ?>"};
358 $.post(
"<?php echo $self; ?>&operation=" + actionValue, parameters,
function(data) {
360 if (data.error.length > 0) {
361 $.homecuValidator.displayMessage(data.error, $.homecuValidator.settings.statusError );
363 if (data.info !=
"") {
364 $.homecuValidator.displayMessage(data.info, $.homecuValidator.settings.statusInfo );
367 repeatingTransfers =
new kendo.data.ObservableArray(data.repeatingTransfers);
368 repeatingTransfersGrid.dataSource.read();
371 actionDDL.enable(
false);
372 $(
"#repeatingTransfersGrid .allCheckbox").prop(
"checked",
false);
379 if (window.activeWindows !=
null) {
380 window.activeWindows.push(
this);
384 if (window.activeWindows !=
null) {
385 window.activeWindows.pop();
391 }).data(
"kendoDialog");
394 $(
"#confirmActionDialog").data(
"actionText", actionText);
395 $(
"#confirmActionDialog").data(
"actionValue", actionValue);
398 var gridData = $(
"#repeatingTransfersGrid").data(
"kendoGrid").dataSource.data();
399 for(var i = 0, length = gridData.length; i != length; i++) {
400 if (gridData[i].checked) {
405 var contents =
"<p>You are about to " + actionText +
" " + count +
" scheduled transaction" + (count == 1 ?
"" :
"s") +
"." + (actionText ==
"skip" ?
" This cannot be undone." :
"")
406 +
"</p><p>Are you sure you want to " + actionText + (count == 1 ?
" this record" :
" these records") +
"?</p>";
407 confirmDialog.title(
"Confirm "+ actionText[0].toUpperCase() + actionText.slice(1)).content(contents).open();
420 <script
id=
"rowTemplate" type=
"text/x-kendo-template">
421 <tr uid=
'#= uid #' class=
"showClickable">
422 <td
class=
"checkboxTD"><input type=
'checkbox' class=
'rowCheckbox'></td>
423 <td>#
if (feature ==
'') { # # }
else { # #: feature # # } #</td>
424 <td>#= details #</td> <?php
425 <td
class=
"hidden-xs hidden-sm">#
if (create_date ==
null) { # # }
else { # #: kendo.toString(create_date,
"d") # # } #</td>
426 <td
class=
"hidden-xs hidden-sm hidden-md"><b>From</b> #
if (start_date ==
null) { # # }
else { # #: kendo.toString(start_date,
"d") # # } #
427 # if (end_date != null) { # <br><b>To</b> #: kendo.toString(end_date, "d") # # } #</td> 428 <td>#
if (next_trigger_date ==
null) { # # }
else { # #: kendo.toString(next_trigger_date,
"d") # # } #</td>
429 <td
class=
"hidden-xs hidden-sm">#
if (intervalText ==
'') { # # }
else { # #: intervalText # # } #</td>
430 <td
class=
"restriction # if (status == 'A') { # allow # } else { # ban # } #">#
if (statusText ==
'') { # # }
else { # #: statusText # # } #</td>
434 <div
class=
"container hcu-all-100 repeatingDiv vsgPrimary hcu-template" id=
"repeatingDiv">
436 <div
class=
"col-xs-12 hcu-secondary">
437 <div
class=
"small vsgSecondary">Click on a row to select/unselect. Actions are skip and cancel
for active records.
438 For inactive records, there is an option to reactivate.<span
class=
"hidden-md hidden-lg"> Rotate to see more columns.</span></div>
441 <div
class=
"row notificationRow hcuSpacer"></div>
443 <div
id=
"formValidateDiv" class=
"k-block k-error-colored formValidateDiv" style=
"display:none"></div>
446 <div
class=
"hcu-all-100" id=
"repeatingTransfersGrid"></div>
448 <div
class=
"hcu-edit-buttons k-state-default row">
449 <a
class=
"closeBtn k-button k-primary" href=
"#"><i
class=
"fa fa-check"></i>Close</a>