CCH taxes with new customer locations, #21485
[freeside.git] / FS / FS / cust_main / Search.pm
index 5c87f2e..f14f897 100644 (file)
@@ -374,7 +374,7 @@ sub smart_search {
   ( my $card_search = $nospace_search ) =~ s/\-//g;
   $card_search =~ s/[x\*\.\_]/x/gi;
   
-  if ( $nospace_search =~ /^[\dx]{15,16}$/i ) { #credit card search
+  if ( $card_search =~ /^[\dx]{15,16}$/i ) { #credit card search
 
     ( my $like_search = $card_search ) =~ s/x/_/g;
     my $mask_search = FS::payinfo_Mixin->mask_payinfo('CARD', $card_search);
@@ -579,7 +579,16 @@ sub search {
   }
 
   ##
-  # do the same for user
+  # parse sales person
+  ##
+
+  if ( $params->{'salesnum'} =~ /^(\d+)$/ ) {
+    push @where, ($1 > 0 ) ? "cust_main.salesnum = $1"
+                           : 'cust_main.salesnum IS NULL';
+  }
+
+  ##
+  # parse usernum
   ##
 
   if ( $params->{'usernum'} =~ /^(\d+)$/ and $1 ) {
@@ -659,7 +668,9 @@ sub search {
   # parse with hardcoded tax location checkbox
   ##
 
-  push @where, "ship_location.geocode is not null"
+  my $tax_prefix = FS::Conf->new->exists('tax-ship_location') ? 'ship_' 
+                                                              : 'bill_';
+  push @where, "${tax_prefix}location.geocode is not null"
     if $params->{'with_geocode'};
 
   ##