self-service interface: move from text to html invoices
[freeside.git] / FS / FS / ClientAPI / MyAccount.pm
index 45c2eb0..163718e 100644 (file)
@@ -27,7 +27,7 @@ use vars qw( @cust_main_editable_fields );
     county state zip country daytime night fax
   ship_first ship_last ship_company ship_address1 ship_address2 ship_city
     ship_state ship_zip ship_country ship_daytime ship_night ship_fax
-  payby payinfo payname
+  payby payinfo payname paystart_month paystart_year payissue payip
 );
 
 use subs qw(_provision);
@@ -226,6 +226,8 @@ sub payment_info {
       'MasterCard' => 'MasterCard',
       'Discover' => 'Discover card',
       'American Express' => 'American Express card',
+      'Switch' => 'Switch',
+      'Solo' => 'Solo',
     },
 
   };
@@ -341,7 +343,8 @@ sub process_payment {
     'payname'  => $payname,
     'paybatch' => $paybatch,
     'paycvv'   => $paycvv,
-    map { $_ => $p->{$_} } qw( address1 address2 city state zip )
+    map { $_ => $p->{$_} } qw( paystart_month paystart_year payissue payip
+                               address1 address2 city state zip )
   );
   return { 'error' => $error } if $error;
 
@@ -350,7 +353,8 @@ sub process_payment {
   if ( $p->{'save'} ) {
     my $new = new FS::cust_main { $cust_main->hash };
     $new->set( $_ => $p->{$_} )
-      foreach qw( payname address1 address2 city state zip payinfo );
+      foreach qw( payname paystart_month paystart_year payissue payip
+                  address1 address2 city state zip payinfo );
     $new->set( 'paydate' => $p->{'year'}. '-'. $p->{'month'}. '-01' );
     $new->set( 'payby' => $p->{'auto'} ? 'CARD' : 'DCRD' );
     my $error = $new->replace($cust_main);
@@ -410,10 +414,37 @@ sub invoice {
   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'})