Validity-Accessor für CVars
[kivitendo-erp.git] / SL / DB / CustomVariable.pm
1 # This file has been auto-generated only because it didn't exist.
2 # Feel free to modify it at will; it will not be overwritten automatically.
3
4 package SL::DB::CustomVariable;
5
6 use strict;
7
8 use SL::DB::MetaSetup::CustomVariable;
9 use SL::DB::CustomVariableValidity;
10
11 __PACKAGE__->meta->initialize;
12
13 # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
14 __PACKAGE__->meta->make_manager_class;
15
16 sub value {
17   my $self = $_[0];
18   my $type = $self->config->type;
19
20   goto &bool_value      if $type eq 'boolean';
21   goto &timestamp_value if $type eq 'timestamp';
22   goto &number_value    if $type eq 'number';
23   goto &text_value; # text and select
24 }
25
26 sub is_valid {
27   my ($self) = @_;
28
29   return SL::DB::Manager::CustomVariableValidity->get_all_count(config_id => $self->config_id, trans_id => $self->trans_id) == 0;
30 }
31
32 1;