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
42 use C4::Interface::CGI::Output;
46 use C4::Branch; # GetBranchDetail
47 use C4::Serials; # CountSubscriptionFromBiblionumber
50 #---- Internal function
52 sub get_authorised_value_desc ($$$$$$$) {
53 my ( $itemtype, $tagslib, $tag, $subfield, $value, $framework, $dbh ) = @_;
56 if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
57 return GetBranchDetail($value)->{branchname};
61 if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
62 my $itemtypedef = getitemtypeinfo($itemtype);
63 return $itemtypedef->{description};
66 #---- "true" authorized value
67 my $category = $tagslib->{$tag}->{$subfield}->{'authorised_value'};
69 if ( $category ne "" ) {
72 "select lib from authorised_values where category = ? and authorised_value = ?"
74 $sth->execute( $category, $value );
75 my $data = $sth->fetchrow_hashref;
76 return $data->{'lib'};
79 return $value; # if nothing is found return the original value
86 my $dbh = C4::Context->dbh;
88 my $biblionumber = $query->param('biblionumber');
89 my $itemtype = &MARCfind_frameworkcode($biblionumber);
90 my $tagslib = &MARCgettagslib( $dbh, 1, $itemtype );
92 my $record = GetMarcBiblio($biblionumber);
95 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
97 template_name => "catalogue/ISBDdetail.tmpl",
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;
175 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
177 if ($subscriptionsnumber) {
178 my $subscriptions = GetSubscriptionsFromBiblionumber($biblionumber);
179 my $subscriptiontitle = $subscriptions->[0]{'bibliotitle'};
181 subscriptionsnumber => $subscriptionsnumber,
182 subscriptiontitle => $subscriptiontitle,
188 biblionumber => $biblionumber,
191 output_html_with_http_headers $query, $cookie, $template->output;