var isPrecat = environment.isPrecat;
var currentLocation = environment.location;
var holdRequestLib = environment.requestLib;
+var holdPickupLib = environment.pickupLib; /* hold pickup lib */
if(patron) {
str += ' Patron=' + patron.id;
str += ', Patron_Username='+ patron.usrname;
- str += ', Patron_Profile Group='+ patronProfile;
+ str += ', Patron_Profile_Group='+ patronProfile;
str += ', Patron_Fines=' + patronFines;
str += ', Patron_OverdueCount=' + patronOverdueCount;
- str += ', Patron_Items Out=' + patronItemsOut;
+ str += ', Patron_Items_Out=' + patronItemsOut;
try {
str += ', Patron_Barcode=' + patron.card.barcode;
} catch(e) {}
}
- if(volume) str += ', Volume=' + volume.id;
- if(title) str += ', Record=' + title.id;
+ if(volume) {
+ str += ', Item_Owning_lib=' + volume.owning_lib;
+ str += ', Volume=' + volume.id;
+ }
+
+ if(title) str += ', Record=' + title.id;
if(recDescriptor) {
str += ', Record_Descriptor=' + recDescriptor.id;
str += ', Is_Renewal: ' + ( (isTrue(isRenewal)) ? "yes" : "no" );
str += ', Is_Precat: ' + ( (isTrue(isPrecat)) ? "yes" : "no" );
str += (holdRequestLib) ? ', Hold_request_lib=' + holdRequestLib.shortname : '';
+ str += (holdPickupLib) ? ', Hold_Pickup_Lib=' + holdPickupLib : '';
log_info(str);
}
log_vars('circ_permit_hold');
+/* is a staff member placing this hold? */
+var isStaffHold = isGroupDescendant('Staff', patronProfile);
+
/* non-staff members are allowed 50 open holds at most */
-if( ! isGroupDescendant('Staff', patronProfile) ) {
+if( ! isStaffHold ) {
var count = userHoldCount(patron.id);
log_info("patron has " + count + " open holds");
if( count >= 50 )
result.events.push('MAX_HOLDS');
-}
+}
if( isTrue(patron.barred) )
/* all STATELIB items are holdable regardless of type */
if( isOrgDescendent('STATELIB', copy.circ_lib.id) ) return;
+
var mod = (copy.circ_modifier) ? copy.circ_modifier.toLowerCase() : "";
+var marcItemType = getMARCItemType();
+
log_info("circ-modifier = "+mod);
+log_info("marc-type = "+marcItemType);
+
if( mod == 'bestsellernh' )
result.events.push('ITEM_NOT_HOLDABLE');
-var marcItemType = getMARCItemType();
-var isAnc;
if( ( marcItemType == 'g' ||
marcItemType == 'i' ||
mod == 'video-long' ||
mod == 'video' ) ) {
- isAnc = hasCommonAncestor( copy.circ_lib.id, patron.home_ou.id, 1 );
- if( isAnc) {
- log_info("patron and copy circ_lib share a common ancestor, hold allowed");
+ log_info("this is a range-protected item...");
+
+ if( ! hasCommonAncestor( volume.owning_lib, holdPickupLib, 1 ) ) {
+
+ /* we don't want these items to transit to the pickup lib */
+ result.events.push('ITEM_NOT_HOLDABLE');
+ log_info("pickup_lib is not in the owning_lib's region...NOT OK");
- } else {
- log_info("patron and copy circ_lib do NOT share a common ancestor");
+ } else { /* pickup lib is in the owning region */
- if( hasCommonAncestor( copy.circ_lib.id, holdRequestLib.id, 1) ) {
- log_info("request_lib and copy circ_lib DO share a common ancestor");
+ if( isStaffHold && hasCommonAncestor( volume.owning_lib, holdRequestLib.id, 1) ) {
- } else {
+ /* staff in the region can place holds for patrons outside the region with local pickup lib */
+ log_info("local, staff-placed hold is allowed with local pickup_lib...OK");
- log_info("request_lib and copy circ_lib also do NOT share a common ancestor, hold on this type of material not allowed");
- result.events.push('ITEM_NOT_HOLDABLE');
- }
- }
+ } else {
+
+ if( hasCommonAncestor( volume.owning_lib, patron.home_ou.id, 1 ) ) {
+
+ /* patrons can hold the item if they are registered
+ in the region and pickup lib is local */
+ log_info("patron's home_ou is in the owning region...OK");
+
+ } else {
+
+ log_info("patron's home_ou lies outside the owning region...NOT OK");
+ result.events.push('ITEM_NOT_HOLDABLE');
+ }
+ }
+ }
}
+
+
} go();
+
+