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::XISBN qw(get_xisbns get_biblio_from_xisbn);
36 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
38 template_name => "opac-detail.tmpl",
42 flagsrequired => { borrow => 1 },
46 my $biblionumber = $query->param('biblionumber') || $query->param('bib');
47 $template->param( biblionumber => $biblionumber );
49 # change back when ive fixed request.pl
50 my @items = &GetItemsInfo( $biblionumber, 'opac' );
51 my $dat = &GetBiblioData($biblionumber);
54 print $query->redirect("/cgi-bin/koha/koha-tmpl/errors/404.pl");
57 #coping with subscriptions
58 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
60 GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
62 foreach my $subscription (@subscriptions) {
64 $cell{subscriptionid} = $subscription->{subscriptionid};
65 $cell{subscriptionnotes} = $subscription->{notes};
67 #get the three latest serials.
68 $cell{latestserials} =
69 GetLatestSerials( $subscription->{subscriptionid}, 3 );
73 $dat->{'count'} = @items;
75 #adding RequestOnOpac filter to allow or not the display of plce reserve button
76 # FIXME - use me or delete me.
78 if (C4::Context->preference("RequestOnOpac")) {
83 foreach my $itm (@items) {
84 $norequests = 0 && $norequests
85 if ( (not $itm->{'wthdrawn'} )
86 || (not $itm->{'itemlost'} )
87 || (not $itm->{'itemnotforloan'} )
88 || ($itm->{'itemnumber'} ) );
89 $itm->{ $itm->{'publictype'} } = 1;
91 #get collection code description, too
92 $itm->{'ccode'} = GetAuthorisedValueDesc('','', $itm->{'ccode'} ,'','','CCODE');
95 $template->param( norequests => $norequests, RequestOnOpac=>$RequestOnOpac );
97 ## get notes and subjects from MARC record
98 my $dbh = C4::Context->dbh;
99 my $marcflavour = C4::Context->preference("marcflavour");
100 my $record = GetMarcBiblio($biblionumber);
101 my $marcnotesarray = GetMarcNotes( $record, $marcflavour );
102 my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
103 my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
104 my $marcseriesarray = GetMarcSeries($record,$marcflavour);
105 my $marcurlsarray = GetMarcUrls($record,$marcflavour);
108 MARCNOTES => $marcnotesarray,
109 MARCSUBJCTS => $marcsubjctsarray,
110 MARCAUTHORS => $marcauthorsarray,
111 MARCSERIES => $marcseriesarray,
112 MARCURLS => $marcurlsarray,
115 my @results = ( $dat, );
116 foreach ( keys %{$dat} ) {
117 $template->param( "$_" => $dat->{$_} . "" );
120 my $reviews = getreviews( $biblionumber, 1 );
121 foreach ( @$reviews ) {
122 my $borrower_number_review = $_->{borrowernumber};
123 my $borrowerData = GetMember($borrower_number_review,'borrowernumber');
124 # setting some borrower info into this hash
125 $_->{title} = $borrowerData->{'title'};
126 $_->{surname} = $borrowerData->{'surname'};
127 $_->{firstname} = $borrowerData->{'firstname'};
131 ITEM_RESULTS => \@items,
132 subscriptionsnumber => $subscriptionsnumber,
133 biblionumber => $biblionumber,
134 subscriptions => \@subs,
135 subscriptionsnumber => $subscriptionsnumber,
140 my $xisbn=$dat->{'isbn'};
141 $xisbn =~ s/(p|-| |:)//g;
142 $template->param(amazonisbn => $xisbn);
143 if (C4::Context->preference("OPACFRBRizeEditions")==1) {
147 XISBNS => get_xisbns($xisbn)
150 if ($@) { warn "XISBN Failed $@"; }
152 if ( C4::Context->preference("OPACAmazonContent") == 1 ) {
153 my $amazon_details = &get_amazon_details( $xisbn );
154 foreach my $result ( @{ $amazon_details->{Details} } ) {
155 $template->param( item_description => $result->{ProductDescription} );
156 $template->param( image => $result->{ImageUrlMedium} );
157 $template->param( list_price => $result->{ListPrice} );
158 $template->param( amazon_url => $result->{url} );
163 for my $details ( @{ $amazon_details->{Details} } ) {
164 next unless $details->{SimilarProducts};
165 for my $product ( @{ $details->{SimilarProducts}->{Product} } ) {
166 if (C4::Context->preference("OPACAmazonSimilarItems") ) {
170 if (C4::Context->preference("OPACXISBNAmazonSimilarItems") ) {
171 my $xbiblio = get_biblio_from_xisbn($product);
172 push @xisbns, $xbiblio;
173 $xbiblios = \@xisbns;
176 $xbiblios = get_xisbns($product);
178 push @products, +{ product => $xbiblios };
181 next unless $details->{Reviews};
182 for my $product ( @{ $details->{Reviews}->{AvgCustomerRating} } ) {
183 $template->param( rating => $product * 20 );
185 for my $reviews ( @{ $details->{Reviews}->{CustomerReview} } ) {
188 summary => $reviews->{Summary},
189 comment => $reviews->{Comment},
193 $template->param( SIMILAR_PRODUCTS => \@products );
194 $template->param( AMAZONREVIEWS => \@reviews );
197 output_html_with_http_headers $query, $cookie, $template->output;