clean up all temp files!
[freeside.git] / FS / FS / cust_bill.pm
index a5602a7..60eaac6 100644 (file)
@@ -941,17 +941,25 @@ sub print_latex {
     'zip'          => _latex_escape($cust_main->zip),
     'country'      => _latex_escape($cust_main->country),
     'footer'       => join("\n", $conf->config('invoice_latexfooter') ),
+    'smallfooter'  => $conf->config('invoice_latexsmallfooter'),
     'quantity'     => 1,
     'terms'        => $conf->config('invoice_default_terms') || 'Payable upon receipt',
-    'notes'        => join("\n", $conf->config('invoice_latexnotes') ),
+    #'notes'        => join("\n", $conf->config('invoice_latexnotes') ),
   );
 
-  $invoice_data{'footer'} =~ s/\n+$//;
-  $invoice_data{'notes'} =~ s/\n+$//;
-
   my $countrydefault = $conf->config('countrydefault') || 'US';
   $invoice_data{'country'} = '' if $invoice_data{'country'} eq $countrydefault;
 
+  #do variable substitutions in notes
+  $invoice_data{'notes'} =
+    join("\n",
+      map { my $b=$_; $b =~ s/\$(\w+)/$invoice_data{$1}/eg; $b }
+        $conf->config('invoice_latexnotes')
+    );
+
+  $invoice_data{'footer'} =~ s/\n+$//;
+  $invoice_data{'notes'} =~ s/\n+$//;
+
   $invoice_data{'po_line'} =
     (  $cust_main->payby eq 'BILL' && $cust_main->payinfo )
       ? _latex_escape("Purchase Order #". $cust_main->payinfo)
@@ -1101,9 +1109,7 @@ sub print_ps {
   open(POSTSCRIPT, "<$file.ps")
     or die "can't open $file.ps (probable error in LaTeX template): $!\n";
 
-  #rm $file.dvi $file.log $file.aux
-  unlink("$file.dvi", "$file.log", "$file.aux", "$file.ps");
-  #unlink("$file.dvi", "$file.log", "$file.aux");
+  unlink("$file.dvi", "$file.log", "$file.aux", "$file.ps", "$file.tex");
 
   my $ps = '';
   while (<POSTSCRIPT>) {
@@ -1146,7 +1152,7 @@ sub print_pdf {
   open(PDF, "<$file.pdf")
     or die "can't open $file.pdf (probably error in LaTeX tempalte: $!\n";
 
-  unlink("$file.dvi", "$file.log", "$file.aux", "$file.pdf");
+  unlink("$file.dvi", "$file.log", "$file.aux", "$file.pdf", "$file.tex");
 
   my $pdf = '';
   while (<PDF>) {