1 <% include("/elements/header.html", "Edit $type2desc{$type} invoice logo",
3 'View all invoice templates' => $p.'browse/invoice_template.html'
9 <FONT SIZE="+1" COLOR="#ff0000">Error: <% $error %></FONT>
13 % if ( $cgi->param('msg') ) {
14 <FONT SIZE="+1"><B><% $cgi->param('msg') |h %></B></FONT>
18 % if ( $mode eq 'upload' ) {
19 <FORM ACTION="invoice_logo.html" METHOD="POST" ENCTYPE="multipart/form-data">
20 <INPUT TYPE="hidden" NAME="mode" VALUE="preview">
21 % } elsif ( $mode eq 'preview' ) {
22 <FORM ACTION="process/invoice_logo.html" METHOD="POST">
23 <INPUT TYPE="hidden" NAME="preview_session" VALUE="<% $session %>">
26 <INPUT TYPE="hidden" NAME="type" VALUE="<% $type %>">
27 <INPUT TYPE="hidden" NAME="name" VALUE="<% $name %>">
29 <% include('/elements/table-grid.html') %>
32 <TH CLASS="grid" BGCOLOR="#cccccc">Current logo</TH>
33 <TH CLASS="grid" BGCOLOR="#cccccc">New logo preview</TH>
38 <TD CLASS="grid" BGCOLOR="#ffffff">
40 % if ( $type eq 'png' ) {
42 <IMG SRC="<% $p %>view/logo.cgi?type=png;name=<% $name %>">
44 % } elsif ( $type eq 'eps' ) {
46 <i>EPS preview not yet supported</i>
52 <TD CLASS="grid" BGCOLOR="#ffffff">
54 % if ( $mode eq 'upload' ) {
56 Upload new logo (.<%uc($type)%> format): <INPUT TYPE="file" NAME="new_logo">
57 <BR><INPUT TYPE="submit" NAME="submit" VALUE="Upload">
59 % } elsif ( $mode eq 'preview' ) {
61 <IMG SRC="<% $p %>view/logo.cgi?type=png;preview_session=<% $session %>">
72 % if ( $mode eq 'preview' ) {
74 <INPUT TYPE="submit" NAME="submit" VALUE="Change logo">
79 <% include("/elements/footer.html") %>
85 'eps' => 'Print/PDF (typeset)',
92 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
94 my $conf = new FS::Conf;
96 my $type = $cgi->param('type');
98 $cgi->param('name') =~ /^([^\.\/]*)$/ or die "illegal name";
101 $cgi->param('mode') =~ /^(\w*)$/ or die "illegal mode";
102 my $mode = $1 || 'upload';
106 if ( $mode eq 'preview' ) {
108 my $fh = $cgi->upload('new_logo');
113 my $logo_data = <$fh>;
115 $session = int(rand(4294967296)); #XXX
116 my $pref = new FS::access_user_pref({
117 'usernum' => $FS::CurrentUser::CurrentUser->usernum,
118 'prefname' => "logo_preview$session",
119 'prefvalue' => encode_base64($logo_data),
120 'expiration' => time + 3600, #1h? 1m?
122 my $pref_error = $pref->insert;
124 die "FATAL: couldn't set preview cookie: $pref_error\n";
130 $error = 'No file uploaded';