From 3e12a18f2cc2af491ddfe4ccb812cd2024b6dbb4 Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Mon, 18 Jul 2011 11:35:08 -0400 Subject: [PATCH] Allow "override once per patron" at checkout Specifically for patron-derived overrides: PATRON_EXCEEDS_OVERDUE_COUNT PATRON_BARRED PATRON_EXCEEDS_CHECKOUT_COUNT PATRON_EXCEEDS_FINES This is done by: Adding support for a list of "reported" overrides to util/network.js Using that in Checkout to build an auto-override list for the current patron Passing that list in at Checkout Signed-off-by: Thomas Berezansky Signed-off-by: Jason Etheridge --- .../staff_client/chrome/content/util/network.js | 24 +++++++++++++++++++++- Open-ILS/xul/staff_client/server/circ/checkout.js | 13 +++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/util/network.js b/Open-ILS/xul/staff_client/chrome/content/util/network.js index 4fcca5098f..2b716d8595 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/network.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/network.js @@ -49,7 +49,14 @@ util.network.prototype = { if (req.cancelled) { result = fake_ilsevent_for_network_errors; } else { - result = req.getResultObject(); + result = req.getResultObject(); + if(result && req._reported_events) { + if(typeof result.ilsevent != 'undefined') { + result._reported_events = req._reported_events; + } else { + result[0]._reported_events = req._reported_events; + } + } } } catch(E) { try { @@ -449,6 +456,7 @@ util.network.prototype = { try { if (!override_params.text) override_params.text = {}; if (!override_params.auto_override_these_events) override_params.auto_override_these_events = []; + if (!override_params.report_override_on_events) override_params.report_override_on_events = []; function override(r) { try { // test to see if we can suppress this dialog and auto-override @@ -507,6 +515,20 @@ util.network.prototype = { ); if (fancy_prompt_data.fancy_status == 'complete') { req = obj._request(app,name + '.override',params); + if (req && override_params.report_override_on_events.length > 0 && typeof result == 'object') { + var reported_events = []; + for (var i = 0; i < r.length; i++) { + if (typeof r[i].ilsevent != 'undefined') { + if (override_params.report_override_on_events.indexOf( r[i].ilsevent == null ? null : Number(r[i].ilsevent) ) != -1) { + reported_events.push(Number(r[i].ilsevent)); + } + if (override_params.report_override_on_events.indexOf( r[i].textcode ) != -1) { + reported_events.push(r[i].textcode); + } + } + } + req._reported_events = reported_events; + } } return req; } catch(E) { diff --git a/Open-ILS/xul/staff_client/server/circ/checkout.js b/Open-ILS/xul/staff_client/server/circ/checkout.js index 53a4b0d546..8e34752fa4 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkout.js +++ b/Open-ILS/xul/staff_client/server/circ/checkout.js @@ -18,6 +18,8 @@ circ.checkout.prototype = { obj.patron_id = params.patron_id; + obj.auto_override_events = []; + JSAN.use('circ.util'); var columns = circ.util.columns( { @@ -653,6 +655,13 @@ circ.checkout.prototype = { 7016 /* ITEM_ON_HOLDS_SHELF */, 7013 /* PATRON_EXCEEDS_FINES */ ], + 'report_override_on_events' : [ /* Allow auto-override of Patron overrides only */ + 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */, + 1213 /* PATRON_BARRED */, + 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */, + 7013 /* PATRON_EXCEEDS_FINES */ + ], + 'auto_override_these_events' : obj.auto_override_events, 'text' : { '1232' : function(r) { return document.getElementById('circStrings').getString('staff.circ.checkout.override.item_deposit_required.warning'); @@ -697,7 +706,9 @@ circ.checkout.prototype = { /**********************************************************************************************************************/ /* Normal case, proceed with checkout */ if (permit.ilsevent === '0') { - + if(permit._reported_events != 'undefined') { + obj.auto_override_events = obj.auto_override_events.concat(permit._reported_events); + } JSAN.use('util.sound'); var sound = new util.sound(); sound.circ_good(); params.permit_key = permit.payload; obj._checkout( params, permit ); -- 2.11.0