From f524e490f42e7c6fc27b93467d8004915df274f7 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 5 Feb 2024 01:07:27 +0000 Subject: [PATCH] fix responsible --- Controller/BackendController.php | 3 +++ Models/Task.php | 25 +++++++++++++++++++++++++ Theme/Backend/task-dashboard.tpl.php | 20 +++++++------------- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 5b1d3d7..50a305d 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -136,6 +136,9 @@ public function viewTaskDashboard(RequestAbstract $request, ResponseAbstract $re ->with('createdBy') ->with('tags') ->with('tags/title') + ->with('taskElements') + ->with('taskElements/accRelation') + ->with('taskElements/accRelation/relation') ->where('tags/title/language', $response->header->l11n->language) ->where('type', TaskType::SINGLE) ->where('status', TaskStatus::OPEN) diff --git a/Models/Task.php b/Models/Task.php index 4360877..8060f9e 100755 --- a/Models/Task.php +++ b/Models/Task.php @@ -428,6 +428,31 @@ public function getTaskElement(int $id) : TaskElement return $this->taskElements[$id] ?? new NullTaskElement(); } + public function getResponsible() : array + { + $responsible = []; + foreach ($this->taskElements as $element) { + if (empty($element->accRelation)) { + continue; + } + + $first = true; + + foreach ($element->accRelation as $accRel) { + if ($accRel->duty === DutyType::TO) { + if ($first) { + $responsible = []; + } + + $responsible[] = $accRel->relation; + $first = false; + } + } + } + + return $responsible; + } + /** * {@inheritdoc} */ diff --git a/Theme/Backend/task-dashboard.tpl.php b/Theme/Backend/task-dashboard.tpl.php index fb29f21..3a8457b 100755 --- a/Theme/Backend/task-dashboard.tpl.php +++ b/Theme/Backend/task-dashboard.tpl.php @@ -161,24 +161,18 @@ - - - printHtml($this->renderUserName( - '%3$s %2$s %1$s', - [ - $task->createdBy->name1, - $task->createdBy->name2, - $task->createdBy->name3, - $task->createdBy->login ?? '', - ]) - ); ?> - + getResponsible(); + foreach ($responsibles as $responsible) : ?> + + printHtml($responsible->name1); ?> printHtml($responsible->name2); ?> + + printHtml($task->createdAt->format('Y-m-d H:i')); ?> getHtml('Empty', '0', '0'); ?> - +