From 96e32f352f3937bdd2deb279a55d94871396d9c0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Thu, 31 Mar 2022 19:17:59 +0200 Subject: [PATCH] Kunden-/Lieferanten-Suche nach allen Telefonnummern: Leerzeichen ignorieren. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Sowohl in der Sucheingabe, als auch beim Vergleich der DB-Einträge. --- SL/CT.pm | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/SL/CT.pm b/SL/CT.pm index f901a3e69..b52c8794a 100644 --- 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', -- 2.20.1