put default country up top
[freeside.git] / httemplate / edit / cust_main.cgi
index 47e18d7..cfd99c8 100755 (executable)
@@ -1,5 +1,5 @@
 <%
-#<!-- $Id: cust_main.cgi,v 1.4 2001-08-28 14:34:14 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 
@@ -22,7 +22,7 @@ use FS::cust_main_county;
   #for misplaced logic below
   use FS::part_pkg;
 
-  #for false laziness below
+  #for false laziness below (now more properly lazy)
   use FS::svc_acct_pop;
 
   #for (other) false laziness below
@@ -74,13 +74,13 @@ $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;
 
 print qq!<FORM ACTION="${p1}process/cust_main.cgi" METHOD=POST NAME="form1">!,
       qq!<INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum">!,
-      qq!Customer # !, ( $custnum ? $custnum : " (NEW)" ),
+      qq!Customer # !, ( $custnum ? "<B>$custnum</B>" : " (NEW)" ),
       
 ;
 
@@ -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,6 +413,8 @@ unless ( $custnum ) {
 
   if ( @part_pkg ) {
 
+#    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">!;
 
@@ -433,25 +440,18 @@ unless ( $custnum ) {
 <TD><INPUT TYPE="text" NAME="_password" VALUE="$password" SIZE=10 MAXLENGTH=8>
 (blank to generate)</TD></TR>
 END
-    print qq!<TR><TD ALIGN="right">POP</TD><TD><SELECT NAME="popnum" SIZE=1><OPTION> !;
-    my($svc_acct_pop);
-    foreach $svc_acct_pop ( qsearch ('svc_acct_pop',{} ) ) {
-    print qq!<OPTION VALUE="!, $svc_acct_pop->popnum, '"',
-          ( $popnum && $svc_acct_pop->popnum == $popnum ) ? ' SELECTED' : '', ">", 
-          $svc_acct_pop->popnum, ": ", 
-          $svc_acct_pop->city, ", ",
-          $svc_acct_pop->state,
-          " (", $svc_acct_pop->ac, ")/",
-          $svc_acct_pop->exch, "\n"
-        ;
-    }
-    print "</SELECT></TD></TR></TABLE>";
+
+    print '<TR><TD ALIGN="right">Access number</TD><TD WIDTH="100%">'
+          .
+          &FS::svc_acct_pop::popselector($popnum).
+          '</TD></TR></TABLE>'
+          ;
   }
 }
 
 $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>",
 ;