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,
102 my $res = GetISBDView($biblionumber, "opac");
103 my @items = &GetItemsInfo($biblionumber, 'opac');
105 my $itemtypes = GetItemTypes();
106 for my $itm (@items) {
108 if ( (not $itm->{'wthdrawn'} )
109 && (not $itm->{'itemlost'} )
110 && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'} )
111 && (not $itemtypes->{$itm->{'itype'}}->{notforloan} )
112 && ($itm->{'itemnumber'} ) );
115 my $reviews = getreviews( $biblionumber, 1 );
116 foreach ( @$reviews ) {
117 my $borrower_number_review = $_->{borrowernumber};
118 my $borrowerData = GetMember($borrower_number_review,'borrowernumber');
119 # setting some borrower info into this hash
120 $_->{title} = $borrowerData->{'title'};
121 $_->{surname} = $borrowerData->{'surname'};
122 $_->{firstname} = $borrowerData->{'firstname'};
127 RequestOnOpac => C4::Context->preference("RequestOnOpac"),
128 AllowOnShelfHolds => C4::Context->preference('AllowOnShelfHolds'),
129 norequests => $norequests,
131 biblionumber => $biblionumber,
135 my $amazon_reviews = C4::Context->preference("AmazonReviews");
136 my $amazon_similars = C4::Context->preference("AmazonSimilarItems");
138 if ( $amazon_reviews ) {
139 $template->param( AmazonReviews => 1 );
140 push( @services, 'EditorialReview' );
142 if ( $amazon_similars ) {
143 $template->param( AmazonSimilarItems => 1 );
144 push( @services, 'Similarities' );
148 #not used unless preference set
149 if ( C4::Context->preference("AmazonContent") == 1 ) {
150 use C4::External::Amazon;
151 $dat->{'amazonisbn'} = $dat->{'isbn'};
152 $dat->{'amazonisbn'} =~ s|-||g;
154 $template->param( amazonisbn => $dat->{amazonisbn} );
156 my $amazon_details = &get_amazon_details( $dat->{amazonisbn}, $record, $marcflavour );
158 foreach my $result ( @{ $amazon_details->{Details} } ) {
159 $template->param( item_description => $result->{ProductDescription} );
160 $template->param( image => $result->{ImageUrlMedium} );
161 $template->param( list_price => $result->{ListPrice} );
162 $template->param( amazon_url => $result->{url} );
167 for my $details ( @{ $amazon_details->{Details} } ) {
168 next unless $details->{SimilarProducts};
169 for my $product ( @{ $details->{SimilarProducts}->{Product} } ) {
170 push @products, +{ Product => $product };
172 next unless $details->{Reviews};
173 for my $product ( @{ $details->{Reviews}->{AvgCustomerRating} } ) {
174 $template->param( rating => $product * 20 );
176 for my $reviews ( @{ $details->{Reviews}->{CustomerReview} } ) {
179 Summary => $reviews->{Summary},
180 Comment => $reviews->{Comment},
184 $template->param( SIMILAR_PRODUCTS => \@products );
185 $template->param( AMAZONREVIEWS => \@reviews );
188 output_html_with_http_headers $query, $cookie, $template->output;