Lagerberichte nach Waren-CVars filtern können …
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 14 Jun 2019 13:50:19 +0000 (15:50 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Tue, 31 Aug 2021 09:42:59 +0000 (11:42 +0200)
… nur Waren-CVars aus den Stammdaten - nicht aus Überlagerung aus Belegen

Übernahme aus Kundenprojekt

SL/WH.pm
bin/mozilla/wh.pl
templates/webpages/wh/journal_filter.html
templates/webpages/wh/report_filter.html

index c2e562b..f0f5ef2 100644 (file)
--- a/SL/WH.pm
+++ b/SL/WH.pm
@@ -306,6 +306,18 @@ sub get_warehouse_journal {
 
   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))",
@@ -642,6 +654,18 @@ sub get_warehouse_report {
         ( 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
index 4012fa2..3f0a5b6 100644 (file)
@@ -575,7 +575,7 @@ sub journal {
   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');
@@ -649,11 +649,16 @@ sub generate_journal {
 
   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]") },
@@ -811,7 +816,7 @@ sub report {
   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');
@@ -915,12 +920,17 @@ sub generate_report {
 
   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'), },
index 0c6f7d4..694e1fd 100644 (file)
           [% L.date_tag('todate') %]
         </td>
        </tr>
+       [% CUSTOM_VARIABLES_FILTER_CODE %]
       </table>
      </td>
     </tr>
index a4c1c72..3aff1b4 100644 (file)
          [% L.input_number_tag("per_page", 20, size=4) %]
         </td>
        </tr>
+       [% CUSTOM_VARIABLES_FILTER_CODE %]
       </table>
      </td>
     </tr>