fix self-service agent-specific logos
authorivan <ivan>
Mon, 13 Jul 2009 09:19:03 +0000 (09:19 +0000)
committerivan <ivan>
Mon, 13 Jul 2009 09:19:03 +0000 (09:19 +0000)
FS/FS/ClientAPI/MyAccount.pm
fs_selfservice/FS-SelfService/cgi/cust_bill-logo.cgi

index d297cf9..c643b36 100644 (file)
@@ -555,7 +555,14 @@ sub invoice_logo {
   #sessioning for this?  how do we get the session id to the backend invoice
   # template so it can add it to the link, blah
 
-  my $templatename = $p->{'templatename'};
+  my $agentnum = '';
+  if ( $p->{'invnum'} ) {
+    my $cust_bill = qsearchs('cust_bill', { 'invnum' => $p->{'invnum'} } )
+      or return { 'error' => 'unknown invnum' };
+    $agentnum = $cust_bill->cust_main->agentnum;
+  }
+
+  my $templatename = $p->{'template'} || $p->{'templatename'};
 
   #false laziness-ish w/view/cust_bill-logo.cgi
 
@@ -569,7 +576,7 @@ sub invoice_logo {
   my $filename = "logo$templatename.png";
 
   return { 'error'        => '',
-           'logo'         => $conf->config_binary($filename),
+           'logo'         => $conf->config_binary($filename, $agentnum),
            'content_type' => 'image/png', #should allow gif, jpg too
          };
 }
index 5f344a3..253f853 100644 (file)
@@ -7,10 +7,16 @@ use FS::SelfService qw( invoice_logo );
 
 my $cgi = new CGI;
 
-my($query) = $cgi->keywords;
-$query =~ /^([^\.\/]*)$/ or '' =~ /^()$/;
-my $templatename = $1;
-my $hashref = invoice_logo('templatename' => $templatename);
+my %hash = ();
+if ( $cgi->param('invnum') ) {
+  $hash{$_} = scalar($cgi->param($_)) foreach qw( invnum template );
+} else {
+  my($query) = $cgi->keywords;
+  $query =~ /^([^\.\/]*)$/ or '' =~ /^()$/;
+  $hash{'template'} = $1;
+}
+
+my $hashref = invoice_logo(%hash);
 
 print $cgi->header( '-type'    => $hashref->{'content_type'},
                     '-expires' => 'now',