7 use C4::Bull; #uses getsubscriptionfrom biblionumber
8 use C4::Interface::CGI::Output;
14 my ($template, $borrowernumber, $cookie)
15 = get_template_and_user({template_name => "opac-detail.tmpl",
19 flagsrequired => {borrow => 1},
22 my $biblionumber=$query->param('bib');
23 $template->param(biblionumber => $biblionumber);
26 # change back when ive fixed request.pl
27 my @items = &ItemInfo(undef, $biblionumber, 'opac');
28 my $dat = &bibdata($biblionumber);
29 my ($authorcount, $addauthor) = &addauthor($biblionumber);
30 my ($webbiblioitemcount, @webbiblioitems) = &getwebbiblioitems($biblionumber);
31 my ($websitecount, @websites) = &getwebsites($biblionumber);
32 my $subscriptionsnumber = getsubscriptionfrombiblionumber($biblionumber);
35 $dat->{'count'}=@items;
37 if ($dat->{'author'}){
39 $authorpush{author}=$dat->{'author'};
40 push @author, \%authorpush
42 $dat->{'additional'}=$addauthor->[0]->{'author'};
43 if ($dat->{'additional'}){
45 $authorpush{author} =$addauthor->[0]->{'author'};
46 push @author, \%authorpush
49 foreach my $word (split(" ", $dat->{'title'})){
50 unless (length($word) == 4){
53 unless (C4::Context->stopwords->{uc($word)} or length($word)==1) {
55 $titlepush{title} =$word;
56 push @title, \%titlepush;
57 }#it's NOT a stopword => use it. Otherwise, ignore
60 for (my $i = 1; $i < $authorcount; $i++) {
61 $dat->{'additional'} .= " ; " . $addauthor->[$i]->{'author'};
64 $authorpush{author}=$addauthor->[$i]->{'author'};
65 push @author, \%authorpush
69 foreach my $itm (@items) {
70 $norequests = 0 unless $itm->{'notforloan'};
71 $itm->{$itm->{'publictype'}} = 1;
74 $template->param(norequests => $norequests);
76 ## get notes and subjects from MARC record
77 my $marc = C4::Context->preference("marc");
78 my @results = ($dat,);
79 if (C4::Boolean::true_p($marc)) {
80 my $dbh = C4::Context->dbh;
81 my $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblionumber);
82 my $marcflavour = C4::Context->preference("marcflavour");
83 my $marcnotesarray = &getMARCnotes($dbh,$bibid,$marcflavour);
84 $results[0]->{MARCNOTES} = $marcnotesarray;
85 my $marcsubjctsarray = &getMARCsubjects($dbh,$bibid,$marcflavour);
86 $results[0]->{MARCSUBJCTS} = $marcsubjctsarray;
87 # $template->param(MARCNOTES => $marcnotesarray);
88 # $template->param(MARCSUBJCTS => $marcsubjctsarray);
91 my @results = ($dat,);
98 my $resultsarray=\@results;
99 my $itemsarray=\@items;
100 my $webarray=\@webbiblioitems;
101 my $sitearray=\@websites;
102 my $titlewords=\@title;
103 my $authorwords=\@author;
106 #coping with subscriptions
107 my $subscriptionsnumber = getsubscriptionfrombiblionumber($biblionumber);
108 my @subscriptions = getsubscriptions($dat->{title},$dat->{issn},$biblionumber);
110 foreach my $subscription (@subscriptions){
111 warn "subsid :".$subscription->{subscriptionid};
113 $cell{subscriptionid}= $subscription->{subscriptionid};
114 $cell{subscriptionnotes}= $subscription->{notes};
115 #get the three latest serials.
116 $cell{latestserials}=getlatestserials($subscription->{subscriptionid},3);
120 $template->param(BIBLIO_RESULTS => $resultsarray,
121 ITEM_RESULTS => $itemsarray,
122 WEB_RESULTS => $webarray,
123 SITE_RESULTS => $sitearray,
124 subscriptionsnumber => $subscriptionsnumber,
125 LibraryName => C4::Context->preference("LibraryName"),
126 suggestion => C4::Context->preference("suggestion"),
127 virtualshelves => C4::Context->preference("virtualshelves"),
128 titlewords => $titlewords,
129 authorwords => $authorwords,
133 my $isbn=$dat->{'isbn'};
134 my $amazon_details = &get_amazon_details($isbn);
135 foreach my $result (@{$amazon_details->{Details}}){
136 $template->param(item_description => $result->{ProductDescription});
137 $template->param(image => $result->{ImageUrlMedium});
138 $template->param(list_price => $result->{ListPrice});
139 $template->param(amazon_url => $result->{url});
144 for my $details( @{ $amazon_details->{ Details } } ) {
145 next unless $details->{ SimilarProducts };
146 for my $product ( @{ $details->{ SimilarProducts }->{ Product } } ) {
147 push @products, +{ Product => $product };
149 next unless $details->{ Reviews };
150 for my $product ( @{ $details->{ Reviews }->{ AvgCustomerRating } } ) {
151 $template->param(rating => $product);
153 for my $reviews ( @{ $details->{ Reviews }->{ CustomerReview } } ) {
154 push @reviews, +{ Summary => $reviews->{ Summary }, Comment => $reviews->{ Comment }, };
157 $template->param( SIMILAR_PRODUCTS => \@products );
158 $template->param( REVIEWS => \@reviews );
159 ## End of Amazon Stuff
161 output_html_with_http_headers $query, $cookie, $template->output;