]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/backend/circ/circ_permit_patron.js
moved script building to a generic framework using cstore as the base - standardizing...
[Evergreen.git] / Open-ILS / src / javascript / backend / circ / circ_permit_patron.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 patron                              = environment.patron;
9 var patronProfile               = patron.profile.name.toLowerCase();
10 var patronItemsOut      = environment.patronItemsOut;
11 var patronFines         = environment.patronFines;
12 var isRenewal                   = environment.isRenewal;
13
14
15 log_debug('circ_permit_patron: permit circ on ' +
16         ', Patron:'                                     + patron.id +
17         ', Patron Username:'            + patron.usrname +
18         ', Patron Profile: '            + patronProfile +
19         ', Patron copies: '             + patronItemsOut +
20         ', Patron Library: '            + patron.home_ou.name +
21         ', Patron fines: '              + patronFines +
22         ', Is Renewal: '                        + ( (isRenewal) ? "yes" : "no" ) +
23         '');
24
25
26 if( isTrue(patron.barred) ) 
27         result.events.push('PATRON_BARRED');
28
29
30 /* define the items out limits */
31 var PROFILES = {
32
33         restricted : {
34                 itemsOutLimit : 2,
35         },
36         patrons : {
37                 itemsOutLimit : 10,
38         },
39         'class' : {
40                 itemsOutLimit : 10,
41         },
42         'local system administrator' : {
43                 itemsOut : -1,
44         },
45         circulators : {
46                 itemsOut : -1,
47         }
48
49
50         /* Add profiles as necessary ... */
51 }
52
53
54 var profile = PROFILES[patronProfile];
55 if( profile ) {
56         if( patronItemsOut > 0 && patronItemsOut > profile.itemsOutLimit )
57                 result.events.push('PATRON_EXCEEDS_CHECKOUT_COUNT');
58 } else {
59         log_warn("profile has no configured information: " + patronProfile);
60 }
61
62
63 } go();
64
65