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
53 my $dbh = C4::Context->dbh;
55 my $biblionumber = $query->param('biblionumber');
56 my $itemtype = &GetFrameworkCode($biblionumber);
57 my $tagslib = &GetMarcStructure( 1, $itemtype );
59 my $record = GetMarcBiblio($biblionumber);
62 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
64 template_name => "catalogue/ISBDdetail.tmpl",
68 flagsrequired => { catalogue => 1 },
72 my $ISBD = C4::Context->preference('ISBD');
74 # my @blocs = split /\@/,$ISBD;
75 # my @fields = $record->fields();
78 # foreach my $bloc (@blocs) {
83 my ($holdingbrtagf,$holdingbrtagsubf) = &GetMarcFromKohaField("items.holdingbranch",$itemtype);
84 # @big_array = sort {$a->{$holdingbrtagsubf} cmp $b->{$holdingbrtagsubf}} @big_array;
86 foreach my $isbdfield ( split /#/, $bloc ) {
88 # $isbdfield= /(.?.?.?)/;
89 $isbdfield =~ /(\d\d\d)\|(.*)\|(.*)\|(.*)/;
92 my $analysestring = $3;
95 # warn "==> $1 / $2 / $3 / $4";
96 # my $fieldvalue=substr($isbdfield,0,3);
97 if ( $fieldvalue > 0 ) {
99 # warn "ERROR IN ISBD DEFINITION at : $isbdfield" unless $fieldvalue;
100 # warn "FV : $fieldvalue";
101 my $hasputtextbefore = 0;
102 my @fieldslist = $record->field($fieldvalue);
103 @fieldslist= sort {$a->subfield($holdingbrtagsubf) cmp $b->subfield($holdingbrtagsubf)} @fieldslist if ($fieldvalue eq $holdingbrtagf);
104 foreach my $field ( @fieldslist ) {
105 my $calculated = $analysestring;
106 my $tag = $field->tag();
110 my @subf = $field->subfields;
111 for my $i ( 0 .. $#subf ) {
112 my $subfieldcode = $subf[$i][0];
114 GetAuthorisedValueDesc( $tag, $subf[$i][0],
115 $subf[$i][1], $itemtype,$tagslib);
116 my $tagsubf = $tag . $subfieldcode;
117 $calculated =~s/\{(.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g;
119 # field builded, store the result
120 if ( $calculated && !$hasputtextbefore )
121 { # put textbefore if not done
122 $blocres .= $textbefore;
123 $hasputtextbefore = 1;
126 # remove punctuation at start
127 $calculated =~ s/^( |;|:|\.|-)*//g;
128 $blocres .= $calculated;
131 $blocres .= $textafter if $hasputtextbefore;
134 $blocres .= $isbdfield;
140 $res =~ s/\{(.*?)\}//g;
142 $res =~ s/\n/<br\/>/g;
146 # count of item linked with biblio
147 my $itemcount = GetItemsCount($biblionumber);
148 $template->param( count => $itemcount);
149 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
151 if ($subscriptionsnumber) {
152 my $subscriptions = GetSubscriptionsFromBiblionumber($biblionumber);
153 my $subscriptiontitle = $subscriptions->[0]{'bibliotitle'};
155 subscriptionsnumber => $subscriptionsnumber,
156 subscriptiontitle => $subscriptiontitle,
162 biblionumber => $biblionumber,
165 output_html_with_http_headers $query, $cookie, $template->output;