add fuzzy-fuzziness config, RT#22519
authorIvan Kohler <ivan@freeside.biz>
Fri, 19 Apr 2013 07:42:21 +0000 (00:42 -0700)
committerIvan Kohler <ivan@freeside.biz>
Fri, 19 Apr 2013 07:42:21 +0000 (00:42 -0700)
FS/FS/Conf.pm
FS/FS/cust_main/Search.pm

index 76f29bd..6a19ff4 100644 (file)
@@ -3823,6 +3823,13 @@ and customer address. Include units.',
     'type'        => 'checkbox',
   },
 
+  {
+    'key'         => 'fuzzy-fuzziness',
+    'section'     => 'UI',
+    'description' => 'Set the "fuzziness" of fuzzy searching (see the String::Approx manpage for details).  Defaults to 10%',
+    'type'        => 'text',
+  },
+
   { 'key'         => 'pkg_referral',
     'section'     => '',
     'description' => 'Enable package-specific advertising sources.',
index 9ec40cd..7dbb7a8 100644 (file)
@@ -954,6 +954,11 @@ sub fuzzy_search {
 
   my @cust_main = ();
 
+  my @fuzzy_mod = 'i';
+  my $conf = new FS::Conf;
+  my $fuzziness = $conf->config('fuzzy-fuzziness');
+  push @fuzzy_mod, $fuzziness if $fuzziness;
+
   check_and_rebuild_fuzzyfiles();
   foreach my $field ( keys %$fuzzy ) {
 
@@ -961,7 +966,7 @@ sub fuzzy_search {
     next unless scalar(@$all);
 
     my %match = ();
-    $match{$_}=1 foreach ( amatch( $fuzzy->{$field}, ['i'], @$all ) );
+    $match{$_}=1 foreach ( amatch( $fuzzy->{$field}, \@fuzzy_mod, @$all ) );
     next if !keys(%match);
 
     my $in_matches = 'IN (' .