summaryrefslogtreecommitdiff
path: root/httemplate/view/cust_bill-logo.cgi
blob: dc8b674ecf69d3ef2aa9702fe0badfc2cfb589e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<% $conf->config_binary("logo$templatename.png", $agentnum) %>
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('View invoices')
      or $FS::CurrentUser::CurrentUser->access_right('Configuration');

my $conf;

my $templatename;
my $agentnum = '';
if ( $cgi->param('invnum') =~ /^(\d+)$/ ) {
  my $invnum = $1; 
  $templatename = $cgi->param('template') || $cgi->param('templatename');
  my $cust_bill = FS::cust_bill->by_key($invnum)
               || FS::cust_bill_void->by_key($invnum);
  die 'unknown invnum' unless $cust_bill;
  $conf = $cust_bill->conf;
  $agentnum = $cust_bill->cust_main->agentnum;
} else {
  # assume the default config
  $conf = FS::Conf->new;
  my($query) = $cgi->keywords;
  $query =~ /^([^\.\/]*)$/ or die 'illegal query';
  $templatename = $1;
}

if ( $templatename && $conf->exists("logo_$templatename.png") ) {
  $templatename = "_$templatename";
} else {
  $templatename = '';
}

http_header('Content-Type' => 'image/png' );

</%init>