add selfservice_server-single_domain config, and login_info self-service method to...
[freeside.git] / fs_selfservice / FS-SelfService / cgi / selfservice.cgi
index 36557b6..cd81aeb 100644 (file)
@@ -9,7 +9,7 @@ use Text::Template;
 use HTML::Entities;
 use Date::Format;
 use Number::Format 1.50;
 use HTML::Entities;
 use Date::Format;
 use Number::Format 1.50;
-use FS::SelfService qw( login customer_info edit_info invoice
+use FS::SelfService qw( login_info login customer_info edit_info invoice
                         payment_info process_payment 
                         process_prepay
                         list_pkgs order_pkg signup_info order_recharge
                         payment_info process_payment 
                         process_prepay
                         list_pkgs order_pkg signup_info order_recharge
@@ -28,7 +28,9 @@ $form_max = 255;
 $cgi = new CGI;
 
 unless ( defined $cgi->param('session') ) {
 $cgi = new CGI;
 
 unless ( defined $cgi->param('session') ) {
-  do_template('login',{});
+  my $login_info = login_info();
+
+  do_template('login', $login_info );
   exit;
 }
 
   exit;
 }
 
@@ -52,10 +54,12 @@ if ( $cgi->param('session') eq 'login' ) {
     'password' => $password,
   );
   if ( $rv->{error} ) {
     'password' => $password,
   );
   if ( $rv->{error} ) {
+    my $login_info = login_info();
     do_template('login', {
       'error'    => $rv->{error},
       'username' => $username,
       'domain'   => $domain,
     do_template('login', {
       'error'    => $rv->{error},
       'username' => $username,
       'domain'   => $domain,
+      %$login_info,
     } );
     exit;
   } else {
     } );
     exit;
   } else {
@@ -81,7 +85,10 @@ die $@ if $@;
 if ( $result->{error} eq "Can't resume session"
   || $result->{error} eq "Expired session" ) { #ick
 
 if ( $result->{error} eq "Can't resume session"
   || $result->{error} eq "Expired session" ) { #ick
 
-  do_template('login',{});
+  my $login_info = login_info();
+  use Data::Dumper;
+  warn Dumper($login_info);
+  do_template('login', $login_info);
   exit;
 }
 
   exit;
 }
 
@@ -140,7 +147,7 @@ sub _process_change_info {
 sub process_change_bill {
         _process_change_info( 'change_bill', 
           qw( first last company address1 address2 city state
 sub process_change_bill {
         _process_change_info( 'change_bill', 
           qw( first last company address1 address2 city state
-              county state zip country daytime night fax )
+              county zip country daytime night fax )
         );
 }
 
         );
 }
 
@@ -157,11 +164,22 @@ sub process_change_ship {
 }
 
 sub process_change_pay {
 }
 
 sub process_change_pay {
-        _process_change_info( 'change_pay', 
+        my $postal = $cgi->param( 'postal_invoicing' );
+        my @list =
           qw( payby payinfo payinfo1 payinfo2 month year payname
               address1 address2 city county state zip country auto paytype
           qw( payby payinfo payinfo1 payinfo2 month year payname
               address1 address2 city county state zip country auto paytype
-              paystate ss stateid stateid_state )
-        );
+              paystate ss stateid stateid_state invoicing_list
+            );
+        push @list, 'postal_invoicing' if $postal;
+        unless ( $postal || $cgi->param( 'invoicing_list' ) ) {
+          $action = 'change_pay';
+          return {
+            %{&change_pay()},
+            $cgi->Vars,
+            'error' => '<FONT COLOR="#FF0000">Postal or email required.</FONT>',
+          };
+        }
+        _process_change_info( 'change_pay', @list );
 }
 
 sub view_invoice {
 }
 
 sub view_invoice {
@@ -609,12 +627,16 @@ sub do_template {
   $fill_in->{'selfurl'} = $cgi->self_url;
   $fill_in->{'cgi'} = \$cgi;
 
   $fill_in->{'selfurl'} = $cgi->self_url;
   $fill_in->{'cgi'} = \$cgi;
 
-  my $template = new Text::Template( TYPE    => 'FILE',
-                                     SOURCE  => "$template_dir/$name.html",
+  my $source = "$template_dir/$name.html";
+  #warn "creating template for $source\n";
+  my $template = new Text::Template( TYPE       => 'FILE',
+                                     SOURCE     => $source,
                                      DELIMITERS => [ '<%=', '%>' ],
                                      DELIMITERS => [ '<%=', '%>' ],
-                                     UNTAINT => 1,                    )
+                                     UNTAINT    => 1,
+                                   )
     or die $Text::Template::ERROR;
 
     or die $Text::Template::ERROR;
 
+  #warn "filling in $template with $fill_in\n";
   print $cgi->header( '-expires' => 'now' ),
         $template->fill_in( PACKAGE => 'FS::SelfService::_selfservicecgi',
                             HASH    => $fill_in
   print $cgi->header( '-expires' => 'now' ),
         $template->fill_in( PACKAGE => 'FS::SelfService::_selfservicecgi',
                             HASH    => $fill_in