summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2017-08-26 15:00:59 -0700
committerIvan Kohler <ivan@freeside.biz>2017-08-26 15:00:59 -0700
commitce7d68e984aab0075f87cf3fa5a55ee4083fadd2 (patch)
tree65f663671428cf496c18b6ce8c9e6cb6f4da90d9 /FS
parent13bcd704deec03008853c18a0258e031b62e2ec6 (diff)
referral status search, RT#75757
Diffstat (limited to 'FS')
-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 09558b84b..4eab474e1 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
+ )";
+
}
##