From 2d67c8a70279062224bee4d7c6bfb63ddeefeed9 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 12 Mar 2007 15:43:54 +0000 Subject: [PATCH] updated hold logic git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_0@7063 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/javascript/backend/circ/circ_lib.js | 14 ++++-- .../javascript/backend/circ/circ_permit_hold.js | 56 +++++++++++++++------- 2 files changed, 50 insertions(+), 20 deletions(-) diff --git a/Open-ILS/src/javascript/backend/circ/circ_lib.js b/Open-ILS/src/javascript/backend/circ/circ_lib.js index 28639e77a8..8024f5aaa7 100644 --- a/Open-ILS/src/javascript/backend/circ/circ_lib.js +++ b/Open-ILS/src/javascript/backend/circ/circ_lib.js @@ -40,6 +40,7 @@ var isRenewal = environment.isRenewal; var isPrecat = environment.isPrecat; var currentLocation = environment.location; var holdRequestLib = environment.requestLib; +var holdPickupLib = environment.pickupLib; /* hold pickup lib */ @@ -224,10 +225,10 @@ function log_vars( prefix ) { 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; @@ -247,8 +248,12 @@ function log_vars( prefix ) { } 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; @@ -261,6 +266,7 @@ function log_vars( prefix ) { 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); } diff --git a/Open-ILS/src/javascript/backend/circ/circ_permit_hold.js b/Open-ILS/src/javascript/backend/circ/circ_permit_hold.js index 179982a29e..41e3374a72 100644 --- a/Open-ILS/src/javascript/backend/circ/circ_permit_hold.js +++ b/Open-ILS/src/javascript/backend/circ/circ_permit_hold.js @@ -4,14 +4,17 @@ load_lib('circ/circ_lib.js'); 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) ) @@ -26,15 +29,18 @@ if( !isTrue(copy.circulate) ) /* 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' || @@ -58,25 +64,43 @@ if( ( marcItemType == 'g' || 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(); + + -- 2.11.0