feat: filter assignments by assignment status
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Form;
|
||||
use App\Entity\Assignment;
|
||||
use App\Entity\Destination;
|
||||
use App\Entity\JobProfile;
|
||||
use App\Entity\User;
|
||||
use App\Model\AssignmentFilterDto;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
@@ -22,15 +23,22 @@ class AssignmentFilterType extends AbstractType
|
||||
'label' => 'Zeitraum von',
|
||||
'min_date' => $options['min_date'],
|
||||
'max_date' => $options['max_date'],
|
||||
'attr' => [
|
||||
'placeholder' => 'nicht filtern',
|
||||
],
|
||||
])
|
||||
->add('dateTo', DatepickerType::class, [
|
||||
'label' => 'Zeitraum bis',
|
||||
'min_date' => $options['min_date'],
|
||||
'max_date' => $options['max_date'],
|
||||
'attr' => [
|
||||
'placeholder' => 'nicht filtern',
|
||||
],
|
||||
])
|
||||
->add('duration', ChoiceType::class, [
|
||||
'label' => 'Einsatzdauer',
|
||||
'required' => false,
|
||||
'placeholder' => 'nicht filtern',
|
||||
'choices' => [
|
||||
'Wochenende (2-4 Tage)' => AssignmentFilterDto::DURATION_WEEKEND,
|
||||
'Midweek (5-6 Tage)' => AssignmentFilterDto::DURATION_MID_WEEK,
|
||||
@@ -38,15 +46,6 @@ 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',
|
||||
])
|
||||
@@ -55,12 +54,28 @@ class AssignmentFilterType extends AbstractType
|
||||
])
|
||||
;
|
||||
|
||||
/** @var User $user */
|
||||
$user = $options['user'];
|
||||
if ($user->hasRole('ROLE_ADMINISTRATIVE')) {
|
||||
$builder->add('status', ChoiceType::class, [
|
||||
'label' => 'Status',
|
||||
'required' => false,
|
||||
'placeholder' => 'nicht filtern',
|
||||
'choices' => [
|
||||
'voll besetzt' => Assignment::STATUS_STAFFED,
|
||||
'teilweise besetzt' => Assignment::STATUS_PARTLY_STAFFED,
|
||||
'mit Bewerbungen' => Assignment::STATUS_STAFFING,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
if (0 < count($options['job_profiles'])) {
|
||||
$builder
|
||||
->add('jobProfile', EntityType::class, [
|
||||
'label' => 'Job-Profil',
|
||||
'class' => JobProfile::class,
|
||||
'required' => false,
|
||||
'placeholder' => 'nicht filtern',
|
||||
'choice_label' => 'name',
|
||||
'choices' => $options['job_profiles'],
|
||||
])
|
||||
@@ -75,6 +90,7 @@ class AssignmentFilterType extends AbstractType
|
||||
->add('hotel', ChoiceType::class, [
|
||||
'label' => 'Haus',
|
||||
'required' => false,
|
||||
'placeholder' => 'nicht filtern',
|
||||
'choices' => $choices,
|
||||
])
|
||||
;
|
||||
@@ -91,8 +107,10 @@ class AssignmentFilterType extends AbstractType
|
||||
'job_profiles' => [],
|
||||
'hotels' => [],
|
||||
])
|
||||
->setRequired(['user'])
|
||||
->setAllowedTypes('min_date', [\DateTimeImmutable::class, 'null'])
|
||||
->setAllowedTypes('max_date', [\DateTimeImmutable::class, 'null'])
|
||||
->setAllowedTypes('user', User::class)
|
||||
;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user