##
# 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
+ )";
+
}
##
<TH CLASS="background" COLSPAN=2> </TH>
</TR>
<TR>
+ <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1"><% mt('Referral search options') |h %></FONT></TH>
+ </TR>
+
+ <& /elements/tr-input-text.html,
+ label => emt('At least this many'),
+ field => 'with_referrals',
+ size => 4,
+ maxlength => 4,
+ &>
+
+ <& /elements/tr-select-cust_main-status.html,
+ label => emt('Referral status'),
+ field => 'referral_status',
+ &>
+
+ <TR>
+ <TH CLASS="background" COLSPAN=2> </TH>
+ </TR>
+ <TR>
<TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1"><% mt('Package search options') |h %></FONT></TH>
</TR>
<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>