6 use C4::Bull; #uses getsubscriptionfrom biblionumber
7 use C4::Interface::CGI::Output;
15 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
17 template_name => "opac-detail.tmpl",
21 flagsrequired => { borrow => 1 },
25 my $biblionumber = $query->param('bib');
26 $template->param( biblionumber => $biblionumber );
28 # change back when ive fixed request.pl
29 my @items = &ItemInfo( undef, $biblionumber, 'opac' );
30 my $dat = &bibdata($biblionumber);
31 my ( $authorcount, $addauthor ) = &getaddauthor($biblionumber);
32 my ( $webbiblioitemcount, @webbiblioitems ) = &getwebbiblioitems($biblionumber);
33 my ( $websitecount, @websites ) = &getwebsites($biblionumber);
34 my $subscriptionsnumber = getsubscriptionfrombiblionumber($biblionumber);
36 #coping with subscriptions
37 my $subscriptionsnumber = getsubscriptionfrombiblionumber($biblionumber);
39 getsubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
41 foreach my $subscription (@subscriptions) {
43 $cell{subscriptionid} = $subscription->{subscriptionid};
44 $cell{subscriptionnotes} = $subscription->{notes};
46 #get the three latest serials.
47 $cell{latestserials} =
48 getlatestserials( $subscription->{subscriptionid}, 3 );
52 $dat->{'count'} = @items;
54 if ( $dat->{'author'} ) {
56 $authorpush{author} = $dat->{'author'};
57 push @author, \%authorpush;
59 $dat->{'additional'} = $addauthor->[0]->{'author'};
60 if ( $dat->{'additional'} ) {
62 $authorpush{author} = $addauthor->[0]->{'author'};
63 push @author, \%authorpush;
66 foreach my $word ( split( " ", $dat->{'title'} ) ) {
67 unless ( length($word) == 4 ) {
70 unless ( C4::Context->stopwords->{ uc($word) } or length($word) == 1 ) {
72 $titlepush{title} = $word;
73 push @title, \%titlepush;
74 } #it's NOT a stopword => use it. Otherwise, ignore
77 for ( my $i = 1 ; $i < $authorcount ; $i++ ) {
78 $dat->{'additional'} .= " ; " . $addauthor->[$i]->{'author'};
81 $authorpush{author} = $addauthor->[$i]->{'author'};
82 push @author, \%authorpush;
86 foreach my $itm (@items) {
88 unless ( ( $itm->{'wthdrawn'} )
89 || ( $itm->{'itemlost'} )
90 || ( $itm->{'notforloan'} )
91 || ( $itm->{'itemnotforloan'} )
92 || ( !$itm->{'itemnumber'} ) );
93 $itm->{ $itm->{'publictype'} } = 1;
96 $template->param( norequests => $norequests );
98 ## get notes and subjects from MARC record
99 my $marc = C4::Context->preference("marc");
100 my @results = ( $dat, );
101 if ( C4::Boolean::true_p($marc) ) {
102 my $dbh = C4::Context->dbh;
103 my $bibid = &MARCfind_MARCbibid_from_oldbiblionumber( $dbh, $biblionumber );
104 my $marcflavour = C4::Context->preference("marcflavour");
105 my $marcnotesarray = &getMARCnotes( $dbh, $bibid, $marcflavour );
106 $results[0]->{MARCNOTES} = $marcnotesarray;
107 my $marcsubjctsarray = &getMARCsubjects( $dbh, $bibid, $marcflavour );
108 $results[0]->{MARCSUBJCTS} = $marcsubjctsarray;
110 # $template->param(MARCNOTES => $marcnotesarray);
111 # $template->param(MARCSUBJCTS => $marcsubjctsarray);
114 # get the number of reviews
115 my $reviewcount = numberofreviews($biblionumber);
116 $dat->{'reviews'} = $reviewcount;
118 my @results = ( $dat, );
119 my $resultsarray = \@results;
120 my $itemsarray = \@items;
121 my $webarray = \@webbiblioitems;
122 my $sitearray = \@websites;
123 my $titlewords = \@title;
124 my $authorwords = \@author;
126 #coping with subscriptions
127 my $subscriptionsnumber = getsubscriptionfrombiblionumber($biblionumber);
129 getsubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
131 foreach my $subscription (@subscriptions) {
132 warn "subsid :" . $subscription->{subscriptionid};
134 $cell{subscriptionid} = $subscription->{subscriptionid};
135 $cell{subscriptionnotes} = $subscription->{notes};
137 #get the three latest serials.
138 $cell{latestserials} =
139 getlatestserials( $subscription->{subscriptionid}, 3 );
144 BIBLIO_RESULTS => $resultsarray,
145 ITEM_RESULTS => $itemsarray,
146 WEB_RESULTS => $webarray,
147 SITE_RESULTS => $sitearray,
148 subscriptionsnumber => $subscriptionsnumber,
149 LibraryName => C4::Context->preference("LibraryName"),
150 suggestion => C4::Context->preference("suggestion"),
151 virtualshelves => C4::Context->preference("virtualshelves"),
152 titlewords => $titlewords,
153 authorwords => $authorwords,
154 reviewson => C4::Context->preference("marc"),
157 #not used unless preference set
158 if ( C4::Context->preference("AmazonContent") == 1 ) {
160 $dat->{'amazonisbn'} = $dat->{'isbn'};
161 $dat->{'amazonisbn'} =~ s|-||g;
163 $template->param( amazonisbn => $dat->{amazonisbn} );
165 my $amazon_details = &get_amazon_details( $dat->{amazonisbn} );
167 foreach my $result ( @{ $amazon_details->{Details} } ) {
168 $template->param( item_description => $result->{ProductDescription} );
169 $template->param( image => $result->{ImageUrlMedium} );
170 $template->param( list_price => $result->{ListPrice} );
171 $template->param( amazon_url => $result->{url} );
176 for my $details ( @{ $amazon_details->{Details} } ) {
177 next unless $details->{SimilarProducts};
178 for my $product ( @{ $details->{SimilarProducts}->{Product} } ) {
179 push @products, +{ Product => $product };
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( REVIEWS => \@reviews );
196 output_html_with_http_headers $query, $cookie, $template->output;