From d9cf60a55b8dd4b4a105fef9343ec04f68fd58ae Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Fri, 28 Sep 2018 03:00:13 +0000 Subject: [PATCH] Bug 19532: Amended C4/Circulation->CanBookBeIssued() This function now checks for waiting recalls before checking for reserves on an item. If a recall record does exist and it was placed by the same borrower who is trying to check out the item then no check for reserves takes place because the waiting recall takes precedence. Sponsored-By: Toi Ohomai Institute of Technology, New Zealand --- C4/Circulation.pm | 71 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index fba99bc..145b246 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -994,48 +994,51 @@ sub CanBookBeIssued { } } - unless ( $ignore_reserves ) { - # See if the item is on reserve. - my ( $restype, $res ) = C4::Reserves::CheckReserves( $item->{'itemnumber'} ); - if ($restype) { - my $resbor = $res->{'borrowernumber'}; - if ( $resbor ne $patron->borrowernumber ) { - my $patron = Koha::Patrons->find( $resbor ); - if ( $restype eq "Waiting" ) - { - # The item is on reserve and waiting, but has been - # reserved by some other patron. - $needsconfirmation{RESERVE_WAITING} = 1; - $needsconfirmation{'resfirstname'} = $patron->firstname; - $needsconfirmation{'ressurname'} = $patron->surname; - $needsconfirmation{'rescardnumber'} = $patron->cardnumber; - $needsconfirmation{'resborrowernumber'} = $patron->borrowernumber; - $needsconfirmation{'resbranchcode'} = $res->{branchcode}; - $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; - } - elsif ( $restype eq "Reserved" ) { - # The item is on reserve for someone else. - $needsconfirmation{RESERVED} = 1; - $needsconfirmation{'resfirstname'} = $patron->firstname; - $needsconfirmation{'ressurname'} = $patron->surname; - $needsconfirmation{'rescardnumber'} = $patron->cardnumber; - $needsconfirmation{'resborrowernumber'} = $patron->borrowernumber; - $needsconfirmation{'resbranchcode'} = $patron->branchcode; - $needsconfirmation{'resreservedate'} = $res->{reservedate}; - } - } - } - } - + my $recall; #CHECK IF ITEM HAS WAITING RECALL FOR ANOTHER PATRON if ( C4::Context->preference('UseRecalls') ) { - my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'} }); + $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'}, status => 'W' }); if ((defined $recall) && ($recall->patron->borrowernumber != $patron->borrowernumber) && $recall->status eq 'W') { #Item has been recalled by a different patron and is waiting for them $issuingimpossible{WAITING_RECALL_FOR_A_DIFFERENT_PATRON} = 1; } } + if (!((defined $recall) && $recall->patron->borrowernumber == $patron->borrowernumber && $recall->status eq 'W')) { + unless ( $ignore_reserves ) { + # See if the item is on reserve. + my ( $restype, $res ) = C4::Reserves::CheckReserves( $item->{'itemnumber'} ); + if ($restype) { + my $resbor = $res->{'borrowernumber'}; + if ( $resbor ne $patron->borrowernumber ) { + my $patron = Koha::Patrons->find( $resbor ); + if ( $restype eq "Waiting" ) + { + # The item is on reserve and waiting, but has been + # reserved by some other patron. + $needsconfirmation{RESERVE_WAITING} = 1; + $needsconfirmation{'resfirstname'} = $patron->firstname; + $needsconfirmation{'ressurname'} = $patron->surname; + $needsconfirmation{'rescardnumber'} = $patron->cardnumber; + $needsconfirmation{'resborrowernumber'} = $patron->borrowernumber; + $needsconfirmation{'resbranchcode'} = $res->{branchcode}; + $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; + } + elsif ( $restype eq "Reserved" ) { + # The item is on reserve for someone else. + $needsconfirmation{RESERVED} = 1; + $needsconfirmation{'resfirstname'} = $patron->firstname; + $needsconfirmation{'ressurname'} = $patron->surname; + $needsconfirmation{'rescardnumber'} = $patron->cardnumber; + $needsconfirmation{'resborrowernumber'} = $patron->borrowernumber; + $needsconfirmation{'resbranchcode'} = $patron->branchcode; + $needsconfirmation{'resreservedate'} = $res->{reservedate}; + } + } + } + } + } + ## CHECK AGE RESTRICTION my $agerestriction = $biblioitem->agerestriction; my ($restriction_age, $daysToAgeRestriction) = GetAgeRestriction( $agerestriction, $patron->unblessed ); -- 2.1.4