X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main%2FSearch.pm;h=b1438619ba1b2c76756a57087f6183a4014ee5ec;hb=8cc50a2ad12ec3d5bd3f31db741290664064ef06;hp=16db71271ab211bcc4c9250f75d4517bc219727a;hpb=cf4e690746ef76895e50d057b9e3f0e660f8e21e;p=freeside.git diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm index 16db71271..b1438619b 100644 --- a/FS/FS/cust_main/Search.pm +++ b/FS/FS/cust_main/Search.pm @@ -21,6 +21,7 @@ $me = '[FS::cust_main::Search]'; @fuzzyfields = ( 'cust_main.first', 'cust_main.last', 'cust_main.company', + 'cust_main.ship_company', # if you're using it 'cust_location.address1', 'contact.first', 'contact.last', ); @@ -321,6 +322,7 @@ sub smart_search { $sql .= " ( LOWER(cust_main.first) = $q_value OR LOWER(cust_main.last) = $q_value OR LOWER(cust_main.company) = $q_value + OR LOWER(cust_main.ship_company) = $q_value "; #address1 (yes, it's a kludge) @@ -356,27 +358,30 @@ sub smart_search { #substring - my @hashrefs = ( + my @company_hashrefs = ( { 'company' => { op=>'ILIKE', value=>"%$value%" }, }, + { 'ship_company' => { op=>'ILIKE', value=>"%$value%" }, }, ); + my @hashrefs = (); + if ( $first && $last ) { - push @hashrefs, + @hashrefs = ( { 'first' => { op=>'ILIKE', value=>"%$first%" }, 'last' => { op=>'ILIKE', value=>"%$last%" }, }, - ; + ); } else { - push @hashrefs, + @hashrefs = ( { 'first' => { op=>'ILIKE', value=>"%$value%" }, }, { 'last' => { op=>'ILIKE', value=>"%$value%" }, }, - ; + ); } - foreach my $hashref ( @hashrefs ) { + foreach my $hashref ( @company_hashrefs, @hashrefs ) { push @cust_main, qsearch( { 'table' => 'cust_main', @@ -402,8 +407,6 @@ sub smart_search { #contact substring - shift @hashrefs; #no company column in contact table - foreach my $hashref ( @hashrefs ) { push @cust_main, @@ -439,7 +442,7 @@ sub smart_search { %fuzopts ); } - foreach my $field ( 'first', 'last', 'company' ) { + foreach my $field ( 'first', 'last', 'company', 'ship_company' ) { push @cust_main, FS::cust_main::Search->fuzzy_search( { $field => $value }, %fuzopts @@ -1193,6 +1196,7 @@ sub append_fuzzyfiles { #foreach my $fuzzy (@fuzzyfields) { foreach my $fuzzy ( 'cust_main.first', 'cust_main.last', 'cust_main.company', 'cust_location.address1', + 'cust_main.ship_company', ) { append_fuzzyfiles_fuzzyfield($fuzzy, shift);