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
55 use C4::Serials; # uses getsubscriptionfrom biblionumber
56 use C4::Koha; # use getitemtypeinfo
57 use C4::Members; # GetMember
61 my $dbh = C4::Context->dbh;
63 my $biblionumber = $query->param('biblionumber');
64 my $itemtype = &GetFrameworkCode($biblionumber);
65 my $tagslib = &GetMarcStructure( 1, $itemtype );
67 my $record = GetMarcBiblio($biblionumber);
69 #coping with subscriptions
70 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
71 my $dat = TransformMarcToKoha( $dbh, $record );
73 GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
75 foreach my $subscription (@subscriptions) {
77 $cell{subscriptionid} = $subscription->{subscriptionid};
78 $cell{subscriptionnotes} = $subscription->{notes};
80 #get the three latest serials.
81 $cell{latestserials} =
82 GetLatestSerials( $subscription->{subscriptionid}, 3 );
87 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
89 template_name => "opac-ISBDdetail.tmpl",
97 subscriptions => \@subs,
98 subscriptionsnumber => $subscriptionsnumber,
101 my $ISBD = C4::Context->preference('ISBD');
103 # my @blocs = split /\@/,$ISBD;
104 # my @fields = $record->fields();
107 # foreach my $bloc (@blocs) {
111 foreach my $isbdfield ( split /#/, $bloc ) {
113 # $isbdfield= /(.?.?.?)/;
114 $isbdfield =~ /(\d\d\d)\|(.*)\|(.*)\|(.*)/;
117 my $analysestring = $3;
120 # warn "==> $1 / $2 / $3 / $4";
121 # my $fieldvalue=substr($isbdfield,0,3);
122 if ( $fieldvalue > 0 ) {
124 # warn "ERROR IN ISBD DEFINITION at : $isbdfield" unless $fieldvalue;
125 # warn "FV : $fieldvalue";
126 my $hasputtextbefore = 0;
127 foreach my $field ( $record->field($fieldvalue) ) {
128 my $calculated = $analysestring;
129 my $tag = $field->tag();
133 my @subf = $field->subfields;
134 for my $i ( 0 .. $#subf ) {
135 my $subfieldcode = $subf[$i][0];
137 GetAuthorisedValueDesc( $tag, $subf[$i][0],
138 $subf[$i][1], '', $tagslib );
139 my $tagsubf = $tag . $subfieldcode;
141 s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g;
144 # field builded, store the result
145 if ( $calculated && !$hasputtextbefore )
146 { # put textbefore if not done
147 $blocres .= $textbefore;
148 $hasputtextbefore = 1;
151 # remove punctuation at start
152 $calculated =~ s/^( |;|:|\.|-)*//g;
153 $blocres .= $calculated;
156 $blocres .= $textafter if $hasputtextbefore;
159 $blocres .= $isbdfield;
165 $res =~ s/\{(.*?)\}//g;
167 $res =~ s/\n/<br\/>/g;
172 my $reviews = getreviews( $biblionumber, 1 );
173 foreach ( @$reviews ) {
174 my $borrower_number_review = $_->{borrowernumber};
175 my $borrowerData = GetMember($borrower_number_review,'borrowernumber');
176 # setting some borrower info into this hash
177 $_->{title} = $borrowerData->{'title'};
178 $_->{surname} = $borrowerData->{'surname'};
179 $_->{firstname} = $borrowerData->{'firstname'};
185 biblionumber => $biblionumber,
190 #not used unless preference set
191 if ( C4::Context->preference("AmazonContent") == 1 ) {
193 $dat->{'amazonisbn'} = $dat->{'isbn'};
194 $dat->{'amazonisbn'} =~ s|-||g;
196 $template->param( amazonisbn => $dat->{amazonisbn} );
198 my $amazon_details = &get_amazon_details( $dat->{amazonisbn} );
200 foreach my $result ( @{ $amazon_details->{Details} } ) {
201 $template->param( item_description => $result->{ProductDescription} );
202 $template->param( image => $result->{ImageUrlMedium} );
203 $template->param( list_price => $result->{ListPrice} );
204 $template->param( amazon_url => $result->{url} );
209 for my $details ( @{ $amazon_details->{Details} } ) {
210 next unless $details->{SimilarProducts};
211 for my $product ( @{ $details->{SimilarProducts}->{Product} } ) {
212 push @products, +{ Product => $product };
214 next unless $details->{Reviews};
215 for my $product ( @{ $details->{Reviews}->{AvgCustomerRating} } ) {
216 $template->param( rating => $product * 20 );
218 for my $reviews ( @{ $details->{Reviews}->{CustomerReview} } ) {
221 Summary => $reviews->{Summary},
222 Comment => $reviews->{Comment},
226 $template->param( SIMILAR_PRODUCTS => \@products );
227 $template->param( AMAZONREVIEWS => \@reviews );
230 output_html_with_http_headers $query, $cookie, $template->output;