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