CVars für Lagerbestand: Funktion zum Rendern aus SL/CVar nehmen
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Tue, 31 Aug 2021 06:56:57 +0000 (08:56 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Tue, 31 Aug 2021 09:27:43 +0000 (11:27 +0200)
SL/WH.pm
bin/mozilla/wh.pl
templates/webpages/wh/report_filter.html

index 69874ce..2c11f84 100644 (file)
--- a/SL/WH.pm
+++ b/SL/WH.pm
@@ -627,11 +627,11 @@ sub get_warehouse_report {
   $form->{l_part_type}          = 'Y';
 
   my $select_clause = join ', ', map { +/^l_/; "$select_tokens{$'} AS $'" }
-        ( grep( { !/qty/ and /^l_/ and $form->{$_} eq 'Y' } keys %$form),
+        ( grep( { !/qty/ and !/^l_cvar/ and /^l_/ and $form->{$_} eq 'Y' } keys %$form),
           qw(l_parts_id l_qty l_partunit) );
 
   my $group_clause = join ", ", map { +/^l_/; "$'" }
-        ( grep( { !/qty/ and /^l_/ and $form->{$_} eq 'Y' } keys %$form),
+        ( grep( { !/qty/ and !/^l_cvar/ and /^l_/ and $form->{$_} eq 'Y' } keys %$form),
           qw(l_parts_id l_partunit) );
 
   my %join_tokens = (
@@ -639,7 +639,7 @@ sub get_warehouse_report {
     );
 
   my $joins = join ' ', grep { $_ } map { +/^l_/; $join_tokens{"$'"} }
-        ( grep( { !/qty/ and /^l_/ and $form->{$_} eq 'Y' } keys %$form),
+        ( grep( { !/qty/ and !/^l_cvar/ and /^l_/ and $form->{$_} eq 'Y' } keys %$form),
           qw(l_parts_id l_qty l_partunit) );
 
   my $query =
index 3aff194..8f55b01 100644 (file)
@@ -790,8 +790,11 @@ sub report {
 
   show_no_warehouses_error() if (!scalar @{ $form->{WAREHOUSES} });
 
-  my $CVAR_CONFIGS = SL::DB::Manager::CustomVariableConfig->get_all_sorted(where => [ module => 'IC' ]);
-  my $INCLUDABLE_CVAR_CONFIGS = [ grep { $_->includeable } @{ $CVAR_CONFIGS } ];
+  my $cvar_configs                           = CVar->get_configs('module' => 'IC');
+  (undef,
+   $form->{CUSTOM_VARIABLES_INCLUSION_CODE}) = CVar->render_search_options('variables'      => $cvar_configs,
+                                                                           'include_prefix' => 'l_',
+                                                                           'include_value'  => 'Y');
 
   $form->{title}   = $locale->text("Report about warehouse contents");
 
@@ -801,8 +804,6 @@ sub report {
   print $form->parse_html_template("wh/report_filter",
                                    { "WAREHOUSES" => $form->{WAREHOUSES},
                                      "UNITS"      => AM->unit_select_data(AM->retrieve_units(\%myconfig, $form)),
-                                     # "CVAR_CONFIGS"            => $CVAR_CONFIGS, # nyi searchable cvars
-                                     "INCLUDABLE_CVAR_CONFIGS" => $INCLUDABLE_CVAR_CONFIGS,
                                    });
 
   $main::lxdebug->leave_sub();
index c1dea3f..a4c1c72 100644 (file)
         <td align="right"><input name="l_list_price" id="l_list_price" class="checkbox" type="checkbox" value="Y"></td>
         <td nowrap><label for="l_list_price">[% 'List Price' | $T8 %]</label></td>
        </tr>
-       [% IF INCLUDABLE_CVAR_CONFIGS %]
-         <tr><td colspan="6"><hr noshade height="1"></td></tr>
-         [% FOREACH cvar_cfg = INCLUDABLE_CVAR_CONFIGS %]
-         <tr>
-          <td colspan="2" align="left">
-           [% name__ = cvar_cfg.name;
-            L.checkbox_tag("l_cvar_" _ name__, value="1", checked=(cvar_cfg.included_by_default ? 1 : ''), label=cvar_cfg.description) %]
-          </td>
-         </tr>
-         [% END %]
-       [% END %]
+      </table>
+      <table>
+       [% CUSTOM_VARIABLES_INCLUSION_CODE %]
       </table>
      </td>
     </tr>