removed incorrect module import
[koha.git] / opac / opac-ISBDdetail.pl
blob38896eecf6ff1fad85e766426405a3c1a20a6586
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 with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 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 C4::Auth;
46 use C4::Context;
47 use C4::Output;
48 use CGI;
49 use MARC::Record;
50 use C4::Biblio;
51 use C4::Acquisition;
52 use C4::Review;
53 use C4::Serials; # uses getsubscriptionfrom biblionumber
54 use C4::Koha;
55 use C4::Members; # GetMember
56 use C4::External::Amazon;
58 my $query = CGI->new();
59 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
61 template_name => "opac-ISBDdetail.tmpl",
62 query => $query,
63 type => "opac",
64 authnotrequired => 1,
65 debug => 1,
69 my $biblionumber = $query->param('biblionumber');
71 my $marcflavour = C4::Context->preference("marcflavour");
72 my $record = GetMarcBiblio($biblionumber);
74 # some useful variables for enhanced content;
75 # in each case, we're grabbing the first value we find in
76 # the record and normalizing it
77 my $upc = GetNormalizedUPC($record,$marcflavour);
78 my $ean = GetNormalizedEAN($record,$marcflavour);
79 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
80 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
81 my $content_identifier_exists = 1 if ($isbn or $ean or $oclc or $upc);
82 $template->param(
83 normalized_upc => $upc,
84 normalized_ean => $ean,
85 normalized_oclc => $oclc,
86 normalized_isbn => $isbn,
87 content_identifier_exists => $content_identifier_exists,
90 #coping with subscriptions
91 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
92 my $dbh = C4::Context->dbh;
93 my $dat = TransformMarcToKoha( $dbh, $record );
94 my @subscriptions =
95 GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
96 my @subs;
97 foreach my $subscription (@subscriptions) {
98 my %cell;
99 my $serials_to_display;
100 $cell{subscriptionid} = $subscription->{subscriptionid};
101 $cell{subscriptionnotes} = $subscription->{notes};
102 $cell{branchcode} = $subscription->{branchcode};
104 #get the three latest serials.
105 $serials_to_display = $subscription->{opacdisplaycount};
106 $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
107 $cell{opacdisplaycount} = $serials_to_display;
108 $cell{latestserials} =
109 GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
110 push @subs, \%cell;
113 $template->param(
114 subscriptions => \@subs,
115 subscriptionsnumber => $subscriptionsnumber,
118 # my @blocs = split /\@/,$ISBD;
119 # my @fields = $record->fields();
120 my $res = GetISBDView($biblionumber);
122 my $reviews = getreviews( $biblionumber, 1 );
123 foreach ( @$reviews ) {
124 my $borrower_number_review = $_->{borrowernumber};
125 my $borrowerData = GetMember($borrower_number_review,'borrowernumber');
126 # setting some borrower info into this hash
127 $_->{title} = $borrowerData->{'title'};
128 $_->{surname} = $borrowerData->{'surname'};
129 $_->{firstname} = $borrowerData->{'firstname'};
133 $template->param(
134 ISBD => $res,
135 biblionumber => $biblionumber,
136 reviews => $reviews,
139 ## Amazon.com stuff
140 #not used unless preference set
141 if ( C4::Context->preference("OPACAmazonEnabled") == 1 ) {
143 my $amazon_details = &get_amazon_details( $isbn, $record, $marcflavour );
145 foreach my $result ( @{ $amazon_details->{Details} } ) {
146 $template->param( item_description => $result->{ProductDescription} );
147 $template->param( image => $result->{ImageUrlMedium} );
148 $template->param( list_price => $result->{ListPrice} );
149 $template->param( amazon_url => $result->{url} );
152 my @products;
153 my @reviews;
154 for my $details ( @{ $amazon_details->{Details} } ) {
155 next unless $details->{SimilarProducts};
156 for my $product ( @{ $details->{SimilarProducts}->{Product} } ) {
157 push @products, +{ Product => $product };
159 next unless $details->{Reviews};
160 for my $product ( @{ $details->{Reviews}->{AvgCustomerRating} } ) {
161 $template->param( rating => $product * 20 );
163 for my $reviews ( @{ $details->{Reviews}->{CustomerReview} } ) {
164 push @reviews,
166 Summary => $reviews->{Summary},
167 Comment => $reviews->{Comment},
171 $template->param( SIMILAR_PRODUCTS => \@products );
172 $template->param( AMAZONREVIEWS => \@reviews );
175 output_html_with_http_headers $query, $cookie, $template->output;