agent-specific logos for html invoices too
authorivan <ivan>
Thu, 9 Jun 2005 06:56:31 +0000 (06:56 +0000)
committerivan <ivan>
Thu, 9 Jun 2005 06:56:31 +0000 (06:56 +0000)
FS/FS/cust_bill.pm
conf/invoice_html
httemplate/view/cust_bill-logo.cgi

index a603310..7d10411 100644 (file)
@@ -414,10 +414,18 @@ sub generate_email {
     $args{'from'} =~ /\@([\w\.\-]+)/ or $1 = 'example.com';
     my $content_id = join('.', rand()*(2**32), $$, time). "\@$1";
 
+    my $path = "$FS::UID::conf_dir/conf.$FS::UID::datasrc";
+    my $file;
+    if ( [ -e "$path/logo_". $args{'_template'}. ".png" ] ) {
+      $file = "$path/logo_". $args{'_template'}. ".png";
+    } else {
+      $file = "$path/logo.png";
+    }
+
     my $image = build MIME::Entity
       'Type'       => 'image/png',
       'Encoding'   => 'base64',
-      'Path'       => "$FS::UID::conf_dir/conf.$FS::UID::datasrc/logo.png",
+      'Path'       => $file,
       'Filename'   => 'logo.png',
       'Content-ID' => "<$content_id>",
     ;
@@ -1760,6 +1768,7 @@ sub print_html {
     'terms'        => $conf->config('invoice_default_terms')
                       || 'Payable upon receipt',
     'cid'          => $cid,
+    'template'     => $template,
 #    'conf_dir'     => "$FS::UID::conf_dir/conf.$FS::UID::datasrc",
   );
 
index e4e145e..32e5362 100644 (file)
@@ -14,7 +14,7 @@
 
   <table class="invoice_header" width="100%">
     <tr>
-     <td><img src="<%= $cid ? "cid:$cid" : 'cust_bill-logo.cgi' %>"></td>
+     <td><img src="<%= $cid ? "cid:$cid" : "cust_bill-logo.cgi?$template" %>"></td>
      <td align="left"><%= $returnaddress %></td>
       <td align="right">
         <table CLASS="invoice_headerright" cellspacing=0>
index 3e9c67f..50812ea 100755 (executable)
@@ -1,12 +1,9 @@
 <%
 
-##untaint invnum
-#my($query) = $cgi->keywords;
-#$query =~ /^((.+)-)?(\d+)$/;
-#my $templatename = $2;
-#my $invnum = $3;
-
-my $templatename = '';
+my($query) = $cgi->keywords;
+$query =~ /^([^\.\/]*)$/;
+my $templatename = $1;
+$templatename = "_$templatename" if $templatename;
 
 my $conf = new FS::Conf;
 http_header('Content-Type' => 'image/png' );