feat: filter destinations by common name
This commit is contained in:
+24
-1
@@ -7,6 +7,25 @@ parameters:
|
||||
default_email_from: '%env(APP_DEFAULT_EMAIL_FROM)%'
|
||||
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:
|
||||
_defaults:
|
||||
autowire: true
|
||||
@@ -141,4 +160,8 @@ services:
|
||||
arguments:
|
||||
$defaults:
|
||||
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'],
|
||||
'max_date' => $filterOptions['maxDate'],
|
||||
'job_profiles' => $filterOptions['jobProfiles'],
|
||||
'hotels' => $filterOptions['hotels'],
|
||||
];
|
||||
|
||||
$form = $this->createForm(AssignmentFilterType::class, $formData, $formOptions);
|
||||
|
||||
@@ -18,7 +18,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class AssignmentFilterType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly Security $security)
|
||||
public function __construct(private readonly Security $security, private readonly array $destinations)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -90,20 +90,20 @@ class AssignmentFilterType extends AbstractType
|
||||
])
|
||||
;
|
||||
}
|
||||
if (0 < count($options['hotels'])) {
|
||||
$choices = [];
|
||||
foreach ($options['hotels'] as $item) {
|
||||
$choices[$item->getHotel()] = $item->getHotelCode();
|
||||
}
|
||||
$builder
|
||||
->add('hotels', MultiselectType::class, [
|
||||
'label' => 'Haus',
|
||||
'required' => false,
|
||||
'empty_label' => 'nicht filtern',
|
||||
'choices' => $choices,
|
||||
])
|
||||
;
|
||||
$hotelChoices = [];
|
||||
$destinations = $this->destinations;
|
||||
sort($destinations);
|
||||
foreach ($destinations as $item) {
|
||||
$hotelChoices[$item] = $item;
|
||||
}
|
||||
$builder
|
||||
->add('hotels', MultiselectType::class, [
|
||||
'label' => 'Haus/Destination',
|
||||
'required' => false,
|
||||
'empty_label' => 'nicht filtern',
|
||||
'choices' => $hotelChoices,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
@@ -114,7 +114,6 @@ class AssignmentFilterType extends AbstractType
|
||||
'min_date' => null,
|
||||
'max_date' => null,
|
||||
'job_profiles' => [],
|
||||
'hotels' => [],
|
||||
])
|
||||
->setAllowedTypes('min_date', [\DateTimeImmutable::class, 'null'])
|
||||
->setAllowedTypes('max_date', [\DateTimeImmutable::class, 'null'])
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Repository;
|
||||
|
||||
use App\Entity\Application;
|
||||
use App\Entity\Assignment;
|
||||
use App\Entity\Destination;
|
||||
use App\Entity\Teamer;
|
||||
use App\Model\AssignmentFilterDto;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
@@ -119,10 +118,10 @@ class AssignmentRepository extends ServiceEntityRepository
|
||||
;
|
||||
}
|
||||
|
||||
if ($hotelCodes = $filterDto->getHotels()) {
|
||||
foreach ($filterDto->getHotels() as $hotel) {
|
||||
$qb
|
||||
->andWhere($qb->expr()->in('destination.hotelCode', ':hotelCodes'))
|
||||
->setParameter('hotelCodes', $hotelCodes)
|
||||
->andWhere($qb->expr()->like('destination.product', ':hotel'))
|
||||
->setParameter('hotel', '%'.$hotel.'%')
|
||||
;
|
||||
}
|
||||
|
||||
@@ -205,21 +204,6 @@ class AssignmentRepository extends ServiceEntityRepository
|
||||
return $assignment->getJobProfile();
|
||||
}, $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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user