]> wagnertech.de Git - mfinanz.git/blobdiff - SL/DB/CustomVariable.pm
SL::Controller::CustomerVendor::action_new in action_add umbenannt
[mfinanz.git] / SL / DB / CustomVariable.pm
index 26c09cf5b35f31fa300f9c451f648f0645082c0f..dd68cab3ebef9de0e6b05a2075fdec5f9115e0f2 100644 (file)
@@ -6,6 +6,10 @@ package SL::DB::CustomVariable;
 use strict;
 
 use SL::DB::MetaSetup::CustomVariable;
 use strict;
 
 use SL::DB::MetaSetup::CustomVariable;
+use SL::DB::CustomVariableValidity;
+use SL::DB::Customer;
+
+__PACKAGE__->meta->initialize;
 
 # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
 __PACKAGE__->meta->make_manager_class;
 
 # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
 __PACKAGE__->meta->make_manager_class;
@@ -17,7 +21,22 @@ sub value {
   goto &bool_value      if $type eq 'boolean';
   goto &timestamp_value if $type eq 'timestamp';
   goto &number_value    if $type eq 'number';
   goto &bool_value      if $type eq 'boolean';
   goto &timestamp_value if $type eq 'timestamp';
   goto &number_value    if $type eq 'number';
+  if ( $type eq 'customer' ) {
+    if ( defined($_[1]) ) {
+      goto &number_value;
+    }
+    else {
+      my $id = int($self->number_value);
+      return $id ? SL::DB::Customer->new(id => $id)->load() : 0;
+    }
+  }
   goto &text_value; # text and select
 }
 
   goto &text_value; # text and select
 }
 
+sub is_valid {
+  my ($self) = @_;
+
+  return SL::DB::Manager::CustomVariableValidity->get_all_count(config_id => $self->config_id, trans_id => $self->trans_id) == 0;
+}
+
 1;
 1;