[open-ils-commits] r15005 - in trunk/Open-ILS/web/js: dojo/openils/circ/nls ui/default/circ/selfcheck (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Nov 23 11:41:29 EST 2009


Author: erickson
Date: 2009-11-23 11:41:27 -0500 (Mon, 23 Nov 2009)
New Revision: 15005

Modified:
   trunk/Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js
   trunk/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js
Log:
plugged in support for auto-renew-age checking.  more event handling.  self-check should now be functionally equivalent to the old self-check as far as checkout/renewal goes.  still needs receipts, etc.

Modified: trunk/Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js	2009-11-23 15:45:34 UTC (rev 15004)
+++ trunk/Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js	2009-11-23 16:41:27 UTC (rev 15005)
@@ -9,6 +9,7 @@
     'CHECKOUT_SUCCESS' : 'Checkout of item ${0} succeeded',
     'RENEW_SUCCESS' : 'Renewal of item ${0} succeeded',
     'ALREADY_OUT' : 'Item ${0} is already checked out',
+    'OPEN_CIRCULATION_EXISTS' : 'Item ${0} is already checked out to another user',
     'GENERIC_CIRC_FAILURE' : 'Unable to check out item ${0}.  Please see staff.',
     'LOGIN_FAILED' : 'Login for ${0} failed',
     'UNKNOWN_ERROR' : 'An unhandled exception occurred with error code ${0}',

Modified: trunk/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js	2009-11-23 15:45:34 UTC (rev 15004)
+++ trunk/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js	2009-11-23 16:41:27 UTC (rev 15005)
@@ -15,6 +15,7 @@
 const SET_ALERT_ON_CHECKOUT_EVENT = 'circ.selfcheck.alert_on_checkout_event';
 const SET_AUTO_OVERRIDE_EVENTS = 'circ.selfcheck.auto_override_checkout_events';
 const SET_PATRON_PASSWORD_REQUIRED = 'circ.selfcheck.patron_password_required';
+const SET_AUTO_RENEW_INTERVAL = 'circ.checkout_auto_renew_age';
 
 //openils.Util.playAudioUrl('/xul/server/skin/media/audio/bonus.wav');
 
@@ -108,6 +109,8 @@
             SET_PATRON_TIMEOUT,
             SET_ALERT_ON_CHECKOUT_EVENT,
             SET_AUTO_OVERRIDE_EVENTS,
+            SET_PATRON_PASSWORD_REQUIRED,
+            SET_AUTO_RENEW_INTERVAL,
         ]
     );
 
@@ -476,12 +479,13 @@
         ]}
     );
 
+    console.log(js2JSON(result));
+
     var stat = this.handleXactResult('checkout', barcode, result);
 
     if(stat.override) {
         this.checkout(barcode, true);
     } else if(stat.renew) {
-        // TODO check org setting for auto-renewal interval
         this.renew(barcode);
     }
 }
@@ -490,8 +494,11 @@
 SelfCheckManager.prototype.handleXactResult = function(action, item, result) {
 
     var displayText = '';
-    var popup = false;
 
+    // If true, the display message is important enough to pop up.  Whether or not
+    // an alert() actually occurs, depends on org unit settings
+    var popup = false;  
+
     // TODO handle lost/missing/etc checkin+checkout override steps
         
     if(result.textcode == 'NO_SESSION') {
@@ -517,8 +524,37 @@
 
     } else if(result.textcode == 'OPEN_CIRCULATION_EXISTS' && action == 'checkout') {
 
-        return { renew : true };
+        // Server says the item is already checked out.  If it's checked out to the
+        // current user, we may need to renew it.  
 
+        var payload = result.payload || {};
+
+        if(payload.old_circ) { 
+
+            /*
+            old_circ refers to the previous checkout IFF it's for the same user. 
+            If no auto-renew interval is not defined, assume we should renew it
+            If an auto-renew interval is defined and the payload comes back with
+            auto_renew set to true, do the renewal.  Otherwise, let the patron know
+            the item is already checked out to them.  */
+
+            if( !this.orgSettings[SET_AUTO_RENEW_INTERVAL] ||
+                (this.orgSettings[SET_AUTO_RENEW_INTERVAL] && payload.auto_renew) ) {
+                return { renew : true };
+            }
+
+            popup = true;
+            displayText = dojo.string.substitute(localeStrings.ALREADY_OUT, [item]);
+
+        } else {
+            
+            // item is checked out to some other user
+            popup = true;
+            displayText = dojo.string.substitute(localeStrings.OPEN_CIRCULATION_EXISTS, [item]);
+        }
+
+        this.updateScanBox({select:true});
+
     } else {
 
         var overrideEvents = this.orgSettings[SET_AUTO_OVERRIDE_EVENTS];
@@ -567,9 +603,9 @@
                     localeStrings.ITEM_NOT_CATALOGED, [item]);
                 break;
 
-            case 'already-out' : 
+            case 'OPEN_CIRCULATION_EXISTS' :
                 displayText = dojo.string.substitute(
-                    localeStrings.ALREADY_OUT, [item]);
+                    localeStrings.OPEN_CIRCULATION_EXISTS, [item]);
                 break;
 
             default:
@@ -616,6 +652,8 @@
         ]}
     );
 
+    console.log(js2JSON(result));
+
     var stat = this.handleXactResult('renew', barcode, result);
 
     if(stat.override)



More information about the open-ils-commits mailing list