X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=fs_signup%2FFS-SignupClient%2Fcgi%2Fsignup.cgi;h=1b87045b2699f61ef1fa28f1963dae86bf33f6be;hb=9ba9f5252cceb2385c914127062e1ca3954b6d60;hp=816b8213b9557045c2f523de41fbefaaecef0707;hpb=f94fc16ea404c31c0d2ff063fc35ff06a1d2c97a;p=freeside.git diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi index 816b8213b..1b87045b2 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.cgi +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.30 2002-08-26 19:07:10 khoff Exp $ +# $Id: signup.cgi,v 1.29.2.5 2002-12-24 23:03:25 ivan Exp $ use strict; use vars qw( @payby $cgi $locales $packages $pops $init_data $error @@ -18,7 +18,7 @@ use vars qw( @payby $cgi $locales $packages $pops $init_data $error $self_url ); use subs qw( print_form print_okay print_decline - signup_default success_default decline_default + success_default decline_default expselect ); use CGI; #use CGI::Carp qw(fatalsToBrowser); @@ -88,11 +88,13 @@ if ( -e $signup_html ) { $agentnum = $1; } } else { - $signup_template = new Text::Template ( TYPE => 'STRING', - SOURCE => &signup_default, - DELIMITERS => [ '<%=', '%>' ] - ) - or die $Text::Template::ERROR; + #too much maintenance hassle to keep in this file + die "can't find ./signup.html or /usr/local/freeside/signup.html"; + #$signup_template = new Text::Template ( TYPE => 'STRING', + # SOURCE => &signup_default, + # DELIMITERS => [ '<%=', '%>' ] + # ) + # or die $Text::Template::ERROR; } if ( -e $success_html ) { @@ -141,14 +143,29 @@ $cgi = new CGI; if ( defined $cgi->param('magic') ) { if ( $cgi->param('magic') eq 'process' ) { - $cgi->param('state') =~ /^(\w*)( \(([\w ]+)\))? ?\/ ?(\w+)$/ - or die "Oops, illegal \"state\" param: ". $cgi->param('state'); - $state = $1; - $county = $3 || ''; - $country = $4; + if ( $cgi->param('state') =~ /^(\w*)( \(([\w ]+)\))? ?\/ ?(\w+)$/ ) { + $state = $1; + $county = $3 || ''; + $country = $4; + } elsif ( $cgi->param('state') =~ /^(\w*)$/ ) { + $state = $1; + $cgi->param('county') =~ /^([\w ]*)$/ + or die "illegal county: ". $cgi->param('county'); + $county = $1; + $cgi->param('country') =~ /^(\w+)$/ + or die "illegal country: ". $cgi->param('country'); + $country = $1; + } else { + die "illegal state: ". $cgi->param('state'); + } $payby = $cgi->param('payby'); - $payinfo = $cgi->param( $payby. '_payinfo' ); + if ( $payby eq 'CHEK' ) { + #$payinfo = join('@', map { $cgi->param( $payby. "_payinfo$_" ) } (1,2) ); + $payinfo = $cgi->param('CHEK_payinfo1').'@'.$cgi->param('CHEK_payinfo2'); + } else { + $payinfo = $cgi->param( $payby. '_payinfo' ); + } $paydate = $cgi->param( $payby. '_month' ). '-'. $cgi->param( $payby. '_year' ); $payname = $cgi->param( $payby. '_payname' ); @@ -258,9 +275,9 @@ if ( defined $cgi->param('magic') ) { $address1 = ''; $address2 = ''; $city = ''; - $state = ''; + $state = $init_data->{statedefault}; $county = ''; - $country = ''; + $country = $init_data->{countrydefault}; $zip = ''; $daytime = ''; $night = ''; @@ -359,8 +376,7 @@ sub pop_info { #horrible false laziness with FS/FS/svc_acct_pop.pm::popselector sub popselector { - - my( $popnum ) = @_; + my( $popnum, $state ) = @_; return '' unless @$pops; return $pops->[0]{city}. ', '. $pops->[0]{state}. @@ -369,9 +385,7 @@ sub popselector { if scalar(@$pops) == 1; my %pop = (); - foreach (@$pops) { - push @{ $pop{ $_->{state} }->{ $_->{ac} } }, $_; - } + push @{ $pop{$_->{state}} }, $_ foreach @$pops; my $text = < @@ -380,82 +394,45 @@ sub popselector { var length = what.length; what.options[length] = optionName; } - - function acstate_changed(what) { + + function popstate_changed(what) { state = what.options[what.selectedIndex].text; - for (var i = what.form.popac.length;i > 0;i--) - what.form.popac.options[i] = null; - what.form.popac.options[0] = new Option("Area code", "-1", false, true); -END - - foreach my $state ( sort { $a cmp $b } keys %pop ) { - $text .= "\nif ( state == \"$state\" ) {\n"; - - foreach my $ac ( sort { $a cmp $b } keys %{ $pop{$state} }) { - $text .= "opt(what.form.popac, \"$ac\", \"$ac\");\n"; - if ($ac eq $cgi->param('popac')) { - $text .= "what.form.popac.options[what.form.popac.length-1].selected = true;\n"; - } - } - $text .= "}\n"; - } - $text .= "popac_changed(what.form.popac)}\n"; - - $text .= < 0;i--) - what.form.popnum.options[i] = null; - what.form.popnum.options[0] = new Option("City", "-1", false, true); - + 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 $state ( keys %pop ) { - foreach my $popac ( keys %{ $pop{$state} } ) { - $text .= "\nif ( ac == \"$popac\" ) {\n"; + foreach my $popstate ( sort { $a cmp $b } keys %pop ) { + $text .= "\nif ( state == \"$popstate\" ) {\n"; - foreach my $pop ( @{$pop{$state}->{$popac}}) { - my $o_popnum = $pop->{popnum}; - my $poptext = $pop->{city}. ', '. $pop->{state}. - ' ('. $pop->{ac}. ')/'. $pop->{exch}; + 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"; - if ($popnum == $o_popnum) { - $text .= "what.form.popnum.options[what.form.popnum.length-1].selected = true;\n"; - } - } - $text .= "}\n"; + $text .= "opt(what.form.popnum, \"$o_popnum\", \"$poptext\");\n" } + $text .= "}\n"; } - $text .= "}\n\n"; $text .= - qq!State!; - $text .= "param('acstate') ? " SELECTED" : "") . - ">$_" foreach sort { $a cmp $b } keys %pop; - $text .= ''; #callback? return 3 html pieces? #''; - - $text .= - qq!!. - qq!Area code!; + qq!!. + qq! !; + $text .= "$_" foreach sort { $a cmp $b } keys %pop; + $text .= ''; #callback? return 3 html pieces? #''; - $text .= qq!City!; - - #comment this block to disable initial list polulation - foreach my $pop ( sort { $a->{state} cmp $b->{state} } @$pops ) { + $text .= qq! !; + foreach my $pop ( @$pops ) { $text .= qq!{popnum} == $popnum ) ? ' SELECTED' : '' ). ">". $pop->{city}. ', '. $pop->{state}. ' ('. $pop->{ac}. ')/'. $pop->{exch}; } - - $text .= qq!!; + $text .= ''; $text; - } sub expselect { @@ -484,6 +461,123 @@ sub expselect { $return; } +#false laziness w/FS::cust_main_county +sub regionselector { + my ( $selected_county, $selected_state, $selected_country, + $prefix, $onchange ) = @_; + + my $prefix = '' unless defined $prefix; + + my $countyflag = 0; + + my %cust_main_county; + +# unless ( @cust_main_county ) { #cache + #@cust_main_county = qsearch('cust_main_county', {} ); + #foreach my $c ( @cust_main_county ) { + foreach my $c ( @$locales ) { + #$countyflag=1 if $c->county; + $countyflag=1 if $c->{county}; + #push @{$cust_main_county{$c->country}{$c->state}}, $c->county; + #$cust_main_county{$c->country}{$c->state}{$c->county} = 1; + $cust_main_county{$c->{country}}{$c->{state}}{$c->{county}} = 1; + } +# } + $countyflag=1 if $selected_county; + + my $script_html = < + function opt(what,value,text) { + var optionName = new Option(text, value, false, false); + var length = what.length; + what.options[length] = optionName; + } + function ${prefix}country_changed(what) { + country = what.options[what.selectedIndex].text; + for ( var i = what.form.${prefix}state.length; i >= 0; i-- ) + what.form.${prefix}state.options[i] = null; +END + #what.form.${prefix}state.options[0] = new Option('', '', false, true); + + foreach my $country ( sort keys %cust_main_county ) { + $script_html .= "\nif ( country == \"$country\" ) {\n"; + foreach my $state ( sort keys %{$cust_main_county{$country}} ) { + my $text = $state || '(n/a)'; + $script_html .= qq!opt(what.form.${prefix}state, "$state", "$text");\n!; + } + $script_html .= "}\n"; + } + + $script_html .= <= 0; i-- ) + what.form.${prefix}county.options[i] = null; +END + + foreach my $country ( sort keys %cust_main_county ) { + $script_html .= "\nif ( country == \"$country\" ) {\n"; + foreach my $state ( sort keys %{$cust_main_county{$country}} ) { + $script_html .= "\nif ( state == \"$state\" ) {\n"; + #foreach my $county ( sort @{$cust_main_county{$country}{$state}} ) { + foreach my $county ( sort keys %{$cust_main_county{$country}{$state}} ) { + my $text = $county || '(n/a)'; + $script_html .= + qq!opt(what.form.${prefix}county, "$county", "$text");\n!; + } + $script_html .= "}\n"; + } + $script_html .= "}\n"; + } + } + + $script_html .= < +END + + my $county_html = $script_html; + if ( $countyflag ) { + $county_html .= qq!!; + $county_html .= ''; + } else { + $county_html .= + qq!!; + } + + my $state_html = qq!!; + foreach my $state ( sort keys %{ $cust_main_county{$selected_country} } ) { + my $text = $state || '(n/a)'; + my $selected = $state eq $selected_state ? 'SELECTED' : ''; + $state_html .= "\n$text" + } + $state_html .= ''; + + $state_html .= ''; + + my $country_html = qq!!; + my $countrydefault = $init_data->{countrydefault} || 'US'; + foreach my $country ( + sort { ($b eq $countrydefault) <=> ($a eq $countrydefault) or $a cmp $b } + keys %cust_main_county + ) { + my $selected = $country eq $selected_country ? ' SELECTED' : ''; + $country_html .= "\n$country" + } + $country_html .= ''; + + ($county_html, $state_html, $country_html); + +} + sub success_default { #html to use if you don't specify a success file <<'END'; Signup successful @@ -510,187 +604,3 @@ support. END } -sub signup_default { #html to use if you don't specify a template file - <<'END'; -ISP Signup form -ISP Signup form -<%= $error %> - - - - -Contact Information - - - *Contact name(last, first) - , - - - - Company - - - - *Address - - - - - - - - *City - - *State/Country - - - <%= - foreach ( @{$locales} ) { - $OUT .= '{'state'} - && $county eq $_->{'county'} - && $country eq $_->{'country'} - ); - $OUT .= '>'. $_->{'state'}; - $OUT .= ' ('. $_->{'county'}. ')' if $_->{'county'}; - $OUT .= ' / '. $_->{'country'}; - } - %> - - - *Zip - - - - Day Phone - - - - Night Phone - - - - Fax - - -* required fields -Billing information - - - <%= - $OUT .= ' - - Postal mail invoice - -Email invoice - -<%= scalar(@payby) > 1 ? 'Billing type' : '' %> - - - - - <%= - - my $cardselect = ''; - my %types = ( - 'VISA' => 'VISA card', - 'MasterCard' => 'MasterCard', - 'Discover' => 'Discover card', - 'American Express' => 'American Express card', - ); - foreach ( keys %types ) { - $selected = $cgi->param('CARD_type') eq $types{$_} ? 'SELECTED' : ''; - $cardselect .= qq!$_!; - } - $cardselect .= ''; - - my %payby = ( - 'CARD' => qq!Credit card*$cardselect*Exp !. expselect("CARD"). qq!*Name on card!, - 'BILL' => qq!BillingP.O. *Exp !. expselect("BILL", "12-2037"). qq!*Attention!, - 'COMP' => qq!Complimentary*Approved by*Exp !. expselect("COMP"), - 'PREPAY' => qq!Prepaid card*!, - ); - - my %paybychecked = ( - 'CARD' => qq!Credit card*$cardselect*Exp !. expselect("CARD", $paydate). qq!*Name on card!, - 'BILL' => qq!BillingP.O. *Exp !. expselect("BILL", $paydate). qq!*Attention!, - 'COMP' => qq!Complimentary*Approved by*Exp !. expselect("COMP", $paydate), - 'PREPAY' => qq!Prepaid card*!, - ); - - for (@payby) { - if ( scalar(@payby) == 1) { - $OUT .= ''. - qq!!. - "$paybychecked{$_}"; - } else { - $OUT .= qq! $paybychecked{$_}!; - } else { - $OUT .= qq!> $payby{$_}!; - } - - } - } - %> - -* required fields for each billing type -First package - - - (none) - - <%= - foreach my $package ( @{$packages} ) { - $OUT .= '{'pkgpart'} == $pkgpart; - $OUT .= '>'. $package->{'pkg'}; - } - %> - - - - - Username - - - - Password - - - - Re-enter Password - - -<%= - if ( $init_data->{'security_phrase'} ) { - $OUT .= < - Security Phrase - - - -ENDOUT - } else { - $OUT .= ''; - } -%> -<%= - if ( scalar(@$pops) ) { - $OUT .= 'Access number'. - popselector($popnum). ''; - } else { - $OUT .= popselector($popnum); - } -%> - - - -END -}