Bug 33020: Add missing Koha::Logger->history
[koha-ffzg.git] / opac / opac-MARCdetail.pl
index b4dae6d..f55d6bf 100755 (executable)
@@ -52,7 +52,6 @@ use CGI qw ( -utf8 );
 use C4::Biblio qw(
     CountItemsIssued
     GetAuthorisedValueDesc
-    GetMarcBiblio
     GetMarcControlnumber
     GetMarcFromKohaField
     GetMarcISSN
@@ -70,6 +69,7 @@ use Koha::ItemTypes;
 use Koha::Patrons;
 use Koha::RecordProcessor;
 use Koha::DateUtils qw( output_pref );
+use Koha::Util::MARC;
 
 my $query = CGI->new();
 
@@ -90,24 +90,15 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     }
 );
 
-my $patron = Koha::Patrons->find( $loggedinuser );
-my $borcat = q{};
-if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
-    # we need to fetch the borrower info here, so we can pass the category
-    $borcat = $patron ? $patron->categorycode : $borcat;
-}
+my $patron = Koha::Patrons->find($loggedinuser);
+my $biblio = Koha::Biblios->find($biblionumber);
+my $record = $biblio->metadata->record;
 
-my $record = GetMarcBiblio({
-    biblionumber => $biblionumber,
-    embed_items  => 1,
-    opac         => 1,
-    borcat       => $borcat });
 if ( ! $record ) {
     print $query->redirect("/cgi-bin/koha/errors/404.pl");
     exit;
 }
 
-my $biblio = Koha::Biblios->find( $biblionumber );
 unless ( $patron and $patron->category->override_hidden_items ) {
     # only skip this check if there's a logged in user
     # and its category overrides OpacHiddenItems
@@ -117,14 +108,16 @@ unless ( $patron and $patron->category->override_hidden_items ) {
     }
 }
 
+my $items = $biblio->items->filter_by_visible_in_opac({ patron => $patron });
 my $framework = $biblio ? $biblio->frameworkcode : q{};
 my $tagslib   = &GetMarcStructure( 0, $framework );
 
 my $record_processor = Koha::RecordProcessor->new({
-    filters => 'ViewPolicy',
+    filters => [ 'EmbedItems', 'ViewPolicy' ],
     options => {
-        interface => 'opac',
-        frameworkcode => $framework
+        interface     => 'opac',
+        frameworkcode => $framework,
+        items         => [ $items->as_list ],
     }
 });
 $record_processor->process($record);
@@ -144,7 +137,7 @@ $template->param(
      $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8;   # except -8;
 
 my $allow_onshelf_holds;
-my $items = $biblio->items;
+$items->reset;
 
 while ( my $item = $items->next ) {
     $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
@@ -352,6 +345,7 @@ my $issn = $marcissns->[0] || '';
 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
     $dat->{title} =~ s/\/+$//; # remove trailing slash
     $dat->{title} =~ s/\s+$//; # remove trailing space
+    my $oclc_no = Koha::Util::MARC::oclc_number( $record );
     $search_for_title = parametrized_url(
         $search_for_title,
         {
@@ -361,6 +355,7 @@ if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
             ISSN          => $issn,
             CONTROLNUMBER => $marccontrolnumber,
             BIBLIONUMBER  => $biblionumber,
+            OCLC_NO       => $oclc_no,
         }
     );
     $template->param('OPACSearchForTitleIn' => $search_for_title);