alternate decline handline (Bug #408)
[freeside.git] / fs_signup / FS-SignupClient / cgi / signup.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: signup.cgi,v 1.27 2002-04-25 12:03:15 ivan Exp $
4
5 use strict;
6 use vars qw( @payby $cgi $locales $packages $pops $init_data $error
7              $last $first $ss $company $address1 $address2 $city $state $county
8              $country $zip $daytime $night $fax $invoicing_list $payby $payinfo
9              $paydate $payname $referral_custnum
10              $pkgpart $username $password $password2 $sec_phrase $popnum
11              $agentnum
12              $ieak_file $ieak_template $cck_file $cck_template
13              $signup_html $signup_template
14              $success_html $success_template
15              $decline_html $decline_template
16              $ac $exch $loc
17              $email_name $pkg
18              $self_url
19            );
20 use subs qw( print_form print_okay print_decline
21              signup_default success_default decline_default
22              expselect );
23 use CGI;
24 #use CGI::Carp qw(fatalsToBrowser);
25 use Text::Template;
26 use Business::CreditCard;
27 use HTTP::Headers::UserAgent 2.00;
28 use FS::SignupClient 0.03 qw( signup_info new_customer );
29
30 #acceptable payment methods
31 #
32 #@payby = qw( CARD BILL COMP );
33 #@payby = qw( CARD BILL );
34 #@payby = qw( CARD );
35 @payby = qw( CARD PREPAY );
36
37 $ieak_file = '/usr/local/freeside/ieak.template';
38 $cck_file = '/usr/local/freeside/cck.template';
39 $signup_html = -e 'signup.html'
40                  ? 'signup.html'
41                  : '/usr/local/freeside/signup.html';
42 $success_html = -e 'success.html'
43                   ? 'success.html'
44                   : '/usr/local/freeside/success.html';
45 $decline_html = -e 'decline.html'
46                   ? 'decline.html'
47                   : '/usr/local/freeside/decline.html';
48
49 if ( -e $ieak_file ) {
50   my $ieak_txt = Text::Template::_load_text($ieak_file)
51     or die $Text::Template::ERROR;
52   $ieak_txt =~ /^(.*)$/s; #untaint the template source - it's trusted
53   $ieak_txt = $1;
54   $ieak_template = new Text::Template ( TYPE => 'STRING', SOURCE => $ieak_txt )
55     or die $Text::Template::ERROR;
56 } else {
57   $ieak_template = '';
58 }
59
60 if ( -e $cck_file ) {
61   my $cck_txt = Text::Template::_load_text($cck_file)
62     or die $Text::Template::ERROR;
63   $cck_txt =~ /^(.*)$/s; #untaint the template source - it's trusted
64   $cck_txt = $1;
65   $cck_template = new Text::Template ( TYPE => 'STRING', SOURCE => $cck_txt )
66     or die $Text::Template::ERROR;
67 } else {
68   $cck_template = '';
69 }
70
71 $agentnum = '';
72 if ( -e $signup_html ) {
73   my $signup_txt = Text::Template::_load_text($signup_html)
74     or die $Text::Template::ERROR;
75   $signup_txt =~ /^(.*)$/s; #untaint the template source - it's trusted
76   $signup_txt = $1;
77   $signup_template = new Text::Template ( TYPE => 'STRING',
78                                           SOURCE => $signup_txt,
79                                           DELIMITERS => [ '<%=', '%>' ]
80                                         )
81     or die $Text::Template::ERROR;
82   if ( $signup_txt =~
83          /<\s*INPUT TYPE="?hidden"?\s+NAME="?agentnum"?\s+VALUE="?(\d+)"?\s*>/si
84   ) {
85     $agentnum = $1;
86   }
87 } else {
88   $signup_template = new Text::Template ( TYPE => 'STRING',
89                                           SOURCE => &signup_default,
90                                           DELIMITERS => [ '<%=', '%>' ]
91                                         )
92     or die $Text::Template::ERROR;
93 }
94
95 if ( -e $success_html ) {
96   my $success_txt = Text::Template::_load_text($success_html)
97     or die $Text::Template::ERROR;
98   $success_txt =~ /^(.*)$/s; #untaint the template source - it's trusted
99   $success_txt = $1;
100   $success_template = new Text::Template ( TYPE => 'STRING',
101                                            SOURCE => $success_txt,
102                                            DELIMITERS => [ '<%=', '%>' ],
103                                          )
104     or die $Text::Template::ERROR;
105 } else {
106   $success_template = new Text::Template ( TYPE => 'STRING',
107                                            SOURCE => &success_default,
108                                            DELIMITERS => [ '<%=', '%>' ],
109                                          )
110     or die $Text::Template::ERROR;
111 }
112
113 if ( -e $decline_html ) {
114   my $decline_txt = Text::Template::_load_text($decline_html)
115     or die $Text::Template::ERROR;
116   $decline_txt =~ /^(.*)$/s; #untaint the template source - it's trusted
117   $decline_txt = $1;
118   $decline_template = new Text::Template ( TYPE => 'STRING',
119                                            SOURCE => $decline_txt,
120                                            DELIMITERS => [ '<%=', '%>' ],
121                                          )
122     or die $Text::Template::ERROR;
123 } else {
124   $decline_template = new Text::Template ( TYPE => 'STRING',
125                                            SOURCE => &decline_default,
126                                            DELIMITERS => [ '<%=', '%>' ],
127                                          )
128     or die $Text::Template::ERROR;
129 }
130
131
132 ( $locales, $packages, $pops, $init_data ) = signup_info();
133 @payby = @{$init_data->{'payby'}} if @{$init_data->{'payby'}};
134 $packages = $init_data->{agentnum2part_pkg}{$agentnum} if $agentnum;
135
136 $cgi = new CGI;
137
138 if ( defined $cgi->param('magic') ) {
139   if ( $cgi->param('magic') eq 'process' ) {
140
141     $cgi->param('state') =~ /^(\w*)( \(([\w ]+)\))? ?\/ ?(\w+)$/
142       or die "Oops, illegal \"state\" param: ". $cgi->param('state');
143     $state = $1;
144     $county = $3 || '';
145     $country = $4;
146
147     $payby = $cgi->param('payby');
148     $payinfo = $cgi->param( $payby. '_payinfo' );
149     $paydate =
150       $cgi->param( $payby. '_month' ). '-'. $cgi->param( $payby. '_year' );
151     $payname = $cgi->param( $payby. '_payname' );
152
153     if ( $invoicing_list = $cgi->param('invoicing_list') ) {
154       $invoicing_list .= ', POST' if $cgi->param('invoicing_list_POST');
155     } else {
156       $invoicing_list = 'POST';
157     }
158
159     $error = '';
160
161     $last             = $cgi->param('last');
162     $first            = $cgi->param('first');
163     $ss               = $cgi->param('ss');
164     $company          = $cgi->param('company');
165     $address1         = $cgi->param('address1');
166     $address2         = $cgi->param('address2');
167     $city             = $cgi->param('city');
168     #$county,
169     #$state,
170     $zip              = $cgi->param('zip');
171     #$country,
172     $daytime          = $cgi->param('daytime');
173     $night            = $cgi->param('night');
174     $fax              = $cgi->param('fax');
175     #$payby,
176     #$payinfo,
177     #$paydate,
178     #$payname,
179     #$invoicing_list,
180     $referral_custnum = $cgi->param('ref');
181     $pkgpart          = $cgi->param('pkgpart');
182     $username         = $cgi->param('username');
183     $sec_phrase       = $cgi->param('sec_phrase');
184     $password         = $cgi->param('_password');
185     $popnum           = $cgi->param('popnum');
186     #$agentnum, #         = $cgi->param('agentnum'),
187
188     if ( $cgi->param('_password') ne $cgi->param('_password2') ) {
189       $error = $init_data->{msgcat}{passwords_dont_match}; #msgcat
190       $password  = '';
191       $password2 = '';
192     } else {
193       $password2 = $cgi->param('_password2');
194
195       if ( $payby eq 'CARD' && $cgi->param('CARD_type') ) {
196         $payinfo =~ s/\D//g;
197
198         $payinfo =~ /^(\d{13,16})$/
199           or $error ||= $init_data->{msgcat}{invalid_card}; #. $self->payinfo;
200         $payinfo = $1;
201         validate($payinfo)
202           or $error ||= $init_data->{msgcat}{invalid_card}; #. $self->payinfo;
203         cardtype($payinfo) eq $cgi->param('CARD_type')
204           or $error ||= $init_data->{msgcat}{not_a}. $cgi->param('CARD_type');
205       }
206
207       $error ||= new_customer ( {
208         'last'             => $last,
209         'first'            => $first,
210         'ss'               => $ss,
211         'company'          => $company,
212         'address1'         => $address1,
213         'address2'         => $address2,
214         'city'             => $city,
215         'county'           => $county,
216         'state'            => $state,
217         'zip'              => $zip,
218         'country'          => $country,
219         'daytime'          => $daytime,
220         'night'            => $night,
221         'fax'              => $fax,
222         'payby'            => $payby,
223         'payinfo'          => $payinfo,
224         'paydate'          => $paydate,
225         'payname'          => $payname,
226         'invoicing_list'   => $invoicing_list,
227         'referral_custnum' => $referral_custnum,
228         'pkgpart'          => $pkgpart,
229         'username'         => $username,
230         'sec_phrase'       => $sec_phrase,
231         '_password'        => $password,
232         'popnum'           => $popnum,
233         'agentnum'         => $agentnum,
234       } );
235
236     }
237     
238     if ( $error eq '_decline' ) {
239       print_decline();
240     } elsif ( $error ) {
241       print_form();
242     } else {
243       print_okay();
244     }
245
246   } else {
247     die "unrecognized magic: ". $cgi->param('magic');
248   }
249 } else {
250   $error = '';
251   $last = '';
252   $first = '';
253   $ss = '';
254   $company = '';
255   $address1 = '';
256   $address2 = '';
257   $city = '';
258   $state = '';
259   $county = '';
260   $country = '';
261   $zip = '';
262   $daytime = '';
263   $night = '';
264   $fax = '';
265   $invoicing_list = '';
266   $payby = '';
267   $payinfo = '';
268   $paydate = '';
269   $payname = '';
270   $pkgpart = '';
271   $username = '';
272   $password = '';
273   $password2 = '';
274   $sec_phrase = '';
275   $popnum = '';
276   $referral_custnum = $cgi->param('ref') || '';
277   print_form;
278 }
279
280 sub print_form {
281
282   $cgi->delete('ref');
283   $self_url = $cgi->self_url;
284
285   $error = "Error: $error" if $error;
286
287   print $cgi->header( '-expires' => 'now' ),
288         $signup_template->fill_in();
289
290 }
291
292 sub print_decline {
293   print $cgi->header( '-expires' => 'now' ),
294         $decline_template->fill_in();
295 }
296
297 sub print_okay {
298   my $user_agent = new HTTP::Headers::UserAgent $ENV{HTTP_USER_AGENT};
299
300   $cgi->param('username') =~ /^(.+)$/
301     or die "fatal: invalid username got past FS::SignupClient::new_customer";
302   my $username = $1;
303   $cgi->param('_password') =~ /^(.+)$/
304     or die "fatal: invalid password got past FS::SignupClient::new_customer";
305   my $password = $1;
306   ( $cgi->param('first'). ' '. $cgi->param('last') ) =~ /^(.*)$/
307     or die "fatal: invalid email_name got past FS::SignupClient::new_customer";
308   $email_name = $1; #global for template
309
310   my $pop = pop_info($cgi->param('popnum'));
311     #or die "fatal: invalid popnum got past FS::SignupClient::new_customer";
312   if ( $pop ) {
313     ( $ac, $exch, $loc ) = ( $pop->{'ac'}, $pop->{'exch'}, $pop->{'loc'} );
314   } else {
315     ( $ac, $exch, $loc ) = ( '', '', ''); #presumably you're not using them.
316   }
317
318   #global for template
319   $pkg = ( grep { $_->{'pkgpart'} eq $pkgpart } @$packages )[0]->{'pkg'};
320
321   if ( $ieak_template
322        && $user_agent->platform eq 'ia32'
323        && $user_agent->os =~ /^win/
324        && ($user_agent->browser)[0] eq 'IE'
325      )
326   { #send an IEAK config
327     print $cgi->header('application/x-Internet-signup'),
328           $ieak_template->fill_in();
329   } elsif ( $cck_template
330             && $user_agent->platform eq 'ia32'
331             && $user_agent->os =~ /^win/
332             && ($user_agent->browser)[0] eq 'Netscape'
333           )
334   { #send a Netscape config
335     my $cck_data = $cck_template->fill_in();
336     print $cgi->header('application/x-netscape-autoconfigure-dialer-v2'),
337           map {
338             m/(.*)\s+(.*)$/;
339             pack("N", length($1)). $1. pack("N", length($2)). $2;
340           } split(/\n/, $cck_data);
341
342   } else { #send a simple confirmation
343     print $cgi->header( '-expires' => 'now' ),
344           $success_template->fill_in();
345   }
346 }
347
348 sub pop_info {
349   my $popnum = shift;
350   my $pop;
351   foreach $pop ( @{$pops} ) {
352     if ( $pop->{'popnum'} == $popnum ) { return $pop; }
353   }
354   '';
355 }
356
357 #horrible false laziness with FS/FS/svc_acct_pop.pm::popselector
358 sub popselector {
359   my( $popnum, $state ) = @_;
360
361   return '<INPUT TYPE="hidden" NAME="popnum" VALUE="">' unless @$pops;
362   return $pops->[0]{city}. ', '. $pops->[0]{state}.
363          ' ('. $pops->[0]{ac}. ')/'. $pops->[0]{exch}.
364          '<INPUT TYPE="hidden" NAME="popnum" VALUE="'. $pops->[0]{popnum}. '">'
365     if scalar(@$pops) == 1;
366
367   my %pop = ();
368   push @{ $pop{$_->{state}} }, $_ foreach @$pops;
369
370   my $text = <<END;
371     <SCRIPT>
372     function opt(what,href,text) {
373       var optionName = new Option(text, href, false, false)
374       var length = what.length;
375       what.options[length] = optionName;
376     }
377     
378     function popstate_changed(what) {
379       state = what.options[what.selectedIndex].text;
380       for (var i = what.form.popnum.length;i > 0;i--)
381                 what.form.popnum.options[i] = null;
382       what.form.popnum.options[0] = new Option("", "", false, true);
383 END
384
385   foreach my $popstate ( sort { $a cmp $b } keys %pop ) {
386     $text .= "\nif ( state == \"$popstate\" ) {\n";
387
388     foreach my $pop ( @{$pop{$popstate}}) {
389       my $o_popnum = $pop->{popnum};
390       my $poptext =  $pop->{city}. ', '. $pop->{state}.
391                      ' ('. $pop->{ac}. ')/'. $pop->{exch};
392
393       $text .= "opt(what.form.popnum, \"$o_popnum\", \"$poptext\");\n"
394     }
395     $text .= "}\n";
396   }
397
398   $text .= "}\n</SCRIPT>\n";
399
400   $text .=
401     qq!<SELECT NAME="popstate" SIZE=1 onChange="popstate_changed(this)">!.
402     qq!<OPTION> !;
403   $text .= "<OPTION>$_" foreach sort { $a cmp $b } keys %pop;
404   $text .= '</SELECT>'; #callback? return 3 html pieces?  #'</TD><TD>';
405
406   $text .= qq!<SELECT NAME="popnum" SIZE=1><OPTION> !;
407   foreach my $pop ( @$pops ) {
408     $text .= qq!<OPTION VALUE="!. $pop->{popnum}. '"'.
409              ( ( $popnum && $pop->{popnum} == $popnum ) ? ' SELECTED' : '' ). ">".
410              $pop->{city}. ', '. $pop->{state}.
411                ' ('. $pop->{ac}. ')/'. $pop->{exch};
412   }
413   $text .= '</SELECT>';
414
415   $text;
416 }
417
418 sub expselect {
419   my $prefix = shift;
420   my $date = shift || '';
421   my( $m, $y ) = ( 0, 0 );
422   if ( $date  =~ /^(\d{4})-(\d{2})-\d{2}$/ ) { #PostgreSQL date format
423     ( $m, $y ) = ( $2, $1 );
424   } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
425     ( $m, $y ) = ( $1, $3 );
426   }
427   my $return = qq!<SELECT NAME="$prefix!. qq!_month" SIZE="1">!;
428   for ( 1 .. 12 ) {
429     $return .= "<OPTION";
430     $return .= " SELECTED" if $_ == $m;
431     $return .= ">$_";
432   }
433   $return .= qq!</SELECT>/<SELECT NAME="$prefix!. qq!_year" SIZE="1">!;
434   for ( 2001 .. 2037 ) {
435     $return .= "<OPTION";
436     $return .= " SELECTED" if $_ == $y;
437     $return .= ">$_";
438   }
439   $return .= "</SELECT>";
440
441   $return;
442 }
443
444 sub success_default { #html to use if you don't specify a success file
445   <<'END';
446 <HTML><HEAD><TITLE>Signup successful</TITLE></HEAD>
447 <BODY BGCOLOR="#e8e8e8"><FONT SIZE=7>Signup successful</FONT><BR><BR>
448 Thanks for signing up!
449 <BR><BR>
450 Signup information for <%= $email_name %>:
451 <BR><BR>
452 Username: <%= $username %><BR>
453 Password: <%= $password %><BR>
454 Access number: (<%= $ac %>) / $exch - $local<BR>
455 Package: <%= $pkg %><BR>
456 </BODY></HTML>
457 END
458 }
459
460 sub decline_default { #html to use if there is a decline
461   <<'END';
462 <HTML><HEAD><TITLE>Processing error</TITLE></HEAD>
463 <BODY BGCOLOR="#e8e8e8"><FONT SIZE=7>Processing error</FONT><BR><BR>
464 There has been an error processing your account.  Please contact customer
465 support.
466 </BODY></HTML>
467 END
468 }
469
470 sub signup_default { #html to use if you don't specify a template file
471   <<'END';
472 <HTML><HEAD><TITLE>ISP Signup form</TITLE></HEAD>
473 <BODY BGCOLOR="#e8e8e8"><FONT SIZE=7>ISP Signup form</FONT><BR><BR>
474 <FONT SIZE="+1" COLOR="#ff0000"><%= $error %></FONT>
475 <FORM ACTION="<%= $self_url %>" METHOD=POST>
476 <INPUT TYPE="hidden" NAME="magic" VALUE="process">
477 <INPUT TYPE="hidden" NAME="ref" VALUE="<%= $referral_custnum %>">
478 <INPUT TYPE="hidden" NAME="ss" VALUE="">
479 Contact Information
480 <TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=0 WIDTH="100%">
481 <TR>
482   <TH ALIGN="right"><font color="#ff0000">*</font>Contact name<BR>(last, first)</TH>
483   <TD COLSPAN=5><INPUT TYPE="text" NAME="last" VALUE="<%= $last %>">,
484                 <INPUT TYPE="text" NAME="first" VALUE="<%= $first %>"></TD>
485 </TR>
486 <TR>
487   <TD ALIGN="right">Company</TD>
488   <TD COLSPAN=5><INPUT TYPE="text" NAME="company" SIZE=70 VALUE="<%= $company %>"></TD>
489 </TR>
490 <TR>
491   <TH ALIGN="right"><font color="#ff0000">*</font>Address</TH>
492   <TD COLSPAN=5><INPUT TYPE="text" NAME="address1" SIZE=70 VALUE="<%= $address1 %>"></TD>
493 </TR>
494 <TR>
495   <TD ALIGN="right">&nbsp;</TD>
496   <TD COLSPAN=5><INPUT TYPE="text" NAME="address2" SIZE=70 VALUE="<%= $address2 %>"></TD>
497 </TR>
498 <TR>
499   <TH ALIGN="right"><font color="#ff0000">*</font>City</TH>
500   <TD><INPUT TYPE="text" NAME="city" VALUE="<%= $city %>"></TD>
501   <TH ALIGN="right"><font color="#ff0000">*</font>State/Country</TH>
502   <TD><SELECT NAME="state" SIZE="1">
503
504   <%=
505     foreach ( @{$locales} ) {
506       $OUT .= '<OPTION';
507       $OUT .= ' SELECTED' if ( $state eq $_->{'state'}
508                                && $county eq $_->{'county'}
509                                && $country eq $_->{'country'}
510                              );
511       $OUT .= '>'. $_->{'state'};
512       $OUT .= ' ('. $_->{'county'}. ')' if $_->{'county'};
513       $OUT .= ' / '. $_->{'country'};
514     }
515   %>
516
517   </SELECT></TD>
518   <TH><font color="#ff0000">*</font>Zip</TH>
519   <TD><INPUT TYPE="text" NAME="zip" SIZE=10 VALUE="<%= $zip %>"></TD>
520 </TR>
521 <TR>
522   <TD ALIGN="right">Day Phone</TD>
523   <TD COLSPAN=5><INPUT TYPE="text" NAME="daytime" VALUE="<%= $daytime %>" SIZE=18></TD>
524 </TR>
525 <TR>
526   <TD ALIGN="right">Night Phone</TD>
527   <TD COLSPAN=5><INPUT TYPE="text" NAME="night" VALUE="<%= $night %>" SIZE=18></TD>
528 </TR>
529 <TR>
530   <TD ALIGN="right">Fax</TD>
531   <TD COLSPAN=5><INPUT TYPE="text" NAME="fax" VALUE="<%= $fax %>" SIZE=12></TD>
532 </TR>
533 </TABLE><font color="#ff0000">*</font> required fields<BR>
534 <BR>Billing information<TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=0 WIDTH="100%">
535 <TR><TD>
536
537   <%=
538     $OUT .= '<INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST"';
539     my @invoicing_list = split(', ', $invoicing_list );
540     $OUT .= ' CHECKED'
541       if ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list;
542     $OUT .= '>';
543   %>
544
545   Postal mail invoice
546 </TD></TR>
547 <TR><TD>Email invoice <INPUT TYPE="text" NAME="invoicing_list" VALUE="<%= join(', ', grep { $_ ne 'POST' } split(', ', $invoicing_list ) ) %>">
548 </TD></TR>
549 <%= scalar(@payby) > 1 ? '<TR><TD>Billing type</TD></TR>' : '' %>
550 </TABLE>
551 <TABLE BGCOLOR="#c0c0c0" BORDER=1 WIDTH="100%">
552 <TR>
553
554   <%=
555
556     my $cardselect = '<SELECT NAME="CARD_type"><OPTION></OPTION>';
557     my %types = (
558                   'VISA' => 'VISA card',
559                   'MasterCard' => 'MasterCard',
560                   'Discover' => 'Discover card',
561                   'American Express' => 'American Express card',
562                 );
563     foreach ( keys %types ) {
564       $selected = $cgi->param('CARD_type') eq $types{$_} ? 'SELECTED' : '';
565       $cardselect .= qq!<OPTION $selected VALUE="$types{$_}">$_</OPTION>!;
566     }
567     $cardselect .= '</SELECT>';
568   
569     my %payby = (
570       'CARD' => qq!Credit card<BR><font color="#ff0000">*</font>$cardselect<INPUT TYPE="text" NAME="CARD_payinfo" VALUE="" MAXLENGTH=19><BR><font color="#ff0000">*</font>Exp !. expselect("CARD"). qq!<BR><font color="#ff0000">*</font>Name on card<BR><INPUT TYPE="text" NAME="CARD_payname" VALUE="">!,
571       'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE=""><BR><font color="#ff0000">*</font>Exp !. expselect("BILL", "12-2037"). qq!<BR><font color="#ff0000">*</font>Attention<BR><INPUT TYPE="text" NAME="BILL_payname" VALUE="Accounts Payable">!,
572       'COMP' => qq!Complimentary<BR><font color="#ff0000">*</font>Approved by<INPUT TYPE="text" NAME="COMP_payinfo" VALUE=""><BR><font color="#ff0000">*</font>Exp !. expselect("COMP"),
573       'PREPAY' => qq!Prepaid card<BR><font color="#ff0000">*</font><INPUT TYPE="text" NAME="PREPAY_payinfo" VALUE="" MAXLENGTH=80>!,
574     );
575
576     my %paybychecked = (
577       'CARD' => qq!Credit card<BR><font color="#ff0000">*</font>$cardselect<INPUT TYPE="text" NAME="CARD_payinfo" VALUE="$payinfo" MAXLENGTH=19><BR><font color="#ff0000">*</font>Exp !. expselect("CARD", $paydate). qq!<BR><font color="#ff0000">*</font>Name on card<BR><INPUT TYPE="text" NAME="CARD_payname" VALUE="$payname">!,
578       'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE="$payinfo"><BR><font color="#ff0000">*</font>Exp !. expselect("BILL", $paydate). qq!<BR><font color="#ff0000">*</font>Attention<BR><INPUT TYPE="text" NAME="BILL_payname" VALUE="$payname">!,
579       'COMP' => qq!Complimentary<BR><font color="#ff0000">*</font>Approved by<INPUT TYPE="text" NAME="COMP_payinfo" VALUE="$payinfo"><BR><font color="#ff0000">*</font>Exp !. expselect("COMP", $paydate),
580       'PREPAY' => qq!Prepaid card<BR><font color="#ff0000">*</font><INPUT TYPE="text" NAME="PREPAY_payinfo" VALUE="$payinfo" MAXLENGTH=80>!,
581     );
582
583     for (@payby) {
584       if ( scalar(@payby) == 1) {
585         $OUT .= '<TD VALIGN=TOP>'.
586                 qq!<INPUT TYPE="hidden" NAME="payby" VALUE="$_">!.
587                 "$paybychecked{$_}</TD>";
588       } else {
589         $OUT .= qq!<TD VALIGN=TOP><INPUT TYPE="radio" NAME="payby" VALUE="$_"!;
590         if ($payby eq $_) {
591           $OUT .= qq! CHECKED> $paybychecked{$_}</TD>!;
592         } else {
593           $OUT .= qq!> $payby{$_}</TD>!;
594         }
595
596       }
597     }
598   %>
599
600 </TR></TABLE><font color="#ff0000">*</font> required fields for each billing type
601 <BR><BR>First package
602 <TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=0 WIDTH="100%">
603 <TR>
604   <TD COLSPAN=2><SELECT NAME="pkgpart"><OPTION VALUE="">(none)
605
606   <%=
607     foreach my $package ( @{$packages} ) {
608       $OUT .= '<OPTION VALUE="'. $package->{'pkgpart'}. '"';
609       $OUT .= ' SELECTED' if $pkgpart && $package->{'pkgpart'} == $pkgpart;
610       $OUT .= '>'. $package->{'pkg'};
611     }
612   %>
613
614   </SELECT></TD>
615 </TR>
616 <TR>
617   <TD ALIGN="right">Username</TD>
618   <TD><INPUT TYPE="text" NAME="username" VALUE="<%= $username %>"></TD>
619 </TR>
620 <TR>
621   <TD ALIGN="right">Password</TD>
622   <TD><INPUT TYPE="password" NAME="_password" VALUE="<%= $password %>"></TD>
623 </TR>
624 <TR>
625   <TD ALIGN="right">Re-enter Password</TD>
626   <TD><INPUT TYPE="password" NAME="_password2" VALUE="<%= $password2 %>"></TD>
627 </TR>
628 <%=
629   if ( $init_data->{'security_phrase'} ) {
630     $OUT .= <<ENDOUT;
631 <TR>
632   <TD ALIGN="right">Security Phrase</TD>
633   <TD><INPUT TYPE="text" NAME="sec_phrase" VALUE="$sec_phrase">
634   </TD>
635 </TR>
636 ENDOUT
637   } else {
638     $OUT .= '<INPUT TYPE="hidden" NAME="sec_phrase" VALUE="">';
639   }
640 %>
641 <%=
642   if ( scalar(@$pops) ) {
643     $OUT .= '<TR><TD ALIGN="right">Access number</TD><TD>'.
644             popselector($popnum). '</TD></TR>';
645   } else {
646     $OUT .= popselector($popnum);
647   }
648 %>
649 </TABLE>
650 <BR><BR><INPUT TYPE="submit" VALUE="Signup">
651 </FORM></BODY></HTML>
652 END
653 }