added support for selecting individual copy statuses that will prevent checkout at...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 20 Jul 2010 21:15:59 +0000 (21:15 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 20 Jul 2010 21:15:59 +0000 (21:15 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16990 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/0344.data.sc_copy_status_block_setting.sql [new file with mode: 0644]
Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js

index 08bd34c..6c92fac 100644 (file)
@@ -68,7 +68,7 @@ CREATE TABLE config.upgrade_log (
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0343'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0344'); -- berick
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
index 066058b..0340144 100644 (file)
@@ -5928,3 +5928,21 @@ INSERT INTO config.usr_setting_type (name, opac_visible, label, description, dat
         'string'
     );
 
+INSERT INTO config.org_unit_setting_type (name, label, description, datatype) 
+    VALUES (
+        'circ.selfcheck.block_checkout_on_copy_status',
+        oils_i18n_gettext(
+            'circ.selfcheck.block_checkout_on_copy_status',
+            'Selfcheck: Block copy checkout status',
+            'coust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'circ.selfcheck.block_checkout_on_copy_status',
+            'List of copy status IDs that will block checkout even if the generic COPY_NOT_AVAILABLE event is overridden',
+            'coust',
+            'description'
+        ),
+        'array'
+    );
+
diff --git a/Open-ILS/src/sql/Pg/upgrade/0344.data.sc_copy_status_block_setting.sql b/Open-ILS/src/sql/Pg/upgrade/0344.data.sc_copy_status_block_setting.sql
new file mode 100644 (file)
index 0000000..7782a64
--- /dev/null
@@ -0,0 +1,23 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0344');
+
+INSERT INTO config.org_unit_setting_type (name, label, description, datatype) 
+    VALUES (
+        'circ.selfcheck.block_checkout_on_copy_status',
+        oils_i18n_gettext(
+            'circ.selfcheck.block_checkout_on_copy_status',
+            'Selfcheck: Block copy checkout status',
+            'coust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'circ.selfcheck.block_checkout_on_copy_status',
+            'List of copy status IDs that will block checkout even if the generic COPY_NOT_AVAILABLE event is overridden',
+            'coust',
+            'description'
+        ),
+        'array'
+    );
+
+COMMIT;
index a4d061b..a9f2ec6 100644 (file)
@@ -22,6 +22,8 @@ const SET_WORKSTATION_REQUIRED = 'circ.selfcheck.workstation_required';
 const SET_ALERT_POPUP = 'circ.selfcheck.alert.popup';
 const SET_ALERT_SOUND = 'circ.selfcheck.alert.sound';
 const SET_CC_PAYMENT_ALLOWED = 'credit.payments.allow';
+// This setting only comes into play if COPY_NOT_AVAILABLE is in the SET_AUTO_OVERRIDE_EVENTS list
+const SET_BLOCK_CHECKOUT_ON_COPY_STATUS = 'circ.selfcheck.block_checkout_on_copy_status';
 
 function SelfCheckManager() {
 
@@ -243,6 +245,7 @@ SelfCheckManager.prototype.loadOrgSettings = function() {
             SET_ALERT_POPUP,
             SET_ALERT_SOUND,
             SET_AUTO_OVERRIDE_EVENTS,
+            SET_BLOCK_CHECKOUT_ON_COPY_STATUS,
             SET_PATRON_PASSWORD_REQUIRED,
             SET_AUTO_RENEW_INTERVAL,
             SET_WORKSTATION_REQUIRED,
@@ -877,7 +880,7 @@ SelfCheckManager.prototype.checkout = function(barcode, override) {
     console.log("Checkout out item " + barcode + " with method " + method);
 
     var result = fieldmapper.standardRequest(
-        ['open-ils.circ', 'open-ils.circ.checkout.full'],
+        ['open-ils.circ', method],
         {params: [
             this.authtoken, {
                 patron_id : this.patron.id(),
@@ -917,6 +920,7 @@ SelfCheckManager.prototype.handleXactResult = function(action, item, result) {
     var sound = ''; // sound file reference
     var payload = result.payload || {};
     var overrideEvents = this.orgSettings[SET_AUTO_OVERRIDE_EVENTS];
+    var blockStatuses = this.orgSettings[SET_BLOCK_CHECKOUT_ON_COPY_STATUS];
         
     if(result.textcode == 'NO_SESSION') {
 
@@ -1006,13 +1010,27 @@ SelfCheckManager.prototype.handleXactResult = function(action, item, result) {
     
             var override = true;
             for(var i = 0; i < result.length; i++) {
-                var match = overrideEvents.filter(
-                    function(e) { return (e == result[i].textcode); })[0];
+
+                var match = overrideEvents.filter(function(e) { return (e == result[i].textcode); })[0];
+
                 if(!match) {
                     override = false;
                     break;
                 }
 
+                if(result[i].textcode == 'COPY_NOT_AVAILABLE' && blockStatuses && blockStatuses.length) {
+
+                    var stat = result[i].payload.status(); // copy status
+                    if(typeof stat == 'object') stat = stat.id();
+
+                    var match2 = blockStatuses.filter(function(e) { return (e == stat); })[0];
+
+                    if(match2) { // copy is in a blocked status
+                        override = false;
+                        break;
+                    }
+                }
+
                 if(result[i].textcode == 'COPY_IN_TRANSIT') {
                     // to override a transit, we have to abort the transit and check it in first
                     if(this.checkin(item, true)) {
@@ -1020,7 +1038,6 @@ SelfCheckManager.prototype.handleXactResult = function(action, item, result) {
                     } else {
                         override = false;
                     }
-
                 }
             }