X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FCT.pm;h=b52c8794acafa55317b3c4bb674b4eab08d223c9;hb=96e32f352f3937bdd2deb279a55d94871396d9c0;hp=031ef112db172ea2411ef733e57477f15bdc07a3;hpb=3bb4190a48d58f5a598b659c27b9a5bf233aa54b;p=kivitendo-erp.git diff --git a/SL/CT.pm b/SL/CT.pm index 031ef112d..b52c8794a 100644 --- a/SL/CT.pm +++ b/SL/CT.pm @@ -42,6 +42,7 @@ use SL::Common; use SL::CVar; use SL::DBUtils; use SL::DB; +use SL::Util qw(trim); use Text::ParseWords; use strict; @@ -244,6 +245,28 @@ sub search { push @values, $form->{create_zugferd_invoices}; } + if ($form->{all_phonenumbers}) { + 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 ~* ? OR + cp_phone2 ~* ? OR + cp_fax ~* ? OR + cp_mobile1 ~* ? OR + cp_mobile2 ~* ? OR + cp_satphone ~* ? OR + cp_satfax ~* ? OR + cp_privatphone ~* ? + ) + )|; + push @values, ($search_term)x10; + } + my ($cvar_where, @cvar_values) = CVar->build_filter_query('module' => 'CT', 'trans_id_field' => 'ct.id', 'filter' => $form); @@ -289,6 +312,7 @@ sub search { qq|SELECT ct.*, ct.itime::DATE AS insertdate, b.description AS business, e.name as salesman, | . qq| pt.description as payment | . $pg_select . + $main_cp_select . qq|, a.invnumber, a.ordnumber, a.quonumber, a.id AS invid, | . qq| '$module' AS module, 'invoice' AS formtype, | . qq| (a.amount = a.paid) AS closed | . @@ -308,6 +332,7 @@ sub search { qq|SELECT ct.*, ct.itime::DATE AS insertdate, b.description AS business, e.name as salesman, | . qq| pt.description as payment | . $pg_select . + $main_cp_select . qq|, ' ' AS invnumber, o.ordnumber, o.quonumber, o.id AS invid, | . qq| 'oe' AS module, 'order' AS formtype, o.closed | . qq|FROM $cv ct | . @@ -326,6 +351,7 @@ sub search { qq|SELECT ct.*, ct.itime::DATE AS insertdate, b.description AS business, e.name as salesman, | . qq| pt.description as payment | . $pg_select . + $main_cp_select . qq|, ' ' AS invnumber, o.ordnumber, o.quonumber, o.id AS invid, | . qq| 'oe' AS module, 'quotation' AS formtype, o.closed | . qq|FROM $cv ct | .