(bug #4954) allow date expiry modification only on step 0 and 3
[koha.git] / opac / opac-ISBDdetail.pl
blob9b5c031172ae2d37ade61f38bbb76fa3262ae116
1 #!/usr/bin/perl
3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 =head1 NAME
23 opac-ISBDdetail.pl : script to show a biblio in ISBD format
26 =head1 DESCRIPTION
28 This script needs a biblionumber as parameter
30 It shows the biblio
32 The template is in <templates_dir>/catalogue/ISBDdetail.tmpl.
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
38 =head1 FUNCTIONS
40 =over 2
42 =cut
44 use strict;
45 use warnings;
47 use C4::Auth;
48 use C4::Context;
49 use C4::Output;
50 use CGI;
51 use MARC::Record;
52 use C4::Biblio;
53 use C4::Acquisition;
54 use C4::Review;
55 use C4::Serials; # uses getsubscriptionfrom biblionumber
56 use C4::Koha;
57 use C4::Members; # GetMember
58 use C4::External::Amazon;
60 my $query = CGI->new();
61 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
63 template_name => "opac-ISBDdetail.tmpl",
64 query => $query,
65 type => "opac",
66 authnotrequired => 1,
67 debug => 1,
71 my $biblionumber = $query->param('biblionumber');
73 $template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
74 $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
76 my $marcflavour = C4::Context->preference("marcflavour");
77 my $record = GetMarcBiblio($biblionumber);
78 if ( ! $record ) {
79 print $query->redirect("/cgi-bin/koha/errors/404.pl");
80 exit;
82 # some useful variables for enhanced content;
83 # in each case, we're grabbing the first value we find in
84 # the record and normalizing it
85 my $upc = GetNormalizedUPC($record,$marcflavour);
86 my $ean = GetNormalizedEAN($record,$marcflavour);
87 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
88 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
89 my $content_identifier_exists = 1 if ($isbn or $ean or $oclc or $upc);
90 $template->param(
91 normalized_upc => $upc,
92 normalized_ean => $ean,
93 normalized_oclc => $oclc,
94 normalized_isbn => $isbn,
95 content_identifier_exists => $content_identifier_exists,
98 #coping with subscriptions
99 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
100 my $dbh = C4::Context->dbh;
101 my $dat = TransformMarcToKoha( $dbh, $record );
102 my @subscriptions =
103 GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
104 my @subs;
105 foreach my $subscription (@subscriptions) {
106 my %cell;
107 my $serials_to_display;
108 $cell{subscriptionid} = $subscription->{subscriptionid};
109 $cell{subscriptionnotes} = $subscription->{notes};
110 $cell{branchcode} = $subscription->{branchcode};
112 #get the three latest serials.
113 $serials_to_display = $subscription->{opacdisplaycount};
114 $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
115 $cell{opacdisplaycount} = $serials_to_display;
116 $cell{latestserials} =
117 GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
118 push @subs, \%cell;
121 $template->param(
122 subscriptions => \@subs,
123 subscriptionsnumber => $subscriptionsnumber,
126 # my @blocs = split /\@/,$ISBD;
127 # my @fields = $record->fields();
128 my $res = GetISBDView($biblionumber, "opac");
130 my $reviews = getreviews( $biblionumber, 1 );
131 foreach ( @$reviews ) {
132 my $borrower_number_review = $_->{borrowernumber};
133 my $borrowerData = GetMember('borrowernumber' =>$borrower_number_review);
134 # setting some borrower info into this hash
135 $_->{title} = $borrowerData->{'title'};
136 $_->{surname} = $borrowerData->{'surname'};
137 $_->{firstname} = $borrowerData->{'firstname'};
141 $template->param(
142 ISBD => $res,
143 biblionumber => $biblionumber,
144 reviews => $reviews,
147 ## Amazon.com stuff
148 #not used unless preference set
149 if ( C4::Context->preference("OPACAmazonEnabled") == 1 ) {
151 my $amazon_details = &get_amazon_details( $isbn, $record, $marcflavour );
153 foreach my $result ( @{ $amazon_details->{Details} } ) {
154 $template->param( item_description => $result->{ProductDescription} );
155 $template->param( image => $result->{ImageUrlMedium} );
156 $template->param( list_price => $result->{ListPrice} );
157 $template->param( amazon_url => $result->{url} );
160 my @products;
161 my @reviews;
162 for my $details ( @{ $amazon_details->{Details} } ) {
163 next unless $details->{SimilarProducts};
164 for my $product ( @{ $details->{SimilarProducts}->{Product} } ) {
165 push @products, +{ Product => $product };
167 next unless $details->{Reviews};
168 for my $product ( @{ $details->{Reviews}->{AvgCustomerRating} } ) {
169 $template->param( rating => $product * 20 );
171 for my $reviews ( @{ $details->{Reviews}->{CustomerReview} } ) {
172 push @reviews,
174 Summary => $reviews->{Summary},
175 Comment => $reviews->{Comment},
179 $template->param( SIMILAR_PRODUCTS => \@products );
180 $template->param( AMAZONREVIEWS => \@reviews );
183 output_html_with_http_headers $query, $cookie, $template->output;