From 8cb7747544ffa30eb093251c30d40b36f16c4872 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 20 Nov 2020 11:34:11 +0000 Subject: [PATCH] Bug 27064: Only allow transferring a hold from the transfers page MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit These patches replace the 'Waiting' button on the transfers page with a 'Transfer' button and correct some other related problem by passing the hold object to the template and using that to fetch patron info as well as passing the reserve_id through to ensure the correct hold is affected at all times To test: 1 - Place a hold for delivery at Library B 2 - Sign in at Library A 3 - Browse to Circulation->Transfers 4 - Attempt to transfer an item on the title with the hold to Library B 5 - You get a notice that hold was found (missing patron/branch info) 6 - You have the option to set the hold waiting - click it 7 - The transfer is generated and marked completed 8 - The hold is marked as waiting, but the item is still at Library A and no transfer is active 9 - The patron is notified that the hold is waiting 10 - Revert the hold or cancel and place a new one 11 - Apply patches 12 - Attempt transfer again 13 - You now have the option to transfer the hold 14 - Click that 15 - Hold is in transit and transfer is generated correctly 16 - Transfer again and choose 'cancel' 17 - Confirm hold is cancelled and transfer generated Signed-off-by: Martin Renvoize Signed-off-by: Joonas Kylmälä Signed-off-by: Jonathan Druart --- circ/branchtransfers.pl | 44 ++++++++++--------- .../prog/en/modules/circ/branchtransfers.tt | 16 ++++--- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/circ/branchtransfers.pl b/circ/branchtransfers.pl index 95ec789926..59b4f24fec 100755 --- a/circ/branchtransfers.pl +++ b/circ/branchtransfers.pl @@ -77,7 +77,7 @@ my $hold_transferred; my $hold_processed; my $reqmessage; my $cancelled; -my $setwaiting; +my $settransit; my $request = $query->param('request') || ''; my $borrowernumber = $query->param('borrowernumber') || 0; @@ -98,21 +98,20 @@ if ( $request eq "KillWaiting" ) { $reqmessage = 1; } # FIXME else? } -elsif ( $request eq "SetWaiting" ) { +elsif ( $request eq "SetTransit" ) { my $item = $query->param('itemnumber'); - ModReserveAffect( $item, $borrowernumber ); + my $reserve_id = $query->param('reserve_id'); + ModReserveAffect( $item, $borrowernumber, 1, $reserve_id ); $ignoreRs = 1; - $setwaiting = 1; + $settransit = 1; $reqmessage = 1; } elsif ( $request eq 'KillReserved' ) { my $biblionumber = $query->param('biblionumber'); - my $holds = Koha::Holds->search({ - biblionumber => $biblionumber, - borrowernumber => $borrowernumber - }); - if ( $holds->count ) { - $holds->next->cancel; + my $reserve_id = $query->param('reserve_id'); + my $hold = Koha::Holds->find({ reserve_id => $reserve_id }); + if ( $hold ) { + $hold->cancel; $cancelled = 1; $reqmessage = 1; } # FIXME else? @@ -170,20 +169,24 @@ my $biblionumber; ##################### -if ($found) { - my $res = $messages->{'ResFound'}; - $itemnumber = $res->{'itemnumber'}; - $borrowernumber = $res->{'borrowernumber'}; +my $hold; +if ($found){ + $hold = Koha::Holds->find( + { reserve_id => $found->{reserve_id} }, + { prefetch => ['item','patron'] } + ); + $itemnumber = $found->{'itemnumber'}; + $borrowernumber = $found->{'borrowernumber'}; - if ( $res->{'ResFound'} eq "Waiting" ) { + if ( $found->{'ResFound'} eq "Waiting" ) { $waiting = 1; - } elsif ( $res->{'ResFound'} eq "Transferred" ) { + } elsif ( $found->{'ResFound'} eq "Transferred" ) { $hold_transferred = 1; - } elsif ( $res->{'ResFound'} eq "Processing" ) { + } elsif ( $found->{'ResFound'} eq "Processing" ) { $hold_processed = 1; - } elsif ( $res->{'ResFound'} eq "Reserved" ) { + } elsif ( $found->{'ResFound'} eq "Reserved" ) { $reserved = 1; - $biblionumber = $res->{'biblionumber'}; + $biblionumber = $found->{'biblionumber'}; } } @@ -221,6 +224,7 @@ foreach my $code ( keys %$messages ) { $template->param( found => $found, + hold => $hold, reserved => $reserved, waiting => $waiting, transferred => $hold_transferred, @@ -232,7 +236,7 @@ $template->param( tobranchcd => $tobranchcd, reqmessage => $reqmessage, cancelled => $cancelled, - setwaiting => $setwaiting, + settransit => $settransit, trsfitemloop => \@trsfitemloop, errmsgloop => \@errmsgloop, PatronAutoComplete => C4::Context->preference("PatronAutoComplete"), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt index e27f7d4b5e..96058fcd88 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt @@ -40,7 +40,7 @@ @@ -86,6 +89,7 @@ [% END %] + @@ -120,8 +124,8 @@ [% IF ( cancelled ) %]
  • Reserve cancelled
  • [% END %] - [% IF ( setwaiting ) %] -
  • Item should now be waiting at library: [% reqbrchname | html %]
  • + [% IF ( settransit ) %] +
  • Item is now in transit to [% Branches.GetName(tobranchcd) | html %]
  • [% END %] -- 2.39.5
    [% IF ( reserved ) %] - Reserve found for [% name | html %] ([% borrowernumber | html %]). + Reserve found for [% INCLUDE 'patron-title.inc' patron => hold.patron | html %] ([% borrowernumber | html %]). [% END %] [% IF ( waiting ) %] Item is marked waiting at [% branchname | html %] for [% name | html %] ([% borrowernumber | html %]). @@ -51,7 +51,9 @@
    - [% IF ( reserved ) %]Set reserve to waiting and transfer book to [% branchname | html %]: [% END %] + [% IF ( reserved ) %] + Set reserve to transit and transfer book to [% Branches.GetName( hold.branchcode ) | html %]: + [% END %] [% IF ( waiting or transferred ) %]Cancel reservation and then attempt transfer: [% END %] @@ -61,6 +63,7 @@ [% END %] + @@ -70,8 +73,8 @@ [% END %] [% IF ( reserved ) %] - - + + [% END %]