[freeside-commits] branch FREESIDE_4_BRANCH updated. e786870dfc0f7d1f1b84c18a8de8f5dc402ed40a

Ivan ivan at 420.am
Sun Oct 1 15:17:38 PDT 2017


The branch, FREESIDE_4_BRANCH has been updated
       via  e786870dfc0f7d1f1b84c18a8de8f5dc402ed40a (commit)
      from  041ede06710837b92b2d17a0f4b63ab0710a6f25 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e786870dfc0f7d1f1b84c18a8de8f5dc402ed40a
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sun Oct 1 15:17:37 2017 -0700

    sort by referral count, RT#75757

diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index 27559d7..68471ec 100644
--- a/FS/FS/cust_main/Search.pm
+++ b/FS/FS/cust_main/Search.pm
@@ -1081,8 +1081,9 @@ sub search {
                  FS::UI::Web::cust_sql_fields($params->{'cust_fields'}),
                );
 
-  my(@extra_headers) = ();
-  my(@extra_fields)  = ();
+  my @extra_headers     = ();
+  my @extra_fields      = ();
+  my @extra_sort_fields = ();
 
   if ($params->{'flattened_pkgs'}) {
 
@@ -1127,6 +1128,7 @@ sub search {
                                          my $p = $a[!.--$headercount. q!];
                                          $p;
                                         };!;
+      unshift @extra_sort_fields, '';
     }
 
   }
@@ -1142,21 +1144,23 @@ sub search {
 
     unshift @extra_headers, 'Referrals';
     unshift @extra_fields, 'num_referrals';
+    unshift @extra_sort_fields, 'num_referrals';
 
   }
 
   my $select = join(', ', @select);
 
   my $sql_query = {
-    'table'         => 'cust_main',
-    'select'        => $select,
-    'addl_from'     => $addl_from,
-    'hashref'       => {},
-    'extra_sql'     => $extra_sql,
-    'order_by'      => $orderby,
-    'count_query'   => $count_query,
-    'extra_headers' => \@extra_headers,
-    'extra_fields'  => \@extra_fields,
+    'table'             => 'cust_main',
+    'select'            => $select,
+    'addl_from'         => $addl_from,
+    'hashref'           => {},
+    'extra_sql'         => $extra_sql,
+    'order_by'          => $orderby,
+    'count_query'       => $count_query,
+    'extra_headers'     => \@extra_headers,
+    'extra_fields'      => \@extra_fields,
+    'extra_sort_fields' => \@extra_sort_fields,
   };
   $sql_query;
 
diff --git a/httemplate/search/cust_main.html b/httemplate/search/cust_main.html
index c897879..089947d 100755
--- a/httemplate/search/cust_main.html
+++ b/httemplate/search/cust_main.html
@@ -13,6 +13,10 @@
                     \&FS::UI::Web::cust_fields,
                     @extra_fields,
                   ],
+                  #'sort_fields' => [
+                  #  FS::UI::Web::cust_sort_fields(),
+                  #  @extra_sort_fields,
+                  #],
                   'color'       => [ FS::UI::Web::cust_colors(),
                                      map '', @extra_fields
                                    ],
@@ -110,9 +114,10 @@ $search_hash{'current_balance'} =
 ###
 
 my $sql_query = FS::cust_main::Search->search(\%search_hash);
-my $count_query   = delete($sql_query->{'count_query'});
-my @extra_headers = @{ delete($sql_query->{'extra_headers'}) };
-my @extra_fields  = @{ delete($sql_query->{'extra_fields'})  };
+my $count_query = delete($sql_query->{'count_query'});
+my @extra_headers     = @{ delete($sql_query->{'extra_headers'}) };
+my @extra_fields      = @{ delete($sql_query->{'extra_fields'})  };
+my @extra_sort_fields = @{ delete($sql_query->{'extra_sort_fields'})  };
 
 my $link = [ "${p}view/cust_main.cgi?", 'custnum' ];
 

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/cust_main/Search.pm        |   26 +++++++++++++++-----------
 httemplate/search/cust_main.html |   11 ++++++++---
 2 files changed, 23 insertions(+), 14 deletions(-)




More information about the freeside-commits mailing list