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))",
( 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
show_no_warehouses_error() if (!scalar @{ $form->{WAREHOUSES} });
my $cvar_configs = CVar->get_configs('module' => 'IC');
- (undef,
+ ($form->{CUSTOM_VARIABLES_FILTER_CODE},
$form->{CUSTOM_VARIABLES_INCLUSION_CODE}) = CVar->render_search_options('variables' => $cvar_configs,
'include_prefix' => 'l_',
'include_value' => 'Y');
my $cvar_configs = CVar->get_configs('module' => 'IC');
my @includeable_custom_variables = grep { $_->{includeable} } @{ $cvar_configs };
+ my @searchable_custom_variables = grep { $_->{searchable} } @{ $cvar_configs };
push @columns, map { "cvar_$_->{name}" } @includeable_custom_variables;
my @hidden_variables = map { "l_${_}" } @columns;
push @hidden_variables, qw(warehouse_id bin_id partnumber description chargenumber bestbefore qty_op qty qty_unit unit partunit fromdate todate transtype_ids comment projectnumber);
push @hidden_variables, qw(classification_id);
+ push @hidden_variables, map({'cvar_'. $_->{name}} @searchable_custom_variables);
+ push @hidden_variables, map({'cvar_'. $_->{name} .'_from'} grep({$_->{type} eq 'date'} @searchable_custom_variables));
+ push @hidden_variables, map({'cvar_'. $_->{name} .'_to'} grep({$_->{type} eq 'date'} @searchable_custom_variables));
+ push @hidden_variables, map({'cvar_'. $_->{name} .'_qtyop'} grep({$_->{type} eq 'number'} @searchable_custom_variables));
my %column_defs = (
'ids' => { raw_header_data => checkbox_tag("", id => "check_all", checkall => "[data-checkall=1]") },
show_no_warehouses_error() if (!scalar @{ $form->{WAREHOUSES} });
my $cvar_configs = CVar->get_configs('module' => 'IC');
- (undef,
+ ($form->{CUSTOM_VARIABLES_FILTER_CODE},
$form->{CUSTOM_VARIABLES_INCLUSION_CODE}) = CVar->render_search_options('variables' => $cvar_configs,
'include_prefix' => 'l_',
'include_value' => 'Y');
my $cvar_configs = CVar->get_configs('module' => 'IC');
my @includeable_custom_variables = grep { $_->{includeable} } @{ $cvar_configs };
+ my @searchable_custom_variables = grep { $_->{searchable} } @{ $cvar_configs };
push @columns, map { "cvar_$_->{name}" } @includeable_custom_variables;
my @hidden_variables = map { "l_${_}" } @columns;
push @hidden_variables, qw(warehouse_id bin_id partnumber partstypes_id description chargenumber bestbefore qty_op qty qty_unit partunit l_warehousedescription l_bindescription);
push @hidden_variables, qw(include_empty_bins subtotal include_invalid_warehouses date);
push @hidden_variables, qw(classification_id stock_value_basis allrows);
+ push @hidden_variables, map({'cvar_'. $_->{name}} @searchable_custom_variables);
+ push @hidden_variables, map({'cvar_'. $_->{name} .'_from'} grep({$_->{type} eq 'date'} @searchable_custom_variables));
+ push @hidden_variables, map({'cvar_'. $_->{name} .'_to'} grep({$_->{type} eq 'date'} @searchable_custom_variables));
+ push @hidden_variables, map({'cvar_'. $_->{name} .'_qtyop'} grep({$_->{type} eq 'number'} @searchable_custom_variables));
my %column_defs = (
'warehousedescription' => { 'text' => $locale->text('Warehouse'), },