X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FProject.pm;h=54975350c8bc71953b4f77b50caf0d7f03e75f4f;hb=53593baa211863fbf66540cf1bcc36c8fb37257f;hp=73390d85e7ceca2a7ecba81dbe6508941649f891;hpb=efb9a24f2252104ab4af5c25334119d7c5c70a8c;p=kivitendo-erp.git diff --git a/SL/DB/Project.pm b/SL/DB/Project.pm index 73390d85e..54975350c 100644 --- a/SL/DB/Project.pm +++ b/SL/DB/Project.pm @@ -12,6 +12,13 @@ use SL::DB::Helper::CustomVariables( cvars_alias => 1, ); +__PACKAGE__->meta->add_relationship( + employee_invoice_permissions => { + type => 'many to many', + map_class => 'SL::DB::EmployeeProjectInvoices', + }, +); + __PACKAGE__->meta->initialize; sub validate { @@ -48,6 +55,59 @@ 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; +} + +sub may_employee_view_project_invoices { + my ($self, $employee) = @_; + + return undef if !$self->id; + + my $employee_id = ref($employee) ? $employee->id : $employee * 1; + my $query = <db->dbh->selectrow_arrayref($query, undef, $employee_id, $self->id)->[0]; +} + 1; __END__ @@ -83,6 +143,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