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
54 use C4::Serials; # uses getsubscriptionfrom biblionumber
56 use C4::Members; # GetMember
58 my $query = CGI->new();
59 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
61 template_name => "opac-ISBDdetail.tt",
64 authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
69 my $biblionumber = $query->param('biblionumber');
70 $biblionumber = int($biblionumber);
72 # get biblionumbers stored in the cart
73 if(my $cart_list = $query->cookie("bib_list")){
74 my @cart_list = split(/\//, $cart_list);
75 if ( grep {$_ eq $biblionumber} @cart_list) {
76 $template->param( incart => 1 );
80 $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
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($biblionumber);
96 print $query->redirect("/cgi-bin/koha/errors/404.pl");
99 # some useful variables for enhanced content;
100 # in each case, we're grabbing the first value we find in
101 # the record and normalizing it
102 my $upc = GetNormalizedUPC($record,$marcflavour);
103 my $ean = GetNormalizedEAN($record,$marcflavour);
104 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
105 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
106 my $content_identifier_exists;
107 if ( $isbn or $ean or $oclc or $upc ) {
108 $content_identifier_exists = 1;
111 normalized_upc => $upc,
112 normalized_ean => $ean,
113 normalized_oclc => $oclc,
114 normalized_isbn => $isbn,
115 content_identifier_exists => $content_identifier_exists,
118 #coping with subscriptions
119 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
120 my $dbh = C4::Context->dbh;
121 my $dat = TransformMarcToKoha( $record );
123 my @subscriptions = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
125 foreach my $subscription (@subscriptions) {
127 my $serials_to_display;
128 $cell{subscriptionid} = $subscription->{subscriptionid};
129 $cell{subscriptionnotes} = $subscription->{notes};
130 $cell{branchcode} = $subscription->{branchcode};
132 #get the three latest serials.
133 $serials_to_display = $subscription->{opacdisplaycount};
134 $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
135 $cell{opacdisplaycount} = $serials_to_display;
136 $cell{latestserials} =
137 GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
142 subscriptions => \@subs,
143 subscriptionsnumber => $subscriptionsnumber,
147 my $allow_onshelf_holds;
148 my $res = GetISBDView($biblionumber, "opac");
150 my $itemtypes = GetItemTypes();
151 my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
152 for my $itm (@items) {
155 && !$itm->{'withdrawn'}
156 && !$itm->{'itemlost'}
157 && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'})
158 && !$itemtypes->{$itm->{'itype'}}->{notforloan}
159 && $itm->{'itemnumber'};
161 $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed($itm, $borrower)
162 unless $allow_onshelf_holds;
165 my $reviews = getreviews( $biblionumber, 1 );
166 foreach ( @$reviews ) {
167 my $borrower_number_review = $_->{borrowernumber};
168 my $borrowerData = GetMember('borrowernumber' =>$borrower_number_review);
169 # setting some borrower info into this hash
170 $_->{title} = $borrowerData->{'title'};
171 $_->{surname} = $borrowerData->{'surname'};
172 $_->{firstname} = $borrowerData->{'firstname'};
177 RequestOnOpac => C4::Context->preference("RequestOnOpac"),
178 AllowOnShelfHolds => $allow_onshelf_holds,
179 norequests => $norequests,
181 biblionumber => $biblionumber,
185 #Search for title in links
186 my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
187 my $marcissns = GetMarcISSN ( $record, $marcflavour );
188 my $issn = $marcissns->[0] || '';
190 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
191 $dat->{title} =~ s/\/+$//; # remove trailing slash
192 $dat->{title} =~ s/\s+$//; # remove trailing space
193 $search_for_title = parametrized_url(
196 TITLE => $dat->{title},
197 AUTHOR => $dat->{author},
200 CONTROLNUMBER => $marccontrolnumber,
201 BIBLIONUMBER => $biblionumber,
204 $template->param('OPACSearchForTitleIn' => $search_for_title);
207 output_html_with_http_headers $query, $cookie, $template->output;