From 759509512d56a232743dc6379953c8bc7c3448c4 Mon Sep 17 00:00:00 2001 From: phasefx Date: Mon, 7 Aug 2006 14:16:18 +0000 Subject: [PATCH] disable checkout interface on inactive/barred/expired or retrieved by inactive card. lingering bug where you have to hit Refresh after editing patron to get the checkout disable to toggle git-svn-id: svn://svn.open-ils.org/ILS/trunk@5328 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/xul/staff_client/server/circ/checkout.js | 24 +++++++++++++ Open-ILS/xul/staff_client/server/circ/checkout.xul | 4 +++ Open-ILS/xul/staff_client/server/patron/display.js | 40 +++++++++++++++++++--- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/circ/checkout.js b/Open-ILS/xul/staff_client/server/circ/checkout.js index c57006a7e9..7cfe58ce7a 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkout.js +++ b/Open-ILS/xul/staff_client/server/circ/checkout.js @@ -195,6 +195,30 @@ circ.checkout.prototype = { this.controller.render(); this.controller.view.checkout_barcode_entry_textbox.focus(); + this.check_disable(); + + }, + + 'check_disable' : function() { + var obj = this; + try { + if (typeof xulG.check_stop_checkouts == 'function') { + var disable = xulG.check_stop_checkouts(); + if (disable) { + document.getElementById('checkout_submit_barcode_button').disabled = true; + document.getElementById('checkout_done').disabled = true; + obj.controller.view.checkout_menu.disabled = true; + obj.controller.view.checkout_barcode_entry_textbox.disabled = true; + } else { + document.getElementById('checkout_submit_barcode_button').disabled = false; + document.getElementById('checkout_done').disabled = false; + obj.controller.view.checkout_menu.disabled = false; + obj.controller.view.checkout_barcode_entry_textbox.disabled = false; + } + } + } catch(E) { + obj.error.standard_unexpected_error_alert('Error determining whether to disable checkout.',E); + } }, 'print' : function(silent,f) { diff --git a/Open-ILS/xul/staff_client/server/circ/checkout.xul b/Open-ILS/xul/staff_client/server/circ/checkout.xul index 9164ad637b..0369414da3 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkout.xul +++ b/Open-ILS/xul/staff_client/server/circ/checkout.xul @@ -69,6 +69,10 @@ } } + function refresh() { + g.checkout.check_disable(); + } + ]]> diff --git a/Open-ILS/xul/staff_client/server/patron/display.js b/Open-ILS/xul/staff_client/server/patron/display.js index d1247acb97..5fc51400ec 100644 --- a/Open-ILS/xul/staff_client/server/patron/display.js +++ b/Open-ILS/xul/staff_client/server/patron/display.js @@ -12,6 +12,8 @@ patron.display = function (params) { patron.display.prototype = { 'retrieve_ids' : [], + 'stop_checkouts' : false, + 'check_stop_checkouts' : function() { return this.stop_checkouts; }, 'init' : function( params ) { @@ -28,12 +30,13 @@ patron.display.prototype = { obj.left_deck = new util.deck('patron_left_deck'); function spawn_checkout_interface() { - obj.right_deck.set_iframe( + var frame = obj.right_deck.set_iframe( urls.XUL_CHECKOUT, {}, { 'set_tab' : xulG.set_tab, 'patron_id' : obj.patron.id(), + 'check_stop_checkouts' : function() { return obj.check_stop_checkouts(); }, 'on_list_change' : function(checkout) { /* this stops noncats from getting pushed into Items Out */ @@ -56,6 +59,8 @@ patron.display.prototype = { } } ); + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + obj.checkout_window = frame.contentWindow; } JSAN.use('util.controller'); obj.controller = new util.controller(); @@ -344,7 +349,7 @@ patron.display.prototype = { [ ses(), patron.id() ], function(req) { try { - var msg = ''; + var msg = ''; obj.stop_checkouts = false; if (patron.alert_message()) msg += '"' + patron.alert_message() + '"\n'; //alert('obj.barcode = ' + obj.barcode); if (obj.barcode) { @@ -352,11 +357,18 @@ patron.display.prototype = { //alert('card #'+i+' == ' + js2JSON(patron.cards()[i])); if ( (patron.cards()[i].barcode()==obj.barcode) && ( ! get_bool(patron.cards()[i].active()) ) ) { msg += 'Patron retrieved with an INACTIVE barcode.\n'; + obj.stop_checkouts = true; } } } - if (get_bool(patron.barred())) msg += 'Patron is BARRED.\n'; - if (!get_bool(patron.active())) msg += 'Patron is INACTIVE.\n'; + if (get_bool(patron.barred())) { + msg += 'Patron is BARRED.\n'; + obj.stop_checkouts = true; + } + if (!get_bool(patron.active())) { + msg += 'Patron is INACTIVE.\n'; + obj.stop_checkouts = true; + } if (patron.expire_date()) { var now = new Date(); now = now.getTime()/1000; @@ -368,10 +380,28 @@ patron.display.prototype = { expire.setFullYear(expire_parts[0], expire_parts[1], expire_parts[2]); expire = expire.getTime()/1000 - if (expire < now) msg += 'Patron is EXPIRED.\n'; + if (expire < now) { + msg += 'Patron is EXPIRED.\n'; + obj.stop_checkouts = true; + } } var holds = req.getResultObject(); if (holds.ready && holds.ready > 0) msg += 'Holds available: ' + holds.ready; + if (obj.stop_checkouts && obj.checkout_window) { + setTimeout( function() { + try { + if ( + obj.checkout_window && + obj.checkout_window.g && + obj.checkout_window.g.checkout && + typeof obj.checkout_window.g.check_disable == 'function') { + obj.checkout_window.g.checkout.check_disable(); + } + } catch(E) { + alert(E); + } + }, 0); + } if (msg) { obj.error.yns_alert(msg,'Alert Message','OK',null,null,'Check here to confirm this message.'); } -- 2.11.0