-
-
-
-|;
-
- map { print "$column_header{$_}\n" } @column_index;
+ my %column_header = (
+ id => $::locale->text('ID'),
+ invnumber => $::locale->text('Invoice'),
+ transdate => $::locale->text('Date'),
+ netamount => $::locale->text('Amount'),
+ tax => $::locale->text('Tax'),
+ amount => $::locale->text('Total'),
+ name => $name,
+ );
- print qq|
-
-|;
+ my %column_sorted = map { $_ => 1 } qw(id invnumber transdate);
- # add sort and escape callback
- $callback = $form->escape($callback . "&sort=$form->{sort}");
+ $callback .= "&sort=$::form->{sort}";
my $sameitem;
- if (@{ $form->{TR} }) {
- $sameitem = $form->{TR}->[0]->{ $form->{sort} };
+ if (@{ $::form->{TR} }) {
+ $sameitem = $::form->{TR}->[0]->{ $::form->{sort} };
}
- my ($totalnetamount, $totaltax);
- my ($i);
- foreach my $ref (@{ $form->{TR} }) {
+ my ($totalnetamount, $totaltax, @data);
+ for my $ref (@{ $::form->{TR} }) {
my $module = ($ref->{invoice}) ? $invoice : $arap;
- if ($form->{l_subtotal} eq 'Y') {
- if ($sameitem ne $ref->{ $form->{sort} }) {
- tax_subtotal(\@column_index, \$subtotalnetamount, \$subtotaltax, \$subtotal);
- $sameitem = $ref->{ $form->{sort} };
+ if ($::form->{l_subtotal} eq 'Y') {
+ if ($sameitem ne $ref->{ $::form->{sort} }) {
+ push @data, {
+ subtotal => 1,
+ netamount => $subtotalnetamount,
+ tax => $subtotaltax,
+ amount => $subtotal,
+ };
+ $subtotalnetamount = 0;
+ $subtotaltax = 0;
+ $sameitem = $ref->{ $::form->{sort} };
}
}
- $totalnetamount += $ref->{netamount};
- $totaltax += $ref->{tax};
- $ref->{amount} = $ref->{netamount} + $ref->{tax};
-
$subtotalnetamount += $ref->{netamount};
$subtotaltax += $ref->{tax};
+ $totalnetamount += $ref->{netamount};
+ $totaltax += $ref->{tax};
+ $ref->{amount} = $ref->{netamount} + $ref->{tax};
- map {
- $ref->{$_} = $form->format_amount(\%myconfig, $ref->{$_}, 2, " ");
- } qw(netamount tax amount);
-
- my %column_data;
- $column_data{id} = qq|$ref->{id} | |;
- $column_data{invnumber} =
- qq|{id}&callback=$callback>$ref->{invnumber} | |;
- $column_data{transdate} = qq|$ref->{transdate} | |;
- $column_data{name} = qq|$ref->{name} | |;
-
- map { $column_data{$_} = qq|$ref->{$_} | | }
- qw(netamount tax amount);
-
- $i++;
- $i %= 2;
- print qq|
-
-|;
-
- map { print "$column_data{$_}\n" } @column_index;
-
- print qq|
-
-|;
-
+ push @data, { map { $_ => { data => $ref->{$_} } } keys %$ref };
+ $data[-1]{invnumber}{link} = "$module?action=edit&id=$ref->{id}&callback=$callback";
+ $data[-1]{$_}{numeric} = 1 for qw(netamount tax amount);
}
- if ($form->{l_subtotal} eq 'Y') {
- tax_subtotal(\@column_index, \$subtotalnetamount, \$subtotaltax, \$subtotal);
+ if ($::form->{l_subtotal} eq 'Y') {
+ push @data, {
+ subtotal => 1,
+ netamount => $subtotalnetamount,
+ tax => $subtotaltax,
+ amount => $subtotal,
+ };
}
- my %column_data;
- map { $column_data{$_} = qq| | | } @column_index;
-
- print qq|
-
-
-|;
-
- my $total = $form->format_amount(\%myconfig, $totalnetamount + $totaltax, 2, " ");
- $totalnetamount = $form->format_amount(\%myconfig, $totalnetamount, 2, " ");
- $totaltax = $form->format_amount(\%myconfig, $totaltax, 2, " ");
-
- $column_data{netamount} = qq|| $totalnetamount | |;
- $column_data{tax} = qq|$totaltax | |;
- $column_data{amount} = qq|$total | |;
-
- map { print "$column_data{$_}\n" } @column_index;
-
- print qq|
-
-
- |
-
-