Option to ignore old CDRs, RT#81480
[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('View quotations')
7       or $FS::CurrentUser::CurrentUser->access_right('Configuration');
8
9 my $conf;
10
11 my $templatename;
12 my $agentnum = '';
13 if ( $cgi->param('invnum') =~ /^(\d+)$/ ) {
14   my $invnum = $1; 
15   $templatename = $cgi->param('template') || $cgi->param('templatename');
16   my $cust_bill = FS::cust_bill->by_key($invnum)
17                || FS::cust_bill_void->by_key($invnum)
18                || die 'unknown invnum';
19   $conf = $cust_bill->conf;
20   $agentnum = $cust_bill->cust_main->agentnum;
21 } elsif ( $cgi->param('quotationnum') =~ /^(\d+)$/ ) {
22   my $quotationnum = $1; 
23   my $quotation = FS::quotation->by_key($quotationnum)
24     or die 'unknown quotationnum';
25   $conf = $quotation->conf;
26   $agentnum = $quotation->agentnum;
27 } else {
28   # assume the default config
29   $conf = FS::Conf->new;
30   my($query) = $cgi->keywords;
31   $query =~ /^([^\.\/]*)$/ or die 'illegal query';
32   $templatename = $1;
33 }
34
35 if ( $templatename && $conf->exists("logo_$templatename.png") ) {
36   $templatename = "_$templatename";
37 } else {
38   $templatename = '';
39 }
40
41 http_header('Content-Type' => 'image/png' );
42
43 </%init>