Bug 28171: Revert "Bug 27980: Remove itemdata_publisheddate from controller"
[koha-ffzg.git] / catalogue / detail.pl
index 4e64043..14b4f17 100755 (executable)
@@ -70,31 +70,8 @@ if ( C4::Context->config('enable_plugins') ) {
     my @plugins = Koha::Plugins->new()->GetPlugins({
         method => 'intranet_catalog_biblio_enhancements_toolbar_button'
     });
-
-    my @tab_plugins = Koha::Plugins->new()->GetPlugins({
-        method => 'intranet_catalog_biblio_tab',
-    });
-    my @tabs;
-    foreach my $tab_plugin (@tab_plugins) {
-        my @biblio_tabs;
-
-        try {
-            @biblio_tabs = $tab_plugin->intranet_catalog_biblio_tab();
-            foreach my $tab (@biblio_tabs) {
-                my $tab_id = 'tab-' . $tab->title;
-                $tab_id =~ s/[^0-9A-Za-z]+/-/g;
-                $tab->id( $tab_id );
-                push @tabs, $tab,
-            }
-        }
-        catch {
-            warn "Error calling 'intranet_catalog_biblio_tab' on the " . $tab_plugin->{class} . "plugin ($_)";
-        };
-    }
-
     $template->param(
         plugins => \@plugins,
-        tabs => \@tabs,
     );
 }
 
@@ -115,15 +92,17 @@ if ( not defined $record ) {
 eval { $biblio->metadata->record };
 $template->param( decoding_error => $@ );
 
-if($query->cookie("holdfor")){ 
+if($query->cookie("holdfor")){
     my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
-    $template->param(
-        # FIXME Should pass the patron object
-        holdfor => $query->cookie("holdfor"),
-        holdfor_surname => $holdfor_patron->surname,
-        holdfor_firstname => $holdfor_patron->firstname,
-        holdfor_cardnumber => $holdfor_patron->cardnumber,
-    );
+    if ( $holdfor_patron ) {
+        $template->param(
+            # FIXME Should pass the patron object
+            holdfor => $query->cookie("holdfor"),
+            holdfor_surname => $holdfor_patron->surname,
+            holdfor_firstname => $holdfor_patron->firstname,
+            holdfor_cardnumber => $holdfor_patron->cardnumber,
+        );
+    }
 }
 
 if($query->cookie("searchToOrder")){
@@ -195,7 +174,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 } };
 
@@ -408,21 +387,20 @@ foreach my $item (@items) {
     }
 
     if ( C4::Context->preference("LocalCoverImages") == 1 ) {
-        my $cover_image = $item_object->cover_image;
-        $item->{imagenumber} = $cover_image ? $cover_image->imagenumber : undef;
+        $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->{imagenumber};
+            $itemloop_has_images++ if $item_object->cover_images->count;
         } else {
             push @otheritemloop, $item;
-            $otheritemloop_has_images++ if $item->{imagenumber};
+            $otheritemloop_has_images++ if $item_object->cover_images->count;
         }
     } else {
         push @itemloop, $item;
-        $itemloop_has_images++ if $item->{imagenumber};
+        $itemloop_has_images++ if $item_object->cover_images->count;
     }
 }
 
@@ -439,6 +417,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},
@@ -581,6 +580,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;