X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FHelper%2FParseFilter.pm;h=5e18081eea4f0fe8806181b990c882506347e14d;hb=9c785acd332352877abd90cd0c79a2fa1ef214a1;hp=2ff97987c727fef8b0520b4edd1add46a711201a;hpb=3e988f3db569f269c7f1a4040f5dd4c9c5ebf2e6;p=kivitendo-erp.git diff --git a/SL/Controller/Helper/ParseFilter.pm b/SL/Controller/Helper/ParseFilter.pm index 2ff97987c..5e18081ee 100644 --- a/SL/Controller/Helper/ParseFilter.pm +++ b/SL/Controller/Helper/ParseFilter.pm @@ -8,6 +8,7 @@ our @EXPORT = qw(parse_filter); use DateTime; use SL::Helper::DateTime; use List::MoreUtils qw(uniq); +use SL::Util qw(trim); use SL::MoreCommon qw(listify); use Data::Dumper; use Text::ParseWords; @@ -24,9 +25,10 @@ my %filters = ( date => sub { DateTime->from_lxoffice($_[0]) }, number => sub { $::form->parse_amount(\%::myconfig, $_[0]) }, percent => sub { $::form->parse_amount(\%::myconfig, $_[0]) / 100 }, - head => sub { $_[0] . '%' }, - tail => sub { '%' . $_[0] }, - substr => sub { '%' . $_[0] . '%' }, + head => sub { trim($_[0]) . '%' }, + tail => sub { '%' . trim($_[0]) }, + substr => sub { '%' . trim($_[0]) . '%' }, + trim => sub { trim($_[0]) }, ); my %methods = ( @@ -277,10 +279,10 @@ SL::Controller::Helper::ParseFilter - Convert a form filter spec into a RDBO get =head1 SYNOPSIS use SL::Controller::Helper::ParseFilter; - SL::DB::Object->get_all(parse_filter($::form->{filter})); + SL::DB::Manager::Object->get_all(parse_filter($::form->{filter})); # or more complex - SL::DB::Object->get_all(parse_filter($::form->{filter}, + SL::DB::Manager::Object->get_all(parse_filter($::form->{filter}, with_objects => [ qw(part customer) ])); =head1 DESCRIPTION @@ -432,22 +434,22 @@ Pasres the input string with C<< Form->parse_amount >> Parses the input string with C<< Form->parse_amount / 100 >> +=item trim + +Removes whitespace characters (to be precice, characters with the \p{WSpace} +property from beginning and end of the value. + =item head -Adds "%" at the end of the string. +Adds "%" at the end of the string and applies C. =item tail -Adds "%" at the end of the string. +Adds "%" at the end of the string and applies C. =item substr -Adds "% .. %" around the search string. - -=item eq_ignore_empty - -Ignores this item if it's empty. Otherwise compares it with the -standard SQL C<=> operator. +Adds "% .. %" around the search string and applies C. =back @@ -465,13 +467,18 @@ standard SQL C<=> operator. All these are recognized like the L methods. -=item lazu_bool_eq +=item lazy_bool_eq If the value is undefined or an empty string then this parameter will be completely removed from the query. Otherwise a falsish filter value will match for C and C; trueish values will only match C. +=item eq_ignore_empty + +Ignores this item if it's empty. Otherwise compares it with the +standard SQL C<=> operator. + =back =head1 BUGS AND CAVEATS