3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
24 opac-ISBDdetail.pl : script to show a biblio in ISBD format
29 This script needs a biblionumber as parameter
33 The template is in <templates_dir>/catalogue/ISBDdetail.tmpl.
34 this template must be divided into 11 "tabs".
36 The first 10 tabs present the biblio, the 11th one presents
37 the items attached to the biblio
50 use C4::Interface::CGI::Output;
56 use C4::Serials; # uses getsubscriptionfrom biblionumber
57 use C4::Koha; # use getitemtypeinfo
58 use C4::Members; # GetMember
62 my $dbh = C4::Context->dbh;
64 my $biblionumber = $query->param('biblionumber');
65 my $itemtype = &MARCfind_frameworkcode($biblionumber);
66 my $tagslib = &MARCgettagslib( $dbh, 1, $itemtype );
68 my $record = GetMarcBiblio($biblionumber);
70 #coping with subscriptions
71 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
72 my $dat = MARCmarc2koha( $dbh, $record );
74 GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
76 foreach my $subscription (@subscriptions) {
78 $cell{subscriptionid} = $subscription->{subscriptionid};
79 $cell{subscriptionnotes} = $subscription->{notes};
81 #get the three latest serials.
82 $cell{latestserials} =
83 GetLatestSerials( $subscription->{subscriptionid}, 3 );
88 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
90 template_name => "opac-ISBDdetail.tmpl",
98 subscriptions => \@subs,
99 subscriptionsnumber => $subscriptionsnumber,
102 my $ISBD = C4::Context->preference('ISBD');
104 # my @blocs = split /\@/,$ISBD;
105 # my @fields = $record->fields();
108 # foreach my $bloc (@blocs) {
112 foreach my $isbdfield ( split /#/, $bloc ) {
114 # $isbdfield= /(.?.?.?)/;
115 $isbdfield =~ /(\d\d\d)\|(.*)\|(.*)\|(.*)/;
118 my $analysestring = $3;
121 # warn "==> $1 / $2 / $3 / $4";
122 # my $fieldvalue=substr($isbdfield,0,3);
123 if ( $fieldvalue > 0 ) {
125 # warn "ERROR IN ISBD DEFINITION at : $isbdfield" unless $fieldvalue;
126 # warn "FV : $fieldvalue";
127 my $hasputtextbefore = 0;
128 foreach my $field ( $record->field($fieldvalue) ) {
129 my $calculated = $analysestring;
130 my $tag = $field->tag();
134 my @subf = $field->subfields;
135 for my $i ( 0 .. $#subf ) {
136 my $subfieldcode = $subf[$i][0];
138 GetAuthorisedValueDesc( $tag, $subf[$i][0],
139 $subf[$i][1], '', $tagslib );
140 my $tagsubf = $tag . $subfieldcode;
142 s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g;
145 # field builded, store the result
146 if ( $calculated && !$hasputtextbefore )
147 { # put textbefore if not done
148 $blocres .= $textbefore;
149 $hasputtextbefore = 1;
152 # remove punctuation at start
153 $calculated =~ s/^( |;|:|\.|-)*//g;
154 $blocres .= $calculated;
157 $blocres .= $textafter if $hasputtextbefore;
160 $blocres .= $isbdfield;
166 $res =~ s/\{(.*?)\}//g;
168 $res =~ s/\n/<br\/>/g;
173 my $reviews = getreviews( $biblionumber, 1 );
174 foreach ( @$reviews ) {
175 my $borrower_number_review = $_->{borrowernumber};
176 my $borrowerData = GetMember('',$borrower_number_review);
177 # setting some borrower info into this hash
178 $_->{title} = $borrowerData->{'title'};
179 $_->{surname} = $borrowerData->{'surname'};
180 $_->{firstname} = $borrowerData->{'firstname'};
186 biblionumber => $biblionumber,
191 #not used unless preference set
192 if ( C4::Context->preference("AmazonContent") == 1 ) {
194 $dat->{'amazonisbn'} = $dat->{'isbn'};
195 $dat->{'amazonisbn'} =~ s|-||g;
197 $template->param( amazonisbn => $dat->{amazonisbn} );
199 my $amazon_details = &get_amazon_details( $dat->{amazonisbn} );
201 foreach my $result ( @{ $amazon_details->{Details} } ) {
202 $template->param( item_description => $result->{ProductDescription} );
203 $template->param( image => $result->{ImageUrlMedium} );
204 $template->param( list_price => $result->{ListPrice} );
205 $template->param( amazon_url => $result->{url} );
210 for my $details ( @{ $amazon_details->{Details} } ) {
211 next unless $details->{SimilarProducts};
212 for my $product ( @{ $details->{SimilarProducts}->{Product} } ) {
213 push @products, +{ Product => $product };
215 next unless $details->{Reviews};
216 for my $product ( @{ $details->{Reviews}->{AvgCustomerRating} } ) {
217 $template->param( rating => $product * 20 );
219 for my $reviews ( @{ $details->{Reviews}->{CustomerReview} } ) {
222 Summary => $reviews->{Summary},
223 Comment => $reviews->{Comment},
227 $template->param( SIMILAR_PRODUCTS => \@products );
228 $template->param( AMAZONREVIEWS => \@reviews );
231 output_html_with_http_headers $query, $cookie, $template->output;