feat: filter destinations by common name
This commit is contained in:
@@ -7,6 +7,25 @@ parameters:
|
|||||||
default_email_from: '%env(APP_DEFAULT_EMAIL_FROM)%'
|
default_email_from: '%env(APP_DEFAULT_EMAIL_FROM)%'
|
||||||
default_email_to: '%env(APP_DEFAULT_EMAIL_TO)%'
|
default_email_to: '%env(APP_DEFAULT_EMAIL_TO)%'
|
||||||
|
|
||||||
|
destinations:
|
||||||
|
- Schwendi
|
||||||
|
- Waldschlössli
|
||||||
|
- Spinabad
|
||||||
|
- Schweizerhaus
|
||||||
|
- Weißfluh
|
||||||
|
- Victoria
|
||||||
|
- Klein Tirol
|
||||||
|
- Jürg-Jenatsch
|
||||||
|
- Lederer
|
||||||
|
- Steinachhof
|
||||||
|
- Val Thorens
|
||||||
|
- Les Deux Alpes
|
||||||
|
- Josefsheim
|
||||||
|
- Ranalt
|
||||||
|
- Jolimont
|
||||||
|
- Christiler
|
||||||
|
- Heuberghaus
|
||||||
|
|
||||||
services:
|
services:
|
||||||
_defaults:
|
_defaults:
|
||||||
autowire: true
|
autowire: true
|
||||||
@@ -142,3 +161,7 @@ services:
|
|||||||
$defaults:
|
$defaults:
|
||||||
from: '%default_email_from%'
|
from: '%default_email_from%'
|
||||||
to: '%default_email_to%'
|
to: '%default_email_to%'
|
||||||
|
|
||||||
|
App\Form\AssignmentFilterType:
|
||||||
|
arguments:
|
||||||
|
$destinations: '%destinations%'
|
||||||
@@ -33,7 +33,6 @@ class AssignmentFilterController extends AbstractController
|
|||||||
'min_date' => $filterOptions['minDate'],
|
'min_date' => $filterOptions['minDate'],
|
||||||
'max_date' => $filterOptions['maxDate'],
|
'max_date' => $filterOptions['maxDate'],
|
||||||
'job_profiles' => $filterOptions['jobProfiles'],
|
'job_profiles' => $filterOptions['jobProfiles'],
|
||||||
'hotels' => $filterOptions['hotels'],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$form = $this->createForm(AssignmentFilterType::class, $formData, $formOptions);
|
$form = $this->createForm(AssignmentFilterType::class, $formData, $formOptions);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
|
|
||||||
class AssignmentFilterType extends AbstractType
|
class AssignmentFilterType extends AbstractType
|
||||||
{
|
{
|
||||||
public function __construct(private readonly Security $security)
|
public function __construct(private readonly Security $security, private readonly array $destinations)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,21 +90,21 @@ class AssignmentFilterType extends AbstractType
|
|||||||
])
|
])
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
if (0 < count($options['hotels'])) {
|
$hotelChoices = [];
|
||||||
$choices = [];
|
$destinations = $this->destinations;
|
||||||
foreach ($options['hotels'] as $item) {
|
sort($destinations);
|
||||||
$choices[$item->getHotel()] = $item->getHotelCode();
|
foreach ($destinations as $item) {
|
||||||
|
$hotelChoices[$item] = $item;
|
||||||
}
|
}
|
||||||
$builder
|
$builder
|
||||||
->add('hotels', MultiselectType::class, [
|
->add('hotels', MultiselectType::class, [
|
||||||
'label' => 'Haus',
|
'label' => 'Haus/Destination',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'empty_label' => 'nicht filtern',
|
'empty_label' => 'nicht filtern',
|
||||||
'choices' => $choices,
|
'choices' => $hotelChoices,
|
||||||
])
|
])
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver): void
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
{
|
{
|
||||||
@@ -114,7 +114,6 @@ class AssignmentFilterType extends AbstractType
|
|||||||
'min_date' => null,
|
'min_date' => null,
|
||||||
'max_date' => null,
|
'max_date' => null,
|
||||||
'job_profiles' => [],
|
'job_profiles' => [],
|
||||||
'hotels' => [],
|
|
||||||
])
|
])
|
||||||
->setAllowedTypes('min_date', [\DateTimeImmutable::class, 'null'])
|
->setAllowedTypes('min_date', [\DateTimeImmutable::class, 'null'])
|
||||||
->setAllowedTypes('max_date', [\DateTimeImmutable::class, 'null'])
|
->setAllowedTypes('max_date', [\DateTimeImmutable::class, 'null'])
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ namespace App\Repository;
|
|||||||
|
|
||||||
use App\Entity\Application;
|
use App\Entity\Application;
|
||||||
use App\Entity\Assignment;
|
use App\Entity\Assignment;
|
||||||
use App\Entity\Destination;
|
|
||||||
use App\Entity\Teamer;
|
use App\Entity\Teamer;
|
||||||
use App\Model\AssignmentFilterDto;
|
use App\Model\AssignmentFilterDto;
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
@@ -119,10 +118,10 @@ class AssignmentRepository extends ServiceEntityRepository
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($hotelCodes = $filterDto->getHotels()) {
|
foreach ($filterDto->getHotels() as $hotel) {
|
||||||
$qb
|
$qb
|
||||||
->andWhere($qb->expr()->in('destination.hotelCode', ':hotelCodes'))
|
->andWhere($qb->expr()->like('destination.product', ':hotel'))
|
||||||
->setParameter('hotelCodes', $hotelCodes)
|
->setParameter('hotel', '%'.$hotel.'%')
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,21 +204,6 @@ class AssignmentRepository extends ServiceEntityRepository
|
|||||||
return $assignment->getJobProfile();
|
return $assignment->getJobProfile();
|
||||||
}, $result);
|
}, $result);
|
||||||
|
|
||||||
// Hotels
|
|
||||||
$qb = $this->createQueryBuilder('assignment');
|
|
||||||
$result = $qb
|
|
||||||
->select('assignment', 'destination')
|
|
||||||
->innerJoin('assignment.destination', 'destination')
|
|
||||||
->where($qb->expr()->isNull('assignment.deletedAt'))
|
|
||||||
->groupBy('destination.hotelBusProId')
|
|
||||||
->orderBy('destination.hotel', 'ASC')
|
|
||||||
->getQuery()
|
|
||||||
->getResult()
|
|
||||||
;
|
|
||||||
$options['hotels'] = array_map(function (Assignment $assignment) {
|
|
||||||
return $assignment->getDestination();
|
|
||||||
}, $result);
|
|
||||||
|
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user