[freeside-commits] branch FREESIDE_4_BRANCH updated. a2bb568ac8f2b12250d068d388b1f75431f4cd5c

Jonathan Prykop jonathan at 420.am
Fri May 13 21:00:57 PDT 2016


The branch, FREESIDE_4_BRANCH has been updated
       via  a2bb568ac8f2b12250d068d388b1f75431f4cd5c (commit)
       via  7fc3c31fd31c0aab6ec8c7f16f41799e36c51238 (commit)
       via  3dc73a4d5a199dc197ac8a361ba3e015afb94e3a (commit)
       via  7c648f511c8622deb5b2b72c54281d2bb11ab856 (commit)
      from  f94bba288f69daaadfb23e1ebf9b13e72a670220 (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 a2bb568ac8f2b12250d068d388b1f75431f4cd5c
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Fri May 13 22:47:53 2016 -0500

    RT#41394: Add advertising source to customer fields selection [added referral join to search/cust_event]

diff --git a/httemplate/search/cust_event.html b/httemplate/search/cust_event.html
index ad953e3..b1ba909 100644
--- a/httemplate/search/cust_event.html
+++ b/httemplate/search/cust_event.html
@@ -181,12 +181,16 @@ $search{'ending'}    = $ending;
 my $where = ' WHERE '. FS::cust_event->search_sql_where( \%search );
 
 my $join = FS::cust_event->join_sql() .
+  # warning: does not show the true service address for package events.
+  # the query to do that would be painfully slow.
   'LEFT JOIN cust_location bill_location '.
   'ON (cust_main.bill_locationnum = bill_location.locationnum) '.
   'LEFT JOIN cust_location ship_location '.
-  'ON (cust_main.ship_locationnum = ship_location.locationnum)';
-  # warning: does not show the true service address for package events.
-  # the query to do that would be painfully slow.
+  'ON (cust_main.ship_locationnum = ship_location.locationnum)'.
+  # include link to referral in case it's in cust-fields
+  #   (maybe we should be using FS::UI::Web::join_cust_main instead?)
+  'LEFT JOIN (select refnum, referral from part_referral) AS part_referral_x '.
+  'ON (cust_main.refnum = part_referral_x.refnum) ';
 
 my $sql_query = {
   'table'     => 'cust_event',

commit 7fc3c31fd31c0aab6ec8c7f16f41799e36c51238
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Fri May 13 22:39:07 2016 -0500

    Bug fix, fallout from #36741 commit 11df448b, discovered/fixed while testing #41394

diff --git a/httemplate/search/cust_event.html b/httemplate/search/cust_event.html
index 122bee0..ad953e3 100644
--- a/httemplate/search/cust_event.html
+++ b/httemplate/search/cust_event.html
@@ -157,7 +157,7 @@ die "access denied"
               || $cgi->param('pkgnum')  =~ /^(\d+)$/
             );
 
-my @statuses = $cgi->multi_param('event_status');
+my @statuses = $cgi->param('event_status');
 my $title = 'Billing events';
 if ( $statuses[0] eq 'failed' and !defined($statuses[1]) ) {
   # tweak the title if we're showing only failed events

commit 3dc73a4d5a199dc197ac8a361ba3e015afb94e3a
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 7c648f511c8622deb5b2b72c54281d2bb11ab856
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 = (

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

Summary of changes:
 FS/FS/ConfDefaults.pm             |    3 +++
 FS/FS/UI/Web.pm                   |    8 ++++++++
 FS/FS/cust_main/Search.pm         |    4 ++++
 FS/FS/cust_payby.pm               |    3 +++
 httemplate/search/cust_event.html |   12 ++++++++----
 5 files changed, 26 insertions(+), 4 deletions(-)




More information about the freeside-commits mailing list