Bug 27268: Move GetMarcNotes to Koha namespace
[srvgit] / catalogue / detail.pl
index 3a22b5d..8049906 100755 (executable)
@@ -36,13 +36,13 @@ use C4::External::Amazon;
 use C4::Search;        # enabled_staff_search_views
 use C4::Tags qw(get_tags);
 use C4::XSLT;
-use C4::Images;
 use Koha::DateUtils;
 use C4::HTML5Media;
 use C4::CourseReserves qw(GetItemCourseReservesInfo);
 use C4::Acquisition qw(GetOrdersByBiblionumber);
 use Koha::AuthorisedValues;
 use Koha::Biblios;
+use Koha::CoverImages;
 use Koha::Illrequests;
 use Koha::Items;
 use Koha::ItemTypes;
@@ -152,7 +152,7 @@ if ( $xslfile ) {
     $cleaned_title =~ tr|/||;
     my $query =
       ( C4::Context->preference('UseControlNumber') and $record->field('001') )
-      ? 'rcn:'. $record->field('001')->data . ' and (bib-level:a or bib-level:b)'
+      ? 'rcn:'. $record->field('001')->data . ' AND (bib-level:a OR bib-level:b)'
       : "Host-item:$cleaned_title";
     my ( $err, $result, $count ) = $searcher->simple_search_compat( $query, 0, 0 );
 
@@ -195,7 +195,7 @@ $template->param(
     normalized_isbn => $isbn,
 );
 
-my $marcnotesarray   = GetMarcNotes( $record, $marcflavour );
+my $marcnotesarray   = $biblio->get_marc_notes({ marcflavour => $marcflavour });
 
 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
 
@@ -322,6 +322,7 @@ if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
     $template->param(SeparateHoldings => 1);
 }
 my $separatebranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch';
+my ( $itemloop_has_images, $otheritemloop_has_images );
 foreach my $item (@items) {
     my $itembranchcode = $item->{$separatebranch};
 
@@ -406,17 +407,29 @@ foreach my $item (@items) {
         }
     }
 
+    if ( C4::Context->preference("LocalCoverImages") == 1 ) {
+        $item->{cover_images} = $item_object->cover_images;
+    }
+
     if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
         if ($itembranchcode and $itembranchcode eq $currentbranch) {
             push @itemloop, $item;
+            $itemloop_has_images++ if $item_object->cover_images->count;
         } else {
             push @otheritemloop, $item;
+            $otheritemloop_has_images++ if $item_object->cover_images->count;
         }
     } else {
         push @itemloop, $item;
+        $itemloop_has_images++ if $item_object->cover_images->count;
     }
 }
 
+$template->param(
+    itemloop_has_images      => $itemloop_has_images,
+    otheritemloop_has_images => $otheritemloop_has_images,
+);
+
 # Display only one tab if one items list is empty
 if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
     $template->param(SeparateHoldings => 0);
@@ -425,6 +438,27 @@ if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
     }
 }
 
+my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
+    {
+        borrowernumber => $borrowernumber,
+        add_allowed    => 1,
+        category       => 1,
+    }
+);
+my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
+    {
+        borrowernumber => $borrowernumber,
+        add_allowed    => 1,
+        category       => 2,
+    }
+);
+
+
+$template->param(
+    add_to_some_private_shelves => $some_private_shelves,
+    add_to_some_public_shelves  => $some_public_shelves,
+);
+
 $template->param(
     MARCNOTES   => $marcnotesarray,
     itemdata_ccode      => $itemfields{ccode},
@@ -517,8 +551,8 @@ if (C4::Context->preference("FRBRizeEditions")==1) {
 }
 
 if ( C4::Context->preference("LocalCoverImages") == 1 ) {
-    my @images = ListImagesForBiblio($biblionumber);
-    $template->{VARS}->{localimages} = \@images;
+    my $images = $biblio->cover_images;
+    $template->param( localimages => $biblio->cover_images );
 }
 
 # HTML5 Media
@@ -567,6 +601,17 @@ if ($StaffDetailItemSelection) {
     }
 }
 
+# get biblionumbers stored in the cart
+my @cart_list;
+
+if($query->cookie("intranet_bib_list")){
+    my $cart_list = $query->cookie("intranet_bib_list");
+    @cart_list = split(/\//, $cart_list);
+    if ( grep {$_ eq $biblionumber} @cart_list) {
+        $template->param( incart => 1 );
+    }
+}
+
 $template->param(biblio => $biblio);
 
 output_html_with_http_headers $query, $cookie, $template->output;