X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main%2FSearch.pm;h=cc23f50e067a830455a9e2d11bf4338d71db645d;hb=3b50b841a272a5cd55497958d572dd73a3339e7b;hp=097f2fb47f55b8117fc642e027c66da8e322d1e9;hpb=92c9e14aa28f017837fb94e4da1d9862e30b02f8;p=freeside.git diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm index 097f2fb47..cc23f50e0 100644 --- a/FS/FS/cust_main/Search.pm +++ b/FS/FS/cust_main/Search.pm @@ -531,10 +531,12 @@ sub email_search { if $DEBUG; push @cust_main, - map $_->cust_main, + map { $_->cust_main } + map { $_->cust_contact } + map { $_->contact } qsearch( { - 'table' => 'cust_main_invoice', - 'hashref' => { 'dest' => $email }, + 'table' => 'contact_email', + 'hashref' => { 'emailaddress' => $email }, } ); @@ -618,6 +620,10 @@ listref (list returned by FS::UI::Web::parse_lt_gt($cgi, 'current_balance')) bool +=item select_referral + +bool, join to part_referral and select part_referral.referral + =back =cut @@ -808,30 +814,24 @@ sub search { ## push @where, - 'EXISTS ( SELECT 1 FROM cust_main_invoice - WHERE cust_main_invoice.custnum = cust_main.custnum - AND length(dest) > 5 - )' # AND dest LIKE '%@%' + 'EXISTS ( SELECT 1 FROM contact_email + JOIN cust_contact USING (contactnum) + WHERE cust_contact.custnum = cust_main.custnum + )' if $params->{'with_email'}; ## # "with postal mail invoices" checkbox ## - push @where, - "EXISTS ( SELECT 1 FROM cust_main_invoice - WHERE cust_main_invoice.custnum = cust_main.custnum - AND dest = 'POST' )" + push @where, "cust_main.postal_invoice = 'Y'" if $params->{'POST'}; ## # "without postal mail invoices" checkbox ## - push @where, - "NOT EXISTS ( SELECT 1 FROM cust_main_invoice - WHERE cust_main_invoice.custnum = cust_main.custnum - AND dest = 'POST' )" + push @where, "cust_main.postal_invoice IS NULL" if $params->{'no_POST'}; ## @@ -1031,6 +1031,13 @@ sub search { my(@extra_headers) = (); my(@extra_fields) = (); + if ($params->{'select_referral'}) { + $addl_from .= ' LEFT JOIN part_referral ON ( cust_main.refnum = part_referral.refnum ) '; + push @select, 'part_referral.referral'; + push @extra_headers, 'Advertising Source'; + push @extra_fields, 'referral'; + } + if ($params->{'flattened_pkgs'}) { #my $pkg_join = '';