Merge branch 'patch-19' of https://github.com/gjones2/Freeside
[freeside.git] / fs_selfservice / FS-SelfService / cgi / signup.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <HTML>
3 <HEAD>
4   <TITLE><%= $agent || ( $signup_service eq 'svc_phone' ? 'ITSP' : 'ISP' ) %> Signup form</TITLE>
5   <%= $head %>
6 </HEAD>
7 <BODY BGCOLOR="<%= $body_bgcolor || '#e8e8e8' %>" onUnload="myclose()">
8 <%= if ( $terms_of_service =~ /\S/ ) { # enable overlib
9   $OUT .= qq!<SCRIPT type="text/javascript" src="$_.js"></SCRIPT>\n!
10     foreach (qw(overlibmws overlibmws_iframe overlibmws_draggable 
11                 overlibmws_crossframe iframecontentmws ));
12 }
13 %>
14 <script type="text/javascript">
15   var mywindow = -1;
16   function myopen(filename,windowname,properties) {
17     myclose();
18     mywindow = window.open(filename,windowname,properties);
19   }
20   function myclose() {
21     if ( mywindow != -1 )
22       mywindow.close();
23     mywindow = -1
24   }
25 </script>
26
27 <%= $OUT .= $body_header
28       || '<FONT SIZE=7>'.
29          ( $agent || ( $signup_service eq 'svc_phone' ? 'ITSP' : 'ISP' ) ).
30          ' Signup form</FONT><BR><BR>';
31 %>
32
33 <FONT SIZE="+1" COLOR="#ff0000"><%= encode_entities($error) %></FONT>
34
35 <FORM NAME="OneTrueForm" ACTION="<%= $self_url %>" METHOD=POST onSubmit="document.OneTrueForm.signup.disabled=true">
36 <INPUT TYPE="hidden" NAME="prepaid_shortform" VALUE="<%= encode_entities($prepaid_shortform) %>">
37 <INPUT TYPE="hidden" NAME="session" VALUE="<%= $session_id %>">
38 <INPUT TYPE="hidden" NAME="action" VALUE="process_signup">
39 <INPUT TYPE="hidden" NAME="agentnum" VALUE="<%= $agentnum %>">
40 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<%= $referral_custnum %>">
41 <INPUT TYPE="hidden" NAME="ss" VALUE="">
42 <input type="hidden" name="payby">
43 <%=
44   $OUT = join("\n",map { my $method = $_ ; map { qq|<input type="hidden" name="${method}_$_" />| } qw / payinfo payinfo1 payinfo2 payname paystate paytype paycvv month year type  /  } @payby);
45 %>
46
47 <%=
48   $OUT = join("\n", map { qq|<input type="hidden" name="$_" />| } qw / promo_code reg_code pkgpart username _password _password2 sec_phrase popnum mac_addr countrycode phonenum sip_password pin / );
49 %>
50
51 <%=
52   if ($override_ban_warn) {
53     $OUT .= 'Are you sure you want to sign up again? <SELECT NAME="override_ban_warn"><OPTION VALUE="0">No<OPTION VALUE="1">Yes</SELECT><BR><BR>';
54   } else {
55     $OUT .= '';
56   }
57 %>
58
59 Where did you hear about our service? <SELECT NAME="refnum">
60 <%=
61   $OUT .= '<OPTION VALUE="">' unless $refnum;
62   foreach my $part_referral ( @part_referral ) {
63     $OUT .= '<OPTION VALUE="'. $part_referral->{'refnum'}. '"';
64     $OUT .= ' SELECTED' if $part_referral->{'refnum'} == $refnum;
65     $OUT .= '>'. $part_referral->{'referral'};
66   }
67 %>
68 </SELECT><BR><BR>
69
70 <%= unless ( $prepaid_template_custnum && $prepaid_shortform  ) {
71
72 my $bgcolor = $box_bgcolor || '#c0c0c0';
73 $OUT .= qq!
74 Contact Information
75 <TABLE BGCOLOR="$bgcolor" BORDER=0 CELLSPACING=0 WIDTH="100%">
76 <TR>
77   <TH ALIGN="right"><font color="#ff0000">*</font>Contact name<BR>(last, first)</TH>
78   <TD COLSPAN=5><INPUT TYPE="text" NAME="last" VALUE="$last">,
79                 <INPUT TYPE="text" NAME="first" VALUE="$first"></TD>
80 </TR>
81 <TR>
82   <TD ALIGN="right">Company</TD>
83   <TD COLSPAN=5><INPUT TYPE="text" NAME="company" SIZE=70 VALUE="$company"></TD>
84 </TR>
85 <TR>
86   <TH ALIGN="right"><font color="#ff0000">*</font>Address</TH>
87   <TD COLSPAN=5><INPUT TYPE="text" NAME="address1" SIZE=70 VALUE="$address1"></TD>
88 </TR>
89 <TR>
90   <TD ALIGN="right">&nbsp;</TD>
91   <TD COLSPAN=5><INPUT TYPE="text" NAME="address2" SIZE=70 VALUE="$address2"></TD>
92 </TR>
93 <TR>
94   <TH ALIGN="right"><font color="#ff0000">*</font>City</TH>
95   <TD><INPUT TYPE="text" NAME="city" VALUE="$city"></TD> !;
96
97         my ($county_html, $state_html, $country_html) =
98           regionselector( {
99             selected_county  => $county,
100             selected_state   => $state,
101             selected_country => $country,
102             default_state    => $statedefault,
103             default_country  => $countrydefault,
104             locales          => \@cust_main_county,
105           } );
106  
107 $county_out = ($county_html =~ /SELECT/) ? 'County/State' : 'State';
108 $OUT .= qq!<TH ALIGN="right"><font color="#ff0000">*</font> $county_out </TH>
109   <TD>
110     $county_html $state_html
111   </TD>
112   <TH><font color="#ff0000">*</font>Zip</TH>
113   <TD><INPUT TYPE="text" NAME="zip" SIZE=10 VALUE="$zip"></TD>
114 </TR>
115 <TR>
116   <TH ALIGN="right"><font color="#ff0000">*</font>Country</TH>
117   <TD>$country_html</TD>
118 <TR>
119   <TD ALIGN="right">Day Phone</TD>
120   <TD COLSPAN=5><INPUT TYPE="text" NAME="daytime" VALUE="$daytime" SIZE=18></TD>
121 </TR>
122 <TR>
123   <TD ALIGN="right">Night Phone</TD>
124   <TD COLSPAN=5><INPUT TYPE="text" NAME="night" VALUE="$night" SIZE=18></TD>
125 </TR>
126 <TR>
127   <TD ALIGN="right">Fax</TD>
128   <TD COLSPAN=5><INPUT TYPE="text" NAME="fax" VALUE="$fax" SIZE=12></TD>
129 </TR>
130 !;
131   if ( $stateid_enabled ) {
132     my ($county_html, $state_html, $country_html) =
133       regionselector( {
134         prefix           => 'stateid_',
135         default_state    => $statedefault,
136         default_country  => $countrydefault,
137         locales          => \@cust_main_county,
138       } );
139     $OUT .= qq!<TR><TD ALIGN="right">!. $label{stateid}.'</TD>';
140     $OUT .= qq!<TD><INPUT TYPE="text" NAME="stateid" VALUE="$stateid" SIZE=12></TD>!;
141     $OUT .= qq!<TD ALIGN="right">!. $label{stateid_state} .'</TD>';
142     $OUT .="<TD COLSPAN=3>$county_html $state_html</TD></TR>";
143   }
144 $OUT .= qq!
145 </TABLE><font color="#ff0000">*</font> required fields<BR>
146 !;
147
148 }
149 else {
150     @payby = ('PREPAY');
151 }
152 '';
153 %>
154
155 <BR>Billing information<TABLE BGCOLOR="<%= $box_bgcolor || '#c0c0c0' %>" BORDER=0 CELLSPACING=0 WIDTH="100%">
156 <TR><TD>
157
158   <%=
159     $OUT ='';
160     unless ( $emailinvoiceonly ) { 
161     $OUT .= '<INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST"';
162     my @invoicing_list = split(', ', $invoicing_list );
163     $OUT .= ' CHECKED'
164       if ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list;
165     $OUT .= '>   Postal mail invoice'; } 
166   %>
167
168
169 </TD></TR>
170 <TR><TD><%= $OUT = ( $emailinvoiceonly ? q|<font color="#ff0000">*</font>| : q|| ) %> Email invoice <INPUT TYPE="text" NAME="invoicing_list" VALUE="<%= join(', ', grep { $_ ne 'POST' } split(', ', $invoicing_list ) ) %>">
171 </TD></TR>
172 <%= ( scalar(@payby) > 1 or 1 ) ? '<TR><TD>Billing type ' : '' %>
173 <!--</TABLE>
174 <TABLE BGCOLOR="#c0c0c0" BORDER=1 WIDTH="100%">
175 <TR>-->
176
177   <%=
178
179     my $cardselect = '<SELECT NAME="CARD_type"><OPTION></OPTION>';
180     foreach ( keys %card_types ) {
181       $selected = $CARD_type eq $card_types{$_} ? 'SELECTED' : '';
182       $cardselect .= qq!<OPTION $selected VALUE="$card_types{$_}">$_</OPTION>!;
183     }
184     $cardselect .= '</SELECT>';
185   
186     my %payby = (
187       '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="">!,
188       'DCRD' => qq!Credit card<BR><font color="#ff0000">*</font>$cardselect<INPUT TYPE="text" NAME="DCRD_payinfo" VALUE="" MAXLENGTH=19><BR><font color="#ff0000">*</font>Exp !. expselect("DCRD"). qq!<BR><font color="#ff0000">*</font>Name on card<BR><INPUT TYPE="text" NAME="DCRD_payname" VALUE="">!,
189       'CHEK' => qq!Electronic check<BR>${r}Account number <INPUT TYPE="text" NAME="CHEK_payinfo1" VALUE="" MAXLENGTH=10><BR>${r}ABA/Routing code <INPUT TYPE="text" NAME="CHEK_payinfo2" VALUE="" SIZE=10 MAXLENGTH=9> Type <SELECT NAME="CHEK_paytype">!. join('', map {qq!<OPTION VALUE="$_">$_</OPTION>!} @paytypes). qq!</SELECT><BR>{$r}Bank State <INPUT TYPE="text" NAME="CHEK_paystate" VALUE="" SIZE=5 MAXLENGTH=4><INPUT TYPE="hidden" NAME="CHEK_month" VALUE="12"><INPUT TYPE="hidden" NAME="CHEK_year" VALUE="2037"><BR>${r}Bank name <INPUT TYPE="text" NAME="CHEK_payname" VALUE="">!,
190       'DCHK' => qq!Electronic check<BR>${r}Account number <INPUT TYPE="text" NAME="DCHK_payinfo1" VALUE="" MAXLENGTH=10> Type <SELECT NAME="DCHK_paytype">!. join('', map {qq!<OPTION VALUE="$_">$_</OPTION>!} @paytypes). qq!</SELECT><BR>${r}ABA/Routing code <INPUT TYPE="text" NAME="DCHK_payinfo2" VALUE="" SIZE=10 MAXLENGTH=9><BR>{$r}Bank State <INPUT TYPE="text" NAME="DCHK_paystate" VALUE="" SIZE=5 MAXLENGTH=4><INPUT TYPE="hidden" NAME="DCHK_month" VALUE="12"><INPUT TYPE="hidden" NAME="DCHK_year" VALUE="2037"><BR>${r}Bank name <INPUT TYPE="text" NAME="DCHK_payname" VALUE="">!,
191       'LECB' => qq!Phone bill billing<BR>${r}Phone number <INPUT TYPE="text" NAME="LECB_payinfo" VALUE="" MAXLENGTH=15 SIZE=16><INPUT TYPE="hidden" NAME="LECB_month" VALUE="12"><INPUT TYPE="hidden" NAME="LECB_year" VALUE="2037"><INPUT TYPE="hidden" NAME="LECB_payname" VALUE="">!,
192       'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE=""><BR><INPUT TYPE="hidden" NAME="BILL_month" VALUE="12"><INPUT TYPE="hidden" NAME="BILL_year" VALUE="2037">Attention<INPUT TYPE="text" NAME="BILL_payname" VALUE="Accounts Payable">!,
193       '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"),
194       'PREPAY' => qq!Prepaid card<BR><font color="#ff0000">*</font><INPUT TYPE="text" NAME="PREPAY_payinfo" VALUE="" MAXLENGTH=80>!,
195     );
196
197     if ( $cvv_enabled ) {
198       foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5
199         $payby{$payby} .= qq!<TR><TD ALIGN="right">CVV2&nbsp;(<A HREF="javascript:myopen('cvv2.html','cvv2','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=480,height=288')">help</A>)</TD><TD><INPUT TYPE="text" NAME=${payby}_paycvv VALUE="" SIZE=4 MAXLENGTH=4></TD></TR>!;
200       }
201     }
202     if ( $paystate_enabled ) {
203       foreach my $payby ( grep { exists $payby{$_} } qw(CHEK DCHK) ) { 
204         my ($county_html, $state_html, $country_html) =
205           regionselector( {
206             prefix           => "${payby}_pay",
207             default_state    => $statedefault,
208             default_country  => $countrydefault,
209             locales          => \@cust_main_county,
210           } );
211         $payby{$payby} .= "<BR>${r}Bank state $county_html $state_html";
212       }
213     }
214
215     my( $account, $aba ) = split('@', $payinfo);
216     my %paybychecked = (
217       'CARD' => '<TABLE BGCOLOR="'. ( $box_bgcolor || '#c0c0c0' ). qq!" BORDER=0 CELLSPACING=0 WIDTH="100%"><TR><TD ALIGN="right"><font color="#ff0000">*</font> Card type</TD><TD>$cardselect</TD></TR><TR><TD ALIGN="right"><font color="#ff0000">*</font> Card number</TD><TD><INPUT TYPE="text" NAME="CARD_payinfo" VALUE="$payinfo" MAXLENGTH=19></TD></TR><TR><TD ALIGN="right"><font color="#ff0000">*</font> Expiration</TD><TD>!. expselect("CARD", $paydate). qq!</TD></TR><TR><TD ALIGN="right"><font color="#ff0000">*</font> Name on card</TD><TD><INPUT TYPE="text" NAME="CARD_payname" VALUE="$payname"></TD></TR>!,
218       'DCRD' => qq!Credit card<BR><font color="#ff0000">*</font>$cardselect<INPUT TYPE="text" NAME="DCRD_payinfo" VALUE="$payinfo" MAXLENGTH=19><BR><font color="#ff0000">*</font>Exp !. expselect("DCRD", $paydate). qq!<BR><font color="#ff0000">*</font>Name on card<BR><INPUT TYPE="text" NAME="DCRD_payname" VALUE="$payname">!,
219       'CHEK' => qq!Electronic check<BR>${r}Account number <INPUT TYPE="text" NAME="CHEK_payinfo1" VALUE="$account" MAXLENGTH=10> Type <SELECT NAME="CHEK_paytype">!. join('', map {qq!<OPTION VALUE="$_"!.($paytype eq $_ ? 'SELECTED' : '').">$_</OPTION>"} @paytypes). qq!</SELECT><BR>${r}ABA/Routing code <INPUT TYPE="text" NAME="CHEK_payinfo2" VALUE="$aba" SIZE=10 MAXLENGTH=9><INPUT TYPE="hidden" NAME="CHEK_month" VALUE="12"><INPUT TYPE="hidden" NAME="CHEK_year" VALUE="2037"><BR>${r}Bank name <INPUT TYPE="text" NAME="CHEK_payname" VALUE="$payname">!,
220       'DCHK' => qq!Electronic check<BR>${r}Account number <INPUT TYPE="text" NAME="DCHK_payinfo1" VALUE="$account" MAXLENGTH=10> Type <SELECT NAME="DCHK_paytype">!. join('', map {qq!<OPTION VALUE="$_"!.($paytype eq $_ ? 'SELECTED' : '').">$_</OPTION>"} @paytypes). qq!</SELECT><BR>${r}ABA/Routing code <INPUT TYPE="text" NAME="DCHK_payinfo2" VALUE="$aba" SIZE=10 MAXLENGTH=9><INPUT TYPE="hidden" NAME="DCHK_month" VALUE="12"><INPUT TYPE="hidden" NAME="DCHK_year" VALUE="2037"><BR>${r}Bank name <INPUT TYPE="text" NAME="DCHK_payname" VALUE="">!,
221       'LECB' => qq!Phone bill billing<BR>${r}Phone number <INPUT TYPE="text" BANE="LECB_payinfo" VALUE="$payinfo" MAXLENGTH=15 SIZE=16><INPUT TYPE="hidden" NAME="LECB_month" VALUE="12"><INPUT TYPE="hidden" NAME="LECB_year" VALUE="2037"><INPUT TYPE="hidden" NAME="LECB_payname" VALUE="">!,
222       'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE="$payinfo"><BR><INPUT TYPE="hidden" NAME="BILL_month" VALUE="12"><INPUT TYPE="hidden" NAME="BILL_year" VALUE="2037">Attention<INPUT TYPE="text" NAME="BILL_payname" VALUE="$payname">!,
223       '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),
224       'PREPAY' => qq!Prepaid card<BR><font color="#ff0000">*</font><INPUT TYPE="text" NAME="PREPAY_payinfo" VALUE="$payinfo" MAXLENGTH=80>!,
225     );
226
227     if ( $cvv_enabled ) {
228       foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5
229         $paybychecked{$payby} .= qq!<TR><TD ALIGN="right">CVV2&nbsp;(<A HREF="javascript:myopen('cvv2.html','cvv2','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=480,height=288')">help</A>)</TD><TD><INPUT TYPE="text" NAME=${payby}_paycvv VALUE="$paycvv" SIZE=4 MAXLENGTH=4></TD></TR>!;
230       }
231     }
232     if ( $paystate_enabled ) {
233       foreach my $payby ( grep { exists $payby{$_} } qw(CHEK DCHK) ) { 
234         my ($county_html, $state_html, $country_html) =
235           regionselector( {
236             prefix           => "${payby}_pay",
237             selected_county  => $county,
238             selected_state   => $state,
239             selected_country => $country,
240             default_state    => $statedefault,
241             default_country  => $countrydefault,
242             locales          => \@cust_main_county,
243           } );
244         $paybychecked{$payby} .= "<BR>${r}Bank state $county_html $state_html";
245       }
246     }
247
248   my %payby_index = ( 'CARD'   => qq/Credit Card/,
249                       'DCRD'   => qq/Credit Card/,
250                       'CHEK'   => qq/Check/,
251                       'DCHK'   => qq/Check/,
252                       'LECB'   => qq/Phone Bill Billing/,
253                       'BILL'   => qq/Billing/,
254                       'COMP'   => qq/Complimentary/,
255                       'PREPAY' => qq/Prepaid Card/,
256                     );
257   
258
259 tie my %options, 'Tie::IxHash', ();
260
261 foreach my $payby_option ( @payby ) {
262   $options{$payby_option} = $payby_index{$payby_option};
263 }
264
265 my $selected_layer = ( grep { $_ eq 'CARD' } @payby ) ? 'CARD' : $payby[0];
266
267 HTML::Widgets::SelectLayers->new(
268   options => \%options,
269   selected_layer => $selected_layer,
270   form_name => 'dummy',
271   html_between => '</td></tr></table>',
272   form_action => 'dummy.cgi',
273   layer_callback => sub { my $layer = shift; return ( shift @hide_payment_fields ? '' : $paybychecked{$layer} ) . '</TABLE>'; },
274 )->html;
275
276
277   %>
278
279 </TR></TABLE><font color="#ff0000">*</font> required fields
280 <FORM name="signup_form" action="<%= $self_url %>" METHOD="POST" onsubmit="return fixup_form();"><BR><BR>First package
281 <INPUT TYPE="hidden" NAME="promo_code" VALUE="<%= $promo_code %>">
282 <INPUT TYPE="hidden" NAME="reg_code" VALUE="<%= $reg_code %>">
283 <TABLE BGCOLOR="<%= $box_bgcolor || '#c0c0c0' %>" BORDER=0 CELLSPACING=0 WIDTH="100%">
284 <TR>
285   <TD COLSPAN=2><SELECT NAME="pkgpart">
286
287   <%=
288     $OUT .= '<OPTION VALUE="">(none)'
289       unless scalar(@part_pkg) == 1 or $default_pkgpart;
290     foreach my $part_pkg ( @part_pkg ) {
291       $OUT .= '<OPTION VALUE="'. $part_pkg->{'pkgpart'}. '"';
292       $OUT .= ' SELECTED' if $pkgpart && $part_pkg->{'pkgpart'} == $pkgpart;
293       $OUT .= '>'. $part_pkg->{'pkg'};
294     }
295   %>
296
297   </SELECT></TD>
298 </TR>
299 <%=
300   if ( $signup_service eq 'svc_phone' ) {
301
302     $OUT .= '<TR><TD ALIGN="right">Phone number</TD><TD>'.
303             didselector( 'field'   => 'phonenum',
304                          'svcpart' => $default_svcpart,
305                        ).
306             '</TD></TR>';
307
308     $OUT .= <<ENDOUT;
309 <TR>
310   <TD ALIGN="right">Voicemail PIN</TD>
311   <TD><INPUT TYPE="pin" NAME="pin" VALUE="$pin"></TD>
312 </TR>
313 ENDOUT
314
315   } else {
316
317     $OUT .= <<ENDOUT;
318 <TR>
319   <TD ALIGN="right">Username</TD>
320   <TD><INPUT TYPE="text" NAME="username" VALUE="$username"></TD>
321 </TR>
322 <TR>
323   <TD ALIGN="right">Password</TD>
324   <TD><INPUT TYPE="password" NAME="_password" VALUE="$_password"></TD>
325 </TR>
326 <TR>
327   <TD ALIGN="right">Re-enter Password</TD>
328   <TD><INPUT TYPE="password" NAME="_password2" VALUE="$_password2"></TD>
329 </TR>
330 ENDOUT
331
332     if ( $security_phrase ) {
333       $OUT .= <<SECPHRASE;
334 <TR>
335   <TD ALIGN="right">Security Phrase</TD>
336   <TD><INPUT TYPE="text" NAME="sec_phrase" VALUE="$sec_phrase">
337   </TD>
338 </TR>
339 SECPHRASE
340     } else {
341       $OUT .= '<INPUT TYPE="hidden" NAME="sec_phrase" VALUE="">';
342     }
343
344     if ( $nomadix ) {
345
346       warn $mac_addr;
347       $mac_addr ||= $MA;
348       warn $mac_addr;
349
350       $OUT .= <<NOMADIX;
351         <INPUT TYPE="hidden" NAME="mac_addr" VALUE="$mac_addr">
352 NOMADIX
353
354     }
355
356   }
357
358   if ( @svc_acct_pop ) {
359     $OUT .= '<TR><TD ALIGN="right">Access number</TD><TD>'.
360             popselector( 'popnum'        => $popnum,
361                          'pops'          => \@svc_acct_pop,
362                          'init_popstate' => $init_popstate,
363                          'popac'         => $popac,
364                          'acstate'       => $acstate,
365                        ).
366             '</TD></TR>';
367   } else {
368     $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop);
369   }
370
371 %>
372
373 </TABLE>
374
375 <%= 
376 if ( @optional_packages ) { 
377   my @html;
378   foreach my $ii ( 0 .. $#optional_packages) {
379   my $friendly_index = $ii + 1; 
380   if ($optional_packages[$ii]) {
381     push @html, qq|<BR>Optional Package #$friendly_index <br />|,'<table bgcolor="#c0c0c0"><tr><td>';
382
383     push @html, qq|<select name="optional_package${ii}">|;
384     push @html, qq|<option value="none"></option>|;
385     push @html, map { qq|<option value="$_->{pkgpart}">$_->{pkg}</option>| } @{$optional_packages[$ii]};
386     push @html, q|</select>|;
387     
388     push @html, '</td></tr></table>';
389     }
390     $OUT = join("\n", @html);
391   }  
392 } else {
393 $OUT = ''
394 }
395 %>
396 <%=
397   if ( $terms_of_service =~ /\S/ ) {
398     my $title = 'Terms of Service'; #config?
399     my $onclick = qq[overlib( terms_content, CAPTION, "$title", STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK, CLOSETEXT, "Close" );];
400     # Container for $terms_of_service to avoid nasty escaping.
401     $OUT .= qq[
402 <BR>
403 <DIV id="div_terms" style="display:none">$terms_of_service</DIV>
404 <SCRIPT type="text/javascript">
405 function agree_to_terms (val) {
406   document.getElementById("signup").disabled = !val;
407 }
408 function show_terms () {
409   overlib( document.getElementById('div_terms').innerHTML,
410     CAPTION, '$title', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE,
411     CLOSECLICK, CLOSETEXT, 'Close' );
412 }
413 </SCRIPT>
414 <INPUT TYPE="checkbox" onchange="agree_to_terms(this.checked)">&nbsp;
415 I agree to the <a href="javascript:void(0);" onclick="show_terms();">Terms of Service</a>.
416 ];
417   }
418 %>
419 <BR><INPUT TYPE="submit" ID="signup" NAME="signup" VALUE="Signup">
420 <script language="javascript">
421 <%= length($terms_of_service) ? 'agree_to_terms(false)' : '' %>
422
423 function fixup_form() {
424     
425     // copy payment method data up to OneTrueForm
426     
427     var payment_method_elements = new Array( 'payinfo', 'payinfo1', 'payinfo2', 'payname', 'paycvv' , 'paystate', 'paytype', 'month', 'year','type' );
428     var payment_method_form_name = document.OneTrueForm.select.options[document.OneTrueForm.select.selectedIndex].value;
429     document.OneTrueForm.elements['payby'].value = payment_method_form_name;
430     var payment_method_form = document.forms[payment_method_form_name];
431
432     for ( ii = 0 ; ii < payment_method_elements.length ; ii++ ) {
433         var true_element_name = payment_method_form_name + '_' + payment_method_elements[ii];
434         copyelement ( payment_method_form.elements[true_element_name],
435                       document.OneTrueForm.elements[true_element_name] );
436     }
437     
438     // Copy signup details to OneTrueForm
439     
440     var signup_elements = new Array (
441       'promo_code', 'reg_code', 'pkgpart',
442       'username', '_password', '_password2', 'sec_phrase', 'popnum',
443       'mac_addr',
444       'countrycode', 'phonenum', 'sip_password', 'pin'
445     );
446
447     for ( ii = 0 ; ii < signup_elements.length ; ii ++ ) {
448         copyelement ( document.signup_form.elements[signup_elements[ii]],
449                       document.OneTrueForm.elements[signup_elements[ii]]);
450     }
451
452     document.OneTrueForm.submit();
453     return false;
454 }
455
456 function copyelement(from, to) {
457 //    alert ( from + ' ' + to );
458     
459     if ( from == undefined ) {
460         to.value = '';
461     } else { 
462         if ( from.type == 'select-one' ) {
463             to.value = from.options[from.selectedIndex].value;
464         } else if ( from.type == 'checkbox' ) {
465             if ( from.checked ) {
466                 to.value = from.value;
467             } else {
468                 to.value = '';
469             }
470         } else {
471             if ( from.value == undefined ) {
472                 to.value = '';
473             } else {
474                 to.value = from.value;
475             }
476         }
477 //      alert(from.name + " (" + from.type + "): " + to.name + " => " + to.value);
478     }
479 }
480
481 </script>
482 </FORM>
483 <%= $OUT .= $body_footer %>
484 </BODY>
485 </HTML>