3 load_lib('circ/circ_lib.js');
4 log_vars('circ_permit_hold');
7 /* is a staff member placing this hold? */
8 var isStaffHold = isGroupDescendant('Staff', patronProfile);
11 /* non-staff members are allowed 50 open holds at most */
13 var count = userHoldCount(patron.id);
14 log_info("patron has " + count + " open holds");
16 result.events.push('MAX_HOLDS');
20 if( isTrue(patron.barred) )
21 result.events.push('PATRON_BARRED');
23 if( isTrue(copy.ref) )
24 result.events.push('ITEM_NOT_HOLDABLE');
26 if( !isTrue(copy.circulate) )
27 result.events.push('ITEM_NOT_HOLDABLE');
29 /* all STATELIB items are holdable regardless of type */
30 if( isOrgDescendent('STATELIB', copy.circ_lib.id) ) return;
33 var mod = (copy.circ_modifier) ? copy.circ_modifier.toLowerCase() : "";
34 var marcItemType = getMARCItemType();
37 log_info("circ-modifier = "+mod);
38 log_info("marc-type = "+marcItemType);
41 if( mod == 'bestsellernh' )
42 result.events.push('ITEM_NOT_HOLDABLE');
45 if( ( marcItemType == 'g' ||
46 marcItemType == 'i' ||
47 marcItemType == 'j' ||
48 mod == 'softwrlong' ||
60 mod == 'equip-long' ||
63 isTrue(copy.deposit) ||
64 mod == 'video-long' ||
68 log_info("this is a range-protected item...");
70 if( ! hasCommonAncestor( volume.owning_lib, holdPickupLib, 1 ) ) {
72 /* we don't want these items to transit to the pickup lib */
73 result.events.push('ITEM_NOT_HOLDABLE');
74 log_info("pickup_lib is not in the owning_lib's region...NOT OK");
76 } else { /* pickup lib is in the owning region */
78 if( isStaffHold && hasCommonAncestor( volume.owning_lib, holdRequestLib.id, 1) ) {
80 /* staff in the region can place holds for patrons outside the region with local pickup lib */
81 log_info("local, staff-placed hold is allowed with local pickup_lib...OK");
85 if( hasCommonAncestor( volume.owning_lib, patron.home_ou.id, 1 ) ) {
87 /* patrons can hold the item if they are registered
88 in the region and pickup lib is local */
89 log_info("patron's home_ou is in the owning region...OK");
93 log_info("patron's home_ou lies outside the owning region...NOT OK");
94 result.events.push('ITEM_NOT_HOLDABLE');