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
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
23 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.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
55 use C4::External::Amazon;
57 use C4::Serials; # uses getsubscriptionfrom biblionumber
58 use C4::Koha; # use getitemtypeinfo
59 use C4::Members; # GetMember
61 my $query = CGI->new();
62 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
64 template_name => "opac-ISBDdetail.tmpl",
72 my $biblionumber = $query->param('biblionumber');
74 my $marcflavour = C4::Context->preference("marcflavour");
75 my $record = GetMarcBiblio($biblionumber);
77 #coping with subscriptions
78 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
79 my $dbh = C4::Context->dbh;
80 my $dat = TransformMarcToKoha( $dbh, $record );
82 GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
84 foreach my $subscription (@subscriptions) {
86 $cell{subscriptionid} = $subscription->{subscriptionid};
87 $cell{subscriptionnotes} = $subscription->{notes};
88 $cell{branchcode} = $subscription->{branchcode};
90 #get the three latest serials.
91 $cell{latestserials} =
92 GetLatestSerials( $subscription->{subscriptionid}, 3 );
97 subscriptions => \@subs,
98 subscriptionsnumber => $subscriptionsnumber,
101 $template->param(C4::Search::enabled_opac_search_views);
104 my $res = GetISBDView($biblionumber, "opac");
105 my @items = &GetItemsInfo($biblionumber, 'opac');
107 my $itemtypes = GetItemTypes();
108 for my $itm (@items) {
110 if ( (not $itm->{'wthdrawn'} )
111 && (not $itm->{'itemlost'} )
112 && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'} )
113 && (not $itemtypes->{$itm->{'itype'}}->{notforloan} )
114 && ($itm->{'itemnumber'} ) );
117 my $reviews = getreviews( $biblionumber, 1 );
118 foreach ( @$reviews ) {
119 my $borrower_number_review = $_->{borrowernumber};
120 my $borrowerData = GetMember($borrower_number_review,'borrowernumber');
121 # setting some borrower info into this hash
122 $_->{title} = $borrowerData->{'title'};
123 $_->{surname} = $borrowerData->{'surname'};
124 $_->{firstname} = $borrowerData->{'firstname'};
129 RequestOnOpac => C4::Context->preference("RequestOnOpac"),
130 AllowOnShelfHolds => C4::Context->preference('AllowOnShelfHolds'),
131 norequests => $norequests,
133 biblionumber => $biblionumber,
137 my $amazon_reviews = C4::Context->preference("AmazonReviews");
138 my $amazon_similars = C4::Context->preference("AmazonSimilarItems");
140 if ( $amazon_reviews ) {
141 $template->param( AmazonReviews => 1 );
142 push( @services, 'EditorialReview' );
144 if ( $amazon_similars ) {
145 $template->param( AmazonSimilarItems => 1 );
146 push( @services, 'Similarities' );
150 #not used unless preference set
151 if ( C4::Context->preference("AmazonContent") == 1 ) {
152 use C4::External::Amazon;
153 $dat->{'amazonisbn'} = $dat->{'isbn'};
154 $dat->{'amazonisbn'} =~ s|-||g;
156 $template->param( amazonisbn => $dat->{amazonisbn} );
158 my $amazon_details = &get_amazon_details( $dat->{amazonisbn}, $record, $marcflavour );
160 foreach my $result ( @{ $amazon_details->{Details} } ) {
161 $template->param( item_description => $result->{ProductDescription} );
162 $template->param( image => $result->{ImageUrlMedium} );
163 $template->param( list_price => $result->{ListPrice} );
164 $template->param( amazon_url => $result->{url} );
169 for my $details ( @{ $amazon_details->{Details} } ) {
170 next unless $details->{SimilarProducts};
171 for my $product ( @{ $details->{SimilarProducts}->{Product} } ) {
172 push @products, +{ Product => $product };
174 next unless $details->{Reviews};
175 for my $product ( @{ $details->{Reviews}->{AvgCustomerRating} } ) {
176 $template->param( rating => $product * 20 );
178 for my $reviews ( @{ $details->{Reviews}->{CustomerReview} } ) {
181 Summary => $reviews->{Summary},
182 Comment => $reviews->{Comment},
186 $template->param( SIMILAR_PRODUCTS => \@products );
187 $template->param( AMAZONREVIEWS => \@reviews );
190 output_html_with_http_headers $query, $cookie, $template->output;