Allow "override once per patron" at checkout
authorThomas Berezansky <tsbere@mvlc.org>
Mon, 18 Jul 2011 15:35:08 +0000 (11:35 -0400)
committerJason Etheridge <jason@esilibrary.com>
Wed, 10 Aug 2011 18:06:14 +0000 (14:06 -0400)
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 <tsbere@mvlc.org>
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/xul/staff_client/chrome/content/util/network.js
Open-ILS/xul/staff_client/server/circ/checkout.js

index 4fcca50..2b716d8 100644 (file)
@@ -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) {
index 53a4b0d..8e34752 100644 (file)
@@ -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 );