#!/usr/bin/perl -Tw
#
-# $Id: signup.cgi,v 1.13 2001-09-11 11:28:15 ivan Exp $
+# $Id: signup.cgi,v 1.16 2002-04-06 20:37:38 ivan Exp $
use strict;
use vars qw( @payby $cgi $locales $packages $pops $error
$last $first $ss $company $address1 $address2 $city $state $county
$country $zip $daytime $night $fax $invoicing_list $payby $payinfo
$paydate $payname $referral_custnum
- $pkgpart $username $password $popnum
+ $pkgpart $username $password $password2 $popnum
$ieak_file $ieak_template $cck_file $cck_template
$signup_html $signup_template $success_html $success_template
$ac $exch $loc
$invoicing_list = 'POST';
}
- $error = new_customer ( {
- 'last' => $last = $cgi->param('last'),
- 'first' => $first = $cgi->param('first'),
- 'ss' => $ss = $cgi->param('ss'),
- 'company' => $company = $cgi->param('company'),
- 'address1' => $address1 = $cgi->param('address1'),
- 'address2' => $address2 = $cgi->param('address2'),
- 'city' => $city = $cgi->param('city'),
- 'county' => $county,
- 'state' => $state,
- 'zip' => $zip = $cgi->param('zip'),
- 'country' => $country,
- 'daytime' => $daytime = $cgi->param('daytime'),
- 'night' => $night = $cgi->param('night'),
- 'fax' => $fax = $cgi->param('fax'),
- 'payby' => $payby,
- 'payinfo' => $payinfo,
- 'paydate' => $paydate,
- 'payname' => $payname,
- 'invoicing_list' => $invoicing_list,
- 'referral_custnum' => $referral_custnum = $cgi->param('ref'),
- 'pkgpart' => $pkgpart = $cgi->param('pkgpart'),
- 'username' => $username = $cgi->param('username'),
- '_password' => $password = $cgi->param('_password'),
- 'popnum' => $popnum = $cgi->param('popnum'),
- } );
+ $error = '';
+
+ if ( $cgi->param('_password') ne $cgi->param('_password2') ) {
+ $error = "Passwords don't match";
+ $password = '';
+ $password2 = '';
+ } else {
+ $password2 = $cgi->param('_password2');
+
+ $error = new_customer ( {
+ 'last' => $last = $cgi->param('last'),
+ 'first' => $first = $cgi->param('first'),
+ 'ss' => $ss = $cgi->param('ss'),
+ 'company' => $company = $cgi->param('company'),
+ 'address1' => $address1 = $cgi->param('address1'),
+ 'address2' => $address2 = $cgi->param('address2'),
+ 'city' => $city = $cgi->param('city'),
+ 'county' => $county,
+ 'state' => $state,
+ 'zip' => $zip = $cgi->param('zip'),
+ 'country' => $country,
+ 'daytime' => $daytime = $cgi->param('daytime'),
+ 'night' => $night = $cgi->param('night'),
+ 'fax' => $fax = $cgi->param('fax'),
+ 'payby' => $payby,
+ 'payinfo' => $payinfo,
+ 'paydate' => $paydate,
+ 'payname' => $payname,
+ 'invoicing_list' => $invoicing_list,
+ 'referral_custnum' => $referral_custnum = $cgi->param('ref'),
+ 'pkgpart' => $pkgpart = $cgi->param('pkgpart'),
+ 'username' => $username = $cgi->param('username'),
+ '_password' => $password = $cgi->param('_password'),
+ 'popnum' => $popnum = $cgi->param('popnum'),
+ } );
+
+ }
+
if ( $error ) {
print_form();
} else {
print_okay();
}
+
} else {
die "unrecognized magic: ". $cgi->param('magic');
}
$pkgpart = '';
$username = '';
$password = '';
+ $password2 = '';
$popnum = '';
$referral_custnum = $cgi->param('ref') || '';
print_form;
'';
}
+#horrible false laziness with FS/FS/svc_acct_pop.pm::popselector
+sub popselector {
+ my( $popnum, $state ) = @_;
+
+ my %pop = ();
+ push @{ $pop{$_->{state}} }, $_ foreach @$pops;
+
+ my $text = <<END;
+ <SCRIPT>
+ function opt(what,href,text) {
+ var optionName = new Option(text, href, false, false)
+ var length = what.length;
+ what.options[length] = optionName;
+ }
+
+ function popstate_changed(what) {
+ state = what.options[what.selectedIndex].text;
+ for (var i = what.form.popnum.length;i > 0;i--)
+ what.form.popnum.options[i] = null;
+ what.form.popnum.options[0] = new Option("", "", false, true);
+END
+
+ foreach my $popstate ( sort { $a cmp $b } keys %pop ) {
+ $text .= "\nif ( state == \"$popstate\" ) {\n";
+
+ foreach my $pop ( @{$pop{$popstate}}) {
+ my $o_popnum = $pop->{popnum};
+ my $poptext = $pop->{city}. ', '. $pop->{state}.
+ ' ('. $pop->{ac}. ')/'. $pop->{exch};
+
+ $text .= "opt(what.form.popnum, \"$o_popnum\", \"$poptext\");\n"
+ }
+ $text .= "}\n";
+ }
+
+ $text .= "}\n</SCRIPT>\n";
+
+ $text .=
+ qq!<SELECT NAME="popstate" SIZE=1 onChange="popstate_changed(this)">!.
+ qq!<OPTION> !;
+ $text .= "<OPTION>$_" foreach sort { $a cmp $b } keys %pop;
+ $text .= '</SELECT>'; #callback? return 3 html pieces? #'</TD><TD>';
+
+ $text .= qq!<SELECT NAME="popnum" SIZE=1><OPTION> !;
+ foreach my $pop ( @$pops ) {
+ $text .= qq!<OPTION VALUE="!. $pop->{popnum}. '"'.
+ ( ( $popnum && $pop->{popnum} == $popnum ) ? ' SELECTED' : '' ). ">".
+ $pop->{city}. ', '. $pop->{state}.
+ ' ('. $pop->{ac}. ')/'. $pop->{exch};
+ }
+ $text .= '</SELECT>';
+
+ $text;
+}
+
sub expselect {
my $prefix = shift;
my $date = shift || '';
$return .= ">$_";
}
$return .= qq!</SELECT>/<SELECT NAME="$prefix!. qq!_year" SIZE="1">!;
- for ( 1999 .. 2037 ) {
+ for ( 2001 .. 2037 ) {
$return .= "<OPTION";
$return .= " SELECTED" if $_ == $y;
$return .= ">$_";
</TR>
<TR>
<TD ALIGN="right">Password</TD>
- <TD><INPUT TYPE="text" NAME="_password" VALUE="<%= $password %>">
+ <TD><INPUT TYPE="password" NAME="_password" VALUE="<%= $password %>">
(blank to generate)</TD>
</TR>
<TR>
- <TD ALIGN="right">POP</TD>
- <TD><SELECT NAME="popnum" SIZE=1><OPTION>
-
- <%=
- foreach my $pop ( @{$pops} ) {
- $OUT .= '<OPTION VALUE="'. $pop->{'popnum'}. '"';
- $OUT .= ' SELECTED' if $popnum && $pop->{'popnum'} == $popnum;
- $OUT .= '>'. $pop->{'popnum'}. ': '. $pop->{'city'}. ', '.
- $pop->{'state'}. ' ('. $pop->{'ac'}. ')/'. $pop->{'exch'}. "\n";
- }
- %>
-
- </SELECT></TD>
+ <TD ALIGN="right">Re-enter Password</TD>
+ <TD><INPUT TYPE="password" NAME="_password2" VALUE="<%= $password2 %>">
+ </TD>
+</TR>
+<TR>
+ <TD ALIGN="right">Access number</TD>
+ <TD><%= popselector($popnum) %></TD>
</TR>
</TABLE>
<BR><BR><INPUT TYPE="submit" VALUE="Signup">