From: djfiander Date: Fri, 23 Jun 2006 00:15:28 +0000 (+0000) Subject: Change definition of Patron::available to test to see if the item X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0ad1f8c04caeaad1f6d621ef40093f240ee7b8cb;p=working%2FSIPServer.git Change definition of Patron::available to test to see if the item is available for a patron, rather than just available in general. --- diff --git a/ILS.pm b/ILS.pm index 4199163..36c1ac1 100644 --- a/ILS.pm +++ b/ILS.pm @@ -370,6 +370,8 @@ sub renew { if (!defined($item)) { # It's not checked out to $patron_id $trans->screen_msg("Item not checked out to " . $patron->name); + } elsif (!$item->available($patron_id)) { + $trans->screen_msg("Item has outstanding holds"); } else { $trans->item($item); $trans->renewal_ok(1); diff --git a/ILS/Item.pm b/ILS/Item.pm index 31a8244..52b4fd6 100644 --- a/ILS/Item.pm +++ b/ILS/Item.pm @@ -178,14 +178,23 @@ sub screen_msg { } sub print_line { - my $self = shift; + my $self = shift; - return $self->{print_line} || ''; + return $self->{print_line} || ''; } +# An item is available for a patron if +# 1) It's not checked out and (there's no hold queue OR patron +# is at the front of the queue) +# OR +# 2) It's checked out to the patron and there's no hold queue sub available { - my $self = shift; + my ($self, $for_patron) = shift; - return (!$self->{patron_id} && !$self->{hold_queue}); + return ((!$self->{patron_id} && (!scalar @{$self->{hold_queue}} + || $self->{hold_queue}[0] == $for_patron)) + || ($self->{patron_id} && ($self->{patron_id} == $for_patron) + && !scalar @{$self->{hold_queue}})); } + 1; diff --git a/Sip/MsgType.pm b/Sip/MsgType.pm index 9d403dd..1200075 100644 --- a/Sip/MsgType.pm +++ b/Sip/MsgType.pm @@ -1231,7 +1231,7 @@ sub handle_hold { } $resp .= $status->ok; - $resp .= sipbool($status->item && $status->item->available); + $resp .= sipbool($status->item && $status->item->available($patron_id)); $resp .= Sip::timestamp; if ($status->ok) {