From 60ebd03b8391b3eeeb75a2c4408340346732d028 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 4 Mar 2010 10:31:06 +0100 Subject: [PATCH] =?utf8?q?CVars=20=C3=BCber=20die=20Warenmaske=20auch=20in?= =?utf8?q?=20Belegen=20suchen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fix für Bug 1209. --- SL/CVar.pm | 3 +-- SL/IC.pm | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) 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)|; -- 2.20.1