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
57 use Koha::RecordProcessor;
60 my $query = CGI->new();
61 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
63 template_name => "opac-ISBDdetail.tt",
66 authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
71 my $biblionumber = $query->param('biblionumber');
72 $biblionumber = int($biblionumber);
74 # get biblionumbers stored in the cart
75 if(my $cart_list = $query->cookie("bib_list")){
76 my @cart_list = split(/\//, $cart_list);
77 if ( grep {$_ eq $biblionumber} @cart_list) {
78 $template->param( incart => 1 );
82 my $marcflavour = C4::Context->preference("marcflavour");
84 my @items = GetItemsInfo($biblionumber);
85 if (scalar @items >= 1) {
86 my @hiddenitems = GetHiddenItemnumbers(@items);
88 if (scalar @hiddenitems == scalar @items ) {
89 print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
94 my $record = GetMarcBiblio({
95 biblionumber => $biblionumber,
98 print $query->redirect("/cgi-bin/koha/errors/404.pl");
102 my $biblio = Koha::Biblios->find( $biblionumber );
104 my $framework = GetFrameworkCode( $biblionumber );
105 my $record_processor = Koha::RecordProcessor->new({
106 filters => 'ViewPolicy',
109 frameworkcode => $framework
112 $record_processor->process($record);
114 # some useful variables for enhanced content;
115 # in each case, we're grabbing the first value we find in
116 # the record and normalizing it
117 my $upc = GetNormalizedUPC($record,$marcflavour);
118 my $ean = GetNormalizedEAN($record,$marcflavour);
119 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
120 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
121 my $content_identifier_exists;
122 if ( $isbn or $ean or $oclc or $upc ) {
123 $content_identifier_exists = 1;
126 normalized_upc => $upc,
127 normalized_ean => $ean,
128 normalized_oclc => $oclc,
129 normalized_isbn => $isbn,
130 content_identifier_exists => $content_identifier_exists,
133 #coping with subscriptions
134 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
135 my $dbh = C4::Context->dbh;
136 my $dat = TransformMarcToKoha( $record );
138 my @subscriptions = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
140 foreach my $subscription (@subscriptions) {
142 my $serials_to_display;
143 $cell{subscriptionid} = $subscription->{subscriptionid};
144 $cell{subscriptionnotes} = $subscription->{notes};
145 $cell{branchcode} = $subscription->{branchcode};
147 #get the three latest serials.
148 $serials_to_display = $subscription->{opacdisplaycount};
149 $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
150 $cell{opacdisplaycount} = $serials_to_display;
151 $cell{latestserials} =
152 GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
157 subscriptions => \@subs,
158 subscriptionsnumber => $subscriptionsnumber,
162 my $allow_onshelf_holds;
163 my $res = GetISBDView({
165 'template' => 'opac',
166 'framework' => $framework
169 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
170 my $patron = Koha::Patrons->find( $loggedinuser );
171 for my $itm (@items) {
174 && !$itm->{'withdrawn'}
175 && !$itm->{'itemlost'}
176 && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'})
177 && !$itemtypes->{$itm->{'itype'}}->{notforloan}
178 && $itm->{'itemnumber'};
180 $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed( $itm, ( $patron ? $patron->unblessed : {} ) )
181 unless $allow_onshelf_holds;
184 if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->hasItemswaitingOrInTransit ) {
185 $template->param( ReservableItems => 1 );
189 RequestOnOpac => C4::Context->preference("RequestOnOpac"),
190 norequests => $norequests,
195 #Search for title in links
196 my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
197 my $marcissns = GetMarcISSN ( $record, $marcflavour );
198 my $issn = $marcissns->[0] || '';
200 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
201 $dat->{title} =~ s/\/+$//; # remove trailing slash
202 $dat->{title} =~ s/\s+$//; # remove trailing space
203 $search_for_title = parametrized_url(
206 TITLE => $dat->{title},
207 AUTHOR => $dat->{author},
210 CONTROLNUMBER => $marccontrolnumber,
211 BIBLIONUMBER => $biblionumber,
214 $template->param('OPACSearchForTitleIn' => $search_for_title);
217 output_html_with_http_headers $query, $cookie, $template->output;