diff --git a/src/Form/AssignmentFilterType.php b/src/Form/AssignmentFilterType.php index 04ab7c9..d6631f6 100644 --- a/src/Form/AssignmentFilterType.php +++ b/src/Form/AssignmentFilterType.php @@ -2,6 +2,7 @@ namespace App\Form; +use App\Entity\Assignment; use App\Entity\Destination; use App\Entity\JobProfile; use App\Model\AssignmentFilterDto; @@ -37,6 +38,15 @@ class AssignmentFilterType extends AbstractType 'Mehr als einen Woche' => AssignmentFilterDto::DURATION_MORE, ], ]) + ->add('status', ChoiceType::class, [ + 'label' => 'Status', + 'required' => false, + 'choices' => [ + 'Entwurf' => Assignment::STATUS_DRAFT, + 'offen' => Assignment::STATUS_OPEN, + 'geschlossen' => Assignment::STATUS_CLOSED, + ], + ]) ->add('apply', SubmitType::class, [ 'label' => 'filtern', ]) diff --git a/src/Model/AssignmentFilterDto.php b/src/Model/AssignmentFilterDto.php index 988665f..242a0e1 100644 --- a/src/Model/AssignmentFilterDto.php +++ b/src/Model/AssignmentFilterDto.php @@ -17,6 +17,7 @@ class AssignmentFilterDto extends AbstractFilterDto protected ?JobProfile $jobProfile = null; protected ?Destination $destination = null; protected ?int $duration = null; + protected ?string $status = null; public function getDateFrom(): ?\DateTimeImmutable { @@ -77,4 +78,16 @@ class AssignmentFilterDto extends AbstractFilterDto return $this; } + + public function getStatus(): ?string + { + return $this->status; + } + + public function setStatus(?string $status): static + { + $this->status = $status; + + return $this; + } } \ No newline at end of file diff --git a/src/Repository/AssignmentRepository.php b/src/Repository/AssignmentRepository.php index 888e23c..9e73d79 100644 --- a/src/Repository/AssignmentRepository.php +++ b/src/Repository/AssignmentRepository.php @@ -77,6 +77,13 @@ class AssignmentRepository extends ServiceEntityRepository private function applyFilterSettings(AssignmentFilterDto $filterDto, QueryBuilder $qb): void { + if (null !== $status = $filterDto->getStatus()) { + $qb + ->andWhere($qb->expr()->eq('assignment.status', ':status')) + ->setParameter('status', $status) + ; + } + if (null !== $dateFrom = $filterDto->getDateFrom()) { $qb ->andWhere($qb->expr()->gte('destination.dateFrom', ':dateFrom')) diff --git a/src/Service/Common/AssignmentFilterHandler.php b/src/Service/Common/AssignmentFilterHandler.php index 213a638..c52d35f 100644 --- a/src/Service/Common/AssignmentFilterHandler.php +++ b/src/Service/Common/AssignmentFilterHandler.php @@ -79,6 +79,9 @@ class AssignmentFilterHandler if (isset($data['duration']) && 0 < (int) $data['duration']) { $filterDto->setDuration($data['duration']); } + if (isset($data['status'])) { + $filterDto->setStatus($data['status']); + } return $filterDto; } @@ -91,6 +94,7 @@ class AssignmentFilterHandler 'job_profile' => $filterDto->getJobProfile()?->getId(), 'destination' => $filterDto->getDestination()?->getId(), 'duration' => $filterDto->getDuration(), + 'status' => $filterDto->getStatus(), ]); } diff --git a/templates/common/assignment_filter.html.twig b/templates/common/assignment_filter.html.twig index f2a19c0..2e2557e 100644 --- a/templates/common/assignment_filter.html.twig +++ b/templates/common/assignment_filter.html.twig @@ -1,5 +1,6 @@ {{ form_start(filterForm) }}