X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/3f5c7866bc6ee20f028afa3862de2e14745bf795..c6dd542b51ae9549ad42a54f9023b905412bbab9:/SL/DB/Manager/PriceRuleItem.pm diff --git a/SL/DB/Manager/PriceRuleItem.pm b/SL/DB/Manager/PriceRuleItem.pm index 2d3e9cfe9..83a4bf169 100644 --- a/SL/DB/Manager/PriceRuleItem.pm +++ b/SL/DB/Manager/PriceRuleItem.pm @@ -75,7 +75,39 @@ sub not_matching_sql_and_values { sub get_all_types { my ($class, $vc) = @_; - [ map { [ $_, $types{$_}{description} ] } grep { $types{$_}{$vc} } map { $_ } @types ]; + $vc + ? [ map { [ $_, $types{$_}{description} ] } grep { $types{$_}{$vc} } map { $_ } @types ] + : [ map { [ $_, $types{$_}{description} ] } map { $_ } @types ] } +sub get_type { + $types{$_[1]} +} + +sub filter_match { + my ($self, $type, $value) = @_; + + my $type_def = $types{$type}; + + if (!$type_def->{ops}) { + my $evalue = $::form->get_standard_dbh->quote($value); + return "value_$type_def->{data_type} = $evalue"; + } elsif ($type_def->{ops} eq 'date') { + my $date_value = $::form->get_standard_dbh->quote(DateTime->from_kivitendo($value)); + return " + (value_$type_def->{data_type} > $date_value AND op = 'lt') OR + (value_$type_def->{data_type} < $date_value AND op = 'gt') OR + (value_$type_def->{data_type} = $date_value AND op = 'eq') + "; + } elsif ($type_def->{ops} eq 'num') { + my $num_value = $::form->get_standard_dbh->quote($::form->parse_amount(\%::myconfig, $value)); + return " + (value_$type_def->{data_type} >= $num_value AND op = 'le') OR + (value_$type_def->{data_type} <= $num_value AND op = 'ge') OR + (value_$type_def->{data_type} = $num_value AND op = 'eq') + "; + } +} + + 1;