[freeside-commits] branch master updated. 12a1fd3b75876dd3ec5449bc87fd8313da1b750b

Jonathan Prykop jonathan at 420.am
Thu May 12 20:38:50 PDT 2016


The branch, master has been updated
       via  12a1fd3b75876dd3ec5449bc87fd8313da1b750b (commit)
       via  cf2014ff0946351fd7bd4bc134ae2535543b63da (commit)
       via  99721eb3ca5b9200d2aaec4cab0cf120e382ed99 (commit)
      from  350c6073bb6cf465b02ef373bf7bfde2a8a07500 (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 12a1fd3b75876dd3ec5449bc87fd8313da1b750b
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Thu May 12 22:37:25 2016 -0500

    RT#41394: Add advertising source to customer fields selection [safer part_referral join]

diff --git a/FS/FS/UI/Web.pm b/FS/FS/UI/Web.pm
index f460904..e07e682 100644
--- a/FS/FS/UI/Web.pm
+++ b/FS/FS/UI/Web.pm
@@ -456,7 +456,7 @@ sub cust_sql_fields {
     push @extra_fields, FS::cust_main->balance_sql . " AS current_balance";
   }
 
-  push @extra_fields, 'part_referral.referral AS referral'
+  push @extra_fields, 'part_referral_x.referral AS referral'
     if grep { $_ eq 'referral' } @cust_fields;
 
   map("cust_main.$_", @fields), @location_fields, @extra_fields;
@@ -524,7 +524,7 @@ sub join_cust_main {
   }
 
   if ( !@cust_fields or grep { $_ eq 'referral' } @cust_fields ) {
-    $sql .= ' LEFT JOIN part_referral ON (cust_main.refnum = part_referral.refnum) ';
+    $sql .= ' LEFT JOIN (select refnum, referral from part_referral) AS part_referral_x ON (cust_main.refnum = part_referral_x.refnum) ';
   }
 
   $sql;
diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index 8e6d185..11a106a 100644
--- a/FS/FS/cust_main/Search.pm
+++ b/FS/FS/cust_main/Search.pm
@@ -1015,7 +1015,7 @@ sub search {
 
   # always make referral available in results
   #   (maybe we should be using FS::UI::Web::join_cust_main instead?)
-  $addl_from .= ' LEFT JOIN part_referral ON (cust_main.refnum = part_referral.refnum) ';
+  $addl_from .= ' LEFT JOIN (select refnum, referral from part_referral) AS part_referral_x ON (cust_main.refnum = part_referral_x.refnum) ';
 
   my $count_query = "SELECT COUNT(*) FROM cust_main $addl_from $extra_sql";
 
diff --git a/FS/FS/cust_payby.pm b/FS/FS/cust_payby.pm
index 50d9ee0..5bfb4af 100644
--- a/FS/FS/cust_payby.pm
+++ b/FS/FS/cust_payby.pm
@@ -831,6 +831,9 @@ sub search_sql {
       ' LEFT JOIN cust_location AS '.$pre.'location '.
       'ON (cust_main.'.$pre.'locationnum = '.$pre.'location.locationnum) ';
   }
+  # always make referral available in results
+  #   (maybe we should be using FS::UI::Web::join_cust_main instead?)
+  $addl_from .= ' LEFT JOIN (select refnum, referral from part_referral) AS part_referral_x ON (cust_main.refnum = part_referral_x.refnum) ';
 
   my $count_query = "SELECT COUNT(*) FROM cust_payby $addl_from $extra_sql";
 

commit cf2014ff0946351fd7bd4bc134ae2535543b63da
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Thu Apr 28 14:08:58 2016 -0500

    RT#41394: Add advertising source to customer fields selection

diff --git a/FS/FS/ConfDefaults.pm b/FS/FS/ConfDefaults.pm
index b24a300..4c37175 100644
--- a/FS/FS/ConfDefaults.pm
+++ b/FS/FS/ConfDefaults.pm
@@ -77,6 +77,9 @@ sub cust_fields_avail { (
   'Cust# | Cust. Status | Name | Company | (bill) Address 1 | (bill) Address 2 | (bill) City | (bill) State | (bill) Zip | (bill) Country | (bill) Latitude | (bill) Longitude | Day phone | Night phone | Mobile phone | Fax number | (service) Address 1 | (service) Address 2 | (service) City | (service) State | (service) Zip | (service) Country | (service) Latitude | (service) Longitude | Invoicing email(s) | Payment Type | Current Balance' =>
     'custnum | Status | Last, First | Company | (address+coord) | (all phones) | (service address+coord) | Invoicing email(s) | Payment Type | Current Balance',
 
+  'Cust# | Cust. Status | Name | Company | (bill) Address 1 | (bill) Address 2 | (bill) City | (bill) State | (bill) Zip | (bill) Country | (bill) Latitude | (bill) Longitude | Day phone | Night phone | Mobile phone | Fax number | (service) Address 1 | (service) Address 2 | (service) City | (service) State | (service) Zip | (service) Country | (service) Latitude | (service) Longitude | Invoicing email(s) | Payment Type | Current Balance | Advertising Source' =>
+    'custnum | Status | Last, First | Company | (address+coord) | (all phones) | (service address+coord) | Invoicing email(s) | Payment Type | Current Balance | Advertising Source',
+
   'Invoicing email(s)' => 'Invoicing email(s)',
   'Cust# | Invoicing email(s)' => 'custnum | Invoicing email(s)',
 
diff --git a/FS/FS/UI/Web.pm b/FS/FS/UI/Web.pm
index 8f10011..f460904 100644
--- a/FS/FS/UI/Web.pm
+++ b/FS/FS/UI/Web.pm
@@ -346,6 +346,7 @@ sub cust_header {
     'Payment Type'             => 'cust_payby',
     'Current Balance'          => 'current_balance',
     'Agent Cust#'              => 'agent_custid',
+    'Advertising Source'       => 'referral',
   );
   $header2method{'Cust#'} = 'display_custnum'
     if $conf->exists('cust_main-default_agent_custid');
@@ -455,6 +456,9 @@ sub cust_sql_fields {
     push @extra_fields, FS::cust_main->balance_sql . " AS current_balance";
   }
 
+  push @extra_fields, 'part_referral.referral AS referral'
+    if grep { $_ eq 'referral' } @cust_fields;
+
   map("cust_main.$_", @fields), @location_fields, @extra_fields;
 }
 
@@ -519,6 +523,10 @@ sub join_cust_main {
             " ON (ship_location.locationnum = $location_table.$locationnum) ";
   }
 
+  if ( !@cust_fields or grep { $_ eq 'referral' } @cust_fields ) {
+    $sql .= ' LEFT JOIN part_referral ON (cust_main.refnum = part_referral.refnum) ';
+  }
+
   $sql;
 }
 
diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index c8a084c..8e6d185 100644
--- a/FS/FS/cust_main/Search.pm
+++ b/FS/FS/cust_main/Search.pm
@@ -1013,6 +1013,10 @@ sub search {
       'ON (cust_main.'.$pre.'locationnum = '.$pre.'location.locationnum) ';
   }
 
+  # always make referral available in results
+  #   (maybe we should be using FS::UI::Web::join_cust_main instead?)
+  $addl_from .= ' LEFT JOIN part_referral ON (cust_main.refnum = part_referral.refnum) ';
+
   my $count_query = "SELECT COUNT(*) FROM cust_main $addl_from $extra_sql";
 
   my @select = (

commit 99721eb3ca5b9200d2aaec4cab0cf120e382ed99
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Thu May 12 21:48:48 2016 -0500

    Revert "RT#41394: Add advertising source to customer fields selection [new solution, for advanced customer report only]"
    
    This reverts commit 3b50b841a272a5cd55497958d572dd73a3339e7b.

diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index cc23f50..c8a084c 100644
--- a/FS/FS/cust_main/Search.pm
+++ b/FS/FS/cust_main/Search.pm
@@ -620,10 +620,6 @@ listref (list returned by FS::UI::Web::parse_lt_gt($cgi, 'current_balance'))
 
 bool
 
-=item select_referral
-
-bool, join to part_referral and select part_referral.referral
-
 =back
 
 =cut
@@ -1031,13 +1027,6 @@ sub search {
   my(@extra_headers) = ();
   my(@extra_fields)  = ();
 
-  if ($params->{'select_referral'}) {
-    $addl_from .= ' LEFT JOIN part_referral ON ( cust_main.refnum = part_referral.refnum ) ';
-    push @select, 'part_referral.referral';
-    push @extra_headers, 'Advertising Source';
-    push @extra_fields, 'referral';
-  }
-    
   if ($params->{'flattened_pkgs'}) {
 
     #my $pkg_join = '';
diff --git a/httemplate/search/cust_main.html b/httemplate/search/cust_main.html
index 84eee1b..672c201 100755
--- a/httemplate/search/cust_main.html
+++ b/httemplate/search/cust_main.html
@@ -50,7 +50,6 @@ my @scalars = qw (
   all_tags
   all_pkg_classnums
   any_pkg_status
-  select_referral
 );
 
 for my $param ( @scalars ) {
diff --git a/httemplate/search/report_cust_main.html b/httemplate/search/report_cust_main.html
index 2e8f67b..ba7c99a 100755
--- a/httemplate/search/report_cust_main.html
+++ b/httemplate/search/report_cust_main.html
@@ -278,11 +278,6 @@
     <& /elements/tr-select-cust-fields.html &>
 
     <TR>
-      <TD ALIGN="right" VALIGN="center"><% mt('Add advertising source column') |h %></TD>
-        <TD><INPUT TYPE="checkbox" NAME="select_referral"></TD>
-    </TR>
-
-    <TR>
       <TD ALIGN="right" VALIGN="center"><% mt('Add package columns') |h %></TD>
         <TD><INPUT TYPE="checkbox" NAME="flattened_pkgs"></TD>
     </TR>

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

Summary of changes:
 FS/FS/ConfDefaults.pm                   |    3 +++
 FS/FS/UI/Web.pm                         |    8 ++++++++
 FS/FS/cust_main/Search.pm               |   15 ++++-----------
 FS/FS/cust_payby.pm                     |    3 +++
 httemplate/search/cust_main.html        |    1 -
 httemplate/search/report_cust_main.html |    5 -----
 6 files changed, 18 insertions(+), 17 deletions(-)




More information about the freeside-commits mailing list