]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/backend/circ/circ_permit_copy.js
moved script building to a generic framework using cstore as the base - standardizing...
[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 /* collect some useful variables */
7 var copy                                        = environment.copy;
8 var patron                              = environment.patron;
9 var volume                              = environment.volume;
10 var title                               = environment.title;
11 var recDescriptor               = environment.titleDescriptor;
12 var patronProfile               = patron.profile.name.toLowerCase();
13 var copyStatus                  = copy.status.name.toLowerCase();
14 var isRenewal                   = environment.isRenewal;
15
16 /*
17 - at some point we should add a library of objects that map 
18 codes to names (item_form, item_type, etc.)
19 load_lib('item_form_map.js');
20 var form_name = item_form_map[env.record_descriptor.item_form];
21 */
22
23
24 log_debug('circ_permit_copy: permit circ on ' +
25         '  Copy: '                                      + copy.id + 
26         ', Patron:'                                     + patron.id +
27         ', Patron Username:'            + patron.usrname +
28         ', Patron Library: '            + patron.home_ou.name +
29         ', Copy status: '                       + copyStatus +
30         ', Copy location: '             + copy.location.name +
31         ', Is Renewal: '                        + ( (isTrue(isRenewal)) ? "yes" : "no" ) +
32         ', Item Type: '                 + recDescriptor.item_type +
33         ', Item Form: '                 + recDescriptor.item_form +
34         ', Item Lang: '                 + recDescriptor.item_lang +
35         ', Item Audience: '             + recDescriptor.audience +
36         '');
37
38
39
40 if( ! isTrue(copy.circulate) ) 
41         result.events.push('COPY_CIRC_NOT_ALLOWED');
42
43 if( isTrue(copy.ref) ) 
44         result.events.push('COPY_IS_REFERENCE');
45
46
47
48 if(copyStatus != 'available' && 
49         copyStatus != 'on holds shelf' && copyStatus != 'reshelving' ) {
50                 result.events.push('COPY_NOT_AVAILABLE');
51 }
52
53 /* this should happen very rarely .. but it needs to be protected */
54 if( recDescriptor.item_type == 'g'  /* projected medium */
55         && copy.circ_lib != patron.home_ou.id )
56         result.events.push('CIRC_EXCEEDS_COPY_RANGE');
57
58
59
60         
61 } go();
62
63