sample permit script for circ and a file of utility functions for the circ scripts
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 6 Jan 2006 23:21:09 +0000 (23:21 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 6 Jan 2006 23:21:09 +0000 (23:21 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2653 dcc99617-32d9-48b4-a31d-7c20da2025e4

Evergreen/circ_rules/circ_permit.js [new file with mode: 0644]
Evergreen/circ_rules/script_libs.js [new file with mode: 0644]

diff --git a/Evergreen/circ_rules/circ_permit.js b/Evergreen/circ_rules/circ_permit.js
new file mode 100644 (file)
index 0000000..a91aecf
--- /dev/null
@@ -0,0 +1,35 @@
+function go() {
+
+log_debug('Checking permit circ on ' +
+       ' Copy: '                               + copy.id + 
+       ' Patron:'                              + patron.id +
+       ' Patron Profile: '     + patron.profile +
+       ' Patron Standing: ' + patron.standing +
+       ' Patron copies: '      + patron_info.items_out +
+       ' Patron fines: '               + patron_info.fines );
+
+
+/* Patron checks --------------------------------------------- */
+if( ! patron.standing.match(/good/i) ) 
+       return result.event = 'PATRON_BAD_STANDING';
+
+if( patron.profile.match(/patrons/i) && patron_info.items_out > 10 )
+       return result.event = 'PATRON_EXCEEDS_CHECKOUT_COUNT';
+
+if( patron.profile.match(/staff/i) && patron_info.items_out > 30 )
+       return result.event = 'PATRON_EXCEEDS_CHECKOUT_COUNT';
+
+
+/* Copy checks ------------------------------------------------ */
+if( is_false( copy.circulate ) ) 
+       return result.event = 'COPY_CIRC_NOT_ALLOWED';
+
+/* check for holds -------------------------------------------- */
+fetch_hold_by_copy( copy.id );
+if( hold && hold.usr != patron.id )
+       return result.event = 'COPY_NEEDED_FOR_HOLD';
+
+
+} go();
+
+
diff --git a/Evergreen/circ_rules/script_libs.js b/Evergreen/circ_rules/script_libs.js
new file mode 100644 (file)
index 0000000..ceb6e4b
--- /dev/null
@@ -0,0 +1,9 @@
+function is_true(item) {
+       return !is_false(item);
+}
+
+function is_false(item) { 
+       if( ! item ) return true;
+       if( item.match(/0/) ) return true;
+       false;
+}