summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/rp.pl66
-rw-r--r--templates/demo/statement.html4
-rw-r--r--templates/demo/statement.tex6
3 files changed, 49 insertions, 27 deletions
diff --git a/bin/rp.pl b/bin/rp.pl
index 226bd84c..533582f5 100644
--- a/bin/rp.pl
+++ b/bin/rp.pl
@@ -2156,33 +2156,52 @@ sub print {
if ( $form->{format} !~ /(postscript|pdf)/ );
}
+ my @batch_data = ();
+
for $i ( 1 .. $form->{rowcount} ) {
+
if ( $form->{"statement_$i"} ) {
$form->{"$form->{ct}_id"} = $form->{"$form->{ct}_id_$i"};
$language_code = $form->{"language_code_$i"};
$curr = $form->{"curr_$i"};
$selected = 1;
- last;
+
+ if ( $form->{media} !~ /(screen|email)/ ) {
+ # SC: I may not need this anymore...
+ # But I'll wait until lpr output is working before deciding
+ $form->{OUT} = "${LedgerSMB::Sysconfig::printer}{$form->{media}}";
+ $form->{"$form->{ct}_id"} = "";
+ $SIG{INT} = 'IGNORE';
+ }
+ else {
+ $form->{"statement_1"} = 1;
+ $form->{"language_code_1"} = $language_code;
+ $form->{"curr_1"} = $curr;
+ }
+
+ RP->aging( \%myconfig, \%$form );
+
+ $printhash = &print_form;
+
+ push @batch_data, $printhash;
}
}
$form->error( $locale->text('Nothing selected!') ) unless $selected;
-
- if ( $form->{media} !~ /(screen|email)/ ) {
- $form->{OUT} = "${LedgerSMB::Sysconfig::printer}{$form->{media}}";
- $form->{printmode} = '|-';
- $form->{"$form->{ct}_id"} = "";
- $SIG{INT} = 'IGNORE';
- }
- else {
- $form->{"statement_1"} = 1;
- $form->{"language_code_1"} = $language_code;
- $form->{"curr_1"} = $curr;
+
+ my $template = LedgerSMB::Template->new(
+ user => \%myconfig,
+ template => $form->{'formname'} || $form->{'type'},
+ format => uc $form->{format}
+ );
+ try {
+ $template->render({data => \@batch_data});
+ $template->output($form);
}
-
- RP->aging( \%myconfig, \%$form );
-
- &print_form;
+ catch Error::Simple with {
+ my $E = shift;
+ $form->error( $E->stacktrace );
+ };
$form->redirect( $locale->text('Statements sent to printer!') )
if ( $form->{media} !~ /(screen|email)/ );
@@ -2276,18 +2295,11 @@ sub print_form {
$form->format_amount( \%myconfig, $form->{"${_}total"},
2 );
}
+
+ my $printhash = {};
+ for (keys %$form) { $printhash->{$_} = $form->{$_}}
- my $template = LedgerSMB::Template->new( user => \%myconfig,
- template => $form->{'formname'} || $form->{'type'},
- format => uc $form->{format} );
- try {
- $template->render($form);
- $template->output(%{$form});
- }
- catch Error::Simple with {
- my $E = shift;
- $form->error( $E->stacktrace );
- };
+ return $printhash;
}
}
}
diff --git a/templates/demo/statement.html b/templates/demo/statement.html
index 6bdee5d1..bc6ccc1e 100644
--- a/templates/demo/statement.html
+++ b/templates/demo/statement.html
@@ -1,6 +1,9 @@
<body bgcolor=ffffff>
+<?lsmb FOREACH customer IN data ?>
+<?lsmb import(customer) ?>
+
<table width="100%">
<?lsmb INCLUDE letterhead.html ?>
@@ -133,6 +136,7 @@
</table>
+<?lsmb END ?>
</body>
</html>
diff --git a/templates/demo/statement.tex b/templates/demo/statement.tex
index b6580af6..8bfe6240 100644
--- a/templates/demo/statement.tex
+++ b/templates/demo/statement.tex
@@ -7,6 +7,8 @@
\begin{document}
+<?lsmb FOREACH customer IN data ?>
+<?lsmb import(customer) ?>
\pagestyle{myheadings}
\thispagestyle{empty}
@@ -82,5 +84,9 @@ All amounts in \textbf{<?lsmb currency ?>} funds.
Please make check payable to \textbf{<?lsmb company ?>}
+<?lsmb IF NOT loop.last ?>
+\pagebreak
+<?lsmb END ?>
+<?lsmb END ?>
\end{document}
<?lsmb END ?>