summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2010-08-10 06:28:40 +0000
committerivan <ivan>2010-08-10 06:28:40 +0000
commit1ec723c2b944c08c32362d05cefe8b332c80276d (patch)
tree1266ed1e51f636bd985d7c778390c44b85c9188c
parenta416f179e995b0d4f53e8c58e9904f31371a938b (diff)
add logo_file support to welcome_letter and fix leaving temp files around for invoices and letters, RT#9497
-rw-r--r--FS/FS/cust_bill.pm2
-rw-r--r--FS/FS/cust_main.pm23
-rw-r--r--conf/welcome_letter4
3 files changed, 24 insertions, 5 deletions
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 4bd9aa1..3e7109e 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -3039,6 +3039,7 @@ sub print_ps {
my ($file, $lfile) = $self->print_latex(@_);
my $ps = generate_ps($file);
+ unlink($file.'.tex');
unlink($lfile);
$ps;
@@ -3067,6 +3068,7 @@ sub print_pdf {
my ($file, $lfile) = $self->print_latex(@_);
my $pdf = generate_pdf($file);
+ unlink($file.'.tex');
unlink($lfile);
$pdf;
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 955daf8..e107e6c 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -8937,6 +8937,7 @@ I<$returnaddress> - the return address defaults to invoice_latexreturnaddress or
=cut
+# a lot like cust_bill::print_latex
sub generate_letter {
my ($self, $template, %options) = @_;
@@ -9000,6 +9001,17 @@ sub generate_letter {
$letter_data{company_name} = $conf->config('company_name', $self->agentnum);
my $dir = $FS::UID::conf_dir."/cache.". $FS::UID::datasrc;
+
+ my $lh = new File::Temp( TEMPLATE => 'letter.'. $self->custnum. '.XXXXXXXX',
+ DIR => $dir,
+ SUFFIX => '.eps',
+ UNLINK => 0,
+ ) or die "can't open temp file: $!\n";
+ print $lh $conf->config_binary('logo.eps', $self->agentnum)
+ or die "can't write temp file: $!\n";
+ close $lh;
+ $letter_data{'logo_file'} = $lh->filename;
+
my $fh = new File::Temp( TEMPLATE => 'letter.'. $self->custnum. '.XXXXXXXX',
DIR => $dir,
SUFFIX => '.tex',
@@ -9009,7 +9021,8 @@ sub generate_letter {
$letter_template->fill_in( OUTPUT => $fh, HASH => \%letter_data );
close $fh;
$fh->filename =~ /^(.*).tex$/ or die "unparsable filename: ". $fh->filename;
- return $1;
+ return ($1, $letter_data{'logo_file'});
+
}
=item print_ps TEMPLATE
@@ -9020,8 +9033,12 @@ Returns an postscript letter filled in from TEMPLATE, as a scalar.
sub print_ps {
my $self = shift;
- my $file = $self->generate_letter(@_);
- FS::Misc::generate_ps($file);
+ my($file, $lfile) = $self->generate_letter(@_);
+ my $ps = FS::Misc::generate_ps($file);
+ unlink($file.'.tex');
+ unlink($lfile);
+
+ $ps;
}
=item print TEMPLATE
diff --git a/conf/welcome_letter b/conf/welcome_letter
index be7b484..b95a715 100644
--- a/conf/welcome_letter
+++ b/conf/welcome_letter
@@ -67,7 +67,7 @@
\returninset
\makebox{
\begin{tabular}{ll}
- \includegraphics{[@-- $conf_dir --@]/logo.eps} &
+ \includegraphics{[@-- $logo_file --@]} &
\begin{minipage}[b]{5.5cm}
[@-- $returnaddress --@]
\end{minipage}
@@ -75,7 +75,7 @@
}
}
{ % ... pages
- %\includegraphics{[@-- $conf_dir --@]/logo.eps} % Uncomment if you want the logo on all pages.
+ %\includegraphics{[@-- $logo_file --@]} % Uncomment if you want the logo on all pages.
}
}