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
26 use C4::Serials; #uses getsubscriptionfrom biblionumber
29 use C4::Dates qw/format_date/;
30 use C4::XISBN qw(get_xisbns get_biblio_from_xisbn);
37 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
39 template_name => "opac-detail.tmpl",
43 flagsrequired => { borrow => 1 },
47 my $biblionumber = $query->param('biblionumber') || $query->param('bib');
48 $template->param( biblionumber => $biblionumber );
50 # change back when ive fixed request.pl
51 my @items = &GetItemsInfo( $biblionumber, 'opac' );
52 my $dat = &GetBiblioData($biblionumber);
55 print $query->redirect("/cgi-bin/koha/koha-tmpl/errors/404.pl");
59 #coping with subscriptions
60 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
62 GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
64 foreach my $subscription (@subscriptions) {
66 $cell{subscriptionid} = $subscription->{subscriptionid};
67 $cell{subscriptionnotes} = $subscription->{notes};
69 #get the three latest serials.
70 $cell{latestserials} =
71 GetLatestSerials( $subscription->{subscriptionid}, 3 );
75 $dat->{'count'} = @items;
77 #adding RequestOnOpac filter to allow or not the display of plce reserve button
78 # FIXME - use me or delete me.
80 if (C4::Context->preference("RequestOnOpac")) {
85 foreach my $itm (@items) {
86 $norequests = 0 && $norequests
87 if ( (not $itm->{'wthdrawn'} )
88 || (not $itm->{'itemlost'} )
89 || (not $itm->{'itemnotforloan'} )
90 || ($itm->{'itemnumber'} ) );
91 $itm->{ $itm->{'publictype'} } = 1;
93 #get collection code description, too
94 $itm->{'ccode'} = GetAuthorisedValueDesc('','', $itm->{'ccode'} ,'','','CCODE');
97 $template->param( norequests => $norequests, RequestOnOpac=>$RequestOnOpac );
99 ## get notes and subjects from MARC record
100 my $dbh = C4::Context->dbh;
101 my $marcflavour = C4::Context->preference("marcflavour");
102 my $record = GetMarcBiblio($biblionumber);
103 my $marcnotesarray = GetMarcNotes( $record, $marcflavour );
104 my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
105 my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
106 my $marcseriesarray = GetMarcSeries($record,$marcflavour);
107 my $marcurlsarray = GetMarcUrls($record,$marcflavour);
110 MARCNOTES => $marcnotesarray,
111 MARCSUBJCTS => $marcsubjctsarray,
112 MARCAUTHORS => $marcauthorsarray,
113 MARCSERIES => $marcseriesarray,
114 MARCURLS => $marcurlsarray,
117 foreach ( keys %{$dat} ) {
118 $template->param( "$_" => $dat->{$_} . "" );
121 my $reviews = getreviews( $biblionumber, 1 );
122 foreach ( @$reviews ) {
123 my $borrower_number_review = $_->{borrowernumber};
124 my $borrowerData = GetMember($borrower_number_review,'borrowernumber');
125 # setting some borrower info into this hash
126 $_->{title} = $borrowerData->{'title'};
127 $_->{surname} = $borrowerData->{'surname'};
128 $_->{firstname} = $borrowerData->{'firstname'};
129 $_->{datereviewed} = format_date($_->{datereviewed});
133 ITEM_RESULTS => \@items,
134 subscriptionsnumber => $subscriptionsnumber,
135 biblionumber => $biblionumber,
136 subscriptions => \@subs,
137 subscriptionsnumber => $subscriptionsnumber,
142 my $xisbn=$dat->{'isbn'};
143 $xisbn =~ s/(p|-| |:)//g;
144 $template->param(amazonisbn => $xisbn);
145 if (C4::Context->preference("OPACFRBRizeEditions")==1) {
149 XISBNS => get_xisbns($xisbn)
152 if ($@) { warn "XISBN Failed $@"; }
154 if ( C4::Context->preference("OPACAmazonContent") == 1 ) {
155 my $amazon_details = &get_amazon_details( $xisbn );
156 foreach my $result ( @{ $amazon_details->{Details} } ) {
157 $template->param( item_description => $result->{ProductDescription} );
158 $template->param( image => $result->{ImageUrlMedium} );
159 $template->param( list_price => $result->{ListPrice} );
160 $template->param( amazon_url => $result->{url} );
165 for my $details ( @{ $amazon_details->{Details} } ) {
166 next unless $details->{SimilarProducts};
167 for my $product ( @{ $details->{SimilarProducts}->{Product} } ) {
168 if (C4::Context->preference("OPACAmazonSimilarItems") ) {
172 if (C4::Context->preference("OPACXISBNAmazonSimilarItems") ) {
173 my $xbiblio = get_biblio_from_xisbn($product);
174 push @xisbns, $xbiblio;
175 $xbiblios = \@xisbns;
178 $xbiblios = get_xisbns($product);
180 push @products, +{ product => $xbiblios };
183 next unless $details->{Reviews};
184 for my $product ( @{ $details->{Reviews}->{AvgCustomerRating} } ) {
185 $template->param( rating => $product * 20 );
187 for my $reviews ( @{ $details->{Reviews}->{CustomerReview} } ) {
190 summary => $reviews->{Summary},
191 comment => $reviews->{Comment},
195 $template->param( SIMILAR_PRODUCTS => \@products );
196 $template->param( AMAZONREVIEWS => \@reviews );
199 output_html_with_http_headers $query, $cookie, $template->output;