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 MARCdetail.pl : script to show a biblio in MARC format
29 This script needs a biblionumber as parameter
31 It shows the biblio in a (nice) MARC format depending on MARC
34 The template is in <templates_dir>/catalogue/MARCdetail.tmpl.
35 this template must be divided into 11 "tabs".
37 The first 10 tabs present the biblio, the 11th one presents
38 the items attached to the biblio
54 my $dbh = C4
::Context
->dbh;
56 my $biblionumber = $query->param('biblionumber');
57 my $itemtype = &GetFrameworkCode
($biblionumber);
58 my $tagslib = &GetMarcStructure
( 0, $itemtype );
59 my $biblio = GetBiblioData
($biblionumber);
60 my $record = GetMarcBiblio
($biblionumber);
63 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
65 template_name
=> "opac-MARCdetail.tmpl",
74 bibliotitle
=> $biblio->{title
},
77 $template->param( 'AllowOnShelfHolds' => C4
::Context
->preference('AllowOnShelfHolds') );
78 $template->param( 'ItemsIssued' => CountItemsIssued
( $biblionumber ) );
80 # adding the $RequestOnOpac param
82 if (C4
::Context
->preference("RequestOnOpac")) {
90 # loop through each tab 0 through 9
91 for ( my $tabloop = 0 ; $tabloop <= 10 ; $tabloop++ ) {
93 # loop through each tag
98 unless ( $tagslib->{'000'}->{'@'}->{tab
} ne $tabloop
99 or $tagslib->{'000'}->{'@'}->{hidden
} > 0 )
102 $subfield_data{marc_lib
} = $tagslib->{'000'}->{'@'}->{lib
};
103 $subfield_data{marc_value
} = $record->leader();
104 $subfield_data{marc_subfield
} = '@';
105 $subfield_data{marc_tag
} = '000';
106 push( @subfields_data, \
%subfield_data );
108 $tag_data{tag
} = '000 -' . $tagslib->{'000'}->{lib
};
109 my @tmp = @subfields_data;
110 $tag_data{subfield
} = \
@tmp;
111 push( @loop_data, \
%tag_data );
112 undef @subfields_data;
114 my @fields = $record->fields();
115 for ( my $x_i = 0 ; $x_i <= $#fields ; $x_i++ ) {
117 # if tag <10, there's no subfield, use the "@" trick
118 if ( $fields[$x_i]->tag() < 10 ) {
121 $tagslib->{ $fields[$x_i]->tag() }->{'@'}->{tab
} ne $tabloop );
122 next if ( $tagslib->{ $fields[$x_i]->tag() }->{'@'}->{hidden
} > 0 );
124 $subfield_data{marc_lib
} =
125 $tagslib->{ $fields[$x_i]->tag() }->{'@'}->{lib
};
126 $subfield_data{marc_value
} = $fields[$x_i]->data();
127 $subfield_data{marc_subfield
} = '@';
128 $subfield_data{marc_tag
} = $fields[$x_i]->tag();
129 push( @subfields_data, \
%subfield_data );
132 my @subf = $fields[$x_i]->subfields;
134 # loop through each subfield
135 for my $i ( 0 .. $#subf ) {
136 $subf[$i][0] = "@" unless $subf[$i][0];
139 $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }->{tab
}
142 if ( $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }->{hidden
} > 0 );
144 $subfield_data{marc_lib
} =
145 ($tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }->{lib
} eq $previous) ?
147 $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }->{lib
};
148 $previous = $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }->{lib
};
149 $subfield_data{link} =
150 $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }->{link};
151 $subf[$i][1] =~ s/\n/<br\/>/g
;
152 if ( $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }
155 $subfield_data{marc_value
} =
156 "<a href=\"$subf[$i][1]\">$subf[$i][1]</a>";
158 elsif ( $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }
159 ->{kohafield
} eq "biblioitems.isbn" )
162 # warn " tag : ".$tagslib->{$fields[$x_i]->tag()}." subfield :".$tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}. "ISBN : ".$subf[$i][1]."PosttraitementISBN :".DisplayISBN($subf[$i][1]);
163 $subfield_data{marc_value
} = $subf[$i][1];
166 if ( $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }
169 $subfield_data{authority
} = $fields[$x_i]->subfield(9);
171 $subfield_data{marc_value
} =
172 GetAuthorisedValueDesc
( $fields[$x_i]->tag(),
173 $subf[$i][0], $subf[$i][1], '', $tagslib, '', 'opac' );
175 $subfield_data{marc_subfield
} = $subf[$i][0];
176 $subfield_data{marc_tag
} = $fields[$x_i]->tag();
177 push( @subfields_data, \
%subfield_data );
180 if ( $#subfields_data >= 0 ) {
182 if ( ( $fields[$x_i]->tag() eq $fields[ $x_i - 1 ]->tag() )
183 && ( C4
::Context
->preference('LabelMARCView') eq 'economical' )
189 if ( C4
::Context
->preference('hide_marc') ) {
190 $tag_data{tag
} = $tagslib->{ $fields[$x_i]->tag() }->{lib
};
196 . C4
::Koha
::display_marc_indicators
($fields[$x_i])
198 . $tagslib->{ $fields[$x_i]->tag() }->{lib
};
201 my @tmp = @subfields_data;
202 $tag_data{subfield
} = \
@tmp;
203 push( @loop_data, \
%tag_data );
204 undef @subfields_data;
207 $template->param( $tabloop . "XX" => \
@loop_data );
211 # now, build item tab !
212 # the main difference is that datas are in lines and not in columns : thus, we build the <th> first, then the values...
213 # loop through each tag
214 # warning : we may have differents number of columns in each row. Thus, we first build a hash, complete it if necessary
215 # then construct template.
216 my @fields = $record->fields();
218 ; #---- stores the list of subfields used at least once, with the "meaning" of the code
220 foreach my $field (@fields) {
221 next if ( $field->tag() < 10 );
222 my @subf = $field->subfields;
225 # loop through each subfield
226 for my $i ( 0 .. $#subf ) {
227 next if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{tab
} ne 10 );
228 next if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{hidden
} > 0 );
229 $witness{ $subf[$i][0] } =
230 $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib
};
232 if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{isurl
} ) {
233 $this_row{ $subf[$i][0] } =
234 "<a href=\"$subf[$i][1]\">$subf[$i][1]</a>";
236 elsif ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{kohafield
} eq
239 $this_row{ $subf[$i][0] } = $subf[$i][1];
242 $this_row{ $subf[$i][0] } =
243 GetAuthorisedValueDesc
( $field->tag(), $subf[$i][0],
244 $subf[$i][1], '', $tagslib, '', 'opac' );
248 push( @big_array, \
%this_row );
251 my ( $holdingbrtagf, $holdingbrtagsubf ) =
252 &GetMarcFromKohaField
( "items.holdingbranch", $itemtype );
254 sort { $a->{$holdingbrtagsubf} cmp $b->{$holdingbrtagsubf} } @big_array;
256 #fill big_row with missing datas
257 foreach my $subfield_code ( keys(%witness) ) {
258 for ( my $i = 0 ; $i <= $#big_array ; $i++ ) {
259 $big_array[$i]{$subfield_code} = " "
260 unless ( $big_array[$i]{$subfield_code} );
264 # now, construct template !
266 my @header_value_loop;
267 for ( my $i = 0 ; $i <= $#big_array ; $i++ ) {
269 foreach my $subfield_code ( keys(%witness) ) {
270 $items_data .= "<td>" . $big_array[$i]{$subfield_code} . "</td>";
273 $row_data{item_value
} = $items_data;
274 push( @item_value_loop, \
%row_data );
277 foreach my $subfield_code ( keys(%witness) ) {
279 $header_value{header_value
} = $witness{$subfield_code};
280 push( @header_value_loop, \
%header_value );
283 if(C4
::Context
->preference("ISBD")) {
284 $template->param(ISBD
=> 1);
288 item_loop
=> \
@item_value_loop,
289 item_header_loop
=> \
@header_value_loop,
290 biblionumber
=> $biblionumber,
293 output_html_with_http_headers
$query, $cookie, $template->output;