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 in bib parameter (bibnumber from koha style DB. Automaticaly maps to marc biblionumber).
30 It shows the biblio in a (nice) MARC format depending on MARC parameters tables.
31 The template is in <templates_dir>/catalogue/MARCdetail.tmpl. this template must be divided in 11 "tabs".
32 The 10 firsts presents the biblio, the 11th one presents the items attached to the biblio
55 my $dbh=C4::Context->dbh;
57 my $biblionumber=$query->param('bib');
58 my $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblionumber);
60 my $tagslib = &MARCgettagslib($dbh,1);
62 my $record =MARCgetbiblio($dbh,$bibid);
63 #warn $record->as_formatted();
65 my ($template, $loggedinuser, $cookie)
66 = get_template_and_user({template_name => "catalogue/MARCdetail.tmpl",
70 flagsrequired => {catalogue => 1},
77 # loop through each tab 0 through 9
78 for (my $tabloop = 0; $tabloop<=10;$tabloop++) {
79 # loop through each tag
80 my @fields = $record->fields();
82 foreach my $field (@fields) {
83 my @subf=$field->subfields;
84 my $previous_tag = '';
86 # loop through each subfield
87 for my $i (0..$#subf) {
88 $previous_tag = $field->tag();
89 next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne $tabloop);
91 $subfield_data{marc_lib}=$tagslib->{$field->tag()}->{$subf[$i][0]}->{lib};
92 $subfield_data{marc_value}=$subf[$i][1];
93 $subfield_data{marc_tag}=$subf[$i][0];
94 push(@subfields_data, \%subfield_data);
96 if ($#subfields_data>=0) {
98 $tag_data{tag}=$field->tag().' -'. $tagslib->{$field->tag()}->{lib};
99 $tag_data{subfield} = \@subfields_data;
100 push (@loop_data, \%tag_data);
103 $template->param($tabloop."XX" =>\@loop_data);
105 # now, build item tab !
106 # the main difference is that datas are in lines and not in columns : thus, we build the <th> first, then the values...
107 # loop through each tag
108 # warning : we may have differents number of columns in each row. Thus, we first build a hash, complete it if necessary
109 # then construct template.
110 my @fields = $record->fields();
111 my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code
113 foreach my $field (@fields) {
114 my @subf=$field->subfields;
116 # loop through each subfield
117 for my $i (0..$#subf) {
118 next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne 10);
119 $witness{$subf[$i][0]} = $tagslib->{$field->tag()}->{$subf[$i][0]}->{lib};
120 $this_row{$subf[$i][0]} =$subf[$i][1];
123 push(@big_array, \%this_row);
126 #fill big_row with missing datas
127 foreach my $subfield_code (keys(%witness)) {
128 for (my $i=0;$i<=$#big_array;$i++) {
129 $big_array[$i]{$subfield_code}=" " unless ($big_array[$i]{$subfield_code});
130 # warn "filled : ".$big_array[$i]{$subfield_code};
133 # now, construct template !
135 my @header_value_loop;
136 for (my $i=0;$i<=$#big_array; $i++) {
138 foreach my $subfield_code (keys(%witness)) {
139 $items_data .="<td>".$big_array[$i]{$subfield_code}."</td>";
143 $row_data{item_value} = $items_data;
144 push(@item_value_loop,\%row_data);
146 foreach my $subfield_code (keys(%witness)) {
148 $header_value{header_value} = $witness{$subfield_code};
149 push(@header_value_loop, \%header_value);
152 $template->param(item_loop => \@item_value_loop,
153 item_header_loop => \@header_value_loop,
154 biblionumber => $biblionumber,
156 print $query->header(-cookie => $cookie),$template->output;