Compare commits
3
Commits
b502127e2e
...
20e56aab1f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20e56aab1f | ||
|
|
d7219ec341 | ||
|
|
0bdc6c873b |
No files matched your search
@@ -57,6 +57,7 @@ class AjaxCalendarController extends ActionController
|
|||||||
$this->tagPageCacheForHotel($hotelCode);
|
$this->tagPageCacheForHotel($hotelCode);
|
||||||
|
|
||||||
$dateRange = DateUtility::getDateRange(null, null, $months);
|
$dateRange = DateUtility::getDateRange(null, null, $months);
|
||||||
|
$period = $dateRange['period'];
|
||||||
$today = new \DateTimeImmutable('today');
|
$today = new \DateTimeImmutable('today');
|
||||||
|
|
||||||
$priceDataByDate = [];
|
$priceDataByDate = [];
|
||||||
@@ -69,11 +70,7 @@ class AjaxCalendarController extends ActionController
|
|||||||
// for config.cache_period. An additional application-level cache here would
|
// for config.cache_period. An additional application-level cache here would
|
||||||
// key on exactly the same granularity (hotel + date range) and only stack a
|
// key on exactly the same granularity (hotel + date range) and only stack a
|
||||||
// second TTL on top, pushing worst-case staleness past the freshness budget.
|
// second TTL on top, pushing worst-case staleness past the freshness budget.
|
||||||
$rawData = $this->myEpClient->getPriceConfigData(
|
$rawData = $this->myEpClient->getPriceConfigData($hotelCode);
|
||||||
$hotelCode,
|
|
||||||
$dateRange['period']->getStartDate(),
|
|
||||||
$dateRange['period']->getEndDate()
|
|
||||||
);
|
|
||||||
|
|
||||||
$availableDates = [];
|
$availableDates = [];
|
||||||
foreach ($rawData as $item) {
|
foreach ($rawData as $item) {
|
||||||
@@ -82,6 +79,11 @@ class AjaxCalendarController extends ActionController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The API no longer honours a date-range constraint, so it may return data
|
||||||
|
// further out than the default $months grid covers. Grow the grid to match
|
||||||
|
// whatever the API actually returned rather than silently dropping the tail.
|
||||||
|
$lastDataDate = null;
|
||||||
|
|
||||||
foreach ($rawData as $item) {
|
foreach ($rawData as $item) {
|
||||||
$date = $item['date'];
|
$date = $item['date'];
|
||||||
$dt = \DateTimeImmutable::createFromFormat('Y-m-d', $date);
|
$dt = \DateTimeImmutable::createFromFormat('Y-m-d', $date);
|
||||||
@@ -89,6 +91,10 @@ class AjaxCalendarController extends ActionController
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null === $lastDataDate || $dt > $lastDataDate) {
|
||||||
|
$lastDataDate = $dt;
|
||||||
|
}
|
||||||
|
|
||||||
$prevDate = $dt->modify('-1 day')->format('Y-m-d');
|
$prevDate = $dt->modify('-1 day')->format('Y-m-d');
|
||||||
$isAvailable = ($item['status'] ?? '') === 'OK';
|
$isAvailable = ($item['status'] ?? '') === 'OK';
|
||||||
$prevAvailable = isset($availableDates[$prevDate]);
|
$prevAvailable = isset($availableDates[$prevDate]);
|
||||||
@@ -113,6 +119,13 @@ class AjaxCalendarController extends ActionController
|
|||||||
'minNights' => (int)($item['minNights'] ?? 0),
|
'minNights' => (int)($item['minNights'] ?? 0),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null !== $lastDataDate) {
|
||||||
|
$dataEnd = $lastDataDate->modify('first day of next month')->setTime(0, 0, 0);
|
||||||
|
if ($dataEnd > $period->getEndDate()) {
|
||||||
|
$period = new \League\Period\Period($period->getStartDate(), $dataEnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (ApiException $e) {
|
} catch (ApiException $e) {
|
||||||
$error = true;
|
$error = true;
|
||||||
$errorMessage = $e->getMessage();
|
$errorMessage = $e->getMessage();
|
||||||
@@ -126,18 +139,14 @@ class AjaxCalendarController extends ActionController
|
|||||||
|
|
||||||
$this->view->assignMultiple([
|
$this->view->assignMultiple([
|
||||||
'priceDataByDate' => $priceDataByDate,
|
'priceDataByDate' => $priceDataByDate,
|
||||||
'calendarMonths' => $this->buildCalendarMonths($dateRange['period']),
|
'calendarMonths' => $this->buildCalendarMonths($period),
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'errorMessage' => $errorMessage,
|
'errorMessage' => $errorMessage,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function priceConfigAction(Hotel $hotel, string $year = null, string $month = null, int $months = 12)
|
public function priceConfigAction(Hotel $hotel): void
|
||||||
{
|
{
|
||||||
$dateRange = DateUtility::getDateRange($year, $month, $months);
|
|
||||||
|
|
||||||
$apiDateFrom = $dateRange['period']->getStartDate();
|
|
||||||
$apiDateTo = $dateRange['period']->getEndDate();
|
|
||||||
$hotelCode = trim($hotel->getCode() ?? '');
|
$hotelCode = trim($hotel->getCode() ?? '');
|
||||||
$this->tagPageCacheForHotel($hotelCode);
|
$this->tagPageCacheForHotel($hotelCode);
|
||||||
|
|
||||||
@@ -148,7 +157,7 @@ class AjaxCalendarController extends ActionController
|
|||||||
];
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$priceConfig['data'] = $this->myEpClient->getPriceConfigData($hotelCode, $apiDateFrom, $apiDateTo);
|
$priceConfig['data'] = $this->myEpClient->getPriceConfigData($hotelCode);
|
||||||
} catch (ApiException $e) {
|
} catch (ApiException $e) {
|
||||||
$priceConfig['success'] = false;
|
$priceConfig['success'] = false;
|
||||||
$priceConfig['error'] = $e->getMessage();
|
$priceConfig['error'] = $e->getMessage();
|
||||||
|
|||||||
@@ -221,34 +221,64 @@ class ApiMiddleware implements MiddlewareInterface
|
|||||||
$icons = [];
|
$icons = [];
|
||||||
|
|
||||||
if (($hotel['beds_count'] ?? 0) > 0) {
|
if (($hotel['beds_count'] ?? 0) > 0) {
|
||||||
$icons['bed'] = sprintf('%d Betten', $hotel['beds_count']);
|
$icons[] = [
|
||||||
|
'icon' => 'bed',
|
||||||
|
'label' => sprintf('%d Betten', $hotel['beds_count']),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
if (($hotel['parking_count'] ?? 0) > 0) {
|
if (($hotel['parking_count'] ?? 0) > 0) {
|
||||||
$icons['parking'] = sprintf('%d Parkplätze', $hotel['parking_count']);
|
$icons[] = [
|
||||||
|
'icon' => 'parking',
|
||||||
|
'label' => sprintf('%d Parkplätze', $hotel['parking_count']),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
if ($hotel['altitude'] ?? null) {
|
if ($hotel['altitude'] ?? null) {
|
||||||
$icons['mountain'] = $hotel['altitude'];
|
$icons[] = [
|
||||||
|
'icon' => 'mountain',
|
||||||
|
'label' => $hotel['altitude'],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
if ($hotel['distance_bus'] ?? null) {
|
if ($hotel['distance_bus'] ?? null) {
|
||||||
$icons['bus'] = $hotel['distance_bus'];
|
$icons[] = [
|
||||||
|
'icon' => 'bus',
|
||||||
|
'label' => $hotel['distance_bus'],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
if ($hotel['distance_lift'] ?? null) {
|
if ($hotel['distance_lift'] ?? null) {
|
||||||
$icons['lift'] = $hotel['distance_lift'];
|
$icons[] = [
|
||||||
|
'icon' => 'lift',
|
||||||
|
'label' => $hotel['distance_lift'],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
if ($hotel['shower'] ?? null) {
|
if ($hotel['shower'] ?? null) {
|
||||||
$icons['shower'] = $hotel['shower'];
|
$icons[] = [
|
||||||
|
'icon' => 'shower',
|
||||||
|
'label' => $hotel['shower'],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
if ($hotel['partyroom'] ?? false) {
|
if ($hotel['partyroom'] ?? false) {
|
||||||
$icons['party'] = 'Partyzimmer';
|
$icons[] = [
|
||||||
|
'icon' => 'party',
|
||||||
|
'label' => 'Partyzimmer',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
if ($hotel['gamesroom'] ?? false) {
|
if ($hotel['gamesroom'] ?? false) {
|
||||||
$icons['dice'] = 'Spielezimmer';
|
$icons[] = [
|
||||||
|
'icon' => 'dice',
|
||||||
|
'label' => 'Spielezimmer',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
if ($hotel['sauna'] ?? false) {
|
if ($hotel['sauna'] ?? false) {
|
||||||
$icons['sauna'] = 'Sauna';
|
$icons[] = [
|
||||||
|
'icon' => 'sauna',
|
||||||
|
'label' => 'Sauna',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
if ($hotel['wifi'] ?? false) {
|
if ($hotel['wifi'] ?? false) {
|
||||||
$icons['wifi'] = 'WiFi';
|
$icons[] = [
|
||||||
|
'icon' => 'wifi',
|
||||||
|
'label' => 'WiFi',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -144,13 +144,11 @@ class ApiClient implements LoggerAwareInterface
|
|||||||
/**
|
/**
|
||||||
* @throws ApiException
|
* @throws ApiException
|
||||||
*/
|
*/
|
||||||
public function getPriceConfigData(string $hotelCode, \DateTimeImmutable $dateFrom, \DateTimeImmutable $dateTo): array
|
public function getPriceConfigData(string $hotelCode): array
|
||||||
{
|
{
|
||||||
return $this->requestJson('GET', 'contingents/calendar', [
|
return $this->requestJson('GET', 'contingents/calendar', [
|
||||||
'query' => [
|
'query' => [
|
||||||
'hotelCode' => $hotelCode,
|
'hotelCode' => $hotelCode,
|
||||||
'dateFrom' => $dateFrom->format('Y-m-d'),
|
|
||||||
'dateTo' => $dateTo->format('Y-m-d'),
|
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,15 @@
|
|||||||
</config>
|
</config>
|
||||||
</TCEforms>
|
</TCEforms>
|
||||||
</settings.hideMoreLink>
|
</settings.hideMoreLink>
|
||||||
|
<settings.hideHeader>
|
||||||
|
<TCEforms>
|
||||||
|
<exclude>0</exclude>
|
||||||
|
<label>Header ausblenden:</label>
|
||||||
|
<config>
|
||||||
|
<type>check</type>
|
||||||
|
</config>
|
||||||
|
</TCEforms>
|
||||||
|
</settings.hideHeader>
|
||||||
</el>
|
</el>
|
||||||
</ROOT>
|
</ROOT>
|
||||||
</sDEF>
|
</sDEF>
|
||||||
|
|||||||
@@ -6,9 +6,13 @@
|
|||||||
<f:layout name="Default"/>
|
<f:layout name="Default"/>
|
||||||
|
|
||||||
<f:section name="Main">
|
<f:section name="Main">
|
||||||
|
<f:if condition="{settings.hideHeader}">
|
||||||
|
<f:else>
|
||||||
<f:render partial="SubpageHeader"
|
<f:render partial="SubpageHeader"
|
||||||
arguments="{images: concept.headerImages, topline: concept.headerSubtitle, headline: concept.headerTitle, settings: settings}"/>
|
arguments="{images: concept.headerImages, topline: concept.headerSubtitle, headline: concept.headerTitle, settings: settings}"/>
|
||||||
<f:cObject typoscriptObjectPath="lib.breadcrumb"/>
|
<f:cObject typoscriptObjectPath="lib.breadcrumb"/>
|
||||||
|
</f:else>
|
||||||
|
</f:if>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<f:render partial="Header/Header"
|
<f:render partial="Header/Header"
|
||||||
arguments="{layout: 8, subheader: concept.name, header: concept.headline}"/>
|
arguments="{layout: 8, subheader: concept.name, header: concept.headline}"/>
|
||||||
|
|||||||
Reference in new issue
Block a user