use SL::IO;
use SL::MoreCommon;
use SL::DB::Default;
+use SL::Util qw(trim);
use Data::Dumper;
use strict;
}
if ($form->{"cp_name"}) {
$where .= " AND (cp.cp_name ILIKE ? OR cp.cp_givenname ILIKE ?)";
- push(@values, ('%' . $form->{"cp_name"} . '%')x2);
+ push(@values, ('%' . trim($form->{"cp_name"}) . '%')x2);
}
if ($form->{department}) {
# ähnlich wie commit 0bbfb33b6aa8e38bb6c81d1684ab7d08e5b5c5af abteilung
if ($form->{transdatefrom}) {
$where .= " AND a.transdate >= ?";
- push(@values, $form->{transdatefrom});
+ push(@values, trim($form->{transdatefrom}));
}
if ($form->{transdateto}) {
$where .= " AND a.transdate <= ?";
- push(@values, $form->{transdateto});
+ push(@values, trim($form->{transdateto}));
}
if ($form->{open} || $form->{closed}) {
unless ($form->{open} && $form->{closed}) {
use SL::MoreCommon;
use SL::DB::Default;
use SL::TransNumber;
+use SL::Util qw(trim);
use strict;
if ($form->{customernumber}) {
$where .= " AND c.customernumber = ?";
- push(@values, $form->{customernumber});
+ push(@values, trim($form->{customernumber}));
}
if ($form->{customer_id}) {
$where .= " AND a.customer_id = ?";
}
if ($form->{"cp_name"}) {
$where .= " AND (cp.cp_name ILIKE ? OR cp.cp_givenname ILIKE ?)";
- push(@values, ('%' . $form->{"cp_name"} . '%')x2);
+ push(@values, ('%' . trim($form->{"cp_name"}) . '%')x2);
}
if ($form->{business_id}) {
my $business_id = $form->{business_id};
push(@values, $department_id);
}
if ($form->{department}) {
- my $department = "%" . $form->{department} . "%";
+ my $department = "%" . trim($form->{department}) . "%";
$where .= " AND d.description ILIKE ?";
push(@values, $department);
}
if ($form->{transdatefrom}) {
$where .= " AND a.transdate >= ?";
- push(@values, $form->{transdatefrom});
+ push(@values, trim($form->{transdatefrom}));
}
if ($form->{transdateto}) {
$where .= " AND a.transdate <= ?";
- push(@values, $form->{transdateto});
+ push(@values, trim($form->{transdateto}));
}
if ($form->{duedatefrom}) {
$where .= " AND a.duedate >= ?";
- push(@values, $form->{duedatefrom});
+ push(@values, trim($form->{duedatefrom}));
}
if ($form->{duedateto}) {
$where .= " AND a.duedate <= ?";
- push(@values, $form->{duedateto});
+ push(@values, trim($form->{duedateto}));
}
if ($form->{open} || $form->{closed}) {
unless ($form->{open} && $form->{closed}) {
use SL::DBUtils;
use SL::MoreCommon qw(listify);
+use SL::Util qw(trim);
sub get_configs {
$main::lxdebug->enter_sub();
next unless ($params{filter}->{$name});
push @sub_where, qq|cvar.text_value ILIKE ?|;
- push @sub_values, '%' . $params{filter}->{$name} . '%'
+ push @sub_values, '%' . trim($params{filter}->{$name}) . '%'
} elsif ($config->{type} eq 'select') {
next unless ($params{filter}->{$name});
}
push @sub_where, qq|cvar.number_value $op ?|;
- push @sub_values, $form->parse_amount($myconfig, $params{filter}->{$name});
+ push @sub_values, $form->parse_amount($myconfig, trim($params{filter}->{$name}));
} elsif ($config->{type} eq 'bool') {
next unless ($params{filter}->{$name});
my $table = $config->{type};
push @sub_where, qq|cvar.number_value * 1 IN (SELECT id FROM $table WHERE name ILIKE ?)|;
- push @sub_values, "%$params{filter}->{$name}%";
+ push @sub_values, "%" . trim($params{filter}->{$name}) . "%";
} elsif ($config->{type} eq 'part') {
next unless $params{filter}->{$name};
push @sub_where, qq|cvar.number_value * 1 IN (SELECT id FROM parts WHERE partnumber ILIKE ?)|;
- push @sub_values, "%$params{filter}->{$name}%";
+ push @sub_values, "%" . trim($params{filter}->{$name}) . "%";
}
if (@sub_where) {
package SL::DBUtils;
+use SL::Util qw(trim);
+
require Exporter;
our @ISA = qw(Exporter);
sub conv_date {
my ($value) = @_;
- return (defined($value) && "$value" ne "") ? $value : undef;
+ return undef if !defined $value;
+ $value = trim($value);
+ return $value eq "" ? undef : $value;
}
sub conv_dateq {
use SL::DB::Printer;
use SL::DB::Language;
use SL::TransNumber;
+use SL::Util qw(trim);
use strict;
} elsif ($form->{customer}) {
$where .= qq| AND (ct.name ILIKE ?)|;
- push(@values, '%' . $form->{customer} . '%');
+ push(@values, '%' . trim($form->{customer}) . '%');
}
my %columns = (
foreach my $key (keys(%columns)) {
next unless ($form->{$key});
$where .= qq| AND $columns{$key} ILIKE ?|;
- push(@values, '%' . $form->{$key} . '%');
+ push(@values, '%' . trim($form->{$key}) . '%');
}
if ($form->{dunning_level}) {
$form->{minamount} = $form->parse_amount($myconfig,$form->{minamount});
if ($form->{minamount}) {
$where .= qq| AND ((a.amount - a.paid) > ?) |;
- push(@values, $form->{minamount});
+ push(@values, trim($form->{minamount}));
}
my $query =
use SL::RecordLinks;
use SL::IC;
use SL::TransNumber;
+use SL::Util qw(trim);
use strict;
} elsif ($form->{$vc}) {
push @where, qq|ct.name ILIKE ?|;
- push @values, '%' . $form->{$vc} . '%';
+ push @values, '%' . trim($form->{$vc}) . '%';
}
if ($form->{"cp_name"}) {
push @where, "(cp.cp_name ILIKE ? OR cp.cp_givenname ILIKE ?)";
- push @values, ('%' . $form->{"cp_name"} . '%')x2;
+ push @values, ('%' . trim($form->{"cp_name"}) . '%')x2;
}
foreach my $item (qw(employee_id salesman_id)) {
foreach my $item (qw(donumber ordnumber cusordnumber transaction_description)) {
next unless ($form->{$item});
push @where, qq|dord.$item ILIKE ?|;
- push @values, '%' . $form->{$item} . '%';
+ push @values, '%' . trim($form->{$item}) . '%';
}
if (($form->{open} || $form->{closed}) &&
if ($form->{serialnumber}) {
push @where, 'dord.id IN (SELECT doi.delivery_order_id FROM delivery_order_items doi WHERE doi.serialnumber LIKE ?)';
- push @values, '%' . $form->{serialnumber} . '%';
+ push @values, '%' . trim($form->{serialnumber}) . '%';
}
if($form->{transdatefrom}) {
use SL::Request;
use SL::Template;
use SL::User;
+use SL::Util;
use SL::X;
use Template;
use URI;
}
sub like {
- $main::lxdebug->enter_sub();
-
my ($self, $string) = @_;
- if ($string !~ /%/) {
- $string = "%$string%";
- }
-
- $string =~ s/\'/\'\'/g;
-
- $main::lxdebug->leave_sub();
-
- return $string;
+ return "%" . SL::Util::trim($string // '') . "%";
}
sub redo_rows {
use SL::HTML::Restrict;
use SL::IC;
use SL::TransNumber;
+use SL::Util qw(trim);
use Text::ParseWords;
use strict;
} elsif ($form->{$vc}) {
$query .= " AND ct.name ILIKE ?";
- push(@values, '%' . $form->{$vc} . '%');
+ push(@values, '%' . trim($form->{$vc}) . '%');
}
if ($form->{"cp_name"}) {
$query .= " AND (cp.cp_name ILIKE ? OR cp.cp_givenname ILIKE ?)";
- push(@values, ('%' . $form->{"cp_name"} . '%')x2);
+ push(@values, ('%' . trim($form->{"cp_name"}) . '%')x2);
}
if (!$main::auth->assert('sales_all_edit', 1)) {
if ($form->{$ordnumber}) {
$query .= qq| AND o.$ordnumber ILIKE ?|;
- push(@values, '%' . $form->{$ordnumber} . '%');
+ push(@values, '%' . trim($form->{$ordnumber}) . '%');
}
if ($form->{cusordnumber}) {
$query .= qq| AND o.cusordnumber ILIKE ?|;
- push(@values, '%' . $form->{cusordnumber} . '%');
+ push(@values, '%' . trim($form->{cusordnumber}) . '%');
}
if($form->{transdatefrom}) {
if ($form->{shippingpoint}) {
$query .= qq| AND o.shippingpoint ILIKE ?|;
- push(@values, '%' . $form->{shippingpoint} . '%');
+ push(@values, '%' . trim($form->{shippingpoint}) . '%');
}
if ($form->{taxzone_id} ne '') { # taxzone_id could be 0
if ($form->{transaction_description}) {
$query .= qq| AND o.transaction_description ILIKE ?|;
- push(@values, '%' . $form->{transaction_description} . '%');
+ push(@values, '%' . trim($form->{transaction_description}) . '%');
}
if ($form->{periodic_invoices_active} ne $form->{periodic_invoices_inactive}) {
if (($form->{order_probability_value} || '') ne '') {
my $op = $form->{order_probability_value} eq 'le' ? '<=' : '>=';
$query .= qq| AND (o.order_probability ${op} ?)|;
- push @values, $form->{order_probability_value};
+ push @values, trim($form->{order_probability_value});
}
if ($form->{expected_billing_date_from}) {