From 7ec8571d8854358d31508dc27a700fa2c1e04897 Mon Sep 17 00:00:00 2001 From: Paul POULAIN Date: Mon, 8 Oct 2007 14:24:30 -0500 Subject: [PATCH] #668 cancel reserve on checkout does not work The reserve was cancelled only under certain circumstances (depending on reserve status) cancelling everytime. Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/Circulation.pm | 28 +++++++++++++--------------- C4/Reserves.pm | 4 ++-- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 6917110f25..561a801853 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -855,7 +855,6 @@ AddIssue does the following things : sub AddIssue { my ( $borrower, $barcode, $date, $cancelreserve ) = @_; - my $dbh = C4::Context->dbh; my $barcodecheck=CheckValidBarcode($barcode); if ($borrower and $barcode and $barcodecheck ne '0'){ @@ -925,20 +924,6 @@ if ($borrower and $barcode and $barcodecheck ne '0'){ my $branches = GetBranches(); my $branchname = $branches->{ $res->{'branchcode'} }->{'branchname'}; - if ($cancelreserve) { - CancelReserve( 0, $res->{'itemnumber'}, - $res->{'borrowernumber'} ); - } - else { - - # set waiting reserve to first in reserve queue as book isn't waiting now - ModReserve( - 1, - $res->{'biblionumber'}, - $res->{'borrowernumber'}, - $res->{'branchcode'} - ); - } } elsif ( $restype eq "Reserved" ) { @@ -954,6 +939,19 @@ if ($borrower and $barcode and $barcodecheck ne '0'){ $res->{'borrowernumber'} ); } } + if ($cancelreserve) { + CancelReserve( $res->{'biblionumber'}, 0, + $res->{'borrowernumber'} ); + } + else { + # set waiting reserve to first in reserve queue as book isn't waiting now + ModReserve( + 1, + $res->{'biblionumber'}, + $res->{'borrowernumber'}, + $res->{'branchcode'} + ); + } } # Starting process for transfer job (checking transfert and validate it if we have one) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 9d0061cfc9..d6bb83abf1 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -705,7 +705,7 @@ priorities of the other people who are waiting on the book. sub CancelReserve { my ( $biblio, $item, $borr ) = @_; my $dbh = C4::Context->dbh; - if ( ( $item and $borr ) and ( not $biblio ) ) { + if ( $item and $borr ) { # removing a waiting reserve record.... # update the database... my $query = " @@ -720,7 +720,7 @@ sub CancelReserve { $sth->execute( $item, $borr ); $sth->finish; } - if ( ( $biblio and $borr ) and ( not $item ) ) { + else { # removing a reserve record.... # get the prioritiy on this record.... my $priority; -- 2.20.1