Bug 12495 - Include streetnumber in hold alert address
[koha_fer] / opac / opac-detail.pl
index 01c801f..224bf82 100755 (executable)
@@ -24,6 +24,7 @@ use strict;
 use warnings;
 
 use CGI;
+use C4::Acquisition qw( SearchOrders );
 use C4::Auth qw(:DEFAULT get_session);
 use C4::Branch;
 use C4::Koha;
@@ -596,6 +597,28 @@ if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) {
 my $separatebranch = C4::Context->preference('OpacSeparateHoldingsBranch');
 my $viewallitems = $query->param('viewallitems');
 my $max_items_to_display = C4::Context->preference('OpacMaxItemsToDisplay') // 50;
+
+# Get items on order
+my ( @itemnumbers_on_order );
+if ( C4::Context->preference('OPACAcquisitionDetails' ) ) {
+    my $orders = C4::Acquisition::SearchOrders({
+        biblionumber => $biblionumber,
+        ordered => 1,
+    });
+    my $total_quantity = 0;
+    for my $order ( @$orders ) {
+        if ( C4::Context->preference('AcqCreateItem') eq 'ordering' ) {
+            for my $itemnumber ( C4::Acquisition::GetItemnumbersFromOrder( $order->{ordernumber} ) ) {
+                push @itemnumbers_on_order, $itemnumber;
+            }
+        }
+        $total_quantity += $order->{quantity};
+    }
+    $template->{VARS}->{acquisition_details} = {
+        total_quantity => $total_quantity,
+    };
+}
+
 if ( not $viewallitems and @items > $max_items_to_display ) {
     $template->param(
         too_many_items => 1,
@@ -647,6 +670,14 @@ if ( not $viewallitems and @items > $max_items_to_display ) {
         $itm->{transfertfrom} = $branches->{$transfertfrom}{branchname};
         $itm->{transfertto}   = $branches->{$transfertto}{branchname};
      }
+    
+    if (    C4::Context->preference('OPACAcquisitionDetails')
+        and C4::Context->preference('AcqCreateItem') eq 'ordering' )
+    {
+        $itm->{on_order} = 1
+          if grep /^$itm->{itemnumber}$/, @itemnumbers_on_order;
+    }
+
     my $itembranch = $itm->{$separatebranch};
     if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) {
         if ($itembranch and $itembranch eq $currentbranch) {
@@ -1100,4 +1131,9 @@ if ( C4::Context->preference('UseCourseReserves') ) {
     }
 }
 
+$template->param(
+    'OpacLocationBranchToDisplay'         => C4::Context->preference('OpacLocationBranchToDisplay') ,
+    'OpacLocationBranchToDisplayShelving' => C4::Context->preference('OpacLocationBranchToDisplayShelving'),
+);
+
 output_html_with_http_headers $query, $cookie, $template->output;