fix: properly assign readonly state to form fields for unavailable services
This commit is contained in:
@@ -114,31 +114,28 @@ class Travel
|
||||
public array $insurances = [];
|
||||
|
||||
/**
|
||||
* Retrieves additional services filtered by subtype, availability, and optionally by travel date range.
|
||||
* Retrieves additional services filtered by subtype and optionally by travel date range.
|
||||
*
|
||||
* Filters additional services based on the provided subtype(s), availability,
|
||||
* and optionally whether their date range overlaps with the travel dates.
|
||||
* Services with null dates are considered always available when date filtering is enabled.
|
||||
* Filters additional services based on the provided subtype(s) and optionally whether
|
||||
* their date range overlaps with the travel dates. Services with null dates are
|
||||
* considered always available when date filtering is enabled.
|
||||
* Services are sorted by price in ascending order.
|
||||
*
|
||||
* Availability filtering is NOT applied here - it happens at the form/UI level where
|
||||
* unavailable services are shown as readonly with appropriate tooltips.
|
||||
*
|
||||
* @param mixed $subTypes The service subtype(s) to filter by
|
||||
* @param bool $filterAvailable Whether to include only available services
|
||||
* @param bool $filterByTravelDateRange Whether to filter by travel date range overlap
|
||||
*
|
||||
* @return array<int, Service> The filtered and sorted services array
|
||||
*/
|
||||
public function getAdditionalServicesBySubTypes(mixed $subTypes, bool $filterAvailable = true, bool $filterByTravelDateRange = false): array
|
||||
public function getAdditionalServicesBySubTypes(mixed $subTypes, bool $filterByTravelDateRange = false): array
|
||||
{
|
||||
$subTypes = (array) $subTypes;
|
||||
|
||||
$services = array_filter($this->additionalServices, function (Service $service) use ($subTypes, $filterAvailable, $filterByTravelDateRange) {
|
||||
$services = array_filter($this->additionalServices, function (Service $service) use ($subTypes, $filterByTravelDateRange) {
|
||||
// Check subtype
|
||||
if (false === in_array($service->subType, $subTypes)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check availability
|
||||
if (true === $filterAvailable && null !== $service->available && 0 >= $service->available) {
|
||||
if (false === in_array($service->subType, $subTypes, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -160,30 +157,21 @@ class Travel
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves transportation services filtered by direction and availability.
|
||||
* Retrieves transportation services filtered by direction.
|
||||
*
|
||||
* Filters transportation services based on travel direction and optionally
|
||||
* by availability. Services are sorted by subtype.
|
||||
* Filters transportation services based on travel direction. Services are sorted by subtype.
|
||||
* Availability filtering is NOT applied here - it happens at the form/UI level where
|
||||
* unavailable services are shown as readonly with appropriate tooltips.
|
||||
*
|
||||
* Note: PKW/CAR filtering based on booking context is NOT applied here.
|
||||
* That filtering happens dynamically in ParticipantFieldOptionsProvider using
|
||||
* per-booking availability calculations from ServiceAvailabilityCalculator.
|
||||
*
|
||||
* @param string $direction The travel direction to filter by
|
||||
* @param bool $filterAvailable Whether to include only available services (API availability)
|
||||
* @param string $direction The travel direction to filter by
|
||||
*
|
||||
* @return array<int, Service> The filtered and sorted transportation services
|
||||
*/
|
||||
public function getTransportationServicesByDirection(string $direction, bool $filterAvailable = true): array
|
||||
public function getTransportationServicesByDirection(string $direction): array
|
||||
{
|
||||
$services = array_filter($this->transportationServices, function (Service $service) use ($direction, $filterAvailable) {
|
||||
return $direction === $service->direction
|
||||
&& (false === $filterAvailable || $service->available > 0 || null === $service->available);
|
||||
});
|
||||
$services = array_filter($this->transportationServices, fn (Service $service) => $direction === $service->direction);
|
||||
|
||||
usort($services, function (Service $a, Service $b) {
|
||||
return $a->subType <=> $b->subType;
|
||||
});
|
||||
usort($services, fn (Service $a, Service $b) => $a->subType <=> $b->subType);
|
||||
|
||||
return $services;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user