=cut
-use strict;
-use warnings;
+use Modern::Perl;
use C4::Auth;
use C4::Context;
use C4::Items;
use C4::Reserves;
use C4::Acquisition;
-use C4::Review;
use C4::Serials; # uses getsubscriptionfrom biblionumber
use C4::Koha;
-use C4::Members; # GetMember
+use Koha::IssuingRules;
+use Koha::Items;
+use Koha::ItemTypes;
+use Koha::Patrons;
+use Koha::RecordProcessor;
+use Koha::Biblios;
my $query = CGI->new();
+my $biblionumber = $query->param('biblionumber');
+if ( !$biblionumber ) {
+ print $query->redirect('/cgi-bin/koha/errors/404.pl');
+ exit;
+}
+$biblionumber = int($biblionumber);
+
+#open template
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "opac-ISBDdetail.tt",
}
);
-my $biblionumber = $query->param('biblionumber');
-$biblionumber = int($biblionumber);
+my $patron = Koha::Patrons->find( $loggedinuser );
+my $borcat = q{};
+if ( $patron && C4::Context->preference('OpacHiddenItemsExceptions') ) {
+ $borcat = $patron->categorycode;
+}
+
+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 @all_items = GetItemsInfo($biblionumber);
+my $biblio = Koha::Biblios->find( $biblionumber );
+my $framework = $biblio ? $biblio->frameworkcode : q{};
+my ($tag_itemnumber, $subtag_itemnumber) = &GetMarcFromKohaField('items.itemnumber',$framework);
+my @nonhiddenitems = $record->field($tag_itemnumber);
+if (scalar @all_items >= 1 && scalar @nonhiddenitems == 0) {
+ print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early
+ exit;
+}
+
+my $record_processor = Koha::RecordProcessor->new({
+ filters => 'ViewPolicy',
+ options => {
+ interface => 'opac',
+ frameworkcode => $framework
+ }
+});
+$record_processor->process($record);
# get biblionumbers stored in the cart
if(my $cart_list = $query->cookie("bib_list")){
}
}
-$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
-
my $marcflavour = C4::Context->preference("marcflavour");
-my @items = GetItemsInfo($biblionumber);
-if (scalar @items >= 1) {
- my @hiddenitems = GetHiddenItemnumbers(@items);
-
- if (scalar @hiddenitems == scalar @items ) {
- print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
- exit;
- }
-}
-
-my $record = GetMarcBiblio($biblionumber);
-if ( ! $record ) {
- print $query->redirect("/cgi-bin/koha/errors/404.pl");
- exit;
-}
# some useful variables for enhanced content;
# in each case, we're grabbing the first value we find in
# the record and normalizing it
normalized_ean => $ean,
normalized_oclc => $oclc,
normalized_isbn => $isbn,
- content_identifier_exists => $content_identifier_exists,
+ content_identifier_exists => $content_identifier_exists,
);
#coping with subscriptions
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
-my $dbh = C4::Context->dbh;
my $dat = TransformMarcToKoha( $record );
my @subscriptions = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
my $norequests = 1;
my $allow_onshelf_holds;
-my $res = GetISBDView($biblionumber, "opac");
-
-my $itemtypes = GetItemTypes();
-my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
-for my $itm (@items) {
+my $res = GetISBDView({
+ 'record' => $record,
+ 'template' => 'opac',
+ 'framework' => $framework
+});
+
+my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
+for my $itm (@all_items) {
+ my $item = Koha::Items->find( $itm->{itemnumber} );
$norequests = 0
if $norequests
&& !$itm->{'withdrawn'}
&& !$itemtypes->{$itm->{'itype'}}->{notforloan}
&& $itm->{'itemnumber'};
- $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed($itm, $borrower)
+ $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
unless $allow_onshelf_holds;
}
-my $reviews = getreviews( $biblionumber, 1 );
-foreach ( @$reviews ) {
- my $borrower_number_review = $_->{borrowernumber};
- my $borrowerData = GetMember('borrowernumber' =>$borrower_number_review);
- # setting some borrower info into this hash
- $_->{title} = $borrowerData->{'title'};
- $_->{surname} = $borrowerData->{'surname'};
- $_->{firstname} = $borrowerData->{'firstname'};
+if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) {
+ $template->param( ReservableItems => 1 );
}
-
$template->param(
RequestOnOpac => C4::Context->preference("RequestOnOpac"),
- AllowOnShelfHolds => $allow_onshelf_holds,
norequests => $norequests,
ISBD => $res,
- biblionumber => $biblionumber,
- reviews => $reviews,
+ biblio => $biblio,
);
#Search for title in links
$template->param('OPACSearchForTitleIn' => $search_for_title);
}
+if( C4::Context->preference('ArticleRequests') ) {
+ my $artreqpossible = $patron
+ ? $biblio->can_article_request( $patron )
+ : Koha::ItemTypes->find($biblio->itemtype)->may_article_request;
+ $template->param( artreqpossible => $artreqpossible );
+}
+
output_html_with_http_headers $query, $cookie, $template->output;