[open-ils-commits] r10224 - branches/rel_1_2/Open-ILS/web/opac/extras/selfcheck

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Jul 31 12:44:25 EDT 2008


Author: erickson
Date: 2008-07-31 12:44:18 -0400 (Thu, 31 Jul 2008)
New Revision: 10224

Modified:
   branches/rel_1_2/Open-ILS/web/opac/extras/selfcheck/selfcheck.js
Log:
if a patron barcode regex is configured and a patron barcode is scanned into the item barcode input, the current user is logged out and the new user is logged in

Modified: branches/rel_1_2/Open-ILS/web/opac/extras/selfcheck/selfcheck.js
===================================================================
--- branches/rel_1_2/Open-ILS/web/opac/extras/selfcheck/selfcheck.js	2008-07-31 16:28:30 UTC (rev 10223)
+++ branches/rel_1_2/Open-ILS/web/opac/extras/selfcheck/selfcheck.js	2008-07-31 16:44:18 UTC (rev 10224)
@@ -19,6 +19,7 @@
 ----------------------------------------------------------------- */
 
 var STAFF_SES_PARAM = 'ses';
+var PATRON_BARCODE_COOKIE = 'pbcc';
 var patron = null
 var itemBarcode = null;
 var itemsOutTemplate = null;
@@ -31,6 +32,7 @@
 var successfulItems = {};
 var scanTimeout = 800;
 var scanTimeoutId;
+var patronBarcodeRegex;
 
 
 function selfckInit() {
@@ -43,6 +45,9 @@
     patronTimeout = (t) ? parseInt(t) * 1000 : patronTimeout;
     */
 
+    var reg = fetchOrgSettingDefault(globalOrgTree.id(), 'opac.barcode_regex');
+    if(reg) patronBarcodeRegex = new RegExp(reg);
+
     if(!staff) {
         // should not happen when behind the proxy
         return alert('Staff must login');
@@ -69,10 +74,21 @@
     printTemplate = printWrapper.removeChild($n(printWrapper, 'selfck-print-items-template'));
     itemsOutTemplate = $('selfck-items-out-tbody').removeChild($('selfck-items-out-row'));
 
+    selfckTryPatronCookie();
+
 //    selfckMkDummyCirc(); // testing only
 }
 
+function selfckTryPatronCookie() {
+    var pb = cookieManager.read(PATRON_BARCODE_COOKIE);
+    if(pb) {
+        cookieManager.write(PATRON_BARCODE_COOKIE, '');
+        $('selfck-patron-login-input').value = pb;
+        selfckPatronLogin();
+    }
+}
 
+
 function selfckItemBarcodeKeypress(evt) {
     if(userPressedEnter(evt)) {
         clearTimeout(scanTimeoutId);
@@ -165,6 +181,21 @@
 }
 
 /**
+  * If a user barcode was scanned into the item barcode
+  * input, log out the current user and log in the new user
+  */
+function selfckCheckPatronBarcode(itemBc) {
+    if(patronBarcodeRegex) {
+        if(itemBc.match(patronBarcodeRegex)) {
+            cookieManager.write(PATRON_BARCODE_COOKIE, itemBc, -1);
+            selfckLogoutPatron();
+            return true;
+        }
+    }
+    return false;
+}
+
+/**
   * Sends the checkout request
   */
 function selfckCheckout() {
@@ -179,6 +210,9 @@
     itemBarcode = $('selfck-item-barcode-input').value;
     if(!itemBarcode) return;
 
+    if(selfckCheckPatronBarcode(itemBarcode))
+        return;
+
     if (itemBarcode in successfulItems) {
         selfckShowMsgNode({textcode:'dupe-barcode'});
         $('selfck-item-barcode-input').select();



More information about the open-ils-commits mailing list