From 6aba59f6a18b9d01d7e1461a9df9eeb6719896e6 Mon Sep 17 00:00:00 2001 From: Christopher Brannon Date: Thu, 1 Nov 2018 20:21:08 +0000 Subject: [PATCH] Bug 21346: Streamline logic in holds and transfers 1) Replaced comparison with string to make testing branch easier. 2) Replaced useless 0 values with undef. Does not change any behavior, only simplifies code. Signed-off-by: Lisette Signed-off-by: Liz Rea Signed-off-by: Kyle M Hall Signed-off-by: Nick Clemens (cherry picked from commit 48787acc6f725686583bb05f45888acf3e1231d0) Signed-off-by: Martin Renvoize (cherry picked from commit a1ff52bef45884b9a292cc5f84fdc49fce1c2c36) Signed-off-by: Lucas Gass --- circ/returns.pl | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/circ/returns.pl b/circ/returns.pl index 0d1fd6ff13..95dc6989f4 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -415,15 +415,44 @@ if ( $messages->{'ResFound'}) { my $reserve = $messages->{'ResFound'}; my $patron = Koha::Patrons->find( $reserve->{borrowernumber} ); my $holdmsgpreferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $reserve->{'borrowernumber'}, message_name => 'Hold_Filled' } ); - if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) { + my $branchCheck = ( $userenv_branch eq $reserve->{branchcode} ); + if ( $reserve->{'ResFound'} eq "Reserved" && C4::Context->preference('HoldsAutoFill') ) { + my $item = Koha::Items->find( $itemnumber ); + my $biblio = $item->biblio; + + my $diffBranchSend = !$branchCheck ? $reserve->{branchcode} : undef; + ModReserveAffect( $reserve->{itemnumber}, $reserve->{borrowernumber}, $diffBranchSend, $reserve->{reserve_id} ); + my ( $messages, $nextreservinfo ) = GetOtherReserves($reserve->{itemnumber}); + + my $patron = Koha::Patrons->find( $nextreservinfo ); + + $template->param( + hold_auto_filled => 1, + print_slip => C4::Context->preference('HoldsAutoFillPrintSlip'), + patron => $patron, + borrowernumber => $patron->id, + biblionumber => $biblio->id, + ); + + if ( $messages->{'transfert'} ) { + $template->param( + itemtitle => $biblio->title, + itemnumber => $item->itemnumber, + itembiblionumber => $biblio->biblionumber, + iteminfo => $biblio->author, + diffbranch => 1, + ); + } + } + elsif ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) { if ( $reserve->{'ResFound'} eq "Waiting" ) { $template->param( - waiting => ($userenv_branch eq $reserve->{'branchcode'} ? 1 : 0 ), + waiting => $branchCheck ? 1 : undef, ); } elsif ( $reserve->{'ResFound'} eq "Reserved" ) { $template->param( - intransit => ($userenv_branch eq $reserve->{'branchcode'} ? 0 : 1 ), - transfertodo => ($userenv_branch eq $reserve->{'branchcode'} ? 0 : 1 ), + intransit => $branchCheck ? undef : 1, + transfertodo => $branchCheck ? undef : 1, reserve_id => $reserve->{reserve_id}, reserved => 1, ); -- 2.39.5