installer: move base zebra config files
[koha.git] / catalogue / ISBDdetail.pl
blob4b70d0f91f8694c212af08aead9cb46921882557
1 #!/usr/bin/perl
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
10 # version.
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
20 =head1 NAME
22 ISBDdetail.pl : script to show a biblio in ISBD format
24 =head1 SYNOPSIS
27 =head1 DESCRIPTION
29 This script needs a biblionumber as parameter
31 =head1 FUNCTIONS
33 =over 2
35 =cut
37 use strict;
38 require Exporter;
39 use C4::Auth;
40 use C4::Context;
41 use C4::Output;
42 use CGI;
43 use C4::Koha;
44 use C4::Biblio;
45 use C4::Branch; # GetBranchDetail
46 use C4::Serials; # CountSubscriptionFromBiblionumber
49 #---- Internal function
52 my $query = new CGI;
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);
61 # open template
62 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
64 template_name => "catalogue/ISBDdetail.tmpl",
65 query => $query,
66 type => "intranet",
67 authnotrequired => 0,
68 flagsrequired => { catalogue => 1 },
72 my $ISBD = C4::Context->preference('ISBD');
74 # my @blocs = split /\@/,$ISBD;
75 # my @fields = $record->fields();
76 my $res;
78 # foreach my $bloc (@blocs) {
79 # $bloc =~ s/\n//g;
80 my $bloc = $ISBD;
81 my $blocres;
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)\|(.*)\|(.*)\|(.*)/;
90 my $fieldvalue = $1;
91 my $textbefore = $2;
92 my $analysestring = $3;
93 my $textafter = $4;
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();
107 if ( $tag < 10 ) {
109 else {
110 my @subf = $field->subfields;
111 for my $i ( 0 .. $#subf ) {
112 my $subfieldcode = $subf[$i][0];
113 my $subfieldvalue =
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;
133 else {
134 $blocres .= $isbdfield;
137 $res .= $blocres;
140 $res =~ s/\{(.*?)\}//g;
141 $res =~ s/\\n/\n/g;
142 $res =~ s/\n/<br\/>/g;
144 # remove empty ()
145 $res =~ s/\(\)//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'};
154 $template->param(
155 subscriptionsnumber => $subscriptionsnumber,
156 subscriptiontitle => $subscriptiontitle,
160 $template->param (
161 ISBD => $res,
162 biblionumber => $biblionumber,
163 isbdview => 1,
166 output_html_with_http_headers $query, $cookie, $template->output;