From ca716c66302bd71dc23df93f0e592e7506b16de2 Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Mon, 15 Mar 2021 15:56:20 +0000
Subject: [PATCH] Bug 24295: Remove GetTransfers from opac-reserve.pl

This patch replaces the call to GetTransfers in opac-reserve with the
get_transfer method available from the Koha::Item object

Test plan
1/ Place a reserve on an item at a different branch
2/ Trigger the transfer of the item
3/ Check the opac-reserves page for the display of the current transfer
status
4/ Apply patch
5/ Repeat step 3
---
 opac/opac-reserve.pl | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl
index e8810650f7..da005755e7 100755
--- a/opac/opac-reserve.pl
+++ b/opac/opac-reserve.pl
@@ -23,7 +23,7 @@ use Modern::Perl;
 use CGI qw ( -utf8 );
 use C4::Auth qw( get_template_and_user );
 use C4::Koha qw( getitemtypeimagelocation getitemtypeimagesrc );
-use C4::Circulation qw( GetBranchItemRule GetTransfers );
+use C4::Circulation qw( GetBranchItemRule );
 use C4::Reserves qw( CanItemBeReserved CanBookBeReserved AddReserve GetReservesControlBranch ItemsAnyAvailableAndNotRestricted IsAvailableForItemLevelRequest );
 use C4::Biblio qw( GetBiblioData GetFrameworkCode GetMarcBiblio );
 use C4::Items qw( GetHostItemsInfo GetItemsInfo );
@@ -543,12 +543,11 @@ foreach my $biblioNum (@biblionumbers) {
         }
 
         # Check of the transferred documents
-        my ( $transfertwhen, $transfertfrom, $transfertto ) =
-          GetTransfers($itemNum);
-        if ( $transfertwhen && ($transfertwhen ne '') ) {
-            $itemLoopIter->{transfertwhen} = output_pref({ dt => dt_from_string($transfertwhen), dateonly => 1 });
-            $itemLoopIter->{transfertfrom} = $transfertfrom;
-            $itemLoopIter->{transfertto} = $transfertto;
+        my $transfer = $item->get_transfer;
+        if ( $transfer && $transfer->in_transit ) {
+            $itemLoopIter->{transfertwhen} = output_pref({ dt => dt_from_string($transfer->datesent), dateonly => 1 });
+            $itemLoopIter->{transfertfrom} = $transfer->frombranch;
+            $itemLoopIter->{transfertto} = $transfer->tobranch;
             $itemLoopIter->{nocancel} = 1;
         }
 
-- 
2.20.1