]> git.evergreen-ils.org Git - Evergreen.git/blob - Evergreen/circ_rules/circ_permit.js
2e7408d23729b0770b667317c7d71c997123472c
[Evergreen.git] / Evergreen / circ_rules / circ_permit.js
1 function go() {
2
3 log_debug('Checking permit circ on ' +
4         ' Copy: '                               + copy.id + 
5         ' Patron:'                              + patron.id +
6         ' Patron Profile: '     + patron.profile +
7         ' Patron Standing: ' + patron.standing +
8         ' Patron copies: '      + patron_info.items_out +
9         ' Patron fines: '               + patron_info.fines +
10         ' Copy status: '                + copy.status +
11         ' Copy location: '      + copy.location.name +
12         '');
13
14
15 /* Patron checks --------------------------------------------- */
16 if( ! patron.standing.match(/good/i) ) 
17         return result.event = 'PATRON_BAD_STANDING';
18
19 if( patron.profile.match(/patrons/i) && patron_info.items_out > 10 )
20         return result.event = 'PATRON_EXCEEDS_CHECKOUT_COUNT';
21
22 if( patron.profile.match(/staff/i) && patron_info.items_out > 30 )
23         return result.event = 'PATRON_EXCEEDS_CHECKOUT_COUNT';
24
25 /* Copy checks ------------------------------------------------ */
26 if( is_false( copy.circulate ) ) 
27         return result.event = 'COPY_CIRC_NOT_ALLOWED';
28
29 if( !copy.status.match(/available/i) && !copy.status.match(/on holds shelf/i) )
30         return result.event = 'COPY_NOT_AVAILABLE';
31
32 /* check for holds -------------------------------------------- */
33 fetch_hold_by_copy( copy.id );
34 if( hold && hold.usr != patron.id )
35         return result.event = 'COPY_NEEDED_FOR_HOLD';
36
37
38 } go();
39
40