ticket 1568 config options for new echeck fields and addition to selfservice interface
[freeside.git] / fs_selfservice / FS-SelfService / cgi / signup.cgi
index d2ad0d6..e07b6ee 100755 (executable)
@@ -1,7 +1,5 @@
 #!/usr/bin/perl -T
 #!/usr/bin/perl -Tw
-#
-# $Id: signup.cgi,v 1.2 2005-03-12 14:35:12 ivan Exp $
 
 use strict;
 use vars qw( @payby $cgi $init_data
@@ -151,6 +149,14 @@ if (    ( defined($cgi->param('magic')) && $cgi->param('magic') eq 'process' )
                               ? $cgi->param( $payby. '_paycvv' )
                               : ''
                );
+    $cgi->param('paytype' => defined $cgi->param( $payby. '_paytype' )
+                              ? $cgi->param( $payby. '_paytype' )
+                              : ''
+               );
+    $cgi->param('paystate' => defined $cgi->param( $payby. '_paystate' )
+                              ? $cgi->param( $payby. '_paystate' )
+                              : ''
+               );
 
     if ( $cgi->param('invoicing_list') ) {
       $cgi->param('invoicing_list' => $cgi->param('invoicing_list'). ', POST')
@@ -178,24 +184,30 @@ if (    ( defined($cgi->param('magic')) && $cgi->param('magic') eq 'process' )
         or $error ||= $init_data->{msgcat}{not_a}. $cgi->param('CARD_type');
     }
 
+    if ($init_data->{emailinvoiceonly} && (length $cgi->param('invoicing_list') < 1)) {
+       $error ||= $init_data->{msgcat}{illegal_or_empty_text};
+    }
+
     unless ( $error ) {
       my $rv = new_customer( {
-        map { $_ => scalar($cgi->param($_)) }
-          qw( last first ss company
-              address1 address2 city county state zip country
-              daytime night fax
-
-              ship_last ship_first ship_company
-              ship_address1 ship_address2 ship_city ship_county ship_state
-                ship_zip ship_country
-              ship_daytime ship_night ship_fax
-
-              payby payinfo paycvv paydate payname invoicing_list
-              referral_custnum promo_code reg_code
-              pkgpart username sec_phrase _password popnum refnum
-              agentnum
-            ),
-          grep { /^snarf_/ } $cgi->param
+        ( map { $_ => scalar($cgi->param($_)) }
+            qw( last first ss company
+                address1 address2 city county state zip country
+                daytime night fax stateid stateid_state
+
+                ship_last ship_first ship_company
+                ship_address1 ship_address2 ship_city ship_county ship_state
+                  ship_zip ship_country
+                ship_daytime ship_night ship_fax
+
+                payby payinfo paycvv paydate payname paystate paytype
+                invoicing_list referral_custnum promo_code reg_code
+                pkgpart username sec_phrase _password popnum refnum
+                agentnum
+              ),
+            grep { /^snarf_/ } $cgi->param
+        ),
+        'payip' => $cgi->remote_host(),
       } );
       $error = $rv->{'error'};
     }
@@ -229,6 +241,8 @@ sub print_form {
     'error' => $error,
   };
 
+  $r->{pkgpart} ||= $r->{default_pkgpart};
+
   $r->{referral_custnum} = $r->{'ref'};
   #$cgi->delete('ref');
   #$cgi->delete('init_popstate');
@@ -276,9 +290,10 @@ sub print_okay {
   }
 
   #global for template
-  my $pkg = ( grep { $_->{'pkgpart'} eq $param{'pkgpart'} }
-                   @{ $init_data->{'part_pkg'} }
-            )[0]->{'pkg'};
+  my $part_pkg = ( grep { $_->{'pkgpart'} eq $param{'pkgpart'} }
+                        @{ $init_data->{'part_pkg'} }
+                 )[0];
+  my $pkg =  $part_pkg->{'pkg'};
 
   if ( $ieak_template && $user_agent->windows && $user_agent->ie ) {
     #send an IEAK config
@@ -295,6 +310,7 @@ sub print_okay {
             exch       => $exch,
             loc        => $loc,
             pkg        => $pkg,
+            part_pkg   => \$part_pkg,
           });
   }
 }