altered FS::UI::Web::cust_sort_fields() and cust_sql_fields() so that ->param('cust_f...
[freeside.git] / FS / FS / UI / Web.pm
index d7f998b..6161706 100644 (file)
@@ -323,6 +323,14 @@ sub cust_header {
   @cust_header;
 }
 
+sub cust_sort_fields {
+  cust_header(@_) if( @_ or !@cust_fields );
+  #inefficientish, but tiny lists and only run once per page
+
+  map { $_ eq 'custnum' ? 'custnum' : '' } @cust_fields;
+
+}
+
 =item cust_sql_fields [ CUST_FIELDS_VALUE ]
 
 Returns a list of fields for the SELECT portion of an SQL query.
@@ -338,7 +346,7 @@ sub cust_sql_fields {
   my @fields = qw( last first company );
 #  push @fields, map "ship_$_", @fields;
 
-  cust_header(@_);
+  cust_header(@_) if( @_ or !@cust_fields );
   #inefficientish, but tiny lists and only run once per page
 
   my @location_fields;
@@ -349,6 +357,11 @@ sub cust_sql_fields {
       }
     }
   }
+  foreach my $pre ('bill_','ship_') {
+    if ( grep { $_ eq $pre.'country_full' } @cust_fields ) {
+      push @location_fields, $pre.'locationnum';
+    }
+  }
 
   foreach my $field (qw(daytime night fax payby)) {
     push @fields, $field if (grep { $_ eq $field } @cust_fields);
@@ -473,6 +486,7 @@ element.
 
 sub cust_fields_subs {
   my $unlinked_warn = 0;
+
   return map { 
     my $f = $_;
     if ( $unlinked_warn++ ) {