From: djfiander Date: Wed, 19 Apr 2006 00:03:55 +0000 (+0000) Subject: Remove hold_items_count method, and move the code to drop a hold X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e33554623fee7b764714a3a8dedd4dbe9d0a8ff5;p=working%2FSIPServer.git Remove hold_items_count method, and move the code to drop a hold into a Patron method, rather than embedding it in the ils transaction level. --- diff --git a/ILS.pm b/ILS.pm index f8527ff..8138b89 100644 --- a/ILS.pm +++ b/ILS.pm @@ -235,16 +235,7 @@ sub cancel_hold { } # Remove the hold from the patron's record first - foreach my $i (0 .. scalar @{$patron->{hold_items}}-1) { - $hold = $patron->{hold_items}[$i]; - - if ($hold->{item_id} eq $item_id) { - # found it: now delete it - splice @{$patron->{hold_items}}, $i, 1; - $trans->ok(1); - last; - } - } + $trans->ok($patron->drop_hold($item_id)); if (!$trans->ok) { # We didn't find it on the patron record diff --git a/ILS/Patron.pm b/ILS/Patron.pm index c4d5de1..deae7c4 100644 --- a/ILS/Patron.pm +++ b/ILS/Patron.pm @@ -265,10 +265,22 @@ sub hold_items { return map $_->{item_id}, @{$self->{hold_items}}[$start-1 .. $end-1]; } -sub hold_items_count { - my $self = shift; +# +# remove the hold on item item_id from my hold queue. +# return true if I was holding the item, false otherwise. +# +sub drop_hold { + my ($self, $item_id) = @_; + my $i; + + for ($i = 0; $i < scalar @{$self->{hold_items}}; $i += 1) { + if ($self->{hold_items}[$i]->{item_id} eq $item_id) { + splice @{$self->{hold_items}}, $i, 1; + return 1; + } + } - return scalar @{$self->{hold_items}}; + return 0; } sub overdue_items { diff --git a/Sip/MsgType.pm b/Sip/MsgType.pm index b1a8073..9560bff 100644 --- a/Sip/MsgType.pm +++ b/Sip/MsgType.pm @@ -905,7 +905,7 @@ sub handle_patron_info { $resp .= $lang . Sip::timestamp(); $resp .= add_count('patron_info/hold_items', - $patron->hold_items_count); + scalar $patron->hold_items); $resp .= add_count('patron_info/overdue_items', $patron->overdue_items_count); $resp .= add_count('patron_info/charged_items',