6 use C4::Bull; #uses getsubscriptionfrom biblionumber
7 use C4::Interface::CGI::Output;
15 my ($template, $borrowernumber, $cookie)
16 = get_template_and_user({template_name => "opac-detail.tmpl",
20 flagsrequired => {borrow => 1},
23 my $biblionumber=$query->param('bib');
24 $template->param(biblionumber => $biblionumber);
27 # change back when ive fixed request.pl
28 my @items = &ItemInfo(undef, $biblionumber, 'opac');
29 my $dat = &bibdata($biblionumber);
30 my ($authorcount, $addauthor) = &getaddauthor($biblionumber);
31 my ($webbiblioitemcount, @webbiblioitems) = &getwebbiblioitems($biblionumber);
32 my ($websitecount, @websites) = &getwebsites($biblionumber);
33 my $subscriptionsnumber = getsubscriptionfrombiblionumber($biblionumber);
35 #coping with subscriptions
36 my $subscriptionsnumber = getsubscriptionfrombiblionumber($biblionumber);
37 my @subscriptions = getsubscriptions($dat->{title},$dat->{issn},$biblionumber);
39 foreach my $subscription (@subscriptions){
41 $cell{subscriptionid}= $subscription->{subscriptionid};
42 $cell{subscriptionnotes}= $subscription->{notes};
43 #get the three latest serials.
44 $cell{latestserials}=getlatestserials($subscription->{subscriptionid},3);
48 $dat->{'count'}=@items;
50 if ($dat->{'author'}){
52 $authorpush{author}=$dat->{'author'};
53 push @author, \%authorpush
55 $dat->{'additional'}=$addauthor->[0]->{'author'};
56 if ($dat->{'additional'}){
58 $authorpush{author} =$addauthor->[0]->{'author'};
59 push @author, \%authorpush
62 foreach my $word (split(" ", $dat->{'title'})){
63 unless (length($word) == 4){
66 unless (C4::Context->stopwords->{uc($word)} or length($word)==1) {
68 $titlepush{title} =$word;
69 push @title, \%titlepush;
70 }#it's NOT a stopword => use it. Otherwise, ignore
73 for (my $i = 1; $i < $authorcount; $i++) {
74 $dat->{'additional'} .= " ; " . $addauthor->[$i]->{'author'};
77 $authorpush{author}=$addauthor->[$i]->{'author'};
78 push @author, \%authorpush
82 foreach my $itm (@items) {
83 $norequests = 0 unless (($itm->{'wthdrawn'}) || ($itm->{'itemlost'}) || ($itm->{'notforloan'}) || ($itm->{'itemnotforloan'}) || (!$itm->{'itemnumber'}));
84 $itm->{$itm->{'publictype'}} = 1;
87 $template->param(norequests => $norequests);
89 ## get notes and subjects from MARC record
90 my $marc = C4::Context->preference("marc");
91 my @results = ($dat,);
92 if (C4::Boolean::true_p($marc)) {
93 my $dbh = C4::Context->dbh;
94 my $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblionumber);
95 my $marcflavour = C4::Context->preference("marcflavour");
96 my $marcnotesarray = &getMARCnotes($dbh,$bibid,$marcflavour);
97 $results[0]->{MARCNOTES} = $marcnotesarray;
98 my $marcsubjctsarray = &getMARCsubjects($dbh,$bibid,$marcflavour);
99 $results[0]->{MARCSUBJCTS} = $marcsubjctsarray;
100 # $template->param(MARCNOTES => $marcnotesarray);
101 # $template->param(MARCSUBJCTS => $marcsubjctsarray);
104 # get the number of reviews
105 my $reviewcount=numberofreviews($biblionumber);
106 $dat->{'reviews'}=$reviewcount;
108 my @results = ($dat,);
109 my $resultsarray=\@results;
110 my $itemsarray=\@items;
111 my $webarray=\@webbiblioitems;
112 my $sitearray=\@websites;
113 my $titlewords=\@title;
114 my $authorwords=\@author;
117 #coping with subscriptions
118 my $subscriptionsnumber = getsubscriptionfrombiblionumber($biblionumber);
119 my @subscriptions = getsubscriptions($dat->{title},$dat->{issn},$biblionumber);
121 foreach my $subscription (@subscriptions){
122 warn "subsid :".$subscription->{subscriptionid};
124 $cell{subscriptionid}= $subscription->{subscriptionid};
125 $cell{subscriptionnotes}= $subscription->{notes};
126 #get the three latest serials.
127 $cell{latestserials}=getlatestserials($subscription->{subscriptionid},3);
131 $template->param(BIBLIO_RESULTS => $resultsarray,
132 ITEM_RESULTS => $itemsarray,
133 WEB_RESULTS => $webarray,
134 SITE_RESULTS => $sitearray,
135 subscriptionsnumber => $subscriptionsnumber,
136 LibraryName => C4::Context->preference("LibraryName"),
137 suggestion => C4::Context->preference("suggestion"),
138 virtualshelves => C4::Context->preference("virtualshelves"),
139 titlewords => $titlewords,
140 authorwords => $authorwords,
143 #not used unless preference set
144 if (C4::Context->preference("AmazonContent")==1) {
146 $dat->{'amazonisbn'}=$dat->{'isbn'};
147 $dat->{'amazonisbn'} =~ s|-||g;
149 $template->param( amazonisbn => $dat->{amazonisbn} );
151 my $amazon_details = &get_amazon_details($dat->{amazonisbn});
153 foreach my $result (@{$amazon_details->{Details}}){
154 $template->param(item_description => $result->{ProductDescription});
155 $template->param(image => $result->{ImageUrlMedium});
156 $template->param(list_price => $result->{ListPrice});
157 $template->param(amazon_url => $result->{url});
162 for my $details( @{ $amazon_details->{ Details } } ) {
163 next unless $details->{ SimilarProducts };
164 for my $product ( @{ $details->{ SimilarProducts }->{ Product } } ) {
165 push @products, +{ Product => $product };
167 next unless $details->{ Reviews };
168 for my $product ( @{ $details->{ Reviews }->{ AvgCustomerRating } } ) {
169 $template->param(rating => $product * 20);
171 for my $reviews ( @{ $details->{ Reviews }->{ CustomerReview } } ) {
172 push @reviews, +{ Summary => $reviews->{ Summary }, Comment => $reviews->{ Comment }, };
175 $template->param( SIMILAR_PRODUCTS => \@products );
176 $template->param( REVIEWS => \@reviews );
178 output_html_with_http_headers $query, $cookie, $template->output;