summaryrefslogtreecommitdiff
path: root/FS/FS/cust_main
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2017-08-26 15:01:09 -0700
committerIvan Kohler <ivan@freeside.biz>2017-08-26 15:01:09 -0700
commit0e31e1eebf37df6227de78fda8cb7a1172018e0e (patch)
treeae91a482efc182abfda3267adf0c08cb28157e11 /FS/FS/cust_main
parentbfb7b46876ec9b25c4ccdd862a7b5868efac9675 (diff)
referral status search, RT#75757
Diffstat (limited to 'FS/FS/cust_main')
-rw-r--r--FS/FS/cust_main/Search.pm20
1 files changed, 17 insertions, 3 deletions
diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index 09558b8..4eab474 100644
--- a/FS/FS/cust_main/Search.pm
+++ b/FS/FS/cust_main/Search.pm
@@ -872,10 +872,24 @@ sub search {
##
# with referrals
##
- if ( $params->{'with_referrals'} =~ /^\s*(\d+)\s*$/ ) {
+ if ( $params->{with_referrals} =~ /^\s*(\d+)\s*$/ ) {
+
+ my $n = $1;
+
+ # referral status
+ my $and_status = '';
+ if ( grep { $params->{referral_status} eq $_ } FS::cust_main->statuses() ) {
+ my $method = $params->{referral_status}. '_sql';
+ $and_status = ' AND '. FS::cust_main->$method();
+ $and_status =~ s/ cust_main\./ referred_cust_main./g;
+ }
+
push @where,
- " $1 <= ( SELECT COUNT(*) FROM cust_main AS referred_cust_main
- WHERE cust_main.custnum = referred_cust_main.referral_custnum )";
+ " $n <= ( SELECT COUNT(*) FROM cust_main AS referred_cust_main
+ WHERE cust_main.custnum = referred_cust_main.referral_custnum
+ $and_status
+ )";
+
}
##