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
33 my $dbh=C4::Context->dbh;
35 my $biblionumber=$query->param('biblionumber');
36 my $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblionumber);
38 my $tagslib = &MARCgettagslib($dbh,1);
40 my $record =MARCgetbiblio($dbh,$bibid);
42 my $template = gettemplate("catalogue/MARCdetail.tmpl",0);
46 # loop through each tab 0 through 9
47 for (my $tabloop = 0; $tabloop<=10;$tabloop++) {
48 # loop through each tag
49 my @fields = $record->fields();
51 foreach my $field (@fields) {
52 my @subf=$field->subfields;
53 my $previous_tag = '';
55 # loop through each subfield
56 for my $i (0..$#subf) {
57 $previous_tag = $field->tag();
58 next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne $tabloop);
60 $subfield_data{marc_lib}=$tagslib->{$field->tag()}->{$subf[$i][0]}->{lib};
61 $subfield_data{marc_value}=$subf[$i][1];
62 $subfield_data{marc_tag}=$field->tag().$subf[$i][0];
63 push(@subfields_data, \%subfield_data);
65 if ($#subfields_data>=0) {
67 $tag_data{tag}=$field->tag().' '. $tagslib->{$field->tag()}->{lib};
68 $tag_data{subfield} = \@subfields_data;
69 push (@loop_data, \%tag_data);
72 $template->param($tabloop."XX" =>\@loop_data);
74 # now, build item tab !
75 # the main difference is that datas are in lines and not in columns : thus, we build the <th> first, then the values...
76 # loop through each tag
77 # warning : we may have differents number of columns in each row. Thus, we first build a hash, complete it if necessary
78 # then construct template.
79 my @fields = $record->fields();
80 my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code
83 foreach my $field (@fields) {
84 my @subf=$field->subfields;
86 # loop through each subfield
87 for my $i (0..$#subf) {
88 next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne 10);
89 $witness{$subf[$i][0]} = $tagslib->{$field->tag()}->{$subf[$i][0]}->{lib};
90 $this_row{$subf[$i][0]} =$subf[$i][1];
93 push(@big_array, \%this_row);
96 #fill big_row with missing datas
98 foreach my $subfield_code (keys(%witness)) {
99 for (my $i=0;$i<=$#big_array;$i++) {
100 $big_array[$i]{$subfield_code}=" " unless ($big_array[$i]{$subfield_code});
101 # warn "filled : ".$big_array[$i]{$subfield_code};
104 # now, construct template !
107 my @header_value_loop;
108 for (my $i=0;$i<=$#big_array; $i++) {
110 foreach my $subfield_code (keys(%witness)) {
111 $items_data .="<td>".$big_array[$i]{$subfield_code}."</td>";
115 $row_data{item_value} = $items_data;
116 push(@item_value_loop,\%row_data);
118 foreach my $subfield_code (keys(%witness)) {
120 $header_value{header_value} = $witness{$subfield_code};
121 warn "$subfield_code => ".$witness{$subfield_code};
122 push(@header_value_loop, \%header_value);
125 $template->param(item_loop => \@item_value_loop,
126 item_header_loop => \@header_value_loop,
127 biblionumber => $biblionumber,
129 print "Content-Type: text/html\n\n", $template->output;