added (incomplete) export foo
[freeside.git] / httemplate / edit / cust_main.cgi
index fad4d9e..89a946b 100755 (executable)
@@ -1,4 +1,4 @@
-<!-- $Id: cust_main.cgi,v 1.19 2002-01-30 14:18:08 ivan Exp $ -->
+<!-- mason kludge -->
 <%
 
   #for misplaced logic below
@@ -153,16 +153,24 @@ END
 print <<END;
 <INPUT TYPE="text" NAME="last" VALUE="$last"> , 
 <INPUT TYPE="text" NAME="first" VALUE="$first">
+</TD>
 END
 
+if ( $conf->exists('show_ss') ) {
+  print qq!<TD ALIGN="right">SS#</TD><TD><INPUT TYPE="text" NAME="ss" VALUE="$ss" SIZE=11></TD>!;
+} else {
+  print qq!<TD><INPUT TYPE="hidden" NAME="ss" VALUE="$ss"></TD>!;
+}
+
 print <<END;
-</TD><TD ALIGN="right">SS#</TD><TD><INPUT TYPE="text" NAME="ss" VALUE="$ss" SIZE=11></TD></TR>
+</TR>
 <TR><TD ALIGN="right">Company</TD><TD COLSPAN=5><INPUT TYPE="text" NAME="company" VALUE="$company" SIZE=70></TD></TR>
 <TR><TH ALIGN="right">${r}Address</TH><TD COLSPAN=5><INPUT TYPE="text" NAME="address1" VALUE="$address1" SIZE=70></TD></TR>
 <TR><TD ALIGN="right">&nbsp;</TD><TD COLSPAN=5><INPUT TYPE="text" NAME="address2" VALUE="$address2" SIZE=70></TD></TR>
 <TR><TH ALIGN="right">${r}City</TH><TD><INPUT TYPE="text" NAME="city" VALUE="$city"></TD><TH ALIGN="right">${r}State/Country</TH><TD><SELECT NAME="state" SIZE="1">
 END
 
+#false laziness with ship_state
 my $countrydefault = $conf->config('countrydefault') || 'US';
 $cust_main->country( $countrydefault ) unless $cust_main->country;
 $cust_main->state( $conf->config('statedefault') || 'CA' )
@@ -224,7 +232,8 @@ END
   unless ( $cust_main->ship_last ) {
     print ' CHECKED';
     foreach (
-      qw( last first company address1 address2 city state zip daytime night fax)
+      qw( last first company address1 address2 city county state zip country
+          daytime night fax )
     ) {
       $cust_main->set("ship_$_", $cust_main->get($_) );
     }
@@ -258,11 +267,17 @@ END
   <TR><TH ALIGN="right">${r}City</TH><TD><INPUT TYPE="text" NAME="ship_city" VALUE="$ship_city" onChange="changed(this)"></TD><TH ALIGN="right">${r}State/Country</TH><TD><SELECT NAME="ship_state" SIZE="1" onChange="changed(this)">
 END
 
+  #false laziness with regular state
   $cust_main->ship_country( $conf->config('countrydefault') || 'US' )
     unless $cust_main->ship_country;
   $cust_main->ship_state( $conf->config('statedefault') || 'CA' )
     unless $cust_main->ship_state || $cust_main->ship_country ne 'US';
-  foreach ( qsearch('cust_main_county',{}) ) {
+  foreach ( sort {
+       ( $b->country eq $countrydefault ) <=> ( $a->country eq $countrydefault )
+    or $a->country                        cmp $b->country
+    or $a->state                          cmp $b->state
+    or $a->county                         cmp $b->county
+  } qsearch('cust_main_county',{}) ) {
     print "<OPTION";
     print " SELECTED" if ( $cust_main->ship_state eq $_->state
                            && $cust_main->ship_county eq $_->county