6 use C4::Bull; #uses getsubscriptionfrom biblionumber
7 use C4::Interface::CGI::Output;
16 my ($template, $borrowernumber, $cookie)
17 = get_template_and_user({template_name => "opac-detail.tmpl",
21 flagsrequired => {borrow => 1},
24 my $biblionumber=$query->param('bib');
25 $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);
38 my @subscriptions = getsubscriptions($dat->{title},$dat->{issn},$biblionumber);
40 foreach my $subscription (@subscriptions){
42 $cell{subscriptionid}= $subscription->{subscriptionid};
43 $cell{subscriptionnotes}= $subscription->{notes};
44 #get the three latest serials.
45 $cell{latestserials}=getlatestserials($subscription->{subscriptionid},3);
49 $dat->{'count'}=@items;
51 if ($dat->{'author'}){
53 $authorpush{author}=$dat->{'author'};
54 push @author, \%authorpush
56 $dat->{'additional'}=$addauthor->[0]->{'author'};
57 if ($dat->{'additional'}){
59 $authorpush{author} =$addauthor->[0]->{'author'};
60 push @author, \%authorpush
63 foreach my $word (split(" ", $dat->{'title'})){
64 unless (length($word) == 4){
67 unless (C4::Context->stopwords->{uc($word)} or length($word)==1) {
69 $titlepush{title} =$word;
70 push @title, \%titlepush;
71 }#it's NOT a stopword => use it. Otherwise, ignore
74 for (my $i = 1; $i < $authorcount; $i++) {
75 $dat->{'additional'} .= " ; " . $addauthor->[$i]->{'author'};
78 $authorpush{author}=$addauthor->[$i]->{'author'};
79 push @author, \%authorpush
83 foreach my $itm (@items) {
84 $norequests = 0 unless (($itm->{'wthdrawn'}) || ($itm->{'itemlost'}) || ($itm->{'notforloan'}) || ($itm->{'itemnotforloan'}) || (!$itm->{'itemnumber'}));
85 $itm->{$itm->{'publictype'}} = 1;
88 $template->param(norequests => $norequests);
90 ## get notes and subjects from MARC record
91 my $marc = C4::Context->preference("marc");
92 my @results = ($dat,);
93 if (C4::Boolean::true_p($marc)) {
94 my $dbh = C4::Context->dbh;
95 my $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblionumber);
96 my $marcflavour = C4::Context->preference("marcflavour");
97 my $marcnotesarray = &getMARCnotes($dbh,$bibid,$marcflavour);
98 $results[0]->{MARCNOTES} = $marcnotesarray;
99 my $marcsubjctsarray = &getMARCsubjects($dbh,$bibid,$marcflavour);
100 $results[0]->{MARCSUBJCTS} = $marcsubjctsarray;
101 # $template->param(MARCNOTES => $marcnotesarray);
102 # $template->param(MARCSUBJCTS => $marcsubjctsarray);
105 # get the number of reviews
106 my $reviewcount=numberofreviews($biblionumber);
107 $dat->{'reviews'}=$reviewcount;
109 my @results = ($dat,);
110 my $resultsarray=\@results;
111 my $itemsarray=\@items;
112 my $webarray=\@webbiblioitems;
113 my $sitearray=\@websites;
114 my $titlewords=\@title;
115 my $authorwords=\@author;
118 #coping with subscriptions
119 my $subscriptionsnumber = getsubscriptionfrombiblionumber($biblionumber);
120 my @subscriptions = getsubscriptions($dat->{title},$dat->{issn},$biblionumber);
122 foreach my $subscription (@subscriptions){
123 warn "subsid :".$subscription->{subscriptionid};
125 $cell{subscriptionid}= $subscription->{subscriptionid};
126 $cell{subscriptionnotes}= $subscription->{notes};
127 #get the three latest serials.
128 $cell{latestserials}=getlatestserials($subscription->{subscriptionid},3);
132 $template->param(BIBLIO_RESULTS => $resultsarray,
133 ITEM_RESULTS => $itemsarray,
134 WEB_RESULTS => $webarray,
135 SITE_RESULTS => $sitearray,
136 subscriptionsnumber => $subscriptionsnumber,
137 LibraryName => C4::Context->preference("LibraryName"),
138 suggestion => C4::Context->preference("suggestion"),
139 virtualshelves => C4::Context->preference("virtualshelves"),
140 titlewords => $titlewords,
141 authorwords => $authorwords,
142 reviewson => C4::Context->preference("marc"),
145 #not used unless preference set
146 if (C4::Context->preference("AmazonContent")==1) {
148 $dat->{'amazonisbn'}=$dat->{'isbn'};
149 $dat->{'amazonisbn'} =~ s|-||g;
151 $template->param( amazonisbn => $dat->{amazonisbn} );
153 my $amazon_details = &get_amazon_details($dat->{amazonisbn});
155 foreach my $result (@{$amazon_details->{Details}}){
156 $template->param(item_description => $result->{ProductDescription});
157 $template->param(image => $result->{ImageUrlMedium});
158 $template->param(list_price => $result->{ListPrice});
159 $template->param(amazon_url => $result->{url});
164 for my $details( @{ $amazon_details->{ Details } } ) {
165 next unless $details->{ SimilarProducts };
166 for my $product ( @{ $details->{ SimilarProducts }->{ Product } } ) {
167 push @products, +{ Product => $product };
169 next unless $details->{ Reviews };
170 for my $product ( @{ $details->{ Reviews }->{ AvgCustomerRating } } ) {
171 $template->param(rating => $product * 20);
173 for my $reviews ( @{ $details->{ Reviews }->{ CustomerReview } } ) {
174 push @reviews, +{ Summary => $reviews->{ Summary }, Comment => $reviews->{ Comment }, };
177 $template->param( SIMILAR_PRODUCTS => \@products );
178 $template->param( REVIEWS => \@reviews );
180 output_html_with_http_headers $query, $cookie, $template->output;