referral count search, RT#75757
authorIvan Kohler <ivan@freeside.biz>
Sat, 26 Aug 2017 21:17:55 +0000 (14:17 -0700)
committerIvan Kohler <ivan@freeside.biz>
Sat, 26 Aug 2017 21:17:55 +0000 (14:17 -0700)
FS/FS/cust_main/Search.pm
httemplate/search/report_cust_main.html

index e69e5f2..6d7a9b2 100644 (file)
@@ -884,10 +884,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 )";
   }
 
   ##
index 81d5d58..54e1bb6 100755 (executable)
       <TH ALIGN="right" VALIGN="center"><% mt('Search historical addresses') %></TH>
       <TD><INPUT TYPE="checkbox" NAME="location_history" VALUE="1"></TD>
 
+      <& /elements/tr-input-text.html,
+           label     => emt('At least this many referrals'),
+           field     => 'with_referrals',
+           size      => 4,
+           maxlength => 4,
+      &>
+
   </TABLE>
 
 <BR>