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
30 use C4::Dates qw/format_date/;
31 use C4::XISBN qw(get_xisbns get_biblio_from_xisbn);
38 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
40 template_name => "opac-detail.tmpl",
44 flagsrequired => { borrow => 1 },
48 my $biblionumber = $query->param('biblionumber') || $query->param('bib');
49 $template->param( biblionumber => $biblionumber );
51 # change back when ive fixed request.pl
52 my @items = &GetItemsInfo( $biblionumber, 'opac' );
53 my $dat = &GetBiblioData($biblionumber);
56 print $query->redirect("/cgi-bin/koha/koha-tmpl/errors/404.pl");
60 #coping with subscriptions
61 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
63 GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
65 $dat->{'serial'}=1 if $subscriptionsnumber;
66 foreach my $subscription (@subscriptions) {
68 $cell{subscriptionid} = $subscription->{subscriptionid};
69 $cell{subscriptionnotes} = $subscription->{notes};
70 $cell{branchcode} = $subscription->{branchcode};
71 $cell{hasalert} = $subscription->{hasalert};
72 #get the three latest serials.
73 $cell{latestserials} =
74 GetLatestSerials( $subscription->{subscriptionid}, 3 );
78 $dat->{'count'} = scalar(@items);
80 #adding RequestOnOpac filter to allow or not the display of plce reserve button
81 # FIXME - use me or delete me.
83 if (C4::Context->preference("RequestOnOpac")) {
88 my $imgdir = getitemtypeimagesrc();
89 my $itemtypes = GetItemTypes();
90 foreach my $itm (@items) {
91 $norequests = 0 && $norequests
92 if ( (not $itm->{'wthdrawn'} )
93 || (not $itm->{'itemlost'} )
94 || (not $itm->{'itemnotforloan'} )
95 || ($itm->{'itemnumber'} ) );
96 $itm->{ $itm->{'publictype'} } = 1;
99 my $itemtype = $itm->{'itemtype'};
101 $itm->{'imageurl'} = $imgdir."/".$itemtypes->{$itemtype}->{'imageurl'};
102 $itm->{'description'} = $itemtypes->{$itemtype}->{'description'};
105 #get collection code description, too
106 $itm->{'ccode'} = GetAuthorisedValueDesc('','', $itm->{'ccode'} ,'','','CCODE');
109 $template->param( norequests => $norequests, RequestOnOpac=>$RequestOnOpac );
111 ## get notes and subjects from MARC record
112 my $dbh = C4::Context->dbh;
113 my $marcflavour = C4::Context->preference("marcflavour");
114 my $record = GetMarcBiblio($biblionumber);
115 my $marcnotesarray = GetMarcNotes( $record, $marcflavour );
116 my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
117 my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
118 my $marcseriesarray = GetMarcSeries($record,$marcflavour);
119 my $marcurlsarray = GetMarcUrls($record,$marcflavour);
122 MARCNOTES => $marcnotesarray,
123 MARCSUBJCTS => $marcsubjctsarray,
124 MARCAUTHORS => $marcauthorsarray,
125 MARCSERIES => $marcseriesarray,
126 MARCURLS => $marcurlsarray,
129 foreach ( keys %{$dat} ) {
130 $template->param( "$_" => $dat->{$_} . "" );
133 # COinS format FIXME: for books Only
135 my $fmt = substr $record->leader(), 6,2;
137 $fmts->{'am'} = 'book';
138 $coins_format = $fmts->{$fmt};
140 ocoins_format => $coins_format,
143 my $reviews = getreviews( $biblionumber, 1 );
144 foreach ( @$reviews ) {
145 my $borrower_number_review = $_->{borrowernumber};
146 my $borrowerData = GetMember($borrower_number_review,'borrowernumber');
147 # setting some borrower info into this hash
148 $_->{title} = $borrowerData->{'title'};
149 $_->{surname} = $borrowerData->{'surname'};
150 $_->{firstname} = $borrowerData->{'firstname'};
151 $_->{datereviewed} = format_date($_->{datereviewed});
155 if(C4::Context->preference("ISBD")) {
156 $template->param(ISBD => 1);
160 ITEM_RESULTS => \@items,
161 subscriptionsnumber => $subscriptionsnumber,
162 biblionumber => $biblionumber,
163 subscriptions => \@subs,
164 subscriptionsnumber => $subscriptionsnumber,
169 my $xisbn=$dat->{'isbn'};
170 $xisbn =~ s/(p|-| |:)//g;
171 $template->param(amazonisbn => $xisbn);
172 if (C4::Context->preference("OPACFRBRizeEditions")==1) {
176 XISBNS => get_xisbns($xisbn)
179 if ($@) { warn "XISBN Failed $@"; }
181 if ( C4::Context->preference("OPACAmazonContent") == 1 ) {
182 my $amazon_details = &get_amazon_details( $xisbn );
183 foreach my $result ( @{ $amazon_details->{Details} } ) {
184 $template->param( item_description => $result->{ProductDescription} );
185 $template->param( image => $result->{ImageUrlMedium} );
186 $template->param( list_price => $result->{ListPrice} );
187 $template->param( amazon_url => $result->{url} );
192 for my $details ( @{ $amazon_details->{Details} } ) {
193 next unless $details->{SimilarProducts};
194 for my $product ( @{ $details->{SimilarProducts}->{Product} } ) {
195 if (C4::Context->preference("OPACAmazonSimilarItems") ) {
199 if (C4::Context->preference("OPACXISBNAmazonSimilarItems") ) {
200 my $xbiblio = get_biblio_from_xisbn($product);
201 push @xisbns, $xbiblio;
202 $xbiblios = \@xisbns;
205 $xbiblios = get_xisbns($product);
207 push @products, +{ product => $xbiblios };
210 next unless $details->{Reviews};
211 for my $product ( @{ $details->{Reviews}->{AvgCustomerRating} } ) {
212 $template->param( rating => $product * 20 );
214 for my $reviews ( @{ $details->{Reviews}->{CustomerReview} } ) {
217 summary => $reviews->{Summary},
218 comment => $reviews->{Comment},
222 $template->param( SIMILAR_PRODUCTS => \@products );
223 $template->param( AMAZONREVIEWS => \@reviews );
226 output_html_with_http_headers $query, $cookie, $template->output;