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
57 use C4::Serials; #uses getsubscriptionsfrombiblionumber GetSubscriptionsFromBiblionumber
61 my $dbh = C4::Context->dbh;
62 my $biblionumber = $query->param('biblionumber');
63 my $frameworkcode = $query->param('frameworkcode');
64 $frameworkcode = GetFrameworkCode( $biblionumber ) unless ($frameworkcode);
66 $query->param('popup')
67 ; # if set to 1, then don't insert links, it's just to show the biblio
68 my $subscriptionid = $query->param('subscriptionid');
70 my $tagslib = &GetMarcStructure(1,$frameworkcode);
72 my $record = GetMarcBiblio($biblionumber);
73 my $biblio = GetBiblioData($biblionumber);
75 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
77 template_name => "catalogue/MARCdetail.tmpl",
81 flagsrequired => { catalogue => 1 },
87 my $itemcount = GetItemsCount($biblionumber);
88 $template->param( count => $itemcount,
89 bibliotitle => $biblio->{title}, );
91 #Getting the list of all frameworks
93 $dbh->prepare("select frameworktext, frameworkcode from biblio_framework");
98 push @select_fwk, "Default";
99 $select_fwk{"Default"} = "Default";
101 while ( my ( $description, $fwk ) = $queryfwk->fetchrow ) {
102 push @select_fwk, $fwk;
103 $select_fwk{$fwk} = $description;
105 $curfwk=$frameworkcode;
106 my $framework=CGI::scrolling_list( -name => 'Frameworks',
109 -OnChange => 'Changefwk(this);',
110 -values => \@select_fwk,
111 -labels => \%select_fwk,
114 $template->param(framework => $framework);
119 # loop through each tab 0 through 9
120 for ( my $tabloop = 0 ; $tabloop <= 10 ; $tabloop++ ) {
122 # loop through each tag
123 my @fields = $record->fields();
128 unless ( $tagslib->{'000'}->{'@'}->{tab} ne $tabloop )
129 { # or ($tagslib->{'000'}->{'@'}->{hidden} =~ /-7|-4|-3|-2|2|3|5|8/ )) {
131 $subfield_data{marc_lib} = $tagslib->{'000'}->{'@'}->{lib};
132 $subfield_data{marc_value} = $record->leader();
133 $subfield_data{marc_subfield} = '@';
134 $subfield_data{marc_tag} = '000';
135 push( @subfields_data, \%subfield_data );
137 $tag_data{tag} = '000 -' . $tagslib->{'000'}->{lib};
138 my @tmp = @subfields_data;
139 $tag_data{subfield} = \@tmp;
140 push( @loop_data, \%tag_data );
141 undef @subfields_data;
143 @fields = $record->fields();
144 for ( my $x_i = 0 ; $x_i <= $#fields ; $x_i++ ) {
146 # if tag <10, there's no subfield, use the "@" trick
147 if ( $fields[$x_i]->tag() < 10 ) {
150 $tagslib->{ $fields[$x_i]->tag() }->{'@'}->{tab} ne $tabloop );
151 next if ( $tagslib->{ $fields[$x_i]->tag() }->{'@'}->{hidden} =~ /-7|-4|-3|-2|2|3|5|8/);
153 $subfield_data{marc_lib} =
154 $tagslib->{ $fields[$x_i]->tag() }->{'@'}->{lib};
155 $subfield_data{marc_value} = $fields[$x_i]->data();
156 $subfield_data{marc_subfield} = '@';
157 $subfield_data{marc_tag} = $fields[$x_i]->tag();
158 push( @subfields_data, \%subfield_data );
161 my @subf = $fields[$x_i]->subfields;
163 # loop through each subfield
164 for my $i ( 0 .. $#subf ) {
165 $subf[$i][0] = "@" unless $subf[$i][0];
168 $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }->{tab}
171 if ( $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }
172 ->{hidden} =~ /-7|-4|-3|-2|2|3|5|8/);
174 $subfield_data{short_desc} = $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }->{lib};
175 $subfield_data{long_desc} =
176 $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }->{lib};
177 $subfield_data{link} =
178 $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }->{link};
180 # warn "tag : ".$tagslib->{$fields[$x_i]->tag()}." subfield :".$tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}."lien koha? : "$subfield_data{link};
181 if ( $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }
184 $subfield_data{marc_value} = $subf[$i][1];
185 $subfield_data{is_url} = 1;
187 elsif ( $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }
188 ->{kohafield} eq "biblioitems.isbn" )
191 # 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]);
192 $subfield_data{marc_value} = $subf[$i][1];
195 if ( $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }
198 $subfield_data{authority} = $fields[$x_i]->subfield(9);
200 $subfield_data{marc_value} =
201 GetAuthorisedValueDesc( $fields[$x_i]->tag(),
202 $subf[$i][0], $subf[$i][1], '', $tagslib) || $subf[$i][1];
205 $subfield_data{marc_subfield} = $subf[$i][0];
206 $subfield_data{marc_tag} = $fields[$x_i]->tag();
207 push( @subfields_data, \%subfield_data );
210 if ( $#subfields_data == 0 ) {
211 $subfields_data[0]->{marc_lib} = '';
212 # $subfields_data[0]->{marc_subfield} = '';
214 if ( $#subfields_data >= 0) {
216 if ( $fields[$x_i]->tag() eq $fields[ $x_i - 1 ]->tag() && (C4::Context->preference('LabelMARCView') eq 'economical')) {
220 if ( C4::Context->preference('hide_marc') ) {
221 $tag_data{tag} = $tagslib->{ $fields[$x_i]->tag() }->{lib};
227 . C4::Koha::display_marc_indicators($fields[$x_i])
229 . $tagslib->{ $fields[$x_i]->tag() }->{lib};
232 my @tmp = @subfields_data;
233 $tag_data{subfield} = \@tmp;
234 push( @loop_data, \%tag_data );
235 undef @subfields_data;
238 $template->param( $tabloop . "XX" => \@loop_data );
241 # now, build item tab !
242 # the main difference is that datas are in lines and not in columns : thus, we build the <th> first, then the values...
243 # loop through each tag
244 # warning : we may have differents number of columns in each row. Thus, we first build a hash, complete it if necessary
245 # then construct template.
246 my @fields = $record->fields();
248 ; #---- stores the list of subfields used at least once, with the "meaning" of the code
251 foreach my $field (@fields) {
252 next if ( $field->tag() < 10 );
253 my @subf = $field->subfields;
256 # loop through each subfield
257 for my $i ( 0 .. $#subf ) {
258 next if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{tab} ne 10 );
259 next if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{hidden} =~ /-7|-4|-3|-2|2|3|5|8/);
260 $witness{ $subf[$i][0] } =
261 $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib};
262 $this_row{ $subf[$i][0] } = GetAuthorisedValueDesc( $field->tag(),
263 $subf[$i][0], $subf[$i][1], '', $tagslib) || $subf[$i][1];
264 $norequests = 0 if $subf[$i][1] ==0 and $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{kohafield} eq 'items.notforloan';
267 push( @big_array, \%this_row );
271 my ($holdingbrtagf,$holdingbrtagsubf) = &GetMarcFromKohaField("items.holdingbranch",$frameworkcode);
272 @big_array = sort {$a->{$holdingbrtagsubf} cmp $b->{$holdingbrtagsubf}} @big_array;
274 #fill big_row with missing datas
275 foreach my $subfield_code ( keys(%witness) ) {
276 for ( my $i = 0 ; $i <= $#big_array ; $i++ ) {
277 $big_array[$i]{$subfield_code} = " "
278 unless ( $big_array[$i]{$subfield_code} );
282 # now, construct template !
284 my @header_value_loop;
285 for ( my $i = 0 ; $i <= $#big_array ; $i++ ) {
287 foreach my $subfield_code ( keys(%witness) ) {
288 $items_data .= "<td>" . $big_array[$i]{$subfield_code} . "</td>";
291 $row_data{item_value} = $items_data;
292 push( @item_value_loop, \%row_data );
294 foreach my $subfield_code ( keys(%witness) ) {
296 $header_value{header_value} = $witness{$subfield_code};
297 push( @header_value_loop, \%header_value );
300 my $subscriptionscount = CountSubscriptionFromBiblionumber($biblionumber);
302 if ($subscriptionscount) {
303 my $subscriptions = GetSubscriptionsFromBiblionumber($biblionumber);
304 my $subscriptiontitle = $subscriptions->[0]{'bibliotitle'};
306 subscriptiontitle => $subscriptiontitle,
307 subscriptionsnumber => $subscriptionscount,
312 norequests => $norequests,
313 item_loop => \@item_value_loop,
314 item_header_loop => \@header_value_loop,
315 biblionumber => $biblionumber,
317 hide_marc => C4::Context->preference('hide_marc'),
321 output_html_with_http_headers $query, $cookie, $template->output;