self-service interface: move from text to html invoices
authorivan <ivan>
Wed, 9 Aug 2006 06:34:26 +0000 (06:34 +0000)
committerivan <ivan>
Wed, 9 Aug 2006 06:34:26 +0000 (06:34 +0000)
FS/FS/ClientAPI/MyAccount.pm
fs_selfservice/FS-SelfService/SelfService.pm
fs_selfservice/FS-SelfService/cgi/cust_bill-logo.cgi [new file with mode: 0644]
fs_selfservice/FS-SelfService/cgi/view_invoice.html

index 4b67f53..163718e 100644 (file)
@@ -414,10 +414,37 @@ sub invoice {
   return { 'error'        => '',
            'invnum'       => $invnum,
            'invoice_text' => join('', $cust_bill->print_text ),
   return { 'error'        => '',
            'invnum'       => $invnum,
            'invoice_text' => join('', $cust_bill->print_text ),
+           'invoice_html' => $cust_bill->print_html,
          };
 
 }
 
          };
 
 }
 
+sub invoice_logo {
+  my $p = shift;
+
+  #sessioning for this?  how do we get the session id to the backend invoice
+  # template so it can add it to the link, blah
+
+  my $templatename = $p->{'templatename'};
+
+  #false laziness-ish w/view/cust_bill-logo.cgi
+
+  my $conf = new FS::Conf;
+  if ( $templatename =~ /^([^\.\/]*)$/ && $conf->exists("logo_$1.png") ) {
+    $templatename = "_$1";
+  } else {
+    $templatename = '';
+  }
+
+  my $filename = "logo$templatename.png";
+
+  return { 'error'        => '',
+           'logo'         => $conf->config_binary($filename),
+           'content_type' => 'image/png', #should allow gif, jpg too
+         };
+}
+
+
 sub list_invoices {
   my $p = shift;
   my $session = _cache->get($p->{'session_id'})
 sub list_invoices {
   my $p = shift;
   my $session = _cache->get($p->{'session_id'})
index bfce128..16ca48e 100644 (file)
@@ -27,6 +27,7 @@ $socket .= '.'.$tag if defined $tag && length($tag);
   'customer_info'        => 'MyAccount/customer_info',
   'edit_info'            => 'MyAccount/edit_info',     #add to ss cgi!
   'invoice'              => 'MyAccount/invoice',
   'customer_info'        => 'MyAccount/customer_info',
   'edit_info'            => 'MyAccount/edit_info',     #add to ss cgi!
   'invoice'              => 'MyAccount/invoice',
+  'invoice_logo'         => 'MyAccount/invoice_logo',
   'list_invoices'        => 'MyAccount/list_invoices', #?
   'cancel'               => 'MyAccount/cancel',        #add to ss cgi!
   'payment_info'         => 'MyAccount/payment_info',
   'list_invoices'        => 'MyAccount/list_invoices', #?
   'cancel'               => 'MyAccount/cancel',        #add to ss cgi!
   'payment_info'         => 'MyAccount/payment_info',
diff --git a/fs_selfservice/FS-SelfService/cgi/cust_bill-logo.cgi b/fs_selfservice/FS-SelfService/cgi/cust_bill-logo.cgi
new file mode 100644 (file)
index 0000000..bf82a87
--- /dev/null
@@ -0,0 +1,18 @@
+#!/usr/bin/perl -Tw
+
+use strict;
+use CGI;
+use FS::SelfService qw( invoice_logo );
+
+$cgi = new CGI;
+
+my($query) = $cgi->keywords;
+$query =~ /^([^\.\/]*)$/ or '' =~ /^()$/;
+my $templatename = $1;
+invoice_logo($templatename);
+
+print $cgi->header( '-type'    => $content_type,
+                    '-expires' => 'now',
+                  ).
+      $logo;
+
index 72d0619..ad2f4f4 100644 (file)
@@ -4,9 +4,7 @@
 <%= include('myaccount_menu') %>
 <TD VALIGN="top">
 
 <%= include('myaccount_menu') %>
 <TD VALIGN="top">
 
-<FONT SIZE="-1"><PRE>
-<%= $invoice_text %>
-</FONT></PRE>
+<%= $invoice_html %>
 
 </TD></TR></TABLE>
 <HR>
 
 </TD></TR></TABLE>
 <HR>