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
53 use C4::Serials; # uses getsubscriptionfrom biblionumber
55 use Koha::IssuingRules;
59 use Koha::RecordProcessor;
62 my $query = CGI->new();
63 my $biblionumber = $query->param('biblionumber');
64 if ( !$biblionumber ) {
65 print $query->redirect('/cgi-bin/koha/errors/404.pl');
68 $biblionumber = int($biblionumber);
71 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
73 template_name => "opac-ISBDdetail.tt",
76 authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
81 my $patron = Koha::Patrons->find( $loggedinuser );
83 if ( $patron && C4::Context->preference('OpacHiddenItemsExceptions') ) {
84 $borcat = $patron->categorycode;
87 my $record = GetMarcBiblio({
88 biblionumber => $biblionumber,
93 print $query->redirect("/cgi-bin/koha/errors/404.pl");
97 my @all_items = GetItemsInfo($biblionumber);
98 my $biblio = Koha::Biblios->find( $biblionumber );
99 my $framework = $biblio ? $biblio->frameworkcode : q{};
100 my ($tag_itemnumber, $subtag_itemnumber) = &GetMarcFromKohaField('items.itemnumber',$framework);
101 my @nonhiddenitems = $record->field($tag_itemnumber);
102 if (scalar @all_items >= 1 && scalar @nonhiddenitems == 0) {
103 print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early
107 my $record_processor = Koha::RecordProcessor->new({
108 filters => 'ViewPolicy',
111 frameworkcode => $framework
114 $record_processor->process($record);
116 # get biblionumbers stored in the cart
117 if(my $cart_list = $query->cookie("bib_list")){
118 my @cart_list = split(/\//, $cart_list);
119 if ( grep {$_ eq $biblionumber} @cart_list) {
120 $template->param( incart => 1 );
124 my $marcflavour = C4::Context->preference("marcflavour");
126 # some useful variables for enhanced content;
127 # in each case, we're grabbing the first value we find in
128 # the record and normalizing it
129 my $upc = GetNormalizedUPC($record,$marcflavour);
130 my $ean = GetNormalizedEAN($record,$marcflavour);
131 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
132 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
133 my $content_identifier_exists;
134 if ( $isbn or $ean or $oclc or $upc ) {
135 $content_identifier_exists = 1;
138 normalized_upc => $upc,
139 normalized_ean => $ean,
140 normalized_oclc => $oclc,
141 normalized_isbn => $isbn,
142 content_identifier_exists => $content_identifier_exists,
145 #coping with subscriptions
146 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
147 my $dat = TransformMarcToKoha( $record );
149 my @subscriptions = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
151 foreach my $subscription (@subscriptions) {
153 my $serials_to_display;
154 $cell{subscriptionid} = $subscription->{subscriptionid};
155 $cell{subscriptionnotes} = $subscription->{notes};
156 $cell{branchcode} = $subscription->{branchcode};
158 #get the three latest serials.
159 $serials_to_display = $subscription->{opacdisplaycount};
160 $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
161 $cell{opacdisplaycount} = $serials_to_display;
162 $cell{latestserials} =
163 GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
168 subscriptions => \@subs,
169 subscriptionsnumber => $subscriptionsnumber,
173 my $allow_onshelf_holds;
174 my $res = GetISBDView({
176 'template' => 'opac',
177 'framework' => $framework
180 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
181 for my $itm (@all_items) {
182 my $item = Koha::Items->find( $itm->{itemnumber} );
185 && !$itm->{'withdrawn'}
186 && !$itm->{'itemlost'}
187 && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'})
188 && !$itemtypes->{$itm->{'itype'}}->{notforloan}
189 && $itm->{'itemnumber'};
191 $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
192 unless $allow_onshelf_holds;
195 if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) {
196 $template->param( ReservableItems => 1 );
200 RequestOnOpac => C4::Context->preference("RequestOnOpac"),
201 norequests => $norequests,
206 #Search for title in links
207 my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
208 my $marcissns = GetMarcISSN ( $record, $marcflavour );
209 my $issn = $marcissns->[0] || '';
211 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
212 $dat->{title} =~ s/\/+$//; # remove trailing slash
213 $dat->{title} =~ s/\s+$//; # remove trailing space
214 $search_for_title = parametrized_url(
217 TITLE => $dat->{title},
218 AUTHOR => $dat->{author},
221 CONTROLNUMBER => $marccontrolnumber,
222 BIBLIONUMBER => $biblionumber,
225 $template->param('OPACSearchForTitleIn' => $search_for_title);
228 if( C4::Context->preference('ArticleRequests') ) {
229 my $itemtype = Koha::ItemTypes->find($biblio->itemtype);
230 my $artreqpossible = $patron
231 ? $biblio->can_article_request( $patron )
233 ? $itemtype->may_article_request
235 $template->param( artreqpossible => $artreqpossible );
238 output_html_with_http_headers $query, $cookie, $template->output;