-
-
-
- $invoice |
-
-|;
-
- $column_data{invnumber} =
- qq|| . $locale->text('Invoice') . " | ";
- $column_data{transdate} =
- qq|| . $locale->text('Date') . " | ";
- $column_data{amount} =
- qq|| . $locale->text('Amount') . " | ";
- $column_data{due} =
- qq|| . $locale->text('Due') . " | ";
- $column_data{paid} =
- qq|| . $locale->text('Amount') . " | ";
- $column_data{checked} =
- qq|| . $locale->text('Select') . " | ";
-
- print qq|
-
-|;
- map { print "$column_data{$_}\n" } @column_index;
- print qq|
-
-|;
-
- for my $i (1 .. $form->{rowcount}) {
-
- my $j = 0;
-
- map {
- $form->{"${_}_$i"} =
- $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
- } qw(amount due paid);
-
- $totalamount += $form->{"amount_$i"};
- $totaldue += $form->{"due_$i"};
- $totalpaid += $form->{"paid_$i"};
-
- map {
- $form->{"${_}_$i"} =
- $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2)
- } qw(amount due paid);
-
- $column_data{invnumber} = qq|$form->{"invnumber_$i"} |
-
- {"id_$i"}>|;
- $column_data{transdate} = qq|$form->{"transdate_$i"} |
- {"transdate_$i"}>|;
- $column_data{amount} =
- qq|$form->{"amount_$i"} |
- {"amount_$i"}>|;
- $column_data{due} = qq|$form->{"due_$i"} |
- {"due_$i"}>|;
-
- $column_data{paid} =
- qq|{"paid_$i"}> | |;
-
- $form->{"checked_$i"} = ($form->{"checked_$i"}) ? "checked" : "";
- $column_data{checked} =
- qq|{"checked_$i"}> | |;
-
- $j++;
- $j %= 2;
- print qq|
-
-|;
- map { print "$column_data{$_}\n" } @column_index;
- print qq|
-
-|;
+ $::lxdebug->enter_sub;
+ $::auth->assert('cash');
+
+ my @columns = qw(amount due paid invnumber id transdate checked);
+ my (@invoices, %total);
+ for my $i (1 .. $::form->{rowcount}) {
+ push @invoices, +{ map { $_ => $::form->{"$_\_$i"} } @columns };
+ $total{$_} += $invoices[-1]{$_} = $::form->parse_amount(\%::myconfig, $invoices[-1]{$_}) for qw(amount due paid);
}
- map { $column_data{$_} = " | " } @column_index;
-
- $column_data{amount} =
- qq||
- . $form->format_amount(\%myconfig, $totalamount, 2, " ")
- . qq| | |;
- $column_data{due} =
- qq||
- . $form->format_amount(\%myconfig, $totaldue, 2, " ")
- . qq| | |;
- $column_data{paid} =
- qq||
- . $form->format_amount(\%myconfig, $totalpaid, 2, " ")
- . qq| | |;
-
- print qq|
-
-|;
- map { print "$column_data{$_}\n" } @column_index;
- print qq|
-
-
- |
-
-|;
+ print $::form->parse_html_template('cp/invoices', {
+ invoices => \@invoices,
+ totals => \%total,
+ });
- $lxdebug->leave_sub();
+ $::lxdebug->leave_sub;
}
sub form_footer {
- $lxdebug->enter_sub();
+ $::lxdebug->enter_sub;
+ $::auth->assert('cash');
- $auth->assert('cash');
-
- my ($media, $format, $latex_templates);
-
- $form->{DF}{ $form->{format} } = "selected";
- $form->{OP}{ $form->{media} } = "selected";
-
- $media = qq|
-