From 67142117014d3567edcb10160ebc4b1fe0dafb62 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 4 Jun 2014 10:48:02 -0400 Subject: [PATCH] Bug 5144 [2] - Duplicate holds allowed if patron clicks back button after placing hold Koha is currently not engineered to handle multiple holds per record. Until such time that is does, we should not allow them to be created. Test Plan: 1) Apply the first patch in this series 2) Run t/db_dependent/Reserves.t 3) Note the failure of test 36 4) Apply the second patch in this series 5) Re-run Reserves.t 6) Note the success of test 36 --- C4/Reserves.pm | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index d399ee0..7dbb95e 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -38,8 +38,10 @@ use C4::Branch qw( GetBranchDetail ); use C4::Dates qw( format_date_in_iso ); use Koha::DateUtils; +use Koha::Database; use List::MoreUtils qw( firstidx ); +use Carp; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); @@ -149,6 +151,17 @@ sub AddReserve { $constraint, $bibitems, $priority, $resdate, $expdate, $notes, $title, $checkitem, $found ) = @_; + + my ($count) = C4::Context->dbh->selectrow_array( + 'SELECT COUNT(*) FROM reserves WHERE biblionumber = ? AND borrowernumber = ?', + undef, + ( $biblionumber, $borrowernumber ) + ); + if ( $count > 0 ) { + carp("AddReserve: borrower $borrowernumber already has $count holds for biblionumber $biblionumber"); + return; + } + my $fee = GetReserveFee($borrowernumber, $biblionumber, $constraint, $bibitems ); -- 1.7.2.5