LP1182519 Per-Hold Behind Desk ML
authorBill Erickson <berick@esilibrary.com>
Wed, 22 May 2013 18:48:50 +0000 (14:48 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 22 May 2013 18:48:50 +0000 (14:48 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm

index 2951898..229b250 100644 (file)
@@ -274,11 +274,21 @@ sub promote_lineitem_holds {
             $hold->target( $li->eg_bib_id );
         }
 
-        my $set = $mgr->editor->search_actor_user_setting(
-            {usr => $hold->usr, name => 'circ.holds_behind_desk'})->[0];
+        # if behind-the-desk holds are supported at the 
+        # pickup library, apply the patron default
+        my $bdous = $U->ou_ancestor_setting_value(
+            $hold->pickup_lib, 
+            'circ.holds.behind_desk_pickup_supported', 
+            $mgr->editor
+        );
 
-        $hold->behind_desk('t') if $set and 
-            OpenSRF::Utils::JSON->JSON2perl($set->value);
+        if ($bdous) {
+            my $set = $mgr->editor->search_actor_user_setting(
+                {usr => $hold->usr, name => 'circ.holds_behind_desk'})->[0];
+    
+            $hold->behind_desk('t') if $set and 
+                OpenSRF::Utils::JSON->JSON2perl($set->value);
+        }
 
         $mgr->editor->create_action_hold_request( $hold ) or return 0;
     }
index a2eda23..046dcc9 100644 (file)
@@ -339,11 +339,30 @@ sub create_hold {
         $hold->expire_time(calculate_expire_time($recipient->home_ou));
     }
 
-       my $set = $e->search_actor_user_setting(
-               {usr => $hold->usr, name => 'circ.holds_behind_desk'})->[0];
 
-    $hold->behind_desk('t') if $set and 
-        OpenSRF::Utils::JSON->JSON2perl($set->value);
+    # if behind-the-desk pickup is supported at the hold pickup lib,
+    # set the value to the patron default, unless a value has already
+    # been applied.  If it's not supported, force the value to false.
+
+    my $bdous = $U->ou_ancestor_setting_value(
+        $hold->pickup_lib, 
+        'circ.holds.behind_desk_pickup_supported', $e);
+
+    if ($bdous) {
+        if (!defined $hold->behind_desk) {
+
+            my $set = $e->search_actor_user_setting({
+                usr => $hold->usr, 
+                name => 'circ.holds_behind_desk'
+            })->[0];
+        
+            $hold->behind_desk('t') if $set and 
+                OpenSRF::Utils::JSON->JSON2perl($set->value);
+        }
+    } else {
+        # behind the desk not supported, force it to false
+        $hold->behind_desk('f');
+    }
 
     $hold->requestor($e->requestor->id);
     $hold->request_lib($e->requestor->ws_ou);