Prevent loans of items between patrons whose home library != copy's circulating library
authordbs <dbs@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sat, 2 May 2009 16:46:14 +0000 (16:46 +0000)
committerdbs <dbs@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sat, 2 May 2009 16:46:14 +0000 (16:46 +0000)
Exceptions are for patrons belonging to systems like Laurentian campus libraries

git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/trunk@433 6d9bc8c9-1ec2-4278-b937-99fde70a366f

circ/circ_permit_copy.js [new file with mode: 0644]

diff --git a/circ/circ_permit_copy.js b/circ/circ_permit_copy.js
new file mode 100644 (file)
index 0000000..4550a1e
--- /dev/null
@@ -0,0 +1,55 @@
+function go() {
+
+/* load the lib script */
+load_lib('circ/circ_lib.js');
+load_lib('JSON_v1.js');
+log_vars('circ_permit_copy');
+
+var lusys = ['LUSYS', 'CRC', 'HUNTINGTON', 'LDCR', 'MRC', 'OSUL', 'MEDIACEN', 'SUDBURY'];
+var hearstsys = ['HEARSTSYS', 'HEARST', 'KAP', 'TIMMINS'];
+var nosmsys = ['OSM', 'NOSME', 'NOSMW'];
+
+/* In theory, isOrgDescendent would work - but it isn't, for some reason */
+if (patron.home_ou.id != copy.circ_lib.id) {
+        /* Laurentian campus patrons can borrow from one another */
+        if (isOrgDescendent('LUSYS', patron.home_ou.id) && isOrgDescendent('LUSYS', copy.circ_lib.id)) {
+                // go in peace
+        } else if (isAMember(patron.home_ou.shortname, lusys) && isAMember(copy.circ_lib.shortname, lusys)) {
+                // No problemo
+        } else if (isOrgDescendent('HEARSTSYS', patron.home_ou.id) && isOrgDescendent('LUSYS', copy.circ_lib.id)) {
+                // go in peace
+        } else if (isAMember(patron.home_ou.shortname, hearstsys) && isAMember(copy.circ_lib.shortname, hearstsys)) {
+                // No problemo
+        } else if (isOrgDescendent('OSM', patron.home_ou.id) && isOrgDescendent('OSM', copy.circ_lib.id)) {
+                // go in peace
+        } else if (isAMember(patron.home_ou.shortname, nosmsys) && isAMember(copy.circ_lib.shortname, nosmsys)) {
+                // No problemo
+        } else {
+                result.events.push('CIRC_EXCEEDS_COPY_RANGE');
+        }
+}
+
+if( ! isTrue(copy.circulate) || !isTrue(copy.location.circulate) ) 
+       result.events.push('COPY_CIRC_NOT_ALLOWED');
+
+
+if( ! isTrue(isRenewal) ) {
+       if(copyStatus != 'Available' && 
+               copyStatus != 'On holds shelf' && copyStatus != 'Reshelving' ) {
+                       result.events.push('COPY_NOT_AVAILABLE');
+       } 
+}
+
+}
+
+function isAMember(shortname, group) {
+       for (var i = 0; i < group.length; i++) {
+               if (group[i] == shortname) {
+                       return true;
+               }
+       }
+       return false;
+}
+
+go();
+