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 ) = &getaddauthor($biblionumber);
52 my ( $webbiblioitemcount, @webbiblioitems ) = &getwebbiblioitems($biblionumber);
53 my ( $websitecount, @websites ) = &getwebsites($biblionumber);
54 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
56 #coping with subscriptions
57 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
59 GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
61 foreach my $subscription (@subscriptions) {
63 $cell{subscriptionid} = $subscription->{subscriptionid};
64 $cell{subscriptionnotes} = $subscription->{notes};
66 #get the three latest serials.
67 $cell{latestserials} =
68 GetLatestSerials( $subscription->{subscriptionid}, 3 );
72 $dat->{'count'} = @items;
74 if ( $dat->{'author'} ) {
76 $authorpush{author} = $dat->{'author'};
77 push @author, \%authorpush;
79 $dat->{'additional'} = $addauthor->[0]->{'author'};
80 if ( $dat->{'additional'} ) {
82 $authorpush{author} = $addauthor->[0]->{'author'};
83 push @author, \%authorpush;
86 foreach my $word ( split( " ", $dat->{'title'} ) ) {
87 unless ( length($word) == 4 ) {
90 unless ( C4::Context->stopwords->{ uc($word) } or length($word) == 1 ) {
92 $titlepush{title} = $word;
93 push @title, \%titlepush;
94 } #it's NOT a stopword => use it. Otherwise, ignore
97 for ( my $i = 1 ; $i < $authorcount ; $i++ ) {
98 $dat->{'additional'} .= " ; " . $addauthor->[$i]->{'author'};
101 $authorpush{author} = $addauthor->[$i]->{'author'};
102 push @author, \%authorpush;
106 foreach my $itm (@items) {
108 unless ( ( $itm->{'wthdrawn'} )
109 || ( $itm->{'itemlost'} )
110 || ( $itm->{'notforloan'} )
111 || ( $itm->{'itemnotforloan'} )
112 || ( !$itm->{'itemnumber'} ) );
113 $itm->{ $itm->{'publictype'} } = 1;
116 $template->param( norequests => $norequests );
118 ## get notes and subjects from MARC record
119 my $marc = C4::Context->preference("marc");
120 my @results = ( $dat, );
121 if ( C4::Boolean::true_p($marc) ) {
122 my $dbh = C4::Context->dbh;
123 my $bibid = &MARCfind_MARCbibid_from_oldbiblionumber( $dbh, $biblionumber );
124 my $marcflavour = C4::Context->preference("marcflavour");
125 my $marcnotesarray = &getMARCnotes( $dbh, $bibid, $marcflavour );
126 $results[0]->{MARCNOTES} = $marcnotesarray;
127 my $marcsubjctsarray = &getMARCsubjects( $dbh, $bibid, $marcflavour );
128 $results[0]->{MARCSUBJCTS} = $marcsubjctsarray;
130 # $template->param(MARCNOTES => $marcnotesarray);
131 # $template->param(MARCSUBJCTS => $marcsubjctsarray);
134 # get the number of reviews
135 my $reviewcount = numberofreviews($biblionumber);
136 $dat->{'reviews'} = $reviewcount;
138 my @results = ( $dat, );
139 my $resultsarray = \@results;
140 my $itemsarray = \@items;
141 my $webarray = \@webbiblioitems;
142 my $sitearray = \@websites;
143 my $titlewords = \@title;
144 my $authorwords = \@author;
146 #coping with subscriptions
147 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
149 GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
151 foreach my $subscription (@subscriptions) {
152 warn "subsid :" . $subscription->{subscriptionid};
154 $cell{subscriptionid} = $subscription->{subscriptionid};
155 $cell{subscriptionnotes} = $subscription->{notes};
157 #get the three latest serials.
158 $cell{latestserials} =
159 GetLatestSerials( $subscription->{subscriptionid}, 3 );
164 BIBLIO_RESULTS => $resultsarray,
165 ITEM_RESULTS => $itemsarray,
166 WEB_RESULTS => $webarray,
167 SITE_RESULTS => $sitearray,
168 subscriptionsnumber => $subscriptionsnumber,
169 LibraryName => C4::Context->preference("LibraryName"),
170 suggestion => C4::Context->preference("suggestion"),
171 virtualshelves => C4::Context->preference("virtualshelves"),
172 titlewords => $titlewords,
173 authorwords => $authorwords,
174 reviewson => C4::Context->preference("marc"),
177 #not used unless preference set
178 if ( C4::Context->preference("AmazonContent") == 1 ) {
180 $dat->{'amazonisbn'} = $dat->{'isbn'};
181 $dat->{'amazonisbn'} =~ s|-||g;
183 $template->param( amazonisbn => $dat->{amazonisbn} );
185 my $amazon_details = &get_amazon_details( $dat->{amazonisbn} );
187 foreach my $result ( @{ $amazon_details->{Details} } ) {
188 $template->param( item_description => $result->{ProductDescription} );
189 $template->param( image => $result->{ImageUrlMedium} );
190 $template->param( list_price => $result->{ListPrice} );
191 $template->param( amazon_url => $result->{url} );
196 for my $details ( @{ $amazon_details->{Details} } ) {
197 next unless $details->{SimilarProducts};
198 for my $product ( @{ $details->{SimilarProducts}->{Product} } ) {
199 push @products, +{ Product => $product };
201 next unless $details->{Reviews};
202 for my $product ( @{ $details->{Reviews}->{AvgCustomerRating} } ) {
203 $template->param( rating => $product * 20 );
205 for my $reviews ( @{ $details->{Reviews}->{CustomerReview} } ) {
208 Summary => $reviews->{Summary},
209 Comment => $reviews->{Comment},
213 $template->param( SIMILAR_PRODUCTS => \@products );
214 $template->param( REVIEWS => \@reviews );
216 output_html_with_http_headers $query, $cookie, $template->output;