From 86117fe1c868d43740bb3dd13ea2a5d75cc06e02 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 19 Nov 2012 13:38:37 -0500 Subject: [PATCH] [SIGNED-OFF] Bug 8451 - Confusing and problematic double prompt for processing transfers Content-Type: text/plain; charset="utf-8" This patch will cause changing the priority of a reserve from 'in transit' to a priority number to delete the transfer associated with it, if there is one. Signed-off-by: Owen Leonard Tested with this plan: 1. Place a hold on an item for delivery to another branch. 2. Check in the item and confirm the transfer. 3. Edit the hold, changing the status from in-transit to a priority number. 4. Check in the item again. Before the patch I would see two prompts at step 4. After the patch I see one. --- C4/Reserves.pm | 17 +++++++++++++++-- .../prog/en/modules/reserve/request.tt | 1 + reserve/modrequest.pl | 3 ++- reserve/request.pl | 1 + 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index a380bf0..a730a56 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -273,7 +273,8 @@ sub GetReservesFromBiblionumber { expirationdate, lowestPriority, suspend, - suspend_until + suspend_until, + reserve_id FROM reserves WHERE biblionumber = ? "; unless ( $all_dates ) { @@ -1056,7 +1057,7 @@ itemnumber and supplying itemnumber. sub ModReserve { #subroutine to update a reserve - my ( $rank, $biblio, $borrower, $branch , $itemnumber, $suspend_until) = @_; + my ( $rank, $biblio, $borrower, $branch , $itemnumber, $suspend_until, $reserve_id ) = @_; return if $rank eq "W"; return if $rank eq "n"; my $dbh = C4::Context->dbh; @@ -1089,6 +1090,13 @@ sub ModReserve { } elsif ($rank =~ /^\d+/ and $rank > 0) { + my $reserve; + if ( $reserve_id ) { + my $sth = $dbh->prepare("SELECT * FROM reserves WHERE reserve_id = ?"); + $sth->execute( $reserve_id ); + $reserve = $sth->fetchrow_hashref(); + } + my $query = " UPDATE reserves SET priority = ? ,branchcode = ?, itemnumber = ?, found = NULL, waitingdate = NULL WHERE biblionumber = ? @@ -1098,6 +1106,11 @@ sub ModReserve { $sth->execute( $rank, $branch,$itemnumber, $biblio, $borrower); $sth->finish; + ## If we are re-prioritizing a previously 'in transit' hold, we need to remove any item transfer that may have been created for it. + if ( $reserve->{'found'} eq 'T' ) { + $dbh->do("DELETE FROM branchtransfers WHERE itemnumber = ? AND tobranch = ? AND datearrived IS NULL", undef, ( $itemnumber, $reserve->{'branchcode'} ) ); + } + if ( defined( $suspend_until ) ) { if ( $suspend_until ) { $suspend_until = C4::Dates->new( $suspend_until )->output("iso"); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt index 0ad5d23..06e3385 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -553,6 +553,7 @@ function checkMultiHold() { [% FOREACH reserveloo IN biblioloo.reserveloop %] [% UNLESS ( loop.odd ) %][% ELSE %][% END %] +