From: pines Date: Mon, 23 Oct 2006 18:56:40 +0000 (+0000) Subject: checkdigit test X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=63f692b64f16c55e148452264e94a44ac9e4ab3d;p=evergreen%2Fpines.git checkdigit test git-svn-id: svn://svn.open-ils.org/ILS/trunk@6500 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/xul/staff_client/server/circ/checkin.js b/Open-ILS/xul/staff_client/server/circ/checkin.js index 81a2d129df..6cc903a381 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkin.js +++ b/Open-ILS/xul/staff_client/server/circ/checkin.js @@ -5,6 +5,7 @@ circ.checkin = function (params) { JSAN.use('util.error'); this.error = new util.error(); JSAN.use('util.network'); this.network = new util.network(); + JSAN.use('util.barcode'); JSAN.use('util.date'); this.OpenILS = {}; JSAN.use('OpenILS.data'); this.OpenILS.data = new OpenILS.data(); this.OpenILS.data.init({'via':'stash'}); this.data = this.OpenILS.data; @@ -261,11 +262,36 @@ circ.checkin.prototype = { }, + 'test_barcode' : function(bc) { + var obj = this; + var good = util.barcode.check(bc); + if (good) { + return true; + } else { + if ( 1 == obj.error.yns_alert( + 'Bad checkdigit; possible mis-scan. Use this barcode ("' + bc + '") anyway?', + 'Bad Barcode', + 'Cancel', + 'Accept Barcode', + null, + 'Check here to confirm this action', + '/xul/server/skin/media/images/bad_barcode.png' + ) ) { + return true; + } else { + return false; + } + } + }, + 'checkin' : function() { var obj = this; try { var barcode = obj.controller.view.checkin_barcode_entry_textbox.value; if (!barcode) return; + if (barcode) { + if ( obj.test_barcode(barcode) ) { /* good */ } else { /* bad */ return; } + } var backdate = obj.controller.view.checkin_effective_date_textbox.value; var auto_print = document.getElementById('checkin_auto'); if (auto_print) auto_print = auto_print.checked; diff --git a/Open-ILS/xul/staff_client/server/circ/checkout.js b/Open-ILS/xul/staff_client/server/circ/checkout.js index dc4fc5f270..2087418737 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkout.js +++ b/Open-ILS/xul/staff_client/server/circ/checkout.js @@ -6,6 +6,7 @@ circ.checkout = function (params) { JSAN.use('util.error'); this.error = new util.error(); JSAN.use('util.network'); this.network = new util.network(); JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'}); + JSAN.use('util.barcode'); } circ.checkout.prototype = { @@ -415,6 +416,28 @@ circ.checkout.prototype = { } }, + 'test_barcode' : function(bc) { + var obj = this; + var good = util.barcode.check(bc); + if (good) { + return true; + } else { + if ( 1 == obj.error.yns_alert( + 'Bad checkdigit; possible mis-scan. Use this barcode ("' + bc + '") anyway?', + 'Bad Barcode', + 'Cancel', + 'Accept Barcode', + null, + 'Check here to confirm this action', + '/xul/server/skin/media/images/bad_barcode.png' + ) ) { + return true; + } else { + return false; + } + } + }, + 'checkout' : function(params) { var obj = this; @@ -427,6 +450,10 @@ circ.checkout.prototype = { if (! (params.barcode||params.noncat)) return; + if (params.barcode) { + if ( obj.test_barcode(params.barcode) ) { /* good */ } else { /* bad */ return; } + } + /**********************************************************************************************************************/ /* Permissibility test before checkout */ diff --git a/Open-ILS/xul/staff_client/server/circ/copy_status.js b/Open-ILS/xul/staff_client/server/circ/copy_status.js index 72470873f8..4e05a6dd9c 100644 --- a/Open-ILS/xul/staff_client/server/circ/copy_status.js +++ b/Open-ILS/xul/staff_client/server/circ/copy_status.js @@ -5,6 +5,7 @@ circ.copy_status = function (params) { JSAN.use('util.error'); this.error = new util.error(); JSAN.use('util.network'); this.network = new util.network(); + JSAN.use('util.barcode'); JSAN.use('util.date'); JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'}); } @@ -315,12 +316,37 @@ circ.copy_status.prototype = { }, + 'test_barcode' : function(bc) { + var obj = this; + var good = util.barcode.check(bc); + if (good) { + return true; + } else { + if ( 1 == obj.error.yns_alert( + 'Bad checkdigit; possible mis-scan. Use this barcode ("' + bc + '") anyway?', + 'Bad Barcode', + 'Cancel', + 'Accept Barcode', + null, + 'Check here to confirm this action', + '/xul/server/skin/media/images/bad_barcode.png' + ) ) { + return true; + } else { + return false; + } + } + }, + 'copy_status' : function(barcode) { var obj = this; try { try { document.getElementById('last_scanned').setAttribute('value',''); } catch(E) {} if (!barcode) barcode = obj.controller.view.copy_status_barcode_entry_textbox.value; if (!barcode) return; + if (barcode) { + if ( obj.test_barcode(barcode) ) { /* good */ } else { /* bad */ return; } + } JSAN.use('circ.util'); var copy = obj.network.simple_request( 'FM_ACP_RETRIEVE_VIA_BARCODE', [ barcode ]); if (copy == null) { diff --git a/Open-ILS/xul/staff_client/server/circ/in_house_use.js b/Open-ILS/xul/staff_client/server/circ/in_house_use.js index 83d2eebc9a..0589aa3de4 100644 --- a/Open-ILS/xul/staff_client/server/circ/in_house_use.js +++ b/Open-ILS/xul/staff_client/server/circ/in_house_use.js @@ -5,6 +5,7 @@ circ.in_house_use = function (params) { JSAN.use('util.error'); this.error = new util.error(); JSAN.use('util.network'); this.network = new util.network(); + JSAN.use('util.barcode'); JSAN.use('util.date'); JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'}); } @@ -197,12 +198,37 @@ circ.in_house_use.prototype = { }, + 'test_barcode' : function(bc) { + var obj = this; + var good = util.barcode.check(bc); + if (good) { + return true; + } else { + if ( 1 == obj.error.yns_alert( + 'Bad checkdigit; possible mis-scan. Use this barcode ("' + bc + '") anyway?', + 'Bad Barcode', + 'Cancel', + 'Accept Barcode', + null, + 'Check here to confirm this action', + '/xul/server/skin/media/images/bad_barcode.png' + ) ) { + return true; + } else { + return false; + } + } + }, + 'in_house_use' : function() { var obj = this; try { var barcode; if (obj.controller.view.in_house_use_menu.value == '' || obj.controller.view.in_house_use_menu.value == 'barcode') { barcode = obj.controller.view.in_house_use_barcode_entry_textbox.value; + if (barcode) { + if ( obj.test_barcode(barcode) ) { /* good */ } else { /* bad */ return; } + } } else { barcode = ( obj.controller.view.in_house_use_menu.value ); //barcode = obj.data.hash.cnct[ obj.controller.view.in_house_use_menu.value ].name() diff --git a/Open-ILS/xul/staff_client/server/skin/media/images/bad_barcode.png b/Open-ILS/xul/staff_client/server/skin/media/images/bad_barcode.png new file mode 100644 index 0000000000..e5acc55b4f Binary files /dev/null and b/Open-ILS/xul/staff_client/server/skin/media/images/bad_barcode.png differ