Bug 31028: (follow-up) Rename TICKET_ACKNOWLEDGE
[srvgit] / opac / opac-detail.pl
index ed224e0..98c4f94 100755 (executable)
@@ -480,7 +480,7 @@ if ($session->param('busc')) {
         next unless ($arrBiblios[$j]);
         $dataBiblioPaging = Koha::Biblios->find( $arrBiblios[$j] ) if ($arrBiblios[$j] != $biblionumber);
         next unless $dataBiblioPaging;
-        push @listResults, {index => $j + 1 + $offset, biblionumber => $arrBiblios[$j], title => ($arrBiblios[$j] == $biblionumber)?'':$dataBiblioPaging->title, author => ($arrBiblios[$j] != $biblionumber && $dataBiblioPaging->author)?$dataBiblioPaging->author:'', url => ($arrBiblios[$j] == $biblionumber)?'':'opac-detail.pl?biblionumber=' . $arrBiblios[$j]};
+        push @listResults, {index => $j + 1 + $offset, biblionumber => $arrBiblios[$j], title => ($arrBiblios[$j] == $biblionumber)?'':$dataBiblioPaging->title, author => ($arrBiblios[$j] != $biblionumber && $dataBiblioPaging->author)?$dataBiblioPaging->author:'', part_number => ($arrBiblios[$j] == $biblionumber)?'':$dataBiblioPaging->part_number, part_name => ($arrBiblios[$j] == $biblionumber)?'':$dataBiblioPaging->part_name, url => ($arrBiblios[$j] == $biblionumber)?'':'opac-detail.pl?biblionumber=' . $arrBiblios[$j]};
     }
     $template->param('listResults' => \@listResults) if (@listResults);
     $template->param('indexPag' => 1 + $offset, 'totalPag' => $arrParamsBusc{'total'}, 'indexPagEnd' => scalar(@arrBiblios) + $offset);
@@ -488,10 +488,6 @@ if ($session->param('busc')) {
 }
 }
 
-$template->param(
-    OPACShowCheckoutName => C4::Context->preference("OPACShowCheckoutName"),
-);
-
 $items = Koha::Items->search_ordered(
     [
         'me.biblionumber' => $biblionumber,
@@ -616,8 +612,8 @@ if ( $showcomp eq 'both' || $showcomp eq 'opac' ) {
               );
         }
         $template->param( ComponentParts => $parts );
-        my ( $comp_query, $comp_sort ) = $biblio->get_components_query;
-        my $cpq = $comp_query . "&sort_by=" . $comp_sort;
+        my ( $comp_query, $comp_query_str, $comp_sort ) = $biblio->get_components_query;
+        my $cpq = $comp_query_str . "&sort_by=" . $comp_sort;
         $template->param( ComponentPartsQuery => $cpq );
     }
 } else { # check if we should show analytics anyway
@@ -626,11 +622,12 @@ if ( $showcomp eq 'both' || $showcomp eq 'opac' ) {
 
 # XSLT processing of some stuff
 my $variables = {};
+my $lang = C4::Languages::getlanguage();
 my @plugin_responses = Koha::Plugins->call(
     'opac_detail_xslt_variables',
     {
         biblio_id => $biblionumber,
-        lang      => C4::Languages::getlanguage(),
+        lang      => $lang,
         patron_id => $borrowernumber,
     },
 );
@@ -650,19 +647,10 @@ $template->param(
 );
 
 # Get items on order
-my ( @itemnumbers_on_order );
 if ( C4::Context->preference('OPACAcquisitionDetails' ) ) {
-    my $orders = C4::Acquisition::SearchOrders({
-        biblionumber => $biblionumber,
-        ordered => 1,
-    });
+    my $orders = $biblio->orders->filter_by_active;
     my $total_quantity = 0;
-    for my $order ( @$orders ) {
-        my $order = Koha::Acquisition::Orders->find( $order->{ordernumber} );
-        my $basket = $order->basket;
-        if ( $basket->effective_create_items eq 'ordering' ) {
-            @itemnumbers_on_order = $order->items->get_column('itemnumber');
-        }
+    while ( my $order = $orders->next ) {
         $total_quantity += $order->quantity;
     }
     $template->{VARS}->{acquisition_details} = {
@@ -679,11 +667,21 @@ if ( not $viewallitems and $items->count > $max_items_to_display ) {
     );
 }
 else {
+    my $library_info;
     while ( my $item = $items->next ) {
         my $item_info = $item->unblessed;
         $item_info->{holds_count} = $item_reserves{ $item->itemnumber };
         $item_info->{priority}    = $priority{ $item->itemnumber };
 
+        # Get opac_info from Additional contents for home and holding library
+        my ( $opac_info_home, $opac_info_holding );
+        $opac_info_holding = $library_info->{ $item->holdingbranch } // $item->holding_branch->opac_info({ lang => $lang });
+        $library_info->{ $item->holdingbranch } = $opac_info_holding;
+        $opac_info_home = $library_info->{ $item->homebranch } // $item->home_branch->opac_info({ lang => $lang });
+        $library_info->{ $item->homebranch } = $opac_info_home;
+        $item_info->{holding_library_info} = $opac_info_holding->content if $opac_info_holding;
+        $item_info->{home_library_info} = $opac_info_home->content if $opac_info_home;
+
         $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy(
             { item => $item, patron => $patron } )
           unless $allow_onshelf_holds;
@@ -728,20 +726,12 @@ else {
         $item_info->{checkout} = $item->checkout;
         $item_info->{object} = $item;
 
-        if ( C4::Context->preference('OPACAcquisitionDetails') ) {
-            $item_info->{on_order} = 1
-              if grep { $_ eq $item->itemnumber } @itemnumbers_on_order;
-        }
 
         if ( C4::Context->preference("OPACLocalCoverImages") == 1 ) {
             $item_info->{cover_images} = $item->cover_images;
         }
 
 
-        if ( $item->in_bundle ) {
-            $item_info->{bundle_host} = $item->bundle_host;
-        }
-
         if ( C4::Context->preference('UseCourseReserves') ) {
             $item_info->{course_reserves} = GetItemCourseReservesInfo( itemnumber => $item->itemnumber );
         }
@@ -1100,7 +1090,7 @@ if (C4::Context->preference("OPACShelfBrowser")) {
         );
 
         # in which tab shelf browser should open ?
-        if (grep { $starting_itemnumber == $_->itemnumber } @itemloop) {
+        if (grep { $starting_itemnumber == $_->{itemnumber} } @itemloop) {
             $template->param(shelfbrowser_tab => 'holdings');
         } else {
             $template->param(shelfbrowser_tab => 'otherholdings');