X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fview%2Fcust_bill-logo.cgi;h=85b5d720f00a8d0fd2d8d85035fff4601c9f098d;hp=fd6a81a75ce446a1a2d3ecfa9938c9a45864f2cf;hb=b71b1576c68bc40ad26592b354feace37a029f0e;hpb=c8cccb4a92adceb943c635fe62dad0d034462ce0 diff --git a/httemplate/view/cust_bill-logo.cgi b/httemplate/view/cust_bill-logo.cgi index fd6a81a75..85b5d720f 100755 --- a/httemplate/view/cust_bill-logo.cgi +++ b/httemplate/view/cust_bill-logo.cgi @@ -1,16 +1,43 @@ -% -% -%my $conf = new FS::Conf; -% -%my($query) = $cgi->keywords; -%$query =~ /^([^\.\/]*)$/; -%my $templatename = $1; -%if ( $templatename && $conf->exists("logo_$templatename.png") ) { -% $templatename = "_$templatename"; -%} else { -% $templatename = ''; -%} -% -%http_header('Content-Type' => 'image/png' ); -% -<% $conf->config_binary("logo$templatename.png") %> +<% $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('View quotations') + 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'; + $conf = $cust_bill->conf; + $agentnum = $cust_bill->cust_main->agentnum; +} elsif ( $cgi->param('quotationnum') =~ /^(\d+)$/ ) { + my $quotationnum = $1; + my $quotation = FS::quotation->by_key($quotationnum) + or die 'unknown quotationnum'; + $conf = $quotation->conf; + $agentnum = $quotation->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' ); + +