use Modern::Perl;
-use C4::Auth;
+use C4::Auth qw( get_template_and_user );
use C4::Context;
-use C4::Output;
+use C4::Output qw( parametrized_url output_html_with_http_headers );
use CGI qw ( -utf8 );
-use MARC::Record;
-use C4::Biblio;
-use C4::Items;
+use C4::Biblio qw(
+ CountItemsIssued
+ GetAuthorisedValueDesc
+ GetMarcControlnumber
+ GetMarcFromKohaField
+ GetMarcISSN
+ GetMarcStructure
+ TransformMarcToKoha
+);
use C4::Reserves;
use C4::Members;
-use C4::Acquisition;
-use C4::Koha;
-use List::MoreUtils qw( any uniq );
+use C4::Koha qw( GetNormalizedISBN );
+use List::MoreUtils qw( uniq );
use Koha::Biblios;
use Koha::CirculationRules;
use Koha::Items;
use Koha::ItemTypes;
use Koha::Patrons;
use Koha::RecordProcessor;
-use Koha::DateUtils;
+use Koha::DateUtils qw( output_pref );
+use Koha::Util::MARC;
my $query = CGI->new();
}
);
-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
}
}
+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);
) if $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} <= 0 && # <=0 OPAC visible.
$tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8; # except -8;
-my $norequests = 1;
my $allow_onshelf_holds;
-my $items = $biblio->items;
+$items->reset;
while ( my $item = $items->next ) {
- $norequests = 0
- if $norequests
- && !$item->withdrawn
- && !$item->itemlost
- && ($item->notforloan < 0 || not $item->notforloan )
- && !Koha::ItemTypes->find($item->effective_itemtype)->notforloan
- && $item->itemnumber;
-
$allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
unless $allow_onshelf_holds;
}
$template->param( ReservableItems => 1 );
}
-# adding the $RequestOnOpac param
-my $RequestOnOpac;
-if (C4::Context->preference("RequestOnOpac")) {
- $RequestOnOpac = 1;
-}
-
# fill arrays
my @loop_data = ();
#Search for title in links
my $marcflavour = C4::Context->preference("marcflavour");
-my $dat = TransformMarcToKoha( $record );
+my $dat = TransformMarcToKoha({ record => $record });
my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
my $marcissns = GetMarcISSN( $record, $marcflavour );
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,
{
ISSN => $issn,
CONTROLNUMBER => $marccontrolnumber,
BIBLIONUMBER => $biblionumber,
+ OCLC_NO => $oclc_no,
}
);
$template->param('OPACSearchForTitleIn' => $search_for_title);
$template->param( artreqpossible => $artreqpossible );
}
+my $norequests = ! $biblio->items->filter_by_for_hold->count;
$template->param(
item_loop => \@item_loop,
item_header_loop => \@item_header_loop,