3 load_lib('circ/circ_lib.js');
4 log_vars('circ_permit_hold');
7 /* is a staff member placing this hold? */
8 var isStaffHold = isGroupDescendantId('Staff', requestor.profile);
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');
18 log_info("This is a staff-placed hold");
23 if( isTrue(patron.barred) )
24 result.events.push('PATRON_BARRED');
26 if( isTrue(copy.ref) )
27 result.events.push('ITEM_NOT_HOLDABLE');
29 if( !isTrue(copy.circulate) )
30 result.events.push('ITEM_NOT_HOLDABLE');
32 /* all STATELIB items are holdable regardless of type */
33 if( isOrgDescendent('STATELIB', copy.circ_lib.id) ) return;
36 var mod = (copy.circ_modifier) ? copy.circ_modifier.toLowerCase() : "";
37 var marcItemType = getMARCItemType();
40 log_info("circ-modifier = "+mod);
41 log_info("marc-type = "+marcItemType);
44 if( mod == 'bestsellernh' )
45 result.events.push('ITEM_NOT_HOLDABLE');
48 if( ( marcItemType == 'g' ||
49 marcItemType == 'i' ||
50 marcItemType == 'j' ||
51 mod == 'softwrlong' ||
63 mod == 'equip-long' ||
66 isTrue(copy.deposit) ||
67 mod == 'video-long' ||
71 log_info("this is a range-protected item...");
73 if( ! hasCommonAncestor( volume.owning_lib, holdPickupLib, 1 ) ) {
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");
79 } else { /* pickup lib is in the owning region */
81 if( isStaffHold && hasCommonAncestor( volume.owning_lib, holdRequestLib.id, 1) ) {
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");
88 if( hasCommonAncestor( volume.owning_lib, patron.home_ou.id, 1 ) ) {
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");
96 log_info("patron's home_ou lies outside the owning region...NOT OK");
97 result.events.push('ITEM_NOT_HOLDABLE');