Bug 31318: Remove GetItemsInfo from serials/routing-preview
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 3 Jun 2022 06:26:41 +0000 (08:26 +0200)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 16 Aug 2022 12:27:15 +0000 (09:27 -0300)
Bug 27272 is going to remove C4::Items::GetItemsInfo in favour of Koha::Items->search_ordered.

Here we are going to deal with serials/routing-preview

Test plan:
List items on the modified view and confirm that all the info is
displayed correctly

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
serials/routing-preview.pl

index b33cb8d..462ad30 100755 (executable)
@@ -25,7 +25,6 @@ use C4::Auth qw( get_template_and_user );
 use C4::Output qw( output_html_with_http_headers );
 use C4::Reserves qw( AddReserve ModReserve );
 use C4::Context;
-use C4::Items qw( GetItemsInfo );
 use C4::Serials qw( delroutingmember getroutinglist GetSubscription GetSerials check_routing );
 use URI::Escape;
 
@@ -62,14 +61,18 @@ my $library;
 if($ok){
     # get biblio information....
     my $biblionumber = $subs->{'bibnum'};
-    my @itemresults = GetItemsInfo( $biblionumber );
-    my $branch = @itemresults ? $itemresults[0]->{'holdingbranch'} : $subs->{branchcode};
+
+    my $biblio = Koha::Biblios->find( $biblionumber );
+    my $items = $biblio->items->search_ordered;
+    my $branch =
+        $items->count
+      ? $items->next->holding_branch->branchcode
+      : $subs->{branchcode};
     $library = Koha::Libraries->find($branch);
 
        if (C4::Context->preference('RoutingListAddReserves')){
                # get existing reserves .....
 
-        my $biblio = Koha::Biblios->find( $biblionumber );
         my $holds = $biblio->current_holds;
         my $count = $holds->count;
         while ( my $hold = $holds->next ) {