put default country up top
[freeside.git] / httemplate / edit / cust_main.cgi
index 4711cf5..cfd99c8 100755 (executable)
@@ -1,5 +1,5 @@
 <%
-#<!-- $Id: cust_main.cgi,v 1.6 2001-09-27 21:12:15 ivan Exp $ -->
+#<!-- $Id: cust_main.cgi,v 1.12 2001-10-30 15:42:33 ivan Exp $ -->
 
 use vars qw( $cgi $custnum $action $cust_main $p1 @agents $agentnum 
              $last $first $ss $company $address1 $address2 $city $zip 
@@ -74,7 +74,7 @@ $action = $custnum ? 'Edit' : 'Add';
 # top
 
 $p1 = popurl(1);
-print $cgi->header( '-expires' => 'now' ), header("Customer $action", '');
+print header("Customer $action", '');
 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $error, "</FONT>"
   if $error;
 
@@ -178,11 +178,16 @@ print <<END;
 <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
 
-$cust_main->country( $conf->config('countrydefault') || 'US' )
-  unless $cust_main->country;
+my $countrydefault = $conf->config('countrydefault') || 'US';
+$cust_main->country( $countrydefault ) unless $cust_main->country;
 $cust_main->state( $conf->config('statedefault') || 'CA' )
   unless $cust_main->state || $cust_main->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->state eq $_->state
                          && $cust_main->county eq $_->county 
@@ -408,7 +413,9 @@ unless ( $custnum ) {
 
   if ( @part_pkg ) {
 
-    print "<BR><BR>First package", &itable("#cccccc", "0 ALIGN=LEFT"), #apiabuse
+#    print "<BR><BR>First package", &itable("#cccccc", "0 ALIGN=LEFT"),
+#apiabuse & undesirable wrapping
+    print "<BR><BR>First package", &itable("#cccccc"),
           qq!<TR><TD COLSPAN=2><SELECT NAME="pkgpart_svcpart">!;
 
     print qq!<OPTION VALUE="">(none)!;
@@ -444,7 +451,7 @@ END
 
 $otaker = $cust_main->otaker;
 print qq!<INPUT TYPE="hidden" NAME="otaker" VALUE="$otaker">!,
-      qq!<BR><BR><INPUT TYPE="submit" VALUE="!,
+      qq!<BR><INPUT TYPE="submit" VALUE="!,
       $custnum ?  "Apply Changes" : "Add Customer", qq!">!,
       "</FORM></BODY></HTML>",
 ;