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= /(.?.?.?)/;
90 $isbdfield =~ /(\d\d\d)\|(.*)\|(.*)\|(.*)/;
93 my $analysestring = $3;
96 # warn "==> $1 / $2 / $3 / $4";
97 # my $fieldvalue=substr($isbdfield,0,3);
98 if ( $fieldvalue > 0 ) {
100 # warn "ERROR IN ISBD DEFINITION at : $isbdfield" unless $fieldvalue;
101 # warn "FV : $fieldvalue";
102 my $hasputtextbefore = 0;
103 my @fieldslist = $record->field($fieldvalue);
104 @fieldslist= sort {$a->subfield($holdingbrtagsubf) cmp $b->subfield($holdingbrtagsubf)} @fieldslist if ($fieldvalue eq $holdingbrtagf);
105 foreach my $field ( @fieldslist ) {
106 my $calculated = $analysestring;
107 my $tag = $field->tag();
111 my @subf = $field->subfields;
112 for my $i ( 0 .. $#subf ) {
113 my $subfieldcode = $subf[$i][0];
115 GetAuthorisedValueDesc( $tag, $subf[$i][0],
116 $subf[$i][1], $itemtype,$tagslib);
117 my $tagsubf = $tag . $subfieldcode;
118 $calculated =~s/\{(.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g;
120 # field builded, store the result
121 if ( $calculated && !$hasputtextbefore )
122 { # put textbefore if not done
123 $blocres .= $textbefore;
124 $hasputtextbefore = 1;
127 # remove punctuation at start
128 $calculated =~ s/^( |;|:|\.|-)*//g;
129 $blocres .= $calculated;
132 $blocres .= $textafter if $hasputtextbefore;
135 $blocres .= $isbdfield;
141 $res =~ s/\{(.*?)\}//g;
143 $res =~ s/\n/<br\/>/g;
147 # count of item linked with biblio
148 my $itemcount = GetItemsCount($biblionumber);
149 $template->param( count => $itemcount);
150 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
152 if ($subscriptionsnumber) {
153 my $subscriptions = GetSubscriptionsFromBiblionumber($biblionumber);
154 my $subscriptiontitle = $subscriptions->[0]{'bibliotitle'};
156 subscriptionsnumber => $subscriptionsnumber,
157 subscriptiontitle => $subscriptiontitle,
163 biblionumber => $biblionumber,
167 output_html_with_http_headers $query, $cookie, $template->output;