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