ad2ff5430937d586e041e487e2c3ebbb7e5d5caa
[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 = new FS::Conf;
9
10 my $templatename;
11 my $agentnum = '';
12 if ( $cgi->param('invnum') ) {
13   $templatename = $cgi->param('template') || $cgi->param('templatename');
14   my $cust_bill = qsearchs('cust_bill', { 'invnum' => $cgi->param('invnum') } )
15     or die 'unknown invnum';
16   $agentnum = $cust_bill->cust_main->agentnum;
17 } else {
18   my($query) = $cgi->keywords;
19   $query =~ /^([^\.\/]*)$/ or die 'illegal query';
20   $templatename = $1;
21 }
22
23 if ( $templatename && $conf->exists("logo_$templatename.png") ) {
24   $templatename = "_$templatename";
25 } else {
26   $templatename = '';
27 }
28
29 http_header('Content-Type' => 'image/png' );
30
31 </%init>