diff options
| author | Ivan Kohler <ivan@freeside.biz> | 2017-04-27 13:41:59 -0700 |
|---|---|---|
| committer | Ivan Kohler <ivan@freeside.biz> | 2017-04-27 13:41:59 -0700 |
| commit | d3ccf0b542d3b23f5bd851cdf1edbbc0de81f0b6 (patch) | |
| tree | 82622688735c8c6687c141d71c1f0f2d49453826 /FS | |
| parent | 76ab8e3f6ebd579b2bf9804528b55189d47f77bc (diff) | |
customer referral report, RT#75757
Diffstat (limited to 'FS')
| -rw-r--r-- | FS/FS/cust_main/Search.pm | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm index 4473aeda2..0eb00202b 100644 --- a/FS/FS/cust_main/Search.pm +++ b/FS/FS/cust_main/Search.pm @@ -866,6 +866,15 @@ sub search { if $params->{'no_tax'}; ## + # with referrals + ## + if ( $params->{'with_referrals'} ) { + push @where, + ' EXISTS ( SELECT 1 FROM cust_main AS referred_cust_main + WHERE cust_main.custnum = referred_cust_main.referral_custnum )'; + } + + ## # dates ## @@ -1101,6 +1110,20 @@ sub search { } + if ( $params->{'with_referrals'} ) { + + #XXX next: num for each customer status + + push @select, + '( SELECT COUNT(*) FROM cust_main AS referred_cust_main + WHERE cust_main.custnum = referred_cust_main.referral_custnum + ) AS num_referrals'; + + unshift @extra_headers, 'Referrals'; + unshift @extra_fields, 'num_referrals'; + + } + my $select = join(', ', @select); my $sql_query = { |
