]> git.evergreen-ils.org Git - Evergreen.git/blob - Evergreen/src/javascript/backend/circ/circ_permit_hold.js
updating to match stable branch logic
[Evergreen.git] / Evergreen / 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 /* is a staff member placing this hold? */
8 var isStaffHold = isGroupDescendantId('Staff', requestor.profile);
9
10
11 /* non-staff members are allowed 50 open holds at most */
12 if( ! isStaffHold ) {
13    var count = userHoldCount(patron.id);
14    log_info("patron has " + count + " open holds");
15    if( count >= 50 ) 
16       result.events.push('MAX_HOLDS');
17 } else {
18     log_info("This is a staff-placed hold");
19 }
20
21
22
23 if( isTrue(patron.barred) ) 
24         result.events.push('PATRON_BARRED');
25
26 if( isTrue(copy.ref) ) 
27         result.events.push('ITEM_NOT_HOLDABLE');
28
29 if( !isTrue(copy.circulate) ) 
30         result.events.push('ITEM_NOT_HOLDABLE');
31
32 /* all STATELIB items are holdable regardless of type */
33 if( isOrgDescendent('STATELIB', copy.circ_lib.id) ) return;
34
35
36 var mod = (copy.circ_modifier) ? copy.circ_modifier.toLowerCase() : "";
37 var marcItemType = getMARCItemType();
38
39
40 log_info("circ-modifier = "+mod);
41 log_info("marc-type = "+marcItemType);
42
43
44 if( mod == 'bestsellernh' )
45         result.events.push('ITEM_NOT_HOLDABLE');
46
47
48 if( ( marcItemType == 'g' || 
49                 marcItemType == 'i' || 
50                 marcItemType == 'j' || 
51                 mod == 'softwrlong' || 
52                 mod == 'music' || 
53                 mod == 'audiobook' || 
54                 mod == 'av' || 
55                 mod == 'new-av' || 
56                 mod == 'cd' || 
57                 mod == 'kit' || 
58                 mod == 'dvd' || 
59                 mod == 'deposit' || 
60                 mod == 'atlas' || 
61                 mod == 'magazine' || 
62                 mod == 'equipment' || 
63                 mod == 'equip-long' || 
64                 mod == 'microform' || 
65                 mod == 'record' || 
66                 isTrue(copy.deposit) || 
67                 mod == 'video-long' || 
68                 mod == 'video' ) ) {
69
70
71         log_info("this is a range-protected item...");
72
73     if( ! hasCommonAncestor( volume.owning_lib, holdPickupLib, 1 ) ) {
74
75         /* we don't want these items to transit to the pickup lib */
76         result.events.push('ITEM_NOT_HOLDABLE');
77             log_info("pickup_lib is not in the owning_lib's region...NOT OK");
78
79     } else { /* pickup lib is in the owning region */
80
81         if( isStaffHold && hasCommonAncestor( volume.owning_lib, holdRequestLib.id, 1) ) {
82
83             /* staff in the region can place holds for patrons outside the region with local pickup lib */
84             log_info("local, staff-placed hold is allowed with local pickup_lib...OK");
85
86         } else {
87
88             if( hasCommonAncestor( volume.owning_lib, patron.home_ou.id, 1 ) ) {
89
90                 /* patrons can hold the item if they are registered 
91                     in the region and pickup lib is local */  
92                 log_info("patron's home_ou is in the owning region...OK");
93
94             } else {
95
96                 log_info("patron's home_ou lies outside the owning region...NOT OK");
97                 result.events.push('ITEM_NOT_HOLDABLE');
98             }
99         }
100     }
101 }
102
103
104
105
106 } go();
107
108
109