]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/backend/circ/circ_permit.js
moved to "environment" instead of "env".
[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
7
8 /* collect some useful variables */
9 var standing    = patron.standing.value.toLowerCase();
10 var profile             = patron.profile.name.toLowerCase();
11 var status              = copy.status.name.toLowerCase();
12 var itemsOut    = environment.patronItemsOut;
13 var fines               = environment.patronFines;
14 var isRenewal   = environment.isRenewal;
15
16 log_debug('CIRC PERMIT: permit circ on ' +
17         ' Copy: '                                       + copy.id + 
18         ', Patron:'                                     + patron.id +
19         ', Patron Username:'            + patron.usrname +
20         ', Patron Profile: '            + patron.profile.name +
21         ', Patron Standing: '   + patron.standing.value +
22         ', Patron copies: '             + itemsOut +
23         ', Patron Library: '            + patron.home_ou.name +
24         ', Patron fines: '              + fines +
25         ', Copy status: '                       + copy.status.name +
26         ', Copy location: '             + copy.location.name +
27         ', Is Renewal: '                        + ( (isRenewal) ? "yes" : "no" ) +
28         '');
29
30
31
32 if( standing != 'good' ) 
33         return result.event = 'PATRON_BAD_STANDING';
34
35 if( copy.circulate == '0' ) 
36         return result.event = 'COPY_CIRC_NOT_ALLOWED';
37
38 if( copy.ref != '0' ) 
39         return result.event = 'COPY_IS_REFERENCE';
40
41 if( status != 'available' && status != 'on holds shelf' )
42         return result.event = 'COPY_NOT_AVAILABLE';
43
44
45
46
47 if( profile == 'patrons' && itemsOut > 10 )
48         return result.event = 'PATRON_EXCEEDS_CHECKOUT_COUNT';
49
50 if( profile == 'staff' && itemsOut > 30 )
51         return result.event = 'PATRON_EXCEEDS_CHECKOUT_COUNT';
52
53
54 var hold = copy.fetchHold();
55 if( hold && hold.usr != patron.id )
56         return result.event = 'COPY_NEEDED_FOR_HOLD';
57
58
59 } go();
60
61