]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/backend/circ/circ_permit_hold.js
added a MAX_HOLDS event and tests in the hold permit scripts
[Evergreen.git] / Open-ILS / src / javascript / backend / circ / circ_permit_hold.js
1 function go() {
2
3 load_lib('circ/circ_lib.js');
4 log_vars('circ_permit_hold');
5
6
7
8 /* non-staff members are allowed 50 open holds at most */
9 if( ! isGroupDescendant('Staff', patronProfile) ) {
10    var count = userHoldCount(patron.id);
11    log_info("patron has " + count + " open holds");
12    if( count >= 50 ) 
13       result.events.push('MAX_HOLDS');
14 }
15
16
17 if( isTrue(patron.barred) ) 
18         result.events.push('PATRON_BARRED');
19
20 if( isTrue(copy.ref) ) 
21         result.events.push('ITEM_NOT_HOLDABLE');
22
23 if( !isTrue(copy.circulate) ) 
24         result.events.push('ITEM_NOT_HOLDABLE');
25
26 /* all STATELIB items are holdable regardless of type */
27 if( isOrgDescendent('STATELIB', copy.circ_lib.id) ) return;
28
29 var mod = (copy.circ_modifier) ? copy.circ_modifier.toLowerCase() : "";
30
31 log_info("circ-modifier = "+mod);
32
33 if( mod == 'bestsellernh' )
34         result.events.push('ITEM_NOT_HOLDABLE');
35
36 var marcItemType = getMARCItemType();
37 var isAnc;
38
39 if( ( marcItemType == 'g' || 
40                 marcItemType == 'i' || 
41                 marcItemType == 'j' || 
42                 mod == 'softwrlong' || 
43                 mod == 'music' || 
44                 mod == 'audiobook' || 
45                 mod == 'av' || 
46                 mod == 'cd' || 
47                 mod == 'kit' || 
48                 mod == 'dvd' || 
49                 mod == 'deposit' || 
50                 mod == 'atlas' || 
51                 mod == 'magazine' || 
52                 mod == 'equipment' || 
53                 mod == 'equip-long' || 
54                 mod == 'microform' || 
55                 mod == 'record' || 
56                 isTrue(copy.deposit) || 
57                 mod == 'video-long' || 
58                 mod == 'video' ) ) {
59
60         isAnc = hasCommonAncestor( copy.circ_lib.id, patron.home_ou.id, 1 );
61
62         if( isAnc) {
63                 log_info("patron and copy circ_lib share a common ancestor, hold allowed");
64
65         } else {
66                 log_info("patron and copy circ_lib do NOT share a common ancestor");
67
68                 if( hasCommonAncestor( copy.circ_lib.id, holdRequestLib.id, 1) ) {
69                         log_info("request_lib and copy circ_lib DO share a common ancestor");
70
71                 } else {
72
73                         log_info("request_lib and copy circ_lib also do NOT share a common ancestor, hold on this type of material not allowed");
74                         result.events.push('ITEM_NOT_HOLDABLE');
75                 }
76         }
77 }
78
79
80 } go();
81