use SL::DBUtils;
use SL::MoreCommon qw(listify);
+use SL::Util qw(trim);
sub get_configs {
$main::lxdebug->enter_sub();
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
- my $trans_id = $params{trans_id} ? 'OR (v.trans_id = ?) ' : '';
-
my $sub_module = $params{sub_module} ? $params{sub_module} : '';
my $q_var =
next unless ($params{filter}->{$name});
push @sub_where, qq|cvar.text_value ILIKE ?|;
- push @sub_values, '%' . $params{filter}->{$name} . '%'
+ push @sub_values, like($params{filter}->{$name});
} elsif ($config->{type} eq 'select') {
next unless ($params{filter}->{$name});
}
push @sub_where, qq|cvar.number_value $op ?|;
- push @sub_values, $form->parse_amount($myconfig, $params{filter}->{$name});
+ push @sub_values, $form->parse_amount($myconfig, trim($params{filter}->{$name}));
} elsif ($config->{type} eq 'bool') {
next unless ($params{filter}->{$name});
my $table = $config->{type};
push @sub_where, qq|cvar.number_value * 1 IN (SELECT id FROM $table WHERE name ILIKE ?)|;
- push @sub_values, "%$params{filter}->{$name}%";
+ push @sub_values, like($params{filter}->{$name});
} elsif ($config->{type} eq 'part') {
next unless $params{filter}->{$name};
push @sub_where, qq|cvar.number_value * 1 IN (SELECT id FROM parts WHERE partnumber ILIKE ?)|;
- push @sub_values, "%$params{filter}->{$name}%";
+ push @sub_values, like($params{filter}->{$name});
}
if (@sub_where) {
return $value;
}
+sub get_non_editable_ic_cvars {
+ $main::lxdebug->enter_sub(2);
+ my $self = shift;
+ my %params = @_;
+
+ Common::check_params(\%params, qw(form dbh row sub_module may_converted_from));
+ my $form = $params{form};
+ my $dbh = $params{dbh};
+ my $row = $params{row};
+ my $sub_module = $params{sub_module};
+ my $may_converted_from = $params{may_converted_from};
+
+ my $cvars;
+ if (! $form->{"${sub_module}_id_${row}"}) {
+ my $conv_from = 0;
+ foreach (@{ $may_converted_from }) {
+ if ($form->{"converted_from_${_}_id_$row"}) {
+ $cvars = CVar->get_custom_variables(dbh => $dbh,
+ module => 'IC',
+ sub_module => $_,
+ trans_id => $form->{"converted_from_${_}_id_$row"},
+ );
+ $conv_from = 1;
+ last;
+ }
+ }
+ # get values for CVars from master data for new items
+ if (!$conv_from) {
+ $cvars = CVar->get_custom_variables(dbh => $dbh,
+ module => 'IC',
+ trans_id => $form->{"id_$row"},
+ );
+ }
+ } else {
+ # get values for CVars from custom_variables for existing items
+ $cvars = CVar->get_custom_variables(dbh => $dbh,
+ module => 'IC',
+ sub_module => $sub_module,
+ trans_id => $form->{"${sub_module}_id_${row}"},
+ );
+ }
+ # map only non-editable CVars to form
+ foreach (@{ $cvars }) {
+ next if $_->{flag_editable};
+ $form->{"ic_cvar_$_->{name}_$row"} = $_->{value}
+ }
+
+ $main::lxdebug->leave_sub(2);
+}
+
1;
__END__
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.
+You have a lot of parts in your database, and a set of properties configured. 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>.
Invalidity is saved as a function of config_id, and the trans_id