]> git.evergreen-ils.org Git - Evergreen.git/blob - Evergreen/src/javascript/backend/circ/circ_permit_hold.js
More cleanup of the Evergreen directory. This change replaces the Open-ILS version...
[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     if(newHold) {
14         var count = userHoldCount(patron.id);
15         log_info("patron has " + count + " open holds");
16         if( count >= 50 ) 
17             result.events.push('MAX_HOLDS');
18     }
19 } else {
20     log_info("This is a staff-placed hold");
21 }
22
23
24
25 if( isTrue(patron.barred) ) 
26         result.events.push('PATRON_BARRED');
27
28 if( isTrue(copy.ref) ) 
29         result.events.push('ITEM_NOT_HOLDABLE');
30
31 if( !isTrue(copy.circulate) ) 
32         result.events.push('ITEM_NOT_HOLDABLE');
33
34 /* all STATELIB items are holdable regardless of type */
35 if( isOrgDescendent('STATELIB', copy.circ_lib.id) ) return;
36
37
38 var mod = (copy.circ_modifier) ? copy.circ_modifier.toLowerCase() : "";
39 var marcItemType = getMARCItemType();
40
41
42 log_info("circ-modifier = "+mod);
43 log_info("marc-type = "+marcItemType);
44
45
46 if(mod == 'bestsellernh' || mod == 'eventpass')
47         result.events.push('ITEM_NOT_HOLDABLE');
48
49
50 if( ( marcItemType == 'g' || 
51                 marcItemType == 'i' || 
52                 marcItemType == 'j' || 
53                 mod == 'softwrlong' || 
54                 mod == 'music' || 
55                 mod == 'audiobook' || 
56                 mod == 'av' || 
57                 mod == 'new-av' || 
58                 mod == 'cd' || 
59                 mod == 'kit' || 
60                 mod == 'dvd' || 
61                 mod == 'deposit' || 
62                 mod == 'atlas' || 
63                 mod == 'magazine' || 
64                 mod == 'equipment' || 
65                 mod == 'equip-long' || 
66                 mod == 'microform' || 
67                 mod == 'record' || 
68                 isTrue(copy.deposit) || 
69                 mod == 'video-long' || 
70                 mod == 'video' ) ) {
71
72
73         log_info("this is a range-protected item...");
74
75         /* ------------------------------------------------------------------------ */
76         /** This patch allows DCPL and LEE patrons to place 
77                 holds on protected items accross their systems.  In short, if the pickup lib,
78                 owning lib, and patron home (or request lib) are all within either of the two 
79                 systems, allow the hold */
80         if(
81                 /* DCPL=33, LEE=115 */
82                 (hasCommonAncestor(holdPickupLib, 33, 1) || hasCommonAncestor(holdPickupLib, 115, 1)) &&
83                 (hasCommonAncestor(volume.owning_lib, 33, 1) || hasCommonAncestor(volume.owning_lib, 115, 1)) &&
84                 (
85                         hasCommonAncestor(patron.home_ou.id, 33, 1) || hasCommonAncestor(patron.home_ou.id, 115, 1) || 
86                         hasCommonAncestor(holdRequestLib.id, 33, 1) || hasCommonAncestor(holdRequestLib.id, 115, 1)
87                 )) {
88
89                 log_info("DCPL and LEE are allowed to place holds on protected items accross the two systems");
90                 return;
91         }
92         /* ------------------------------------------------------------------------ */
93
94
95     if( ! hasCommonAncestor( volume.owning_lib, holdPickupLib, 1 ) ) {
96
97         /* we don't want these items to transit to the pickup lib */
98         result.events.push('ITEM_NOT_HOLDABLE');
99             log_info("pickup_lib is not in the owning_lib's region...NOT OK");
100
101     } else { /* pickup lib is in the owning region */
102
103         if( isStaffHold && hasCommonAncestor( volume.owning_lib, holdRequestLib.id, 1) ) {
104
105             /* staff in the region can place holds for patrons outside the region with local pickup lib */
106             log_info("local, staff-placed hold is allowed with local pickup_lib...OK");
107
108         } else {
109
110             if( hasCommonAncestor( volume.owning_lib, patron.home_ou.id, 1 ) ) {
111
112                 /* patrons can hold the item if they are registered 
113                     in the region and pickup lib is local */  
114                 log_info("patron's home_ou is in the owning region...OK");
115
116             } else {
117
118                 log_info("patron's home_ou lies outside the owning region...NOT OK");
119                 result.events.push('ITEM_NOT_HOLDABLE');
120             }
121         }
122     }
123 }
124
125
126
127
128 } go();
129
130
131