dc8b674ecf69d3ef2aa9702fe0badfc2cfb589e0
[freeside.git] / httemplate / view / cust_bill-logo.cgi
1 <% $conf->config_binary("logo$templatename.png", $agentnum) %>
2 <%init>
3
4 die "access denied"
5   unless $FS::CurrentUser::CurrentUser->access_right('View invoices')
6       or $FS::CurrentUser::CurrentUser->access_right('Configuration');
7
8 my $conf;
9
10 my $templatename;
11 my $agentnum = '';
12 if ( $cgi->param('invnum') =~ /^(\d+)$/ ) {
13   my $invnum = $1; 
14   $templatename = $cgi->param('template') || $cgi->param('templatename');
15   my $cust_bill = FS::cust_bill->by_key($invnum)
16                || FS::cust_bill_void->by_key($invnum);
17   die 'unknown invnum' unless $cust_bill;
18   $conf = $cust_bill->conf;
19   $agentnum = $cust_bill->cust_main->agentnum;
20 } else {
21   # assume the default config
22   $conf = FS::Conf->new;
23   my($query) = $cgi->keywords;
24   $query =~ /^([^\.\/]*)$/ or die 'illegal query';
25   $templatename = $1;
26 }
27
28 if ( $templatename && $conf->exists("logo_$templatename.png") ) {
29   $templatename = "_$templatename";
30 } else {
31   $templatename = '';
32 }
33
34 http_header('Content-Type' => 'image/png' );
35
36 </%init>