summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/UI/Web.pm4
-rw-r--r--FS/FS/cust_main/Search.pm2
-rw-r--r--FS/FS/cust_payby.pm3
3 files changed, 6 insertions, 3 deletions
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";