feat: filter assignments by hotel in favor of destination
This commit is contained in:
@@ -33,7 +33,7 @@ class AssignmentFilterController extends AbstractController
|
||||
'min_date' => $filterOptions['minDate'],
|
||||
'max_date' => $filterOptions['maxDate'],
|
||||
'job_profiles' => $filterOptions['jobProfiles'],
|
||||
'destinations' => $filterOptions['destinations'],
|
||||
'hotels' => $filterOptions['hotels'],
|
||||
];
|
||||
|
||||
$form = $this->createForm(AssignmentFilterType::class, $formData, $formOptions);
|
||||
@@ -41,7 +41,7 @@ class AssignmentFilterController extends AbstractController
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->filterHandler->handleRequest($form);
|
||||
$returnUrl = $this->getReturnUrl($request, 'app_admin_assignment_index');
|
||||
$returnUrl = $this->getReturnUrl($request, 'app_administrative_assignment_index');
|
||||
|
||||
return new HxRedirectResponse($returnUrl);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class AssignmentFilterController extends AbstractController
|
||||
public function reset(Request $request): Response
|
||||
{
|
||||
$this->filterHandler->resetFilterSettings();
|
||||
$returnUrl = $this->getReturnUrl($request, 'app_admin_assignment_index');
|
||||
$returnUrl = $this->getReturnUrl($request, 'app_administrative_assignment_index');
|
||||
|
||||
return $this->redirect($returnUrl);
|
||||
}
|
||||
|
||||
@@ -66,16 +66,16 @@ class AssignmentFilterType extends AbstractType
|
||||
])
|
||||
;
|
||||
}
|
||||
if (0 < count($options['destinations'])) {
|
||||
if (0 < count($options['hotels'])) {
|
||||
$choices = [];
|
||||
foreach ($options['hotels'] as $item) {
|
||||
$choices[$item->getHotel()] = $item->getHotelCode();
|
||||
}
|
||||
$builder
|
||||
->add('destination', EntityType::class, [
|
||||
'label' => 'Destination',
|
||||
'class' => Destination::class,
|
||||
->add('hotel', ChoiceType::class, [
|
||||
'label' => 'Haus',
|
||||
'required' => false,
|
||||
'choice_label' => function (Destination $destination) {
|
||||
return $destination->getProduct();
|
||||
},
|
||||
'choices' => $options['destinations'],
|
||||
'choices' => $choices,
|
||||
])
|
||||
;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ class AssignmentFilterType extends AbstractType
|
||||
'min_date' => null,
|
||||
'max_date' => null,
|
||||
'job_profiles' => [],
|
||||
'destinations' => [],
|
||||
'hotels' => [],
|
||||
])
|
||||
->setAllowedTypes('min_date', [\DateTimeImmutable::class, 'null'])
|
||||
->setAllowedTypes('max_date', [\DateTimeImmutable::class, 'null'])
|
||||
|
||||
@@ -15,7 +15,7 @@ class AssignmentFilterDto extends AbstractFilterDto
|
||||
protected ?\DateTimeImmutable $dateFrom = null;
|
||||
protected ?\DateTimeImmutable $dateTo = null;
|
||||
protected ?JobProfile $jobProfile = null;
|
||||
protected ?Destination $destination = null;
|
||||
protected ?string $hotel = null;
|
||||
protected ?int $duration = null;
|
||||
protected ?string $status = null;
|
||||
|
||||
@@ -55,14 +55,14 @@ class AssignmentFilterDto extends AbstractFilterDto
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDestination(): ?Destination
|
||||
public function getHotel(): ?string
|
||||
{
|
||||
return $this->destination;
|
||||
return $this->hotel;
|
||||
}
|
||||
|
||||
public function setDestination(?Destination $destination): static
|
||||
public function setHotel(?string $hotel): static
|
||||
{
|
||||
$this->destination = $destination;
|
||||
$this->hotel = $hotel;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -106,10 +106,10 @@ class AssignmentRepository extends ServiceEntityRepository
|
||||
;
|
||||
}
|
||||
|
||||
if (null !== $destination = $filterDto->getDestination()) {
|
||||
if (null !== $hotelCode = $filterDto->getHotel()) {
|
||||
$qb
|
||||
->andWhere($qb->expr()->eq('assignment.destination', ':destination'))
|
||||
->setParameter('destination', $destination)
|
||||
->andWhere($qb->expr()->eq('destination.hotelCode', ':hotelCode'))
|
||||
->setParameter('hotelCode', $hotelCode)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -186,18 +186,18 @@ class AssignmentRepository extends ServiceEntityRepository
|
||||
return $assignment->getJobProfile();
|
||||
}, $result);
|
||||
|
||||
// Destinations
|
||||
// Hotels
|
||||
$qb = $this->createQueryBuilder('assignment');
|
||||
$result = $qb
|
||||
->select('assignment', 'destination')
|
||||
->innerJoin('assignment.destination', 'destination')
|
||||
->where($qb->expr()->isNull('assignment.deletedAt'))
|
||||
->orderBy('destination.product', 'ASC')
|
||||
->groupBy('destination.id')
|
||||
->groupBy('destination.hotelBusProId')
|
||||
->orderBy('destination.hotel', 'ASC')
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
$options['destinations'] = array_map(function (Assignment $assignment) {
|
||||
$options['hotels'] = array_map(function (Assignment $assignment) {
|
||||
return $assignment->getDestination();
|
||||
}, $result);
|
||||
|
||||
|
||||
@@ -71,4 +71,17 @@ class DestinationRepository extends ServiceEntityRepository
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getHotels(): array
|
||||
{
|
||||
$qb = $this->createQueryBuilder('destination');
|
||||
|
||||
return $qb
|
||||
->select('destination.hotel', 'destination.hotelCode', 'destination.hotelBusProId')
|
||||
->groupBy('destination.hotelBusProId')
|
||||
->orderBy('destination.hotel', 'ASC')
|
||||
->getQuery()
|
||||
->getArrayResult()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Service\Common;
|
||||
|
||||
use App\Entity\Destination;
|
||||
use App\Entity\JobProfile;
|
||||
use App\Model\AssignmentFilterDto;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@@ -68,13 +67,8 @@ class AssignmentFilterHandler
|
||||
;
|
||||
$filterDto->setJobProfile($jobProfile);
|
||||
}
|
||||
if (isset($data['destination']) && 0 < (int) $data['destination']) {
|
||||
$destination = $this
|
||||
->entityManager
|
||||
->getRepository(Destination::class)
|
||||
->find($data['destination'])
|
||||
;
|
||||
$filterDto->setDestination($destination);
|
||||
if (isset($data['hotel'])) {
|
||||
$filterDto->setHotel($data['hotel']);
|
||||
}
|
||||
if (isset($data['duration']) && 0 < (int) $data['duration']) {
|
||||
$filterDto->setDuration($data['duration']);
|
||||
@@ -92,7 +86,7 @@ class AssignmentFilterHandler
|
||||
'date_from' => $filterDto->getDateFrom(),
|
||||
'date_to' => $filterDto->getDateTo(),
|
||||
'job_profile' => $filterDto->getJobProfile()?->getId(),
|
||||
'destination' => $filterDto->getDestination()?->getId(),
|
||||
'hotel' => $filterDto->getHotel(),
|
||||
'duration' => $filterDto->getDuration(),
|
||||
'status' => $filterDto->getStatus(),
|
||||
]);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
{{ form_row(filterForm.dateFrom) }}
|
||||
{{ form_row(filterForm.dateTo) }}
|
||||
{{ form_row(filterForm.jobProfile) }}
|
||||
{{ form_row(filterForm.destination) }}
|
||||
{{ form_row(filterForm.hotel) }}
|
||||
{{ form_row(filterForm.duration) }}
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
|
||||
Reference in New Issue
Block a user