|
|
@@ -225,18 +225,32 @@ function api_resp(xhr,extra) {
|
|
|
}
|
|
|
|
|
|
else if (extra["ui_function"] === "pending.list") {
|
|
|
-
|
|
|
if (dat["result"] === "success") {
|
|
|
+ update_message("ui.pending.message", "success", "");
|
|
|
+ ui_pending_list_cards(dat);
|
|
|
+ }
|
|
|
+ else { update_message("ui.pending.message", "error", dat.api_comment); }
|
|
|
+ }
|
|
|
|
|
|
- console.log(dat);
|
|
|
+ else if (extra["ui_function"] === "pending.populate") {
|
|
|
+ if (dat["result"] === "success") {
|
|
|
+ update_message("ui.pending.message", "success", "");
|
|
|
+ ui_pending_fill(dat);
|
|
|
|
|
|
- update_message("ui.pending.message", "success", "loaded");
|
|
|
- ui_pending_list(dat);
|
|
|
- }
|
|
|
- else {
|
|
|
- update_message("ui.pending.message", "error", dat.api_comment);
|
|
|
+ ui_pending_showload();
|
|
|
}
|
|
|
+ else { update_message("ui.pending.message", "error", dat.api_comment); }
|
|
|
+ }
|
|
|
|
|
|
+ else if (extra["ui_function"] === "pending.processed") {
|
|
|
+ console.log("!!!", dat);
|
|
|
+ if (dat["result"] === "success") {
|
|
|
+ update_message("ui.pending.message", "success", "processed");
|
|
|
+ ui_pending_clear(dat);
|
|
|
+ ui_pending_hideload();
|
|
|
+ ui_pending_list_cards(dat);
|
|
|
+ }
|
|
|
+ else { update_message("ui.pending.message", "error", dat.api_comment); }
|
|
|
}
|
|
|
|
|
|
else if (extra["ui_function"] === "group") {
|
|
|
@@ -304,6 +318,19 @@ function _get_select_id(fid) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+function _set_select_by_id(fid, id) {
|
|
|
+ var ele = document.getElementById(fid);
|
|
|
+ if (!ele) { return; }
|
|
|
+
|
|
|
+ var n = ele.options.length;
|
|
|
+ for (var idx=0; idx<n; idx++) {
|
|
|
+ if (ele.options[idx].id == "id") {
|
|
|
+ ele.selectedIndex = idx;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function _date_only(s) {
|
|
|
if (!s) { return s; }
|
|
|
if (s.length > 0) {
|
|
|
@@ -897,6 +924,37 @@ function reissue_card_fill(card_data) {
|
|
|
// --------------------------------------
|
|
|
// --------------------------------------
|
|
|
|
|
|
+function ui_pending_showload(qid) {
|
|
|
+ var ele = document.getElementById("ui.process.process");
|
|
|
+ ele.style.display = 'block';
|
|
|
+}
|
|
|
+
|
|
|
+function ui_pending_hideload(qid) {
|
|
|
+ var ele = document.getElementById("ui.process.process");
|
|
|
+ ele.style.display = 'none';
|
|
|
+}
|
|
|
+
|
|
|
+function ui_pending_process() {
|
|
|
+ var ele = document.getElementById("ui.pending.org_card_order_queue_id");
|
|
|
+ var qid = ele.innerHTML;
|
|
|
+
|
|
|
+ console.log(">>>", qid);
|
|
|
+
|
|
|
+ var dat = {
|
|
|
+ "api_function":"Pending",
|
|
|
+ "ui_function":"pending.processed",
|
|
|
+ "data": [
|
|
|
+ ["action", "process"],
|
|
|
+ ["org_card_order_queue_id", qid]
|
|
|
+ ]};
|
|
|
+ api_req(dat);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function ui_pending_load(qid) {
|
|
|
+ _redirect( "process_pending_card?org_card_order_queue_id=" + qid);
|
|
|
+}
|
|
|
+
|
|
|
function _html_pending_card(qid, cardid, magid, rfid, idx) {
|
|
|
idx = ((typeof idx === "undefined") ? 0 : idx);
|
|
|
magid = ((typeof magid === "undeifned") ? "" : (magid ? magid : ""))
|
|
|
@@ -910,26 +968,148 @@ function _html_pending_card(qid, cardid, magid, rfid, idx) {
|
|
|
row.classList.add("row-shade");
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ <div class='col-2'>
|
|
|
+ <button type='button' class='btn btn-secondary btn-sm'>Load</button>
|
|
|
+ </div>
|
|
|
+ */
|
|
|
+
|
|
|
+ cell = document.createElement("div");
|
|
|
+ cell.innerHTML = "<button type='button' class='btn btn-secondary btn-sm' onclick='ui_pending_load(" + qid + ");'>Load</button>";
|
|
|
+ cell.classList.add("col-3");
|
|
|
+ row.appendChild(cell);
|
|
|
+
|
|
|
+
|
|
|
cell = document.createElement("div");
|
|
|
cell.innerHTML = "<a href='/process_pending_card?org_card_order_queue_id=" + qid+ "'>" + cardid + "</a>";
|
|
|
- cell.classList.add("col-4");
|
|
|
+ cell.classList.add("col-3");
|
|
|
row.appendChild(cell);
|
|
|
|
|
|
cell = document.createElement("div");
|
|
|
cell.innerHTML = "<a href='/process_pending_card?org_card_order_queue_id=" + qid + "'>" + magid + "</a>";
|
|
|
- cell.classList.add("col-4");
|
|
|
+ cell.classList.add("col-3");
|
|
|
row.appendChild(cell);
|
|
|
|
|
|
cell = document.createElement("div");
|
|
|
cell.innerHTML = "<a href='/process_pending_card?org_card_order_queue_id=" + qid + "'>" + rfid + "</a>";
|
|
|
+ cell.classList.add("col-3");
|
|
|
+ row.appendChild(cell);
|
|
|
+
|
|
|
+ return row;
|
|
|
+}
|
|
|
+
|
|
|
+function _html_pass(data, idx) {
|
|
|
+ idx = ((typeof idx === "undefined") ? 0 : idx);
|
|
|
+ var row, cell;
|
|
|
+
|
|
|
+ row = document.createElement("div");
|
|
|
+ row.classList.add("row");
|
|
|
+ row.classList.add("rowpop");
|
|
|
+ if ((idx % 2) == 0) {
|
|
|
+ row.classList.add("row-shade");
|
|
|
+ }
|
|
|
+
|
|
|
+ var pass_type = "";
|
|
|
+ var pass_val = '';
|
|
|
+ var pass_rule = '';
|
|
|
+ if ("rule" in data) {
|
|
|
+ pass_rule = data.rule;
|
|
|
+ if (data.rule.match(/NRIDE/)) {
|
|
|
+ pass_type = "NRide";
|
|
|
+ pass_val = data.nrides_remain;
|
|
|
+ }
|
|
|
+ else if (data.rule.match(/NDAY/)) {
|
|
|
+ pass_type = "NDay";
|
|
|
+ pass_val = data.nday_orig;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ pass_type = "Other";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ cell = document.createElement("div");
|
|
|
+ cell.innerHTML = pass_type;
|
|
|
+ cell.classList.add("col-4");
|
|
|
+ row.appendChild(cell);
|
|
|
+
|
|
|
+ cell = document.createElement("div");
|
|
|
+ cell.innerHTML = pass_val;
|
|
|
+ cell.classList.add("col-4");
|
|
|
+ row.appendChild(cell);
|
|
|
+
|
|
|
+ cell = document.createElement("div");
|
|
|
+ cell.innerHTML = pass_rule;
|
|
|
cell.classList.add("col-4");
|
|
|
row.appendChild(cell);
|
|
|
|
|
|
return row;
|
|
|
}
|
|
|
|
|
|
+function ui_pending_clear() {
|
|
|
+ console.log("ui_pending_clear:");
|
|
|
+ var ui_pfx = "ui.pending.";
|
|
|
+ var card_fields = [
|
|
|
+ "mag_token", "rfid_token", "logical_card_id", "username", "first_name", "last_name",
|
|
|
+ "email", "phone", "address", "city", "state", "zip",
|
|
|
+ "shipping_name", "shipping_address", "shipping_city",
|
|
|
+ "shipping_state", "shipping_zip" ];
|
|
|
+
|
|
|
+ _fill_input_field(ui_pfx + "org_card_order_queue_id", "");
|
|
|
+ for (var idx=0; idx<card_fields.length; idx++) {
|
|
|
+ var key = card_fields[idx];
|
|
|
+ var ui_id = ui_pfx + key;
|
|
|
+ _fill_input_field(ui_id, "");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function ui_pending_fill(data) {
|
|
|
+ console.log("ui_pending_fill:", data);
|
|
|
+ var ui_pfx = "ui.pending.";
|
|
|
+
|
|
|
+ var card_fields = [
|
|
|
+ "mag_token", "rfid_token", "logical_card_id", "username", "first_name", "last_name",
|
|
|
+ "email", "phone", "address", "city", "state", "zip",
|
|
|
+ "shipping_name", "shipping_address", "shipping_city",
|
|
|
+ "shipping_state", "shipping_zip" ];
|
|
|
+
|
|
|
+
|
|
|
+ _fill_input_field(ui_pfx + "org_card_order_queue_id", data.pending_card["org_card_order_queue_id"]);
|
|
|
+
|
|
|
+ if ("cardinfo" in data) {
|
|
|
+ for (var idx=0; idx<card_fields.length; idx++) {
|
|
|
+ var key = card_fields[idx];
|
|
|
+ var ui_id = ui_pfx + key;
|
|
|
+
|
|
|
+ if (key in data.cardinfo) {
|
|
|
+ _fill_input_field(ui_id, data.cardinfo[key]);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ _fill_input_field(ui_id, "");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("group_id" in data.cardinfo) {
|
|
|
+ _set_select_by_id(ui_pfx + "group", data.cardinfo.group_id);
|
|
|
+ }
|
|
|
+
|
|
|
+ var pass_row = document.getElementById(ui_pfx + "passes");
|
|
|
+ while (pass_row.firstChild) {
|
|
|
+ pass_row.removeChild(pass_row.lastChild);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (var pass_idx=0; pass_idx < data.cardinfo.pass.length; pass_idx++) {
|
|
|
+ var _r = _html_pass(data.cardinfo.pass[pass_idx], pass_idx);
|
|
|
+ pass_row.appendChild( _r );
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
-function ui_pending_list(data) {
|
|
|
+function ui_pending_list_cards(data) {
|
|
|
console.log("pending", data);
|
|
|
|
|
|
var div_card_list = document.getElementById("ui.pending.cards");
|
|
|
@@ -1520,15 +1700,30 @@ function admin_api_init() {
|
|
|
}
|
|
|
|
|
|
else if (_func === "process_pending_card") {
|
|
|
- _attach_button( "ui.process.", (function() { return ui_pending("xxx"); }) );
|
|
|
-
|
|
|
- api_req({
|
|
|
- "api_function":"Pending",
|
|
|
- "ui_function":"pending.list",
|
|
|
- "data": [
|
|
|
- ["action","getall"]
|
|
|
- ]
|
|
|
- });
|
|
|
+ _attach_button( "ui.process.process", (function() { return ui_pending_process(); }) );
|
|
|
+
|
|
|
+ if ("org_card_order_queue_id" in _h) {
|
|
|
+
|
|
|
+ console.log("cp", _h["org_card_order_queue_id"]);
|
|
|
+
|
|
|
+ api_req({
|
|
|
+ "api_function":"Pending",
|
|
|
+ "ui_function":"pending.populate",
|
|
|
+ "data": [
|
|
|
+ ["action","get"],
|
|
|
+ ["org_card_order_queue_id",_h["org_card_order_queue_id"] ]
|
|
|
+ ]
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ api_req({
|
|
|
+ "api_function":"Pending",
|
|
|
+ "ui_function":"pending.list",
|
|
|
+ "data": [
|
|
|
+ ["action","getall"]
|
|
|
+ ]
|
|
|
+ });
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|