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