From e681638c3b53fb6474609b8680d2c89f6fe33fd2 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 25 May 2010 11:44:46 -0400 Subject: [PATCH] Bug 4812: Reserves for a specific copy of a book say book is available even though it it still checked out When you place a reserve on a specific copy of a book a note is immediately put on the card of the person for whom the book is being reserved that says the book is available even though it is still checked out to someone else. The code is in placerequest.pl & opac-reserve.pl holdingbranch if ($checkitem ne ''){ $rank[0] = '0' unless C4::Context->preference('ReservesNeedReturns'); my $item = $checkitem; $item = GetItem($item); if ( $item->{'holdingbranch'} eq $branch ){ $found = 'W' unless C4::Context->preference('ReservesNeedReturns'); } } This code does not bother to check to see if an item is actually on the shelf, it sets it to 'W' reguardless. --- opac/opac-reserve.pl | 12 +++++++++--- reserve/placerequest.pl | 17 ++++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 2be6991..7da0393 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -42,6 +42,7 @@ use Koha::ItemTypes; use Koha::Checkouts; use Koha::Libraries; use Koha::Patrons; +use Koha::Holds; use Date::Calc qw/Today Date_to_Days/; use List::MoreUtils qw/uniq/; @@ -272,11 +273,16 @@ if ( $query->param('place_reserve') ) { my $rank = $biblioData->{rank}; if ( $itemNum ne '' ) { $canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum ) eq 'OK'; - $rank = '0' unless C4::Context->preference('ReservesNeedReturns'); my $item = GetItem($itemNum); if ( $item->{'holdingbranch'} eq $branch ) { - $found = 'W' - unless C4::Context->preference('ReservesNeedReturns'); + unless ( + C4::Context->preference('ReservesNeedReturns') + || Koha::Checkouts->search( { itemnumber => $itemNum } )->count > 0 + || Koha::Holds->search( { itemnumber => $itemNum, priority => 0 } )->count > 0 + ) { + $rank = '0'; + $found = 'W'; + } } } else { diff --git a/reserve/placerequest.pl b/reserve/placerequest.pl index 3c55656..63445ab 100755 --- a/reserve/placerequest.pl +++ b/reserve/placerequest.pl @@ -32,6 +32,8 @@ use C4::Circulation; use C4::Members; use C4::Auth qw/checkauth/; use Koha::Patrons; +use Koha::Checkouts; +use Koha::Holds; my $input = CGI->new(); @@ -74,11 +76,16 @@ my $found; # of the document, we force the value $rank and $found . if (defined $checkitem && $checkitem ne ''){ $holds_to_place_count = 1; - $rank[0] = '0' unless C4::Context->preference('ReservesNeedReturns'); - my $item = $checkitem; - $item = GetItem($item); - if ( $item->{'holdingbranch'} eq $branch ){ - $found = 'W' unless C4::Context->preference('ReservesNeedReturns'); + my $item = GetItem($checkitem); + if ( $item->{'holdingbranch'} eq $branch ) { + unless ( + C4::Context->preference('ReservesNeedReturns') + || Koha::Checkouts->search( { itemnumber => $checkitem } )->count > 0 + || Koha::Holds->search( { itemnumber => $checkitem, priority => 0 } )->count > 0 + ) { + $rank[0] = '0'; + $found = 'W'; + } } } -- 2.10.2