From 91931954782214bafef6f5aef723de55b1ed762b Mon Sep 17 00:00:00 2001 From: tipaul Date: Wed, 9 Oct 2002 15:45:59 +0000 Subject: [PATCH] road to 1.3.1 : viewing biblio MARC detail --- MARCdetail.pl | 85 +++++++++++++---- .../default/en/MARCdetailbiblioselect.tmpl | 10 ++ .../default/en/catalogue/MARCdetail.tmpl | 92 ++++++++++++------- 3 files changed, 136 insertions(+), 51 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/default/en/MARCdetailbiblioselect.tmpl diff --git a/MARCdetail.pl b/MARCdetail.pl index 3c90d3df65..66020f3c67 100755 --- a/MARCdetail.pl +++ b/MARCdetail.pl @@ -43,39 +43,88 @@ my $template = gettemplate("catalogue/MARCdetail.tmpl",0); # fill arrays my @loop_data =(); my $tag; -for ($tag=0 ; $tag<=9 ; $tag++) { -# marc array (tags and subfields) -# loop each field having tag = $tag."XX" - my @fields = $record->field($tag."XX"); - my @loop_data =(); +# loop through each tab 0 through 9 +for (my $tabloop = 0; $tabloop<=10;$tabloop++) { +# loop through each tag + my @fields = $record->fields(); + my @loop_data =(); foreach my $field (@fields) { my @subf=$field->subfields; my $previous_tag = ''; my @subfields_data; # loop through each subfield for my $i (0..$#subf) { -# if we not exactly the same tag (XX can varry !), loop for "tag tittle". - if ($previous_tag ne $field->tag()) { - my %tag_data; - $tag_data{tag}=$field->tag().' '. $tagslib->{$field->tag()}->{lib}; - $tag_data{subfield} = \@subfields_data; - push (@loop_data, \%tag_data); - $previous_tag = $field->tag(); - } $previous_tag = $field->tag(); + next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne $tabloop); my %subfield_data; $subfield_data{marc_lib}=$tagslib->{$field->tag()}->{$subf[$i][0]}->{lib}; $subfield_data{marc_value}=$subf[$i][1]; $subfield_data{marc_tag}=$field->tag().$subf[$i][0]; push(@subfields_data, \%subfield_data); } + if ($#subfields_data>=0) { + my %tag_data; + $tag_data{tag}=$field->tag().' '. $tagslib->{$field->tag()}->{lib}; + $tag_data{subfield} = \@subfields_data; + push (@loop_data, \%tag_data); + } + } + $template->param($tabloop."XX" =>\@loop_data); +} +# now, build item tab ! +# the main difference is that datas are in lines and not in columns : thus, we build the first, then the values... +# loop through each tag +# warning : we may have differents number of columns in each row. Thus, we first build a hash, complete it if necessary +# then construct template. +my @fields = $record->fields(); +my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code +my @big_array; +warn "loop 1"; +foreach my $field (@fields) { + my @subf=$field->subfields; + my %this_row; +# loop through each subfield + for my $i (0..$#subf) { + next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne 10); + $witness{$subf[$i][0]} = $tagslib->{$field->tag()}->{$subf[$i][0]}->{lib}; + $this_row{$subf[$i][0]} =$subf[$i][1]; + } + if (%this_row) { + push(@big_array, \%this_row); } - $template->param($tag."XX" =>\@loop_data); +} +#fill big_row with missing datas +#warn "loop 2"; +foreach my $subfield_code (keys(%witness)) { + for (my $i=0;$i<=$#big_array;$i++) { + $big_array[$i]{$subfield_code}=" " unless ($big_array[$i]{$subfield_code}); +# warn "filled : ".$big_array[$i]{$subfield_code}; + } +} +# now, construct template ! +#warn "loop 3"; +my @item_value_loop; +my @header_value_loop; +for (my $i=0;$i<=$#big_array; $i++) { + my $items_data; + foreach my $subfield_code (keys(%witness)) { + $items_data .="".$big_array[$i]{$subfield_code}.""; + } +# warn $items_data; + my %row_data; + $row_data{item_value} = $items_data; + push(@item_value_loop,\%row_data); +} +foreach my $subfield_code (keys(%witness)) { + my %header_value; + $header_value{header_value} = $witness{$subfield_code}; + warn "$subfield_code => ".$witness{$subfield_code}; + push(@header_value_loop, \%header_value); } -# fill template with arrays -$template->param(biblionumber => $biblionumber); -#$template->param(marc =>\@loop_data); -$template->param(bibid => $bibid); +$template->param(item_loop => \@item_value_loop, + item_header_loop => \@header_value_loop, + biblionumber => $biblionumber, + bibid => $bibid); print "Content-Type: text/html\n\n", $template->output; diff --git a/koha-tmpl/intranet-tmpl/default/en/MARCdetailbiblioselect.tmpl b/koha-tmpl/intranet-tmpl/default/en/MARCdetailbiblioselect.tmpl new file mode 100644 index 0000000000..57aeaa07d5 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/default/en/MARCdetailbiblioselect.tmpl @@ -0,0 +1,10 @@ + + +MARCdetail + +
+biblionumber : + +
+ + \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/default/en/catalogue/MARCdetail.tmpl b/koha-tmpl/intranet-tmpl/default/en/catalogue/MARCdetail.tmpl index 89788502e8..e291d7a381 100644 --- a/koha-tmpl/intranet-tmpl/default/en/catalogue/MARCdetail.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/catalogue/MARCdetail.tmpl @@ -2,7 +2,7 @@ - + - +
MARC biblio : MARC biblio :
@@ -18,7 +18,7 @@
7xx
8xx
9xx
Item
Item
@@ -27,11 +27,12 @@
- + - - + + @@ -41,11 +42,12 @@
+  
- + - - + + @@ -55,11 +57,12 @@
+  
- + - - + + @@ -69,11 +72,12 @@
+  
- + - - + + @@ -83,11 +87,12 @@
+  
- + - - + + @@ -97,11 +102,12 @@
+  
- + - - + + @@ -111,11 +117,12 @@
+  
- + - - + + @@ -125,11 +132,12 @@
+  
- + - - + + @@ -139,42 +147,60 @@
+  
- + - - + +
+  
+ + +