Kunden-/Lieferanten-Suche nach allen Telefonnummern: Leerzeichen ignorieren.
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Thu, 31 Mar 2022 17:17:59 +0000 (19:17 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 4 Apr 2022 12:34:26 +0000 (14:34 +0200)
Sowohl in der Sucheingabe, als auch beim Vergleich der DB-Einträge.

SL/CT.pm

index f901a3e..b52c879 100644 (file)
--- a/SL/CT.pm
+++ b/SL/CT.pm
@@ -246,21 +246,25 @@ sub search {
   }
 
   if ($form->{all_phonenumbers}) {
-    $where .= qq| AND (ct.phone ILIKE ? OR
-                       ct.fax   ILIKE ? OR
+    my $search_term = trim($form->{all_phonenumbers});
+    $search_term    =~ s{\p{WSpace}+}{}g;
+    $search_term    = join ' *', split(//, $search_term);
+
+    $where .= qq| AND (ct.phone ~* ? OR
+                       ct.fax   ~* ? OR
                        ct.id    IN
                          (SELECT cp_cv_id FROM contacts
-                          WHERE cp_phone1      ILIKE ? OR
-                                cp_phone2      ILIKE ? OR
-                                cp_fax         ILIKE ? OR
-                                cp_mobile1     ILIKE ? OR
-                                cp_mobile2     ILIKE ? OR
-                                cp_satphone    ILIKE ? OR
-                                cp_satfax      ILIKE ? OR
-                                cp_privatphone ILIKE ?
+                          WHERE cp_phone1      ~* ? OR
+                                cp_phone2      ~* ? OR
+                                cp_fax         ~* ? OR
+                                cp_mobile1     ~* ? OR
+                                cp_mobile2     ~* ? OR
+                                cp_satphone    ~* ? OR
+                                cp_satfax      ~* ? OR
+                                cp_privatphone ~* ?
                          )
     )|;
-    push @values, (like(trim($form->{all_phonenumbers})))x10;
+    push @values, ($search_term)x10;
   }
 
   my ($cvar_where, @cvar_values) = CVar->build_filter_query('module'         => 'CT',