]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/backend/circ/circ_permit_copy.js
made checkout methods take hash refs instead of named params list since
[Evergreen.git] / Open-ILS / src / javascript / backend / circ / circ_permit_copy.js
1 function go() {
2
3 /* load the lib script */
4 load_lib('circ_lib.js');
5
6
7 /* collect some useful variables */
8 var copy                        = environment.copy;
9 var patron              = environment.patron;
10 var standing    = patron.standing.value.toLowerCase();
11 var profile             = patron.profile.name.toLowerCase();
12 var status              = copy.status.name.toLowerCase();
13 var itemsOut    = environment.patronItemsOut;
14 var fines               = environment.patronFines;
15 var isRenewal   = environment.isRenewal;
16
17
18 log_debug('circ_permit_copy: permit circ on ' +
19         ' Copy: '                                       + copy.id + 
20         ', Patron:'                                     + patron.id +
21         ', Patron Username:'            + patron.usrname +
22         ', Patron Profile: '            + patron.profile.name +
23         ', Patron Standing: '   + patron.standing.value +
24         ', Patron copies: '             + itemsOut +
25         ', Patron Library: '            + patron.home_ou.name +
26         ', Patron fines: '              + fines +
27         ', Copy status: '                       + copy.status.name +
28         ', Copy location: '             + copy.location.name +
29         ', Is Renewal: '                        + ( (isRenewal) ? "yes" : "no" ) +
30         '');
31
32
33
34 if( copy.circulate == '0' ) 
35         return result.event = 'COPY_CIRC_NOT_ALLOWED';
36
37 if( copy.ref != '0' ) 
38         return result.event = 'COPY_IS_REFERENCE';
39
40 if( status != 'available' && status != 'on holds shelf' )
41         return result.event = 'COPY_NOT_AVAILABLE';
42
43 var holds = copy.fetchHold();
44 for( var i in holds ) {
45         var hold = holds[i];
46         if( hold && hold.usr != patron.id )
47                 return result.event = 'COPY_NEEDED_FOR_HOLD';
48 }
49
50
51 } go();
52
53