[freeside-commits] freeside/FS/FS cust_main.pm, 1.531, 1.532 cust_bill.pm, 1.288, 1.289

Ivan,,, ivan at wavetail.420.am
Mon Aug 9 23:28:42 PDT 2010


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv32326/FS/FS

Modified Files:
	cust_main.pm cust_bill.pm 
Log Message:
add logo_file support to welcome_letter and fix leaving temp files around for invoices and letters, RT#9497

Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.531
retrieving revision 1.532
diff -u -w -d -r1.531 -r1.532
--- cust_main.pm	9 Aug 2010 16:20:39 -0000	1.531
+++ cust_main.pm	10 Aug 2010 06:28:39 -0000	1.532
@@ -8937,6 +8937,7 @@
 
 =cut
 
+# a lot like cust_bill::print_latex
 sub generate_letter {
   my ($self, $template, %options) = @_;
 
@@ -9000,6 +9001,17 @@
   $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 @@
   $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 @@
 
 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

Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.288
retrieving revision 1.289
diff -u -w -d -r1.288 -r1.289
--- cust_bill.pm	28 Jun 2010 04:11:47 -0000	1.288
+++ cust_bill.pm	10 Aug 2010 06:28:40 -0000	1.289
@@ -3039,6 +3039,7 @@
 
   my ($file, $lfile) = $self->print_latex(@_);
   my $ps = generate_ps($file);
+  unlink($file.'.tex');
   unlink($lfile);
 
   $ps;
@@ -3067,6 +3068,7 @@
 
   my ($file, $lfile) = $self->print_latex(@_);
   my $pdf = generate_pdf($file);
+  unlink($file.'.tex');
   unlink($lfile);
 
   $pdf;



More information about the freeside-commits mailing list