From b15be226208065463e92b2e892b8ec8b39c89191 Mon Sep 17 00:00:00 2001 From: Andrew Moore Date: Wed, 17 Dec 2008 16:30:46 -0600 Subject: [PATCH] refactor: removing a few unnecessary loops and moving HTML out of script into template Signed-off-by: Galen Charlton --- cataloguing/additem.pl | 21 ++++++------------- .../prog/en/modules/cataloguing/additem.tmpl | 4 +++- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 5a776fdd86..62885d2ae0 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -226,12 +226,7 @@ foreach my $field (@fields) { push(@big_array, \%this_row); } } -#fill big_row with missing data -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}); - } -} + my ($holdingbrtagf,$holdingbrtagsubf) = &GetMarcFromKohaField("items.holdingbranch",$frameworkcode); @big_array = sort {$a->{$holdingbrtagsubf} cmp $b->{$holdingbrtagsubf}} @big_array; @@ -239,17 +234,13 @@ my ($holdingbrtagf,$holdingbrtagsubf) = &GetMarcFromKohaField("items.holdingbran # First, the existing items for display my @item_value_loop; my @header_value_loop; -for (my $i=0;$i<=$#big_array; $i++) { - my $items_data; - foreach my $subfield_code (sort keys(%witness)) { - $items_data .="".$big_array[$i]{$subfield_code}.""; - } +for my $row ( @big_array ) { my %row_data; - $items_data =~ s/"/"/g; - $row_data{item_value} = $items_data; - $row_data{itemnumber} = $big_array[$i]->{itemnumber}; + my @item_fields = map +{ field => $_ || '' }, @$row{ sort keys(%witness) }; + $row_data{item_value} = [ @item_fields ]; + $row_data{itemnumber} = $row->{itemnumber}; #reporting this_row values - $row_data{'nomod'} = $big_array[$i]{'nomod'}; + $row_data{'nomod'} = $row->{'nomod'}; push(@item_value_loop,\%row_data); } foreach my $subfield_code (sort keys(%witness)) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl index 5c8cf52eaf..841279b702 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl @@ -188,7 +188,9 @@ function set_to_today(id, force) { ">  &itemnumber=">Edit &itemnumber=" onclick="confirm_deletion(,); return false;">Delete - + + + -- 2.39.5