From 3540f17383d91c30795ab8922f279b091710832a Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 6 Jan 2006 23:21:09 +0000 Subject: [PATCH 1/1] sample permit script for circ and a file of utility functions for the circ scripts git-svn-id: svn://svn.open-ils.org/ILS/trunk@2653 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Evergreen/circ_rules/circ_permit.js | 35 +++++++++++++++++++++++++++++ Evergreen/circ_rules/script_libs.js | 9 ++++++++ 2 files changed, 44 insertions(+) create mode 100644 Evergreen/circ_rules/circ_permit.js create mode 100644 Evergreen/circ_rules/script_libs.js diff --git a/Evergreen/circ_rules/circ_permit.js b/Evergreen/circ_rules/circ_permit.js new file mode 100644 index 0000000000..a91aecf1e0 --- /dev/null +++ b/Evergreen/circ_rules/circ_permit.js @@ -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 index 0000000000..ceb6e4b397 --- /dev/null +++ b/Evergreen/circ_rules/script_libs.js @@ -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; +} -- 2.43.2