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
46 use C4::Branch; # GetBranchDetail
47 use C4::Serials; # CountSubscriptionFromBiblionumber
50 #---- Internal function
54 my $dbh = C4::Context->dbh;
56 my $biblionumber = $query->param('biblionumber');
57 my $itemtype = &GetFrameworkCode($biblionumber);
58 my $tagslib = &GetMarcStructure( 1, $itemtype );
60 my $record = GetMarcBiblio($biblionumber);
63 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
65 template_name => "catalogue/ISBDdetail.tmpl",
69 flagsrequired => { catalogue => 1 },
73 my $ISBD = C4::Context->preference('ISBD');
75 # my @blocs = split /\@/,$ISBD;
76 # my @fields = $record->fields();
79 # foreach my $bloc (@blocs) {
84 my ($holdingbrtagf,$holdingbrtagsubf) = &GetMarcFromKohaField("items.holdingbranch",$itemtype);
85 # @big_array = sort {$a->{$holdingbrtagsubf} cmp $b->{$holdingbrtagsubf}} @big_array;
87 foreach my $isbdfield ( split /#/, $bloc ) {
89 $isbdfield =~ /(\d\d\d)([^\|])?\|(.*)\|(.*)\|(.*)/;
93 my $analysestring = $4;
96 # warn "==> $1 / $2 / $3 / $4";
97 # my $fieldvalue=substr($isbdfield,0,3);
98 if ( $fieldvalue > 0 ) {
99 my $hasputtextbefore = 0;
100 my @fieldslist = $record->field($fieldvalue);
101 @fieldslist = sort {$a->subfield($holdingbrtagsubf) cmp $b->subfield($holdingbrtagsubf)} @fieldslist if ($fieldvalue eq $holdingbrtagf);
103 # warn "ERROR IN ISBD DEFINITION at : $isbdfield" unless $fieldvalue;
104 # warn "FV : $fieldvalue";
105 if ($subfvalue ne ""){
106 foreach my $field ( @fieldslist ) {
107 foreach my $subfield ($field->subfield($subfvalue)){
108 warn $fieldvalue."$subfvalue";
109 my $calculated = $analysestring;
110 my $tag = $field->tag();
115 GetAuthorisedValueDesc( $tag, $subfvalue,
116 $subfield, '', $tagslib );
117 my $tagsubf = $tag . $subfvalue;
119 s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g;
120 # $calculated =~s#/cgi-bin/koha/[^/]+/([^.]*.pl\?.*)$#opac-$1#g;
122 # field builded, store the result
123 if ( $calculated && !$hasputtextbefore )
124 { # put textbefore if not done
125 $blocres .= $textbefore;
126 $hasputtextbefore = 1;
129 # remove punctuation at start
130 $calculated =~ s/^( |;|:|\.|-)*//g;
131 $blocres .= $calculated;
136 $blocres .= $textafter if $hasputtextbefore;
138 foreach my $field ( @fieldslist ) {
139 my $calculated = $analysestring;
140 my $tag = $field->tag();
144 my @subf = $field->subfields;
145 for my $i ( 0 .. $#subf ) {
146 my $subfieldcode = $subf[$i][0];
148 GetAuthorisedValueDesc( $tag, $subf[$i][0],
149 $subf[$i][1], '', $tagslib );
150 my $tagsubf = $tag . $subfieldcode;
152 s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g;
153 # $calculated =~s#/cgi-bin/koha/[^/]+/([^.]*.pl\?.*)$#opac-$1#g;
156 # field builded, store the result
157 if ( $calculated && !$hasputtextbefore )
158 { # put textbefore if not done
159 $blocres .= $textbefore;
160 $hasputtextbefore = 1;
163 # remove punctuation at start
164 $calculated =~ s/^( |;|:|\.|-)*//g;
165 $blocres .= $calculated;
168 $blocres .= $textafter if $hasputtextbefore;
172 $blocres .= $isbdfield;
178 $res =~ s/\{(.*?)\}//g;
180 $res =~ s/\n/<br\/>/g;
184 # count of item linked with biblio
185 my $itemcount = GetItemsCount($biblionumber);
186 $template->param( count => $itemcount);
187 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
189 if ($subscriptionsnumber) {
190 my $subscriptions = GetSubscriptionsFromBiblionumber($biblionumber);
191 my $subscriptiontitle = $subscriptions->[0]{'bibliotitle'};
193 subscriptionsnumber => $subscriptionsnumber,
194 subscriptiontitle => $subscriptiontitle,
200 biblionumber => $biblionumber,
204 output_html_with_http_headers $query, $cookie, $template->output;