X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FProject.pm;h=df5fe09ec2e24d17cce4f335ac8f48db135e8500;hb=98056ff901abcbbbcf3f0499c3149056628631e8;hp=ba6f12f0a744046a6ab035f892323472743f337c;hpb=7f8599c0909affd56ad82fd842015bb51c6a3dbf;p=kivitendo-erp.git diff --git a/SL/DB/Project.pm b/SL/DB/Project.pm index ba6f12f0a..df5fe09ec 100644 --- a/SL/DB/Project.pm +++ b/SL/DB/Project.pm @@ -8,7 +8,7 @@ use SL::DB::MetaSetup::Project; use SL::DB::Manager::Project; use SL::DB::Helper::CustomVariables( - module => 'Project', + module => 'Projects', cvars_alias => 1, ); @@ -48,6 +48,42 @@ sub is_projectnumber_unique { return !SL::DB::Manager::Project->get_first(where => \@filter); } +sub displayable_name { + my ($self) = @_; + + return join ' ', grep $_, $self->projectnumber, $self->description; +} + +sub full_description { + my ($self, %params) = @_; + + $params{style} ||= 'both'; + my $description; + + if ($params{style} =~ m/number/) { + $description = $self->projectnumber; + + } elsif ($params{style} =~ m/description/) { + $description = $self->description; + + } elsif (($params{style} =~ m/full/) && $self->customer) { + $description = $self->projectnumber; + if ($self->description && do { my $desc = quotemeta $self->description; $self->projectnumber !~ m/$desc/ }) { + $description .= ' ' . $self->description; + } + + $description = $self->customer->name . " (${description})"; + + } else { + $description = $self->projectnumber; + if ($self->description && do { my $desc = quotemeta $self->description; $self->projectnumber !~ m/$desc/ }) { + $description .= ' (' . $self->description . ')'; + } + } + + return $description; +} + 1; __END__ @@ -83,6 +119,46 @@ Returns trueish if the project number is not used for any other project in the database. Also returns trueish if no project number has been set yet. +=item C + +Returns a human-readable description of the project, consisting of projectnumber +and description. + +=item C + +Returns a full description for the project which can consist of the +project number, its description or both. This is determined by the +parameter C