my $where_clause = @filter_ary ? join(" AND ", @filter_ary) . " AND " : '';
+ my ($cvar_where, @cvar_values) = CVar->build_filter_query(
+ module => 'IC',
+ trans_id_field => 'p.id',
+ filter => $form,
+ sub_module => undef,
+ );
+
+ if ($cvar_where) {
+ $where_clause .= qq| ($cvar_where) AND |;
+ push @filter_vars, @cvar_values;
+ }
+
$select_tokens{'trans'} = {
"parts_id" => "i1.parts_id",
"qty" => "ABS(SUM(i1.qty))",
# take all the requested ones from the first hash and overwrite them from the out/in hashes if present.
for my $i ('trans', 'out', 'in') {
$select{$i} = join ', ', map { +/^l_/; ($select_tokens{$i}{"$'"} || $select_tokens{'trans'}{"$'"}) . " AS r_$'" }
- ( grep( { !/qty$/ and /^l_/ and $form->{$_} eq 'Y' } keys %$form), qw(l_parts_id l_qty l_partunit l_shippingdate) );
+ ( grep( { !/qty$/ and !/^l_cvar/ and /^l_/ and $form->{$_} eq 'Y' } keys %$form), qw(l_parts_id l_qty l_partunit l_shippingdate) );
}
my $group_clause = join ", ", map { +/^l_/; "r_$'" }
- ( grep( { !/qty$/ and /^l_/ and $form->{$_} eq 'Y' } keys %$form), qw(l_parts_id l_partunit l_shippingdate l_itime) );
+ ( grep( { !/qty$/ and !/^l_cvar/ and /^l_/ and $form->{$_} eq 'Y' } keys %$form), qw(l_parts_id l_partunit l_shippingdate l_itime) );
$where_clause = defined($where_clause) ? $where_clause : '';
( grep( { !/qty/ and !/^l_cvar/ and /^l_/ and $form->{$_} eq 'Y' } keys %$form),
qw(l_parts_id l_qty l_partunit) );
+ my ($cvar_where, @cvar_values) = CVar->build_filter_query(
+ module => 'IC',
+ trans_id_field => 'p.id',
+ filter => $form,
+ sub_module => undef,
+ );
+
+ if ($cvar_where) {
+ $where_clause .= qq| AND ($cvar_where)|;
+ push @filter_vars, @cvar_values;
+ }
+
my $query =
qq|SELECT * FROM ( SELECT $select_clause
FROM inventory i