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",
100 flagsrequired => { catalogue => 1 },
104 my $ISBD = C4::Context->preference('ISBD');
106 # my @blocs = split /\@/,$ISBD;
107 # my @fields = $record->fields();
110 # foreach my $bloc (@blocs) {
114 foreach my $isbdfield ( split /#/, $bloc ) {
116 # $isbdfield= /(.?.?.?)/;
117 $isbdfield =~ /(\d\d\d)\|(.*)\|(.*)\|(.*)/;
120 my $analysestring = $3;
123 # warn "==> $1 / $2 / $3 / $4";
124 # my $fieldvalue=substr($isbdfield,0,3);
125 if ( $fieldvalue > 0 ) {
127 # warn "ERROR IN ISBD DEFINITION at : $isbdfield" unless $fieldvalue;
128 # warn "FV : $fieldvalue";
129 my $hasputtextbefore = 0;
130 foreach my $field ( $record->field($fieldvalue) ) {
131 my $calculated = $analysestring;
132 my $tag = $field->tag();
136 my @subf = $field->subfields;
137 for my $i ( 0 .. $#subf ) {
138 my $subfieldcode = $subf[$i][0];
140 get_authorised_value_desc( $itemtype,$tagslib, $tag, $subf[$i][0],
141 $subf[$i][1], '', $dbh );
142 my $tagsubf = $tag . $subfieldcode;
144 s/\{(.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue\{$1$tagsubf$2\}$2/g;
147 # field builded, store the result
148 if ( $calculated && !$hasputtextbefore )
149 { # put textbefore if not done
150 $blocres .= $textbefore;
151 $hasputtextbefore = 1;
154 # remove punctuation at start
155 $calculated =~ s/^( |;|:|\.|-)*//g;
156 $blocres .= $calculated;
159 $blocres .= $textafter if $hasputtextbefore;
162 $blocres .= $isbdfield;
168 $res =~ s/\{(.*?)\}//g;
170 $res =~ s/\n/<br\/>/g;
174 # count of item linked with biblio
175 my $itemcount = GetItemsCount($biblionumber);
176 $template->param( count => $itemcount);
177 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
179 if ($subscriptionsnumber) {
180 my $subscriptions = GetSubscriptionsFromBiblionumber($biblionumber);
181 my $subscriptiontitle = $subscriptions->[0]{'bibliotitle'};
183 subscriptionsnumber => $subscriptionsnumber,
184 subscriptiontitle => $subscriptiontitle,
190 biblionumber => $biblionumber,
193 output_html_with_http_headers $query, $cookie, $template->output;