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 ),
82 if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
83 # we need to fetch the borrower info here, so we can pass the category
84 my $patron = Koha::Patrons->find( { borrowernumber => $loggedinuser } );
85 $borcat = $patron ? $patron->categorycode : $borcat;
88 my $record = GetMarcBiblio({
89 biblionumber => $biblionumber,
94 print $query->redirect("/cgi-bin/koha/errors/404.pl");
98 my @all_items = GetItemsInfo($biblionumber);
99 my $biblio = Koha::Biblios->find( $biblionumber );
100 my $framework = $biblio ? $biblio->frameworkcode : q{};
101 my ($tag_itemnumber, $subtag_itemnumber) = &GetMarcFromKohaField('items.itemnumber',$framework);
102 my @nonhiddenitems = $record->field($tag_itemnumber);
103 if (scalar @all_items >= 1 && scalar @nonhiddenitems == 0) {
104 print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early
108 my $record_processor = Koha::RecordProcessor->new({
109 filters => 'ViewPolicy',
112 frameworkcode => $framework
115 $record_processor->process($record);
117 # get biblionumbers stored in the cart
118 if(my $cart_list = $query->cookie("bib_list")){
119 my @cart_list = split(/\//, $cart_list);
120 if ( grep {$_ eq $biblionumber} @cart_list) {
121 $template->param( incart => 1 );
125 my $marcflavour = C4::Context->preference("marcflavour");
127 # some useful variables for enhanced content;
128 # in each case, we're grabbing the first value we find in
129 # the record and normalizing it
130 my $upc = GetNormalizedUPC($record,$marcflavour);
131 my $ean = GetNormalizedEAN($record,$marcflavour);
132 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
133 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
134 my $content_identifier_exists;
135 if ( $isbn or $ean or $oclc or $upc ) {
136 $content_identifier_exists = 1;
139 normalized_upc => $upc,
140 normalized_ean => $ean,
141 normalized_oclc => $oclc,
142 normalized_isbn => $isbn,
143 content_identifier_exists => $content_identifier_exists,
146 #coping with subscriptions
147 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
148 my $dat = TransformMarcToKoha( $record );
150 my @subscriptions = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
152 foreach my $subscription (@subscriptions) {
154 my $serials_to_display;
155 $cell{subscriptionid} = $subscription->{subscriptionid};
156 $cell{subscriptionnotes} = $subscription->{notes};
157 $cell{branchcode} = $subscription->{branchcode};
159 #get the three latest serials.
160 $serials_to_display = $subscription->{opacdisplaycount};
161 $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
162 $cell{opacdisplaycount} = $serials_to_display;
163 $cell{latestserials} =
164 GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
169 subscriptions => \@subs,
170 subscriptionsnumber => $subscriptionsnumber,
174 my $allow_onshelf_holds;
175 my $res = GetISBDView({
177 'template' => 'opac',
178 'framework' => $framework
181 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
182 my $patron = Koha::Patrons->find( $loggedinuser );
183 for my $itm (@all_items) {
184 my $item = Koha::Items->find( $itm->{itemnumber} );
187 && !$itm->{'withdrawn'}
188 && !$itm->{'itemlost'}
189 && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'})
190 && !$itemtypes->{$itm->{'itype'}}->{notforloan}
191 && $itm->{'itemnumber'};
193 $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
194 unless $allow_onshelf_holds;
197 if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) {
198 $template->param( ReservableItems => 1 );
202 RequestOnOpac => C4::Context->preference("RequestOnOpac"),
203 norequests => $norequests,
208 #Search for title in links
209 my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
210 my $marcissns = GetMarcISSN ( $record, $marcflavour );
211 my $issn = $marcissns->[0] || '';
213 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
214 $dat->{title} =~ s/\/+$//; # remove trailing slash
215 $dat->{title} =~ s/\s+$//; # remove trailing space
216 $search_for_title = parametrized_url(
219 TITLE => $dat->{title},
220 AUTHOR => $dat->{author},
223 CONTROLNUMBER => $marccontrolnumber,
224 BIBLIONUMBER => $biblionumber,
227 $template->param('OPACSearchForTitleIn' => $search_for_title);
230 if( C4::Context->preference('ArticleRequests') ) {
231 my $artreqpossible = $patron
232 ? $biblio->can_article_request( $patron )
233 : Koha::ItemTypes->find($biblio->itemtype)->may_article_request;
234 $template->param( artreqpossible => $artreqpossible );
237 output_html_with_http_headers $query, $cookie, $template->output;