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 /* ------------------------------------------------------------------------ */
74 /** This patch allows DCPL and LEE patrons to place
75 holds on protected items accross their systems. In short, if the pickup lib,
76 owning lib, and patron home (or request lib) are all within either of the two
77 systems, allow the hold */
79 /* DCPL=33, LEE=115 */
80 (hasCommonAncestor(holdPickupLib, 33, 1) || hasCommonAncestor(holdPickupLib, 115, 1)) &&
81 (hasCommonAncestor(volume.owning_lib, 33, 1) || hasCommonAncestor(volume.owning_lib, 115, 1)) &&
83 hasCommonAncestor(patron.home_ou.id, 33, 1) || hasCommonAncestor(patron.home_ou.id, 115, 1) ||
84 hasCommonAncestor(holdRequestLib.id, 33, 1) || hasCommonAncestor(holdRequestLib.id, 115, 1)
87 log_info("DCPL and LEE are allowed to place holds on protected items accross the two systems");
90 /* ------------------------------------------------------------------------ */
93 if( ! hasCommonAncestor( volume.owning_lib, holdPickupLib, 1 ) ) {
95 /* we don't want these items to transit to the pickup lib */
96 result.events.push('ITEM_NOT_HOLDABLE');
97 log_info("pickup_lib is not in the owning_lib's region...NOT OK");
99 } else { /* pickup lib is in the owning region */
101 if( isStaffHold && hasCommonAncestor( volume.owning_lib, holdRequestLib.id, 1) ) {
103 /* staff in the region can place holds for patrons outside the region with local pickup lib */
104 log_info("local, staff-placed hold is allowed with local pickup_lib...OK");
108 if( hasCommonAncestor( volume.owning_lib, patron.home_ou.id, 1 ) ) {
110 /* patrons can hold the item if they are registered
111 in the region and pickup lib is local */
112 log_info("patron's home_ou is in the owning region...OK");
116 log_info("patron's home_ou lies outside the owning region...NOT OK");
117 result.events.push('ITEM_NOT_HOLDABLE');