This commit was generated by cvs2svn to compensate for changes in r11022,
[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
9 <script type="text/javascript">
10   var mywindow = -1;
11   function myopen(filename,windowname,properties) {
12     myclose();
13     mywindow = window.open(filename,windowname,properties);
14   }
15   function myclose() {
16     if ( mywindow != -1 )
17       mywindow.close();
18     mywindow = -1
19   }
20 </script>
21
22 <%= $OUT .= $body_header
23       || '<FONT SIZE=7>'.
24          ( $agent || ( $signup_service eq 'svc_phone' ? 'ITSP' : 'ISP' ) ).
25          ' Signup form</FONT><BR><BR>';
26 %>
27
28 <FONT SIZE="+1" COLOR="#ff0000"><%= $error %></FONT>
29
30 <FORM NAME="OneTrueForm" ACTION="<%= $self_url %>" METHOD=POST onSubmit="document.OneTrueForm.signup.disabled=true">
31 <INPUT TYPE="hidden" NAME="prepaid_shortform" VALUE="<%= $prepaid_shortform %>">
32 <INPUT TYPE="hidden" NAME="session" VALUE="<%= $session_id %>">
33 <INPUT TYPE="hidden" NAME="action" VALUE="process_signup">
34 <INPUT TYPE="hidden" NAME="agentnum" VALUE="<%= $agentnum %>">
35 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<%= $referral_custnum %>">
36 <INPUT TYPE="hidden" NAME="ss" VALUE="">
37 <input type="hidden" name="payby">
38 <%=
39   $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);
40 %>
41
42 <%=
43   $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 / );
44 %>
45
46 Where did you hear about our service? <SELECT NAME="refnum">
47 <%=
48   $OUT .= '<OPTION VALUE="">' unless $refnum;
49   foreach my $part_referral ( @part_referral ) {
50     $OUT .= '<OPTION VALUE="'. $part_referral->{'refnum'}. '"';
51     $OUT .= ' SELECTED' if $part_referral->{'refnum'} == $refnum;
52     $OUT .= '>'. $part_referral->{'referral'};
53   }
54 %>
55 </SELECT><BR><BR>
56
57 <%= unless ( $prepaid_template_custnum && $prepaid_shortform  ) {
58
59 my $bgcolor = $box_bgcolor || '#c0c0c0';
60 $OUT .= qq!
61 Contact Information
62 <TABLE BGCOLOR="$bgcolor" BORDER=0 CELLSPACING=0 WIDTH="100%">
63 <TR>
64   <TH ALIGN="right"><font color="#ff0000">*</font>Contact name<BR>(last, first)</TH>
65   <TD COLSPAN=5><INPUT TYPE="text" NAME="last" VALUE="$last">,
66                 <INPUT TYPE="text" NAME="first" VALUE="$first"></TD>
67 </TR>
68 <TR>
69   <TD ALIGN="right">Company</TD>
70   <TD COLSPAN=5><INPUT TYPE="text" NAME="company" SIZE=70 VALUE="$company"></TD>
71 </TR>
72 <TR>
73   <TH ALIGN="right"><font color="#ff0000">*</font>Address</TH>
74   <TD COLSPAN=5><INPUT TYPE="text" NAME="address1" SIZE=70 VALUE="$address1"></TD>
75 </TR>
76 <TR>
77   <TD ALIGN="right">&nbsp;</TD>
78   <TD COLSPAN=5><INPUT TYPE="text" NAME="address2" SIZE=70 VALUE="$address2"></TD>
79 </TR>
80 <TR>
81   <TH ALIGN="right"><font color="#ff0000">*</font>City</TH>
82   <TD><INPUT TYPE="text" NAME="city" VALUE="$city"></TD> !;
83
84         my ($county_html, $state_html, $country_html) =
85           regionselector( {
86             selected_county  => $county,
87             selected_state   => $state,
88             selected_country => $country,
89             default_state    => $statedefault,
90             default_country  => $countrydefault,
91             locales          => \@cust_main_county,
92           } );
93  
94 $county_out = ($county_html =~ /SELECT/) ? 'County/State' : 'State';
95 $OUT .= qq!<TH ALIGN="right"><font color="#ff0000">*</font> $county_out </TH>
96   <TD>
97     $county_html $state_html
98   </TD>
99   <TH><font color="#ff0000">*</font>Zip</TH>
100   <TD><INPUT TYPE="text" NAME="zip" SIZE=10 VALUE="$zip"></TD>
101 </TR>
102 <TR>
103   <TH ALIGN="right"><font color="#ff0000">*</font>Country</TH>
104   <TD>$country_html</TD>
105 <TR>
106   <TD ALIGN="right">Day Phone</TD>
107   <TD COLSPAN=5><INPUT TYPE="text" NAME="daytime" VALUE="$daytime" SIZE=18></TD>
108 </TR>
109 <TR>
110   <TD ALIGN="right">Night Phone</TD>
111   <TD COLSPAN=5><INPUT TYPE="text" NAME="night" VALUE="$night" SIZE=18></TD>
112 </TR>
113 <TR>
114   <TD ALIGN="right">Fax</TD>
115   <TD COLSPAN=5><INPUT TYPE="text" NAME="fax" VALUE="$fax" SIZE=12></TD>
116 </TR>
117 !;
118   if ( $stateid_enabled ) {
119     my ($county_html, $state_html, $country_html) =
120       regionselector( {
121         prefix           => 'stateid_',
122         default_state    => $statedefault,
123         default_country  => $countrydefault,
124         locales          => \@cust_main_county,
125       } );
126     $OUT .= qq!<TR><TD ALIGN="right">!. $label{stateid}.'</TD>';
127     $OUT .= qq!<TD><INPUT TYPE="text" NAME="stateid" VALUE="$stateid" SIZE=12></TD>!;
128     $OUT .= qq!<TD ALIGN="right">!. $label{stateid_state} .'</TD>';
129     $OUT .="<TD COLSPAN=3>$county_html $state_html</TD></TR>";
130   }
131 $OUT .= qq!
132 </TABLE><font color="#ff0000">*</font> required fields<BR>
133 !;
134
135 }
136 else {
137     @payby = ('PREPAY');
138 }
139 %>
140
141 <BR>Billing information<TABLE BGCOLOR="<%= $box_bgcolor || '#c0c0c0' %>" BORDER=0 CELLSPACING=0 WIDTH="100%">
142 <TR><TD>
143
144   <%=
145     $OUT ='';
146     unless ( $emailinvoiceonly ) { 
147     $OUT .= '<INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST"';
148     my @invoicing_list = split(', ', $invoicing_list );
149     $OUT .= ' CHECKED'
150       if ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list;
151     $OUT .= '>   Postal mail invoice'; } 
152   %>
153
154
155 </TD></TR>
156 <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 ) ) %>">
157 </TD></TR>
158 <%= ( scalar(@payby) > 1 or 1 ) ? '<TR><TD>Billing type ' : '' %>
159 <!--</TABLE>
160 <TABLE BGCOLOR="#c0c0c0" BORDER=1 WIDTH="100%">
161 <TR>-->
162
163   <%=
164
165     my $cardselect = '<SELECT NAME="CARD_type"><OPTION></OPTION>';
166     foreach ( keys %card_types ) {
167       $selected = $CARD_type eq $card_types{$_} ? 'SELECTED' : '';
168       $cardselect .= qq!<OPTION $selected VALUE="$card_types{$_}">$_</OPTION>!;
169     }
170     $cardselect .= '</SELECT>';
171   
172     my %payby = (
173       '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="">!,
174       '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="">!,
175       '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="">!,
176       '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="">!,
177       '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="">!,
178       '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">!,
179       '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"),
180       'PREPAY' => qq!Prepaid card<BR><font color="#ff0000">*</font><INPUT TYPE="text" NAME="PREPAY_payinfo" VALUE="" MAXLENGTH=80>!,
181     );
182
183     if ( $cvv_enabled ) {
184       foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5
185         $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>!;
186       }
187     }
188     if ( $paystate_enabled ) {
189       foreach my $payby ( grep { exists $payby{$_} } qw(CHEK DCHK) ) { 
190         my ($county_html, $state_html, $country_html) =
191           regionselector( {
192             prefix           => "${payby}_pay",
193             default_state    => $statedefault,
194             default_country  => $countrydefault,
195             locales          => \@cust_main_county,
196           } );
197         $payby{$payby} .= "<BR>${r}Bank state $county_html $state_html";
198       }
199     }
200
201     my( $account, $aba ) = split('@', $payinfo);
202     my %paybychecked = (
203       '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> Expration</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>!,
204       '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">!,
205       '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">!,
206       '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="">!,
207       '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="">!,
208       '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">!,
209       '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),
210       'PREPAY' => qq!Prepaid card<BR><font color="#ff0000">*</font><INPUT TYPE="text" NAME="PREPAY_payinfo" VALUE="$payinfo" MAXLENGTH=80>!,
211     );
212
213     if ( $cvv_enabled ) {
214       foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5
215         $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>!;
216       }
217     }
218     if ( $paystate_enabled ) {
219       foreach my $payby ( grep { exists $payby{$_} } qw(CHEK DCHK) ) { 
220         my ($county_html, $state_html, $country_html) =
221           regionselector( {
222             prefix           => "${payby}_pay",
223             selected_county  => $county,
224             selected_state   => $state,
225             selected_country => $country,
226             default_state    => $statedefault,
227             default_country  => $countrydefault,
228             locales          => \@cust_main_county,
229           } );
230         $paybychecked{$payby} .= "<BR>${r}Bank state $county_html $state_html";
231       }
232     }
233
234   my %payby_index = ( 'CARD'   => qq/Credit Card/,
235                       'DCRD'   => qq/Credit Card/,
236                       'CHEK'   => qq/Check/,
237                       'DCHK'   => qq/Check/,
238                       'LECB'   => qq/Phone Bill Billing/,
239                       'BILL'   => qq/Billing/,
240                       'COMP'   => qq/Complimentary/,
241                       'PREPAY' => qq/Prepaid Card/,
242                     );
243   
244
245 tie my %options, 'Tie::IxHash', ();
246
247 foreach my $payby_option ( @payby ) {
248   $options{$payby_option} = $payby_index{$payby_option};
249 }
250
251 my $selected_layer = ( grep { $_ eq 'CARD' } @payby ) ? 'CARD' : $payby[0];
252
253 HTML::Widgets::SelectLayers->new(
254   options => \%options,
255   selected_layer => $selected_layer,
256   form_name => 'dummy',
257   html_between => '</td></tr></table>',
258   form_action => 'dummy.cgi',
259   layer_callback => sub { my $layer = shift; return ( shift @hide_payment_fields ? '' : $paybychecked{$layer} ) . '</TABLE>'; },
260 )->html;
261
262
263   %>
264
265 </TR></TABLE><font color="#ff0000">*</font> required fields
266 <FORM name="signup_form" action="<%= $self_url %>" METHOD="POST" onsubmit="return fixup_form();"><BR><BR>First package
267 <INPUT TYPE="hidden" NAME="promo_code" VALUE="<%= $promo_code %>">
268 <INPUT TYPE="hidden" NAME="reg_code" VALUE="<%= $reg_code %>">
269 <TABLE BGCOLOR="<%= $box_bgcolor || '#c0c0c0' %>" BORDER=0 CELLSPACING=0 WIDTH="100%">
270 <TR>
271   <TD COLSPAN=2><SELECT NAME="pkgpart">
272
273   <%=
274     $OUT .= '<OPTION VALUE="">(none)'
275       unless scalar(@part_pkg) == 1 or $default_pkgpart;
276     foreach my $part_pkg ( @part_pkg ) {
277       $OUT .= '<OPTION VALUE="'. $part_pkg->{'pkgpart'}. '"';
278       $OUT .= ' SELECTED' if $pkgpart && $part_pkg->{'pkgpart'} == $pkgpart;
279       $OUT .= '>'. $part_pkg->{'pkg'};
280     }
281   %>
282
283   </SELECT></TD>
284 </TR>
285 <%=
286   if ( $signup_service eq 'svc_phone' ) {
287
288     $OUT .= '<TR><TD ALIGN="right">Phone number</TD><TD>'.
289             didselector( 'field'   => 'phonenum',
290                          'svcpart' => $default_svcpart,
291                        ).
292             '</TD></TR>';
293
294     $OUT .= <<ENDOUT;
295 <TR>
296   <TD ALIGN="right">Voicemail PIN</TD>
297   <TD><INPUT TYPE="pin" NAME="pin" VALUE="$pin"></TD>
298 </TR>
299 ENDOUT
300
301   } else {
302
303     $OUT .= <<ENDOUT;
304 <TR>
305   <TD ALIGN="right">Username</TD>
306   <TD><INPUT TYPE="text" NAME="username" VALUE="$username"></TD>
307 </TR>
308 <TR>
309   <TD ALIGN="right">Password</TD>
310   <TD><INPUT TYPE="password" NAME="_password" VALUE="$_password"></TD>
311 </TR>
312 <TR>
313   <TD ALIGN="right">Re-enter Password</TD>
314   <TD><INPUT TYPE="password" NAME="_password2" VALUE="$_password2"></TD>
315 </TR>
316 ENDOUT
317
318     if ( $security_phrase ) {
319       $OUT .= <<SECPHRASE;
320 <TR>
321   <TD ALIGN="right">Security Phrase</TD>
322   <TD><INPUT TYPE="text" NAME="sec_phrase" VALUE="$sec_phrase">
323   </TD>
324 </TR>
325 SECPHRASE
326     } else {
327       $OUT .= '<INPUT TYPE="hidden" NAME="sec_phrase" VALUE="">';
328     }
329
330     if ( $nomadix ) {
331
332       warn $mac_addr;
333       $mac_addr ||= $MA;
334       warn $mac_addr;
335
336       $OUT .= <<NOMADIX;
337         <INPUT TYPE="hidden" NAME="mac_addr" VALUE="$mac_addr">
338 NOMADIX
339
340     }
341
342   }
343
344   if ( @svc_acct_pop ) {
345     $OUT .= '<TR><TD ALIGN="right">Access number</TD><TD>'.
346             popselector( 'popnum'        => $popnum,
347                          'pops'          => \@svc_acct_pop,
348                          'init_popstate' => $init_popstate,
349                          'popac'         => $popac,
350                          'acstate'       => $acstate,
351                        ).
352             '</TD></TR>';
353   } else {
354     $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop);
355   }
356
357 %>
358
359 </TABLE>
360
361 <%= 
362 if ( @optional_packages ) { 
363   my @html;
364   foreach my $ii ( 0 .. $#optional_packages) {
365   my $friendly_index = $ii + 1; 
366   if ($optional_packages[$ii]) {
367     push @html, qq|<BR>Optional Package #$friendly_index <br />|,'<table bgcolor="#c0c0c0"><tr><td>';
368
369     push @html, qq|<select name="optional_package${ii}">|;
370     push @html, qq|<option value="none"></option>|;
371     push @html, map { qq|<option value="$_->{pkgpart}">$_->{pkg}</option>| } @{$optional_packages[$ii]};
372     push @html, q|</select>|;
373     
374     push @html, '</td></tr></table>';
375     }
376     $OUT = join("\n", @html);
377   }  
378 } else {
379 $OUT = ''
380 }
381 %>
382
383 <BR><INPUT TYPE="submit" NAME="signup" VALUE="Signup">
384 <script language="JavaScript">
385
386 function fixup_form() {
387     
388     // copy payment method data up to OneTrueForm
389     
390     var payment_method_elements = new Array( 'payinfo', 'payinfo1', 'payinfo2', 'payname', 'paycvv' , 'paystate', 'paytype', 'month', 'year','type' );
391     var payment_method_form_name = document.OneTrueForm.select.options[document.OneTrueForm.select.selectedIndex].value;
392     document.OneTrueForm.elements['payby'].value = payment_method_form_name;
393     var payment_method_form = document.forms[payment_method_form_name];
394
395     for ( ii = 0 ; ii < payment_method_elements.length ; ii++ ) {
396         var true_element_name = payment_method_form_name + '_' + payment_method_elements[ii];
397         copyelement ( payment_method_form.elements[true_element_name],
398                       document.OneTrueForm.elements[true_element_name] );
399     }
400     
401     // Copy signup details to OneTrueForm
402     
403     var signup_elements = new Array (
404       'promo_code', 'reg_code', 'pkgpart',
405       'username', '_password', '_password2', 'sec_phrase', 'popnum',
406       'mac_addr',
407       'countrycode', 'phonenum', 'sip_password', 'pin'
408     );
409
410     for ( ii = 0 ; ii < signup_elements.length ; ii ++ ) {
411         copyelement ( document.signup_form.elements[signup_elements[ii]],
412                       document.OneTrueForm.elements[signup_elements[ii]]);
413     }
414
415     document.OneTrueForm.submit();
416     return false;
417 }
418
419 function copyelement(from, to) {
420 //    alert ( from + ' ' + to );
421     
422     if ( from == undefined ) {
423         to.value = '';
424     } else { 
425         if ( from.type == 'select-one' ) {
426             to.value = from.options[from.selectedIndex].value;
427         } else if ( from.type == 'checkbox' ) {
428             if ( from.checked ) {
429                 to.value = from.value;
430             } else {
431                 to.value = '';
432             }
433         } else {
434             if ( from.value == undefined ) {
435                 to.value = '';
436             } else {
437                 to.value = from.value;
438             }
439         }
440 //      alert(from.name + " (" + from.type + "): " + to.name + " => " + to.value);
441     }
442 }
443
444 </script>
445 </FORM>
446 <%= $OUT .= $body_footer %>
447 </BODY>
448 </HTML>