checkdigit test
authorpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 23 Oct 2006 18:56:40 +0000 (18:56 +0000)
committerpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 23 Oct 2006 18:56:40 +0000 (18:56 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@6500 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/circ/checkin.js
Open-ILS/xul/staff_client/server/circ/checkout.js
Open-ILS/xul/staff_client/server/circ/copy_status.js
Open-ILS/xul/staff_client/server/circ/in_house_use.js
Open-ILS/xul/staff_client/server/skin/media/images/bad_barcode.png [new file with mode: 0644]

index 81a2d12..6cc903a 100644 (file)
@@ -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;
index dc4fc5f..2087418 100644 (file)
@@ -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 */
index 7247087..4e05a6d 100644 (file)
@@ -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) {
index 83d2eeb..0589aa3 100644 (file)
@@ -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 (file)
index 0000000..e5acc55
Binary files /dev/null and b/Open-ILS/xul/staff_client/server/skin/media/images/bad_barcode.png differ