From: Sven Schöling Date: Thu, 4 Mar 2010 09:31:06 +0000 (+0100) Subject: CVars über die Warenmaske auch in Belegen suchen. X-Git-Tag: release-2.6.1beta1~33^2~11^2~2 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=60ebd03b8391b3eeeb75a2c4408340346732d028;p=kivitendo-erp.git CVars über die Warenmaske auch in Belegen suchen. Fix für Bug 1209. --- diff --git a/SL/CVar.pm b/SL/CVar.pm index 4d9b6a700..cdc05b5ab 100644 --- a/SL/CVar.pm +++ b/SL/CVar.pm @@ -490,8 +490,7 @@ sub build_filter_query { } if (@sub_where) { - push @sub_where, qq|cvar.sub_module = ?|; - push @sub_values, "$params{sub_module}"; + add_token(\@sub_where, \@sub_values, col => 'cvar.sub_module', val => $params{sub_module} || ''); push @where, qq|$not EXISTS( diff --git a/SL/IC.pm b/SL/IC.pm index 080aedffe..bce0debe7 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -35,7 +35,7 @@ package IC; use Data::Dumper; -use List::MoreUtils qw(all any); +use List::MoreUtils qw(all any uniq); use YAML; use SL::CVar; @@ -1005,9 +1005,23 @@ sub all_parts { my $where_clause = join ' AND ', map { "($_)" } @where_tokens; my $group_clause = ' GROUP BY ' . join ', ', map { $token_builder->($_) } @group_tokens if scalar @group_tokens; - my ($cvar_where, @cvar_values) = CVar->build_filter_query('module' => 'IC', - 'trans_id_field' => 'p.id', - 'filter' => $form); + my %oe_flag_to_cvar = ( + bought => 'invoice', + sold => 'invoice', + onorder => 'orderitems', + ordered => 'orderitems', + rfq => 'orderitems', + quoted => 'orderitems', + ); + + my ($cvar_where, @cvar_values) = CVar->build_filter_query( + module => 'IC', + trans_id_field => $bsooqr ? 'ioi.id': 'p.id', + filter => $form, + sub_module => $bsooqr ? [ uniq grep { $oe_flag_to_cvar{$form->{$_}} } @oe_flags ] : undef, + ); + + $::lxdebug->dump(0, "\@cvar_val", \@cvar_values); if ($cvar_where) { $where_clause .= qq| AND ($cvar_where)|;