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
22 ISBDdetail.pl : script to show a biblio in ISBD format
29 This script needs a biblionumber as parameter
45 use C4::Branch; # GetBranchDetail
46 use C4::Serials; # CountSubscriptionFromBiblionumber
49 #---- Internal function
51 sub get_authorised_value_desc ($$$$$$$) {
52 my ( $itemtype, $tagslib, $tag, $subfield, $value, $framework, $dbh ) = @_;
55 if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
56 return GetBranchDetail($value)->{branchname};
60 if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
61 my $itemtypedef = getitemtypeinfo($itemtype);
62 return $itemtypedef->{description};
65 #---- "true" authorized value
66 my $category = $tagslib->{$tag}->{$subfield}->{'authorised_value'};
68 if ( $category ne "" ) {
71 "select lib from authorised_values where category = ? and authorised_value = ?"
73 $sth->execute( $category, $value );
74 my $data = $sth->fetchrow_hashref;
75 return $data->{'lib'};
78 return $value; # if nothing is found return the original value
85 my $dbh = C4::Context->dbh;
87 my $biblionumber = $query->param('biblionumber');
88 my $itemtype = &GetFrameworkCode($biblionumber);
89 my $tagslib = &GetMarcStructure( 1, $itemtype );
91 my $record = GetMarcBiblio($biblionumber);
94 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
96 template_name => "catalogue/ISBDdetail.tmpl",
103 my $ISBD = C4::Context->preference('ISBD');
105 # my @blocs = split /\@/,$ISBD;
106 # my @fields = $record->fields();
109 # foreach my $bloc (@blocs) {
113 foreach my $isbdfield ( split /#/, $bloc ) {
115 # $isbdfield= /(.?.?.?)/;
116 $isbdfield =~ /(\d\d\d)\|(.*)\|(.*)\|(.*)/;
119 my $analysestring = $3;
122 # warn "==> $1 / $2 / $3 / $4";
123 # my $fieldvalue=substr($isbdfield,0,3);
124 if ( $fieldvalue > 0 ) {
126 # warn "ERROR IN ISBD DEFINITION at : $isbdfield" unless $fieldvalue;
127 # warn "FV : $fieldvalue";
128 my $hasputtextbefore = 0;
129 foreach my $field ( $record->field($fieldvalue) ) {
130 my $calculated = $analysestring;
131 my $tag = $field->tag();
135 my @subf = $field->subfields;
136 for my $i ( 0 .. $#subf ) {
137 my $subfieldcode = $subf[$i][0];
139 get_authorised_value_desc( $itemtype,$tagslib, $tag, $subf[$i][0],
140 $subf[$i][1], '', $dbh );
141 my $tagsubf = $tag . $subfieldcode;
143 s/\{(.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue\{$1$tagsubf$2\}$2/g;
146 # field builded, store the result
147 if ( $calculated && !$hasputtextbefore )
148 { # put textbefore if not done
149 $blocres .= $textbefore;
150 $hasputtextbefore = 1;
153 # remove punctuation at start
154 $calculated =~ s/^( |;|:|\.|-)*//g;
155 $blocres .= $calculated;
158 $blocres .= $textafter if $hasputtextbefore;
161 $blocres .= $isbdfield;
167 $res =~ s/\{(.*?)\}//g;
169 $res =~ s/\n/<br\/>/g;
174 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
176 if ($subscriptionsnumber) {
177 my $subscriptions = GetSubscriptionsFromBiblionumber($biblionumber);
178 my $subscriptiontitle = $subscriptions->[0]{'bibliotitle'};
180 subscriptionsnumber => $subscriptionsnumber,
181 subscriptiontitle => $subscriptiontitle,
187 biblionumber => $biblionumber,
190 output_html_with_http_headers $query, $cookie, $template->output;