+=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>.
+validity 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();
+
+ my $self = shift;
+ my %params = @_;
+
+ Common::check_params(\%params, qw(config_id trans_id validity));
+
+ my $myconfig = \%main::myconfig;
+ my $form = $main::form;
+
+ my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
+
+ my (@where, @values);
+ add_token(\@where, \@values, col => "config_id", val => $params{config_id}, esc => \&conv_i);
+ add_token(\@where, \@values, col => "trans_id", val => $params{trans_id}, esc => \&conv_i);
+
+ my $where = scalar @where ? "WHERE " . join ' AND ', @where : '';
+ my $query = qq|DELETE FROM custom_variables_validity $where|;
+
+ do_query($form, $dbh, $query, @values);
+
+ $query =
+ qq|INSERT INTO custom_variables_validity (config_id, trans_id)
+ VALUES (?, ? )|;
+ my $sth = prepare_query($form, $dbh, $query);
+
+ unless ($params{validity}) {
+ foreach my $config_id (listify $params{config_id}) {
+ foreach my $trans_id (listify $params{trans_id}) {
+ do_statement($form, $sth, $query, conv_i($config_id), conv_i($trans_id));
+ }
+ }
+ }
+
+ $sth->finish();
+
+ $dbh->commit();
+
+ $main::lxdebug->leave_sub();
+}
+
+sub get_custom_variables_validity {
+ $main::lxdebug->enter_sub();
+
+ my $self = shift;
+ my %params = @_;
+
+ Common::check_params(\%params, qw(config_id trans_id));
+
+ my $myconfig = \%main::myconfig;
+ my $form = $main::form;
+
+ my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
+
+ my $query = qq|SELECT COUNT(*) FROM custom_variables_validity WHERE config_id = ? AND trans_id = ?|;
+
+ my ($validity) = selectfirst_array_query($form, $dbh, $query, conv_i($params{config_id}), conv_i($params{trans_id}));
+
+ $main::lxdebug->leave_sub();
+
+ return $validity;
+}