use SL::CVar;
use SL::DBUtils;
use SL::DB;
+use SL::Util qw(trim);
use Text::ParseWords;
use strict;
push @values, $form->{create_zugferd_invoices};
}
+ if ($form->{all_phonenumbers}) {
+ $where .= qq| AND (ct.phone ILIKE ? OR
+ ct.fax ILIKE ? 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 ?
+ )
+ )|;
+ push @values, (like(trim($form->{all_phonenumbers})))x10;
+ }
+
my ($cvar_where, @cvar_values) = CVar->build_filter_query('module' => 'CT',
'trans_id_field' => 'ct.id',
'filter' => $form);
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 | .
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 | .
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 | .