X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FCVar.pm;h=cdc05b5abf183825cb9045529333fbb702f315b5;hb=91ee6cb28c37fe07d001da04808f9c49e1959502;hp=77d34e67a03169713d6c772b91a7985ded07e3d9;hpb=a35a796b017f7ca94f7c881d1b96e0c3cdccd96e;p=kivitendo-erp.git diff --git a/SL/CVar.pm b/SL/CVar.pm index 77d34e67a..cdc05b5ab 100644 --- a/SL/CVar.pm +++ b/SL/CVar.pm @@ -1,5 +1,7 @@ package CVar; +use strict; + use List::Util qw(first); use Data::Dumper; @@ -242,6 +244,8 @@ sub get_custom_variables { : $act_var->{text_value}; $cvar->{valid} = $act_var->{valid}; } else { + $cvar->{valid} = 1; + if ($cvar->{type} eq 'date') { if ($cvar->{default_value} eq 'NOW') { $cvar->{value} = $cvar->{current_date}; @@ -349,7 +353,7 @@ sub save_custom_variables { } sub render_inputs { - $main::lxdebug->enter_sub(); + $main::lxdebug->enter_sub(2); my $self = shift; my %params = @_; @@ -370,7 +374,7 @@ sub render_inputs { $var->{VALID_BOX} = $form->parse_html_template('amcvar/render_checkboxes', { var => $var, %options }); } - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(2); } sub render_search_options { @@ -384,6 +388,8 @@ sub render_search_options { my $myconfig = \%main::myconfig; my $form = $main::form; + $params{hidden_cvar_filters} = $myconfig->{hide_cvar_search_options}; + $params{include_prefix} = 'l_' unless defined($params{include_prefix}); $params{include_value} ||= '1'; @@ -484,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( @@ -600,18 +605,6 @@ sub get_field_format_list { return ($date_fields, $number_fields); } -=head2 VALIDITY - -Suppose the following scenario: - -You have a lot of parts in your database, and a set of properties cofigured. Now not every part has every of these properties, some combinations will just make no sense. In order to clean up your inputs a bit, you want to mark certain combinations as invalid, blocking them from modification and possibly display. - -Validity is assumed. If you modify validity, you actually save B. -iNvalidity is saved as a function of config_id, and the trans_id - -In the naive way, disable an attribute for a specific id (simple) - -=cut sub save_custom_variables_validity { $main::lxdebug->enter_sub(); @@ -655,7 +648,7 @@ sub save_custom_variables_validity { } sub get_custom_variables_validity { - $main::lxdebug->enter_sub(); + $main::lxdebug->enter_sub(2); my $self = shift; my %params = @_; @@ -671,9 +664,42 @@ sub get_custom_variables_validity { my ($invalid) = selectfirst_array_query($form, $dbh, $query, conv_i($params{config_id}), conv_i($params{trans_id})); - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(2); return !$invalid; } 1; + +__END__ + +=head1 NAME + +SL::CVar.pm - Custom Variables module + +=head1 SYNOPSIS + + # dealing with configs + + my $all_configs = CVar->get_configs() + my $config = CVar->get_config(id => '1234') + + CVar->save_config($config); + CVar->delete->config($config) + + # dealing with custom vars + + CVar->get_custom_variables(module => 'ic') + +=head2 VALIDITY + +Suppose the following scenario: + +You have a lot of parts in your database, and a set of properties cofigured. Now not every part has every of these properties, some combinations will just make no sense. In order to clean up your inputs a bit, you want to mark certain combinations as invalid, blocking them from modification and possibly display. + +Validity is assumed. If you modify validity, you actually save B. +Invalidity is saved as a function of config_id, and the trans_id + +In the naive way, disable an attribute for a specific id (simple) + +=cut