X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=fs_signup%2FFS-SignupClient%2Fcgi%2Fsignup.cgi;h=573cf5d65eb8cacef5ca579fa162f9cfd1423503;hp=5d024a812ab5aec6d114c23553071d75fd92f074;hb=0df810cde18282c08271a87c50568dd75b61a578;hpb=5e99168da38e7616fc726242ce7d85e140f22c6f diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi index 5d024a812..573cf5d65 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.cgi +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -1,18 +1,19 @@ #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.10 2001-08-28 16:58:08 ivan Exp $ +# $Id: signup.cgi,v 1.14 2001-09-27 21:32:36 ivan Exp $ use strict; -use vars qw( @payby $cgi $locales $packages $pops $r $error +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 $ieak_file $ieak_template $cck_file $cck_template + $signup_html $signup_template $success_html $success_template $ac $exch $loc + $self_url ); -use subs qw( print_form print_okay expselect ); - +use subs qw( print_form print_okay expselect signup_default success_default ); use CGI; use CGI::Carp qw(fatalsToBrowser); use HTTP::Headers::UserAgent 2.00; @@ -28,6 +29,8 @@ use Text::Template; $ieak_file = '/usr/local/freeside/ieak.template'; $cck_file = '/usr/local/freeside/cck.template'; +$signup_html = '/usr/local/freeside/signup.html'; +$success_html = '/usr/local/freeside/success.html'; if ( -e $ieak_file ) { my $ieak_txt = Text::Template::_load_text($ieak_file) @@ -39,6 +42,7 @@ if ( -e $ieak_file ) { } else { $ieak_template = ''; } + if ( -e $cck_file ) { my $cck_txt = Text::Template::_load_text($cck_file) or die $Text::Template::ERROR; @@ -50,6 +54,42 @@ if ( -e $cck_file ) { $cck_template = ''; } +if ( -e $signup_html ) { + my $signup_txt = Text::Template::_load_text($signup_html) + or die $Text::Template::ERROR; + $signup_txt =~ /^(.*)$/s; #untaint the template source - it's trusted + $signup_txt = $1; + $signup_template = new Text::Template ( TYPE => 'STRING', + SOURCE => $signup_txt, + DELIMITERS => [ '<%=', '%>' ] + ) + or die $Text::Template::ERROR; +} else { + $signup_template = new Text::Template ( TYPE => 'STRING', + SOURCE => &signup_default, + DELIMITERS => [ '<%=', '%>' ] + ) + or die $Text::Template::ERROR; +} + +if ( -e $success_html ) { + my $success_txt = Text::Template::_load_text($success_html) + or die $Text::Template::ERROR; + $success_txt =~ /^(.*)$/s; #untaint the template source - it's trusted + $success_txt = $1; + $success_template = new Text::Template ( TYPE => 'STRING', + SOURCE => $success_txt, + DELIMITERS => [ '<%=', '%>' ], + ) + or die $Text::Template::ERROR; +} else { + $success_template = new Text::Template ( TYPE => 'STRING', + SOURCE => &success_default, + DELIMITERS => [ '<%=', '%>' ], + ) + or die $Text::Template::ERROR; +} + ( $locales, $packages, $pops ) = signup_info(); $cgi = new CGI; @@ -75,7 +115,7 @@ if ( defined $cgi->param('magic') ) { $invoicing_list = 'POST'; } - ( $error = new_customer ( { + $error = new_customer ( { 'last' => $last = $cgi->param('last'), 'first' => $first = $cgi->param('first'), 'ss' => $ss = $cgi->param('ss'), @@ -100,9 +140,12 @@ if ( defined $cgi->param('magic') ) { 'username' => $username = $cgi->param('username'), '_password' => $password = $cgi->param('_password'), 'popnum' => $popnum = $cgi->param('popnum'), - } ) ) - ? print_form() - : print_okay(); + } ); + if ( $error ) { + print_form(); + } else { + print_okay(); + } } else { die "unrecognized magic: ". $cgi->param('magic'); } @@ -137,168 +180,13 @@ if ( defined $cgi->param('magic') ) { sub print_form { - my $r = qq!*!; $cgi->delete('ref'); - my $self_url = $cgi->self_url; + $self_url = $cgi->self_url; - print $cgi->header( '-expires' => 'now' ), <ISP Signup form -ISP Signup form

-END - - print qq!Error: $error! if $error; + $error = "Error: $error" if $error; - print < - - -Contact Information - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
${r}Contact name
(last, first)
, - SS#
Company
${r}Address
 
${r}City${r}State/Country${r}Zip
Day Phone
Night Phone
Fax
$r required fields
-
Billing information -!; - - print <
-END - - print qq!Postal mail invoice
Email invoice ', - qq!
Billing type
- - -END - - my %payby = ( - 'CARD' => qq!Credit card
${r}
${r}Exp !. expselect("CARD"). qq!
${r}Name on card
!, - 'BILL' => qq!Billing
P.O.
${r}Exp !. expselect("BILL", "12-2037"). qq!
${r}Attention
!, - 'COMP' => qq!Complimentary
${r}Approved by
${r}Exp !. expselect("COMP"), - 'PREPAY' => qq!Prepaid card
${r}!, - ); - - my %paybychecked = ( - 'CARD' => qq!Credit card
${r}
${r}Exp !. expselect("CARD", $paydate). qq!
${r}Name on card
!, - 'BILL' => qq!Billing
P.O.
${r}Exp !. expselect("BILL", $paydate). qq!
${r}Attention
!, - 'COMP' => qq!Complimentary
${r}Approved by
${r}Exp !. expselect("COMP", $paydate), - 'PREPAY' => qq!Prepaid card
${r}!, - ); - - for (@payby) { - print qq!!; - } else { - print qq!> $payby{$_}!; - } - } - - print <
$paybychecked{$_}
$r required fields for each billing type -

First package - - - - - - - - - - - - - - - - -
Username
Password - (blank to generate)
POP
-

- -END + print $cgi->header( '-expires' => 'now' ), + $signup_template->fill_in(); } @@ -341,13 +229,8 @@ sub print_okay { } split(/\n/, $cck_data); } else { #send a simple confirmation - print $cgi->header( '-expires' => 'now' ), <Signup successful -Signup successful

-blah blah blah - - -END + print $cgi->header( '-expires' => 'now' ), + $success_template->fill_in(); } } @@ -360,6 +243,61 @@ sub pop_info { ''; } +#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 = < + 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\n"; + + $text .= + qq!'; #callback? return 3 html pieces? #''; + + $text .= qq!'; + + $text; +} + sub expselect { my $prefix = shift; my $date = shift || ''; @@ -386,3 +324,154 @@ sub expselect { $return; } +sub success_default { #html to use if you don't specify a success file + <<'END'; +Signup successful +Signup successful

+Thanks for signing up! + +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*Zip
Day Phone
Night Phone
Fax
* required fields
+
Billing information + + +
+ + <%= + $OUT .= ' + + Postal mail invoice +
Email invoice +
Billing type
+ + + + <%= + my %payby = ( + 'CARD' => qq!Credit card
*
*Exp !. expselect("CARD"). qq!
*Name on card
!, + 'BILL' => qq!Billing
P.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
*
*Exp !. expselect("CARD", $paydate). qq!
*Name on card
!, + 'BILL' => qq!Billing
P.O.
*Exp !. expselect("BILL", $paydate). qq!
*Attention
!, + 'COMP' => qq!Complimentary
*Approved by
*Exp !. expselect("COMP", $paydate), + 'PREPAY' => qq!Prepaid card
*!, + ); + + for (@payby) { + $OUT .= qq!!; + } else { + $OUT .= qq!> $payby{$_}!; + } + } + %> + +
$paybychecked{$_}
* required fields for each billing type +

First package + + + + + + + + + + + + + + + + +
Username
Password + (blank to generate)
Access number<%= popselector($popnum) %>
+

+
+END +}