From 585f86e45fb3c5145def547fbaf3c766673c7c55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Thu, 19 Oct 2023 15:20:44 +0200 Subject: [PATCH] WIP: Improve assignment information display --- src/Entity/Application.php | 26 +++++++++ src/Entity/Assignment.php | 2 +- .../DispositionWorkflowGuardSubscriber.php | 2 +- src/Service/Pdf/ContractRenderer.php | 4 +- src/Service/Pdf/InvoiceRenderer.php | 2 +- src/Twig/AppRuntime.php | 2 +- .../_partials/_assignment_info.html.twig | 2 +- .../_assignment_info_compact.html.twig | 2 +- .../_assignment_requirements_info.html.twig | 4 +- templates/admin/application/index.html.twig | 55 ++++++++++++------- templates/admin/assignment/detail.html.twig | 2 +- templates/admin/assignment/index.html.twig | 16 ++---- templates/admin/document/index.html.twig | 1 - templates/teamer/index.html.twig | 16 ++---- translations/messages.de.yaml | 3 +- 15 files changed, 84 insertions(+), 55 deletions(-) diff --git a/src/Entity/Application.php b/src/Entity/Application.php index 9acab6d..bc4e539 100644 --- a/src/Entity/Application.php +++ b/src/Entity/Application.php @@ -117,4 +117,30 @@ class Application implements TimestampableEntityInterface return $this; } + + public function matchesPickup(): bool + { + if (0 === $pickupId = (int) $this->getAssignment()->getPickup()) { + return true; + } + + $teamer = $this->getTeamer(); + + return $teamer->hasPickup($pickupId); + } + + public function getCompletedTrainingsCount(): int + { + $count = 0; + $requiredTrainings = $this->getAssignment()->getJobProfile()->getRequiredTrainings(); + $teamer = $this->getTeamer(); + + foreach ($requiredTrainings as $requiredTraining) { + if ($teamer->getTrainingAttendance($requiredTraining)) { + ++$count; + } + } + + return $count; + } } diff --git a/src/Entity/Assignment.php b/src/Entity/Assignment.php index 982901b..8be5a10 100644 --- a/src/Entity/Assignment.php +++ b/src/Entity/Assignment.php @@ -172,7 +172,7 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa return $this; } - public function getTotalPeriod(): ?CarbonPeriod + public function getEffectivePeriod(): ?CarbonPeriod { if (null !== $destination = $this->getDestination()) { $dateFrom = $this->getDateFrom() ?? $destination->getDateFrom(); diff --git a/src/EventListener/DispositionWorkflowGuardSubscriber.php b/src/EventListener/DispositionWorkflowGuardSubscriber.php index 85d12c3..22b3317 100644 --- a/src/EventListener/DispositionWorkflowGuardSubscriber.php +++ b/src/EventListener/DispositionWorkflowGuardSubscriber.php @@ -43,7 +43,7 @@ class DispositionWorkflowGuardSubscriber implements EventSubscriberInterface /** @var Disposition $disposition */ $disposition = $event->getSubject(); $assignment = $disposition->getAssignment(); - $assignmentPeriod = $assignment->getTotalPeriod(); + $assignmentPeriod = $assignment->getEffectivePeriod(); $today = new \DateTimeImmutable(); $dueDateFrom = $disposition->getCreatedAt()->modify('+ 7days'); diff --git a/src/Service/Pdf/ContractRenderer.php b/src/Service/Pdf/ContractRenderer.php index 84fdb76..b092bbe 100644 --- a/src/Service/Pdf/ContractRenderer.php +++ b/src/Service/Pdf/ContractRenderer.php @@ -39,8 +39,8 @@ class ContractRenderer extends AbstractPdfRenderer $pdf->Text(21,104.5, utf8_decode($assignment->getJobProfile()->getName())); // Period - $dateFrom = $assignment->getTotalPeriod()->start->format('d.m.Y'); - $dateTo = $assignment->getTotalPeriod()->end->format('d.m.Y'); + $dateFrom = $assignment->getEffectivePeriod()->start->format('d.m.Y'); + $dateTo = $assignment->getEffectivePeriod()->end->format('d.m.Y'); $period = sprintf('%s - %s', $dateFrom, $dateTo); $pdf->Text(57,113, $period); diff --git a/src/Service/Pdf/InvoiceRenderer.php b/src/Service/Pdf/InvoiceRenderer.php index a92be21..fb712aa 100644 --- a/src/Service/Pdf/InvoiceRenderer.php +++ b/src/Service/Pdf/InvoiceRenderer.php @@ -37,7 +37,7 @@ class InvoiceRenderer extends AbstractPdfRenderer // Invoice number $pdf->SetFont('Arial', '', 12); - $number = $assignment->getTotalPeriod()->start->format('d/m/Y'); + $number = $assignment->getEffectivePeriod()->start->format('d/m/Y'); $pdf->Text(85,116, $number); $pdf->SetFont('Arial', '', 10); diff --git a/src/Twig/AppRuntime.php b/src/Twig/AppRuntime.php index c2bc698..1946230 100644 --- a/src/Twig/AppRuntime.php +++ b/src/Twig/AppRuntime.php @@ -58,7 +58,7 @@ class AppRuntime implements RuntimeExtensionInterface return 'unbekannt'; } - return $pickup->getCity(); + return 'ab '.$pickup->getCity(); } public function fileIconFilter(Environment $environment, string $mimeType, ?string $classes = 'w-4 h-4'): string diff --git a/templates/_partials/_assignment_info.html.twig b/templates/_partials/_assignment_info.html.twig index beddd94..20c1cfc 100644 --- a/templates/_partials/_assignment_info.html.twig +++ b/templates/_partials/_assignment_info.html.twig @@ -17,7 +17,7 @@ Einsatztermin
- {{ assignment.totalPeriod.start|date('d.m.Y') }} - {{ assignment.totalPeriod.end|date('d.m.Y') }} + {{ assignment.effectivePeriod.start|date('d.m.Y') }} - {{ assignment.effectivePeriod.end|date('d.m.Y') }}
{% if assignment.pickup and assignment.pickupDate %}
diff --git a/templates/_partials/_assignment_info_compact.html.twig b/templates/_partials/_assignment_info_compact.html.twig index c0fa15b..8c44310 100644 --- a/templates/_partials/_assignment_info_compact.html.twig +++ b/templates/_partials/_assignment_info_compact.html.twig @@ -15,7 +15,7 @@ Einsatztermin
- {{ assignment.totalPeriod.start|date('d.m.Y') }} - {{ assignment.totalPeriod.end|date('d.m.Y') }} + {{ assignment.effectivePeriod.start|date('d.m.Y') }} - {{ assignment.effectivePeriod.end|date('d.m.Y') }}
diff --git a/templates/_partials/_assignment_requirements_info.html.twig b/templates/_partials/_assignment_requirements_info.html.twig index a3f56be..06327d4 100644 --- a/templates/_partials/_assignment_requirements_info.html.twig +++ b/templates/_partials/_assignment_requirements_info.html.twig @@ -1,8 +1,8 @@