Fix images for collapsed groups (temporary hack)
[koha.git] / opac / opac-ISBDdetail.pl
blob4706fde55fc4cf19b48256b13dd2fabe7e0b7ed5
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 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);
79 # some useful variables for enhanced content;
80 # in each case, we're grabbing the first value we find in
81 # the record and normalizing it
82 my $upc = GetNormalizedUPC($record,$marcflavour);
83 my $ean = GetNormalizedEAN($record,$marcflavour);
84 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
85 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
86 my $content_identifier_exists = 1 if ($isbn or $ean or $oclc or $upc);
87 $template->param(
88 normalized_upc => $upc,
89 normalized_ean => $ean,
90 normalized_oclc => $oclc,
91 normalized_isbn => $isbn,
92 content_identifier_exists => $content_identifier_exists,
95 #coping with subscriptions
96 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
97 my $dbh = C4::Context->dbh;
98 my $dat = TransformMarcToKoha( $dbh, $record );
99 my @subscriptions =
100 GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
101 my @subs;
102 foreach my $subscription (@subscriptions) {
103 my %cell;
104 my $serials_to_display;
105 $cell{subscriptionid} = $subscription->{subscriptionid};
106 $cell{subscriptionnotes} = $subscription->{notes};
107 $cell{branchcode} = $subscription->{branchcode};
109 #get the three latest serials.
110 $serials_to_display = $subscription->{opacdisplaycount};
111 $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
112 $cell{opacdisplaycount} = $serials_to_display;
113 $cell{latestserials} =
114 GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
115 push @subs, \%cell;
118 $template->param(
119 subscriptions => \@subs,
120 subscriptionsnumber => $subscriptionsnumber,
123 # my @blocs = split /\@/,$ISBD;
124 # my @fields = $record->fields();
125 my $res = GetISBDView($biblionumber);
127 my $reviews = getreviews( $biblionumber, 1 );
128 foreach ( @$reviews ) {
129 my $borrower_number_review = $_->{borrowernumber};
130 my $borrowerData = GetMember($borrower_number_review,'borrowernumber');
131 # setting some borrower info into this hash
132 $_->{title} = $borrowerData->{'title'};
133 $_->{surname} = $borrowerData->{'surname'};
134 $_->{firstname} = $borrowerData->{'firstname'};
138 $template->param(
139 ISBD => $res,
140 biblionumber => $biblionumber,
141 reviews => $reviews,
144 ## Amazon.com stuff
145 #not used unless preference set
146 if ( C4::Context->preference("OPACAmazonEnabled") == 1 ) {
148 my $amazon_details = &get_amazon_details( $isbn, $record, $marcflavour );
150 foreach my $result ( @{ $amazon_details->{Details} } ) {
151 $template->param( item_description => $result->{ProductDescription} );
152 $template->param( image => $result->{ImageUrlMedium} );
153 $template->param( list_price => $result->{ListPrice} );
154 $template->param( amazon_url => $result->{url} );
157 my @products;
158 my @reviews;
159 for my $details ( @{ $amazon_details->{Details} } ) {
160 next unless $details->{SimilarProducts};
161 for my $product ( @{ $details->{SimilarProducts}->{Product} } ) {
162 push @products, +{ Product => $product };
164 next unless $details->{Reviews};
165 for my $product ( @{ $details->{Reviews}->{AvgCustomerRating} } ) {
166 $template->param( rating => $product * 20 );
168 for my $reviews ( @{ $details->{Reviews}->{CustomerReview} } ) {
169 push @reviews,
171 Summary => $reviews->{Summary},
172 Comment => $reviews->{Comment},
176 $template->param( SIMILAR_PRODUCTS => \@products );
177 $template->param( AMAZONREVIEWS => \@reviews );
180 output_html_with_http_headers $query, $cookie, $template->output;