]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/backend/circ/circ_permit.js
adding permit script. permit circ now basically functions
[Evergreen.git] / Open-ILS / src / javascript / backend / circ / circ_permit.js
1 function go() {
2
3 /* load the lib script */
4 load_lib('circ_lib.js');
5
6 log_debug('CIRC PERMIT: permit circ on ' +
7         ' Copy: '                                       + copy.id + 
8         ', Patron:'                                     + patron.id +
9         ', Patron Username:'            + patron.usrname +
10         ', Patron Profile: '            + patron.profile.name +
11         ', Patron Standing: '   + patron.standing.value +
12         ', Patron copies: '             + patron_info.items_out +
13         ', Patron Library: '            + patron.home_ou.name +
14         ', Patron fines: '              + patron_info.fines +
15         ', Copy status: '                       + copy.status.name +
16         ', Copy location: '             + copy.location.name +
17         '');
18
19
20 /* collect some useful variables */
21 var standing    = patron.standing.value.toLowerCase();
22 var profile             = patron.profile.name.toLowerCase();
23 var status              = copy.status.name.toLowerCase();
24
25 if( standing != 'good' ) 
26         return result.event = 'PATRON_BAD_STANDING';
27
28 if( copy.circulate == '0' ) 
29         return result.event = 'COPY_CIRC_NOT_ALLOWED';
30
31 if( copy.ref != '0' ) 
32         return result.event = 'COPY_IS_REFERENCE';
33
34 if( status != 'available' && status != 'on holds shelf' )
35         return result.event = 'COPY_NOT_AVAILABLE';
36
37
38
39
40 if( profile == 'patrons' && patron_info.items_out > 10 )
41         return result.event = 'PATRON_EXCEEDS_CHECKOUT_COUNT';
42
43 if( profile == 'staff' && patron_info.items_out > 30 )
44         return result.event = 'PATRON_EXCEEDS_CHECKOUT_COUNT';
45
46
47 var hold = copy.fetchHold();
48 if( hold && hold.usr != patron.id )
49         return result.event = 'COPY_NEEDED_FOR_HOLD';
50
51
52 } go();
53
54