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
23 opac-ISBDdetail.pl : script to show a biblio in ISBD format
28 This script needs a biblionumber as parameter
32 The template is in <templates_dir>/catalogue/ISBDdetail.tmpl.
33 this template must be divided into 11 "tabs".
35 The first 10 tabs present the biblio, the 11th one presents
36 the items attached to the biblio
54 use C4
::Serials
; # uses getsubscriptionfrom biblionumber
55 use C4
::Koha
; # use getitemtypeinfo
56 use C4
::Members
; # GetMember
60 my $dbh = C4
::Context
->dbh;
62 my $biblionumber = $query->param('biblionumber');
63 my $itemtype = &GetFrameworkCode
($biblionumber);
64 my $tagslib = &GetMarcStructure
( 1, $itemtype );
66 my $record = GetMarcBiblio
($biblionumber);
68 #coping with subscriptions
69 my $subscriptionsnumber = CountSubscriptionFromBiblionumber
($biblionumber);
70 my $dat = TransformMarcToKoha
( $dbh, $record );
72 GetSubscriptions
( $dat->{title
}, $dat->{issn
}, $biblionumber );
74 foreach my $subscription (@subscriptions) {
76 $cell{subscriptionid
} = $subscription->{subscriptionid
};
77 $cell{subscriptionnotes
} = $subscription->{notes
};
78 $cell{branchcode
} = $subscription->{branchcode
};
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 my ($holdingbrtagf,$holdingbrtagsubf) = &GetMarcFromKohaField
("items.holdingbranch",$itemtype);
113 foreach my $isbdfield ( split /#/, $bloc ) {
115 # $isbdfield= /(.?.?.?)/;
116 $isbdfield =~ /(\d\d\d)([^\|])?\|(.*)\|(.*)\|(.*)/;
120 my $analysestring = $4;
123 # warn "==> $1 / $2 / $3 / $4";
124 # my $fieldvalue=substr($isbdfield,0,3);
125 if ( $fieldvalue > 0 ) {
126 my $hasputtextbefore = 0;
127 my @fieldslist = $record->field($fieldvalue);
128 @fieldslist = sort {$a->subfield($holdingbrtagsubf) cmp $b->subfield($holdingbrtagsubf)} @fieldslist if ($fieldvalue eq $holdingbrtagf);
130 # warn "ERROR IN ISBD DEFINITION at : $isbdfield" unless $fieldvalue;
131 # warn "FV : $fieldvalue";
132 if ($subfvalue ne ""){
133 foreach my $field ( @fieldslist ) {
134 foreach my $subfield ($field->subfield($subfvalue)){
135 warn $fieldvalue."$subfvalue";
136 my $calculated = $analysestring;
137 my $tag = $field->tag();
142 GetAuthorisedValueDesc
( $tag, $subfvalue,
143 $subfield, '', $tagslib );
144 my $tagsubf = $tag . $subfvalue;
146 s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g;
147 $calculated =~s
#/cgi-bin/koha/[^/]+/([^.]*.pl\?.*)$#opac-$1#g;
149 # field builded, store the result
150 if ( $calculated && !$hasputtextbefore )
151 { # put textbefore if not done
152 $blocres .= $textbefore;
153 $hasputtextbefore = 1;
156 # remove punctuation at start
157 $calculated =~ s/^( |;|:|\.|-)*//g;
158 $blocres .= $calculated;
163 $blocres .= $textafter if $hasputtextbefore;
165 foreach my $field ( @fieldslist ) {
166 my $calculated = $analysestring;
167 my $tag = $field->tag();
171 my @subf = $field->subfields;
172 for my $i ( 0 .. $#subf ) {
173 my $subfieldcode = $subf[$i][0];
175 GetAuthorisedValueDesc
( $tag, $subf[$i][0],
176 $subf[$i][1], '', $tagslib );
177 my $tagsubf = $tag . $subfieldcode;
179 s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g;
180 $calculated =~s
#/cgi-bin/koha/[^/]+/([^.]*.pl\?.*)$#opac-$1#g;
183 # field builded, store the result
184 if ( $calculated && !$hasputtextbefore )
185 { # put textbefore if not done
186 $blocres .= $textbefore;
187 $hasputtextbefore = 1;
190 # remove punctuation at start
191 $calculated =~ s/^( |;|:|\.|-)*//g;
192 $blocres .= $calculated;
195 $blocres .= $textafter if $hasputtextbefore;
199 $blocres .= $isbdfield;
205 $res =~ s/\{(.*?)\}//g;
207 $res =~ s/\n/<br\/>/g
;
212 my $reviews = getreviews
( $biblionumber, 1 );
213 foreach ( @
$reviews ) {
214 my $borrower_number_review = $_->{borrowernumber
};
215 my $borrowerData = GetMember
($borrower_number_review,'borrowernumber');
216 # setting some borrower info into this hash
217 $_->{title
} = $borrowerData->{'title'};
218 $_->{surname
} = $borrowerData->{'surname'};
219 $_->{firstname
} = $borrowerData->{'firstname'};
225 biblionumber
=> $biblionumber,
230 #not used unless preference set
231 if ( C4
::Context
->preference("AmazonContent") == 1 ) {
233 $dat->{'amazonisbn'} = $dat->{'isbn'};
234 $dat->{'amazonisbn'} =~ s
|-||g
;
236 $template->param( amazonisbn
=> $dat->{amazonisbn
} );
238 my $amazon_details = &get_amazon_details
( $dat->{amazonisbn
} );
240 foreach my $result ( @
{ $amazon_details->{Details
} } ) {
241 $template->param( item_description
=> $result->{ProductDescription
} );
242 $template->param( image
=> $result->{ImageUrlMedium
} );
243 $template->param( list_price
=> $result->{ListPrice
} );
244 $template->param( amazon_url
=> $result->{url
} );
249 for my $details ( @
{ $amazon_details->{Details
} } ) {
250 next unless $details->{SimilarProducts
};
251 for my $product ( @
{ $details->{SimilarProducts
}->{Product
} } ) {
252 push @products, +{ Product
=> $product };
254 next unless $details->{Reviews
};
255 for my $product ( @
{ $details->{Reviews
}->{AvgCustomerRating
} } ) {
256 $template->param( rating
=> $product * 20 );
258 for my $reviews ( @
{ $details->{Reviews
}->{CustomerReview
} } ) {
261 Summary
=> $reviews->{Summary
},
262 Comment
=> $reviews->{Comment
},
266 $template->param( SIMILAR_PRODUCTS
=> \
@products );
267 $template->param( AMAZONREVIEWS
=> \
@reviews );
270 output_html_with_http_headers
$query, $cookie, $template->output;