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
27 use C4::Interface::CGI::Output;
35 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
37 template_name => "opac-detail.tmpl",
41 flagsrequired => { borrow => 1 },
45 my $biblionumber = $query->param('bib');
46 $template->param( biblionumber => $biblionumber );
48 # change back when ive fixed request.pl
49 my @items = &ItemInfo( undef, $biblionumber, 'opac' );
50 my $dat = &bibdata($biblionumber);
51 my ( $authorcount, $addauthor ) = &addauthor($biblionumber);
52 my ( $webbiblioitemcount, @webbiblioitems ) = &getwebbiblioitems($biblionumber);
53 my ( $websitecount, @websites ) = &getwebsites($biblionumber);
55 #coping with subscriptions
56 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
58 GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
60 foreach my $subscription (@subscriptions) {
62 $cell{subscriptionid} = $subscription->{subscriptionid};
63 $cell{subscriptionnotes} = $subscription->{notes};
65 #get the three latest serials.
66 $cell{latestserials} =
67 GetLatestSerials( $subscription->{subscriptionid}, 3 );
71 $dat->{'count'} = @items;
73 if ( $dat->{'author'} ) {
75 $authorpush{author} = $dat->{'author'};
76 push @author, \%authorpush;
78 $dat->{'additional'} = $addauthor->[0]->{'author'};
79 if ( $dat->{'additional'} ) {
81 $authorpush{author} = $addauthor->[0]->{'author'};
82 push @author, \%authorpush;
85 foreach my $word ( split( " ", $dat->{'title'} ) ) {
86 unless ( length($word) == 4 ) {
89 unless ( C4::Context->stopwords->{ uc($word) } or length($word) == 1 ) {
91 $titlepush{title} = $word;
92 push @title, \%titlepush;
93 } #it's NOT a stopword => use it. Otherwise, ignore
96 for ( my $i = 1 ; $i < $authorcount ; $i++ ) {
97 $dat->{'additional'} .= " ; " . $addauthor->[$i]->{'author'};
100 $authorpush{author} = $addauthor->[$i]->{'author'};
101 push @author, \%authorpush;
105 foreach my $itm (@items) {
107 unless ( ( $itm->{'wthdrawn'} )
108 || ( $itm->{'itemlost'} )
109 || ( $itm->{'notforloan'} )
110 || ( $itm->{'itemnotforloan'} )
111 || ( !$itm->{'itemnumber'} ) );
112 $itm->{ $itm->{'publictype'} } = 1;
115 $template->param( norequests => $norequests );
117 ## get notes and subjects from MARC record
118 my $marc = C4::Context->preference("marc");
119 my @results = ( $dat, );
120 if ( C4::Boolean::true_p($marc) ) {
121 my $dbh = C4::Context->dbh;
122 my $bibid = &MARCfind_MARCbibid_from_oldbiblionumber( $dbh, $biblionumber );
123 my $marcflavour = C4::Context->preference("marcflavour");
124 my $marcnotesarray = &getMARCnotes( $dbh, $bibid, $marcflavour );
125 $results[0]->{MARCNOTES} = $marcnotesarray;
126 my $marcsubjctsarray = &getMARCsubjects( $dbh, $bibid, $marcflavour );
127 $results[0]->{MARCSUBJCTS} = $marcsubjctsarray;
129 # $template->param(MARCNOTES => $marcnotesarray);
130 # $template->param(MARCSUBJCTS => $marcsubjctsarray);
133 # get the number of reviews
134 my $reviewcount = numberofreviews($biblionumber);
135 $dat->{'reviews'} = $reviewcount;
137 my @results = ( $dat, );
138 my $resultsarray = \@results;
139 my $itemsarray = \@items;
140 my $webarray = \@webbiblioitems;
141 my $sitearray = \@websites;
142 my $titlewords = \@title;
143 my $authorwords = \@author;
145 #coping with subscriptions
146 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
148 GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
150 foreach my $subscription (@subscriptions) {
151 warn "subsid :" . $subscription->{subscriptionid};
153 $cell{subscriptionid} = $subscription->{subscriptionid};
154 $cell{subscriptionnotes} = $subscription->{notes};
156 #get the three latest serials.
157 $cell{latestserials} =
158 GetLatestSerials( $subscription->{subscriptionid}, 3 );
163 BIBLIO_RESULTS => $resultsarray,
164 ITEM_RESULTS => $itemsarray,
165 WEB_RESULTS => $webarray,
166 SITE_RESULTS => $sitearray,
167 subscriptionsnumber => $subscriptionsnumber,
168 LibraryName => C4::Context->preference("LibraryName"),
169 suggestion => C4::Context->preference("suggestion"),
170 virtualshelves => C4::Context->preference("virtualshelves"),
171 titlewords => $titlewords,
172 authorwords => $authorwords,
173 reviewson => C4::Context->preference("marc"),
176 #not used unless preference set
177 if ( C4::Context->preference("AmazonContent") == 1 ) {
179 $dat->{'amazonisbn'} = $dat->{'isbn'};
180 $dat->{'amazonisbn'} =~ s|-||g;
182 $template->param( amazonisbn => $dat->{amazonisbn} );
184 my $amazon_details = &get_amazon_details( $dat->{amazonisbn} );
186 foreach my $result ( @{ $amazon_details->{Details} } ) {
187 $template->param( item_description => $result->{ProductDescription} );
188 $template->param( image => $result->{ImageUrlMedium} );
189 $template->param( list_price => $result->{ListPrice} );
190 $template->param( amazon_url => $result->{url} );
195 for my $details ( @{ $amazon_details->{Details} } ) {
196 next unless $details->{SimilarProducts};
197 for my $product ( @{ $details->{SimilarProducts}->{Product} } ) {
198 push @products, +{ Product => $product };
200 next unless $details->{Reviews};
201 for my $product ( @{ $details->{Reviews}->{AvgCustomerRating} } ) {
202 $template->param( rating => $product * 20 );
204 for my $reviews ( @{ $details->{Reviews}->{CustomerReview} } ) {
207 Summary => $reviews->{Summary},
208 Comment => $reviews->{Comment},
212 $template->param( SIMILAR_PRODUCTS => \@products );
213 $template->param( REVIEWS => \@reviews );
215 output_html_with_http_headers $query, $cookie, $template->output;