3 # Copyright 2000-2002 Katipo Communications
4 # parts copyright 2010 BibLibre
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
24 opac-ISBDdetail.pl - script to show a biblio in ISBD format
28 This script needs a biblionumber as parameter
32 The template is in <templates_dir>/catalogue/ISBDdetail.tt.
33 this template must be divided into 11 "tabs".
35 The first 10 tabs present the biblio, the 11th one presents
36 the items attached to the biblio
44 use C4::Auth qw( get_template_and_user );
46 use C4::Output qw( parametrized_url output_html_with_http_headers );
56 use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials );
60 GetNormalizedOCLCNumber
63 use Koha::CirculationRules;
66 use Koha::RecordProcessor;
69 my $query = CGI->new();
70 my $biblionumber = $query->param('biblionumber');
72 $biblio = Koha::Biblios->find( $biblionumber, { prefetch => [ 'metadata', 'items' ] } ) if $biblionumber;
74 print $query->redirect('/cgi-bin/koha/errors/404.pl');
79 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
81 template_name => "opac-ISBDdetail.tt",
84 authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
88 my $patron = Koha::Patrons->find($loggedinuser);
90 my $opachiddenitems_rules = C4::Context->yaml_preference('OpacHiddenItems');
92 unless ( $patron and $patron->category->override_hidden_items ) {
93 # only skip this check if there's a logged in user
94 # and its category overrides OpacHiddenItems
95 if ( $biblio->hidden_in_opac({ rules => $opachiddenitems_rules }) ) {
96 print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early
101 my $record = $biblio->metadata->record;
102 my @items = grep { !$_->hidden_in_opac({ rules => $opachiddenitems_rules }) } @{$biblio->items->as_list} ;
103 my $marcflavour = C4::Context->preference("marcflavour");
105 my $record_processor = Koha::RecordProcessor->new({
106 filters => [ 'ViewPolicy', 'EmbedItems' ],
109 frameworkcode => $biblio->frameworkcode,
113 $record_processor->process($record);
115 # get biblionumbers stored in the cart
116 if(my $cart_list = $query->cookie("bib_list")){
117 my @cart_list = split(/\//, $cart_list);
118 if ( grep {$_ eq $biblionumber} @cart_list) {
119 $template->param( incart => 1 );
123 # some useful variables for enhanced content;
124 # in each case, we're grabbing the first value we find in
125 # the record and normalizing it
126 my $upc = GetNormalizedUPC( $record, $marcflavour );
127 my $ean = GetNormalizedEAN( $record, $marcflavour );
128 my $oclc = GetNormalizedOCLCNumber( $record, $marcflavour );
129 my $isbn = GetNormalizedISBN( undef, $record, $marcflavour );
130 my $content_identifier_exists;
131 if ( $isbn or $ean or $oclc or $upc ) {
132 $content_identifier_exists = 1;
135 normalized_upc => $upc,
136 normalized_ean => $ean,
137 normalized_oclc => $oclc,
138 normalized_isbn => $isbn,
139 content_identifier_exists => $content_identifier_exists,
142 #coping with subscriptions
143 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
144 my $dat = TransformMarcToKoha( $record );
146 my @subscriptions = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
148 foreach my $subscription (@subscriptions) {
150 my $serials_to_display;
151 $cell{subscriptionid} = $subscription->{subscriptionid};
152 $cell{subscriptionnotes} = $subscription->{notes};
153 $cell{branchcode} = $subscription->{branchcode};
155 #get the three latest serials.
156 $serials_to_display = $subscription->{opacdisplaycount};
157 $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
158 $cell{opacdisplaycount} = $serials_to_display;
159 $cell{latestserials} =
160 GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
165 subscriptions => \@subs,
166 subscriptionsnumber => $subscriptionsnumber,
170 my $allow_onshelf_holds;
171 my $res = GetISBDView({
173 'template' => 'opac',
174 'framework' => $biblio->frameworkcode
177 my $items = $biblio->items;
178 while ( my $item = $items->next ) {
183 && ($item->notforloan < 0 || not $item->notforloan )
184 && !Koha::ItemTypes->find($item->effective_itemtype)->notforloan
185 && $item->itemnumber;
187 $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
188 unless $allow_onshelf_holds;
191 if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) {
192 $template->param( ReservableItems => 1 );
196 RequestOnOpac => C4::Context->preference("RequestOnOpac"),
197 norequests => $norequests,
202 #Search for title in links
203 my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
204 my $marcissns = GetMarcISSN ( $record, $marcflavour );
205 my $issn = $marcissns->[0] || '';
207 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
208 $dat->{title} =~ s/\/+$//; # remove trailing slash
209 $dat->{title} =~ s/\s+$//; # remove trailing space
210 $search_for_title = parametrized_url(
213 TITLE => $dat->{title},
214 AUTHOR => $dat->{author},
217 CONTROLNUMBER => $marccontrolnumber,
218 BIBLIONUMBER => $biblionumber,
221 $template->param('OPACSearchForTitleIn' => $search_for_title);
224 if( C4::Context->preference('ArticleRequests') ) {
225 my $itemtype = Koha::ItemTypes->find($biblio->itemtype);
226 my $artreqpossible = $patron
227 ? $biblio->can_article_request( $patron )
229 ? $itemtype->may_article_request
231 $template->param( artreqpossible => $artreqpossible );
234 output_html_with_http_headers $query, $cookie, $template->output;