From: erickson Date: Thu, 31 Jul 2008 16:44:18 +0000 (+0000) Subject: if a patron barcode regex is configured and a patron barcode is scanned into the... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=89518a1d9bc4c70044d5bb48bb9bf84b0b6cec2f;p=Evergreen.git 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 git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2@10224 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/opac/extras/selfcheck/selfcheck.js b/Open-ILS/web/opac/extras/selfcheck/selfcheck.js index 61140b335c..dd84dd1f63 100644 --- a/Open-ILS/web/opac/extras/selfcheck/selfcheck.js +++ b/Open-ILS/web/opac/extras/selfcheck/selfcheck.js @@ -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 printTemplate; var successfulItems = {}; var scanTimeout = 800; var scanTimeoutId; +var patronBarcodeRegex; function selfckInit() { @@ -43,6 +45,9 @@ function selfckInit() { 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,9 +74,20 @@ function selfckInit() { 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)) { @@ -165,6 +181,21 @@ function selfckPatronLogin(barcode) { } /** + * 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 @@ function selfckCheckout() { 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();