summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2017-08-26 14:17:52 -0700
committerIvan Kohler <ivan@freeside.biz>2017-08-26 14:17:52 -0700
commit13bcd704deec03008853c18a0258e031b62e2ec6 (patch)
tree8e83c880be52a819a9cd5d806f5fca5562c94669
parentfaced8039212116eb258f6dc1319d6b4aea8463d (diff)
referral count search, RT#75757
-rw-r--r--FS/FS/cust_main/Search.pm6
-rwxr-xr-xhttemplate/search/report_cust_main.html7
2 files changed, 10 insertions, 3 deletions
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 )";
}
##
diff --git a/httemplate/search/report_cust_main.html b/httemplate/search/report_cust_main.html
index c458bb4af..2a313a13b 100755
--- a/httemplate/search/report_cust_main.html
+++ b/httemplate/search/report_cust_main.html
@@ -107,6 +107,13 @@
</TD>
</TR>
+ <& /elements/tr-input-text.html,
+ label => emt('At least this many referrals'),
+ field => 'with_referrals',
+ size => 4,
+ maxlength => 4,
+ &>
+
</TABLE>
<BR>