Bug 19532: Recalls on intranet
[srvgit] / catalogue / detail.pl
index 3846777..32a3528 100755 (executable)
@@ -95,7 +95,7 @@ if ( not defined $record ) {
     exit;
 }
 
-eval { $biblio->metadata->record };
+my $marc_record = eval { $biblio->metadata->record };
 $template->param( decoding_error => $@ );
 
 if($query->cookie("holdfor")){
@@ -145,8 +145,6 @@ $template->param(
     normalized_isbn => $isbn,
 );
 
-my $marcnotesarray   = $biblio->get_marc_notes({ marcflavour => $marcflavour });
-
 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
 
 my $dbh = C4::Context->dbh;
@@ -200,7 +198,8 @@ my $showcomp = C4::Context->preference('ShowComponentRecords');
 my $show_analytics;
 if ( $showcomp eq 'both' || $showcomp eq 'staff' ) {
     if ( my $components = $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) ) {
-        $show_analytics = 1; # just show link when having results
+        $show_analytics = 1 if @{$components}; # just show link when having results
+        $template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->object_messages};
         my $parts;
         for my $part ( @{$components} ) {
             $part = C4::Search::new_record_from_zebra( 'biblioserver', $part );
@@ -220,7 +219,8 @@ if ( $showcomp eq 'both' || $showcomp eq 'staff' ) {
         $template->param( ComponentPartsQuery => $biblio->get_components_query );
     }
 } else { # check if we should show analytics anyway
-    $show_analytics = 1 if @{$biblio->get_marc_components(1)}; # count matters here, results does not
+    $show_analytics = 1 if $marc_record && @{$biblio->get_marc_components(1)}; # count matters here, results does not
+    $template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->object_messages};
 }
 
 # XSLT processing of some stuff
@@ -401,6 +401,12 @@ foreach my $item (@items) {
         $item->{cover_images} = $item_object->cover_images;
     }
 
+    my $recall = Koha::Recalls->find({ itemnumber => $item->{itemnumber}, old => undef });
+    if ( defined $recall ) {
+        $item->{recalled} = 1;
+        $item->{recall} = $recall;
+    }
+
     if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
         if ($itembranchcode and $itembranchcode eq $currentbranch) {
             push @itemloop, $item;
@@ -432,14 +438,14 @@ my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
     {
         borrowernumber => $borrowernumber,
         add_allowed    => 1,
-        category       => 1,
+        public         => 0,
     }
 );
 my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
     {
         borrowernumber => $borrowernumber,
         add_allowed    => 1,
-        category       => 2,
+        public         => 1,
     }
 );
 
@@ -450,7 +456,7 @@ $template->param(
 );
 
 $template->param(
-    MARCNOTES   => $marcnotesarray,
+    MARCNOTES   => $marc_record ? $biblio->get_marc_notes({ marcflavour => $marcflavour }) : (),
     itemdata_ccode      => $itemfields{ccode},
     itemdata_enumchron  => $itemfields{enumchron},
     itemdata_uri        => $itemfields{uri},
@@ -519,7 +525,7 @@ if (C4::Context->preference("virtualshelves") ) {
     my $shelves = Koha::Virtualshelves->search(
         {
             biblionumber => $biblionumber,
-            category => 2,
+            public => 1,
         },
         {
             join => 'virtualshelfcontents',