From bfb7b46876ec9b25c4ccdd862a7b5868efac9675 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Sat, 26 Aug 2017 14:17:54 -0700 Subject: referral count search, RT#75757 --- FS/FS/cust_main/Search.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'FS') diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm index d66809404..09558b84b 100644 --- a/FS/FS/cust_main/Search.pm +++ b/FS/FS/cust_main/Search.pm @@ -872,10 +872,10 @@ sub search { ## # with referrals ## - if ( $params->{'with_referrals'} ) { + if ( $params->{'with_referrals'} =~ /^\s*(\d+)\s*$/ ) { push @where, - ' EXISTS ( SELECT 1 FROM cust_main AS referred_cust_main - WHERE cust_main.custnum = referred_cust_main.referral_custnum )'; + " $1 <= ( SELECT COUNT(*) FROM cust_main AS referred_cust_main + WHERE cust_main.custnum = referred_cust_main.referral_custnum )"; } ## -- cgit v1.2.1