X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FNote.pm;h=477ae3c81812e6378bdf31510a79b6ccc500796b;hb=770cfea95d02adbaa8e6ebfddd39ef9e52252b97;hp=441a2731ef0fd87ef6179b11d96bbca9ee962960;hpb=6ac47be4e3e318ea212ca595195b0b55a9c386a3;p=kivitendo-erp.git diff --git a/SL/DB/Note.pm b/SL/DB/Note.pm index 441a2731e..477ae3c81 100644 --- a/SL/DB/Note.pm +++ b/SL/DB/Note.pm @@ -1,23 +1,95 @@ -# This file has been auto-generated only because it didn't exist. -# Feel free to modify it at will; it will not be overwritten automatically. - package SL::DB::Note; use strict; -use SL::DB::MetaSetup::Note; +use Carp; -__PACKAGE__->meta->initialize; +use SL::DB::MetaSetup::Note; -# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. -__PACKAGE__->meta->make_manager_class; __PACKAGE__->meta->add_relationships( - followup => { + follow_up => { type => 'one to one', class => 'SL::DB::FollowUp', - column_map => { id => 'id' }, + column_map => { id => 'note_id' }, }, ); +__PACKAGE__->meta->initialize; + +# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. +__PACKAGE__->meta->make_manager_class; + +sub trans_object { + my $self = shift; + + croak "Method is not a setter" if @_; + + return undef if !$self->trans_id || !$self->trans_module; + + if ($self->trans_module eq 'fu') { + require SL::DB::FollowUp; + return SL::DB::Manager::FollowUp->find_by(id => $self->trans_id); + } + + if ($self->trans_module eq 'ct') { + require SL::DB::Customer; + require SL::DB::Vendor; + return SL::DB::Manager::Customer->find_by(id => $self->trans_id) + || SL::DB::Manager::Vendor ->find_by(id => $self->trans_id); + } + + return undef; +} + 1; +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::DB::Note - Notes + +=head1 FUNCTIONS + +=over 4 + +=item C + +A note object is always attached to another database entity. Which one +is determined by the columns C and C. This +function looks at both, retrieves the corresponding object from the +database and returns it. + +Currently the following three types are supported: + +=over 2 + +=item * C for C + +=item * C or C for C (which class is used depends on the value of C; +customers are looked up first) + +=back + +The method returns C in three cases: if no C or no +C has been assigned yet; if C is unknown; +if the referenced object doesn't exist. + +This method is a getter only, not a setter. + +=back + +=head1 BUGS + +Nothing here yet. + +=head1 AUTHOR + +Moritz Bunkus Em.bunkus@linet-services.deE + +=cut