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);
36 $dat->{'count'}=@items;
38 if ($dat->{'author'}){
40 $authorpush{author}=$dat->{'author'};
41 push @author, \%authorpush
43 $dat->{'additional'}=$addauthor->[0]->{'author'};
44 if ($dat->{'additional'}){
46 $authorpush{author} =$addauthor->[0]->{'author'};
47 push @author, \%authorpush
50 foreach my $word (split(" ", $dat->{'title'})){
51 unless (length($word) == 4){
54 unless (C4::Context->stopwords->{uc($word)} or length($word)==1) {
56 $titlepush{title} =$word;
57 push @title, \%titlepush;
58 }#it's NOT a stopword => use it. Otherwise, ignore
61 for (my $i = 1; $i < $authorcount; $i++) {
62 $dat->{'additional'} .= " ; " . $addauthor->[$i]->{'author'};
65 $authorpush{author}=$addauthor->[$i]->{'author'};
66 push @author, \%authorpush
70 foreach my $itm (@items) {
71 $norequests = 0 unless (($itm->{'wthdrawn'}) || ($itm->{'itemlost'}) || ($itm->{'notforloan'}) || ($itm->{'itemnotforloan'}) || (!$itm->{'itemnumber'}));
72 $itm->{$itm->{'publictype'}} = 1;
75 $template->param(norequests => $norequests);
77 ## get notes and subjects from MARC record
78 my $marc = C4::Context->preference("marc");
79 my @results = ($dat,);
80 if (C4::Boolean::true_p($marc)) {
81 my $dbh = C4::Context->dbh;
82 my $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblionumber);
83 my $marcflavour = C4::Context->preference("marcflavour");
84 my $marcnotesarray = &getMARCnotes($dbh,$bibid,$marcflavour);
85 $results[0]->{MARCNOTES} = $marcnotesarray;
86 my $marcsubjctsarray = &getMARCsubjects($dbh,$bibid,$marcflavour);
87 $results[0]->{MARCSUBJCTS} = $marcsubjctsarray;
88 # $template->param(MARCNOTES => $marcnotesarray);
89 # $template->param(MARCSUBJCTS => $marcsubjctsarray);
92 # get the number of reviews
93 my $reviewcount=numberofreviews($biblionumber);
94 $dat->{'reviews'}=$reviewcount;
96 my @results = ($dat,);
97 my $resultsarray=\@results;
98 my $itemsarray=\@items;
99 my $webarray=\@webbiblioitems;
100 my $sitearray=\@websites;
101 my $titlewords=\@title;
102 my $authorwords=\@author;
105 #coping with subscriptions
106 my $subscriptionsnumber = getsubscriptionfrombiblionumber($biblionumber);
107 my @subscriptions = getsubscriptions($dat->{title},$dat->{issn},$biblionumber);
109 foreach my $subscription (@subscriptions){
110 warn "subsid :".$subscription->{subscriptionid};
112 $cell{subscriptionid}= $subscription->{subscriptionid};
113 $cell{subscriptionnotes}= $subscription->{notes};
114 #get the three latest serials.
115 $cell{latestserials}=getlatestserials($subscription->{subscriptionid},3);
119 $template->param(BIBLIO_RESULTS => $resultsarray,
120 ITEM_RESULTS => $itemsarray,
121 WEB_RESULTS => $webarray,
122 SITE_RESULTS => $sitearray,
123 subscriptionsnumber => $subscriptionsnumber,
124 LibraryName => C4::Context->preference("LibraryName"),
125 suggestion => C4::Context->preference("suggestion"),
126 virtualshelves => C4::Context->preference("virtualshelves"),
127 titlewords => $titlewords,
128 authorwords => $authorwords,
132 my $isbn=$dat->{'isbn'};
133 my $amazon_details = &get_amazon_details($isbn);
134 foreach my $result (@{$amazon_details->{Details}}){
135 $template->param(item_description => $result->{ProductDescription});
136 $template->param(image => $result->{ImageUrlMedium});
137 $template->param(list_price => $result->{ListPrice});
138 $template->param(amazon_url => $result->{url});
143 for my $details( @{ $amazon_details->{ Details } } ) {
144 next unless $details->{ SimilarProducts };
145 for my $product ( @{ $details->{ SimilarProducts }->{ Product } } ) {
146 push @products, +{ Product => $product };
148 next unless $details->{ Reviews };
149 for my $product ( @{ $details->{ Reviews }->{ AvgCustomerRating } } ) {
150 $template->param(rating => $product);
152 for my $reviews ( @{ $details->{ Reviews }->{ CustomerReview } } ) {
153 push @reviews, +{ Summary => $reviews->{ Summary }, Comment => $reviews->{ Comment }, };
156 $template->param( SIMILAR_PRODUCTS => \@products );
157 $template->param( REVIEWS => \@reviews );
158 ## End of Amazon Stuff
160 output_html_with_http_headers $query, $cookie, $template->output;