use HTML::Entities;
use Locale::Country;
use FS::UID qw( datasrc );
-use FS::Misc qw( send_email send_fax generate_ps do_print );
+use FS::Misc qw( send_email send_fax generate_ps generate_pdf do_print );
use FS::Record qw( qsearch qsearchs dbh );
use FS::cust_main_Mixin;
use FS::cust_main;
'footer' => sub { map "$_", @_ },
'smallfooter' => sub { map "$_", @_ },
'returnaddress' => sub { map "$_", @_ },
+ 'coupon' => sub { map "$_", @_ },
},
'html' => {
'notes' =>
$_;
} @_
},
+ 'coupon' => sub { "" },
},
'template' => {
'notes' =>
$_;
} @_
},
+ 'coupon' => sub { "" },
},
);
push @address, ''
while (scalar(@address) < 5);
+ $invoice_data{'logo_file'} = $params{'logo_file'}
+ if $params{'logo_file'};
+
+ my( $pr_total, @pr_cust_bill ) = $self->previous; #previous balance
+# my( $cr_total, @cr_cust_credit ) = $self->cust_credit; #credits
+ #my $balance_due = $self->owed + $pr_total - $cr_total;
+ my $balance_due = $self->owed + $pr_total;
+ $invoice_data{'balance'} = $balance_due;
+
#do variable substitution in notes, footer, smallfooter
- foreach my $include (qw( notes footer smallfooter )) {
+ foreach my $include (qw( notes footer smallfooter coupon )) {
my $inc_file = $conf->key_orbase("invoice_${format}$include", $template);
my @inc_src;
? &$escape_function("Purchase Order #". $cust_main->payinfo)
: $nbsp;
- my( $pr_total, @pr_cust_bill ) = $self->previous; #previous balance
-# my( $cr_total, @cr_cust_credit ) = $self->cust_credit; #credits
- #my $balance_due = $self->owed + $pr_total - $cr_total;
- my $balance_due = $self->owed + $pr_total;
-
my %money_chars = ( 'latex' => '',
'html' => $conf->config('money_char') || '$',
'template' => '',
}
}
- $invoice_data{'logo_file'} = $params{'logo_file'}
- if $params{'logo_file'};
-
$invoice_lines = 0;
my $wasfunc = 0;
foreach ( grep /invoice_lines\(\d*\)/, @invoice_template ) { #kludgy
my ($file, $lfile) = $self->print_latex(@_);
my $ps = generate_ps($file);
unlink($lfile);
- $ps;
+ $ps;
}
=item print_pdf [ TIME [ , TEMPLATE ] ]
my $self = shift;
my ($file, $lfile) = $self->print_latex(@_);
+ my $pdf = generate_pdf($file);
+ unlink($lfile);
- my $dir = $FS::UID::conf_dir. "/cache.". $FS::UID::datasrc;
- chdir($dir);
-
- #system('pdflatex', "$file.tex");
- #system('pdflatex', "$file.tex");
- #! LaTeX Error: Unknown graphics extension: .eps.
-
- my $sfile = shell_quote $file;
-
- system("pslatex $sfile.tex >/dev/null 2>&1") == 0
- or die "pslatex $file.tex failed; see $file.log for details?\n";
- system("pslatex $sfile.tex >/dev/null 2>&1") == 0
- or die "pslatex $file.tex failed; see $file.log for details?\n";
-
- #system('dvipdf', "$file.dvi", "$file.pdf" );
- system(
- "dvips -q -t letter -f $sfile.dvi ".
- "| gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$sfile.pdf ".
- " -c save pop -"
- ) == 0
- or die "dvips | gs failed: $!";
-
- open(PDF, "<$file.pdf")
- or die "can't open $file.pdf: $! (error in LaTeX template?)\n";
-
- unlink("$file.dvi", "$file.log", "$file.aux", "$file.pdf", "$file.tex");
- unlink("$lfile");
-
- my $pdf = '';
- while (<PDF>) {
- $pdf .= $_;
- }
-
- close PDF;
-
- return $pdf;
-
+ $pdf;
}
=item print_html [ TIME [ , TEMPLATE [ , CID ] ] ]