Use hold current shelf lib to determine availability : SIP
authorBill Erickson <berick@esilibrary.com>
Wed, 28 Dec 2011 14:54:32 +0000 (09:54 -0500)
committerBill Erickson <berick@esilibrary.com>
Wed, 4 Jan 2012 20:48:47 +0000 (15:48 -0500)
The availability of a hold can now be determined by
hold.current_shelf_lib == hold.pickup_lib.

This change updates the unavailable holds count function for the patron
information SIP call(s).

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm

index d2b2085..68d8c13 100644 (file)
@@ -624,16 +624,27 @@ sub recall_items {
 sub unavail_holds {
      my ($self, $start, $end) = @_;
      syslog('LOG_DEBUG', 'OILS: Patron->unavail_holds()');
+
+     my $ids = $self->{editor}->json_query({
+        select => {ahr => ['id']},
+        from => 'ahr',
+        where => {
+            usr => $self->{user}->id,
+            fulfillment_time => undef,
+            cancel_time => undef,
+            '-or' => [
+                {current_shelf_lib => undef},
+                {current_shelf_lib => {'!=' => {'+ahr' => 'pickup_lib'}}}
+            ]
+        }
+    });
  
      my @holds_sip_output = map {
         OpenILS::SIP::clean_text($self->__hold_to_title($_))
      } @{
-        $self->{editor}->search_action_hold_request({
-            usr              => $self->{user}->id,
-            fulfillment_time => undef,
-            cancel_time      => undef,
-            shelf_time       => undef
-        })
+        $self->{editor}->search_action_hold_request(
+            {id => [map {$_->{id}} @$ids]}
+        )
      };
  
      return (defined $start and defined $end) ?