% include("/elements/header.html", "Edit $type2desc{$type} invoice logo",
menubar(
'View all invoice templates' => $p.'browse/invoice_template.html'
)
)
%>
% if ( $error ) {
Error: <% $error %>
% }
% if ( $cgi->param('msg') ) {
<% $cgi->param('msg') |h %>
% }
% if ( $mode eq 'upload' ) {
<% include("/elements/footer.html") %>
<%once>
my %type2desc = (
'png' => 'online',
'eps' => 'Print/PDF (typeset)',
);
%once>
<%init>
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
my $conf = new FS::Conf;
my $type = $cgi->param('type');
$cgi->param('name') =~ /^([^\.\/]*)$/ or die "illegal name";
my $name = $1;
$cgi->param('mode') =~ /^(\w*)$/ or die "illegal mode";
my $mode = $1 || 'upload';
my $error = '';
my $session = '';
if ( $mode eq 'preview' ) {
my $fh = $cgi->upload('new_logo');
if ( defined $fh ) {
local $/;
my $logo_data = <$fh>;
$session = int(rand(4294967296)); #XXX
my $pref = new FS::access_user_pref({
'usernum' => $FS::CurrentUser::CurrentUser->usernum,
'prefname' => "logo_preview$session",
'prefvalue' => encode_base64($logo_data),
'expiration' => time + 3600, #1h? 1m?
});
my $pref_error = $pref->insert;
if ( $pref_error ) {
die "FATAL: couldn't set preview cookie: $pref_error\n";
}
} else {
$mode = 'upload';
$error = 'No file uploaded';
}
}
%init>