]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/backend/circ/circ_permit.js
plugged in the 'env' object and now pushing env.isRenew into the script
[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         ', Is Renewal: '                        + ( (env.isRenewal) ? "yes" : "no" ) +
18         '');
19
20
21 /* collect some useful variables */
22 var standing    = patron.standing.value.toLowerCase();
23 var profile             = patron.profile.name.toLowerCase();
24 var status              = copy.status.name.toLowerCase();
25
26 if( standing != 'good' ) 
27         return result.event = 'PATRON_BAD_STANDING';
28
29 if( copy.circulate == '0' ) 
30         return result.event = 'COPY_CIRC_NOT_ALLOWED';
31
32 if( copy.ref != '0' ) 
33         return result.event = 'COPY_IS_REFERENCE';
34
35 if( status != 'available' && status != 'on holds shelf' )
36         return result.event = 'COPY_NOT_AVAILABLE';
37
38
39
40
41 if( profile == 'patrons' && patron_info.items_out > 10 )
42         return result.event = 'PATRON_EXCEEDS_CHECKOUT_COUNT';
43
44 if( profile == 'staff' && patron_info.items_out > 30 )
45         return result.event = 'PATRON_EXCEEDS_CHECKOUT_COUNT';
46
47
48 var hold = copy.fetchHold();
49 if( hold && hold.usr != patron.id )
50         return result.event = 'COPY_NEEDED_FOR_HOLD';
51
52
53 } go();
54
55