feat: Kalender-Code replaces the product's calendar hotel

Every hotel field now has one job. The hotel's code and aliases are
import codes only (dates, lookups); a new Kalender-Code (calendar_code)
decides the availability a record shows and may be shared by a house's
summer and winter records. The product's "Unterkunft für
Belegungskalender" is replaced by the checkbox "Kalender anzeigen"
(show_calendar): a product page shows the calendar of the hotel it
displays, the season still decides which one.

- Price calendar, price tables, Belegungskalender, iCal feeds and
  /api/calendar-hotels read the Kalender-Code. A feed without one answers
  404 instead of an empty calendar.
- The upgrade wizard epProductsCalendarCode fills both fields from
  calendar_hotel, preserving today's calendars; the deploy runs it between
  the schema update and the switch. calendar_hotel stays in the database,
  so the previous release keeps working. ep:calendar-codes lists the
  product pages whose calendar differs from it.
- HotelCodeResolver is the one lookup of import codes (date import,
  /api/hotel, Travelinfo); a code on several records resolves to the
  record whose own code it is, then the lowest uid, with a warning.
  Saving a code that is already another visible record's import code is
  refused with a message naming that record.
- /api/product without hotel attaches the product's only visible
  Unterkunft (422 otherwise) and adds board_description,
  additional_services and calendar_hotel_code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
frommeandClaude Opus 5.5 committed 2026-11-16 17:18:00 +01:00
1 parent 659e72fc8c
commit 5455973dba
25 files changed
+875 -122

No files matched your search

+10
View File
@@ -112,6 +112,15 @@ task('deploy:check:site-settings', function () {
} }
}); });
// Data migrations that the new release needs, named one by one: a wizard already done is skipped,
// and pending core or third-party wizards are not run unattended
set('upgrade_wizards', ['epProductsCalendarCode']);
task('typo3:upgrade:run', function () {
foreach (get('upgrade_wizards') as $wizard) {
run("{{bin/php}} {{release_path}}/{{bin/typo3}} upgrade:run $wizard --no-interaction");
}
});
// current_path instead of the recipe's release_path, so it also works after a rollback // current_path instead of the recipe's release_path, so it also works after a rollback
task('typo3:cache:flush', function () { task('typo3:cache:flush', function () {
run('{{bin/php}} {{current_path}}/{{bin/typo3}} cache:flush'); run('{{bin/php}} {{current_path}}/{{bin/typo3}} cache:flush');
@@ -131,6 +140,7 @@ task('deploy', [
'deploy:writable', 'deploy:writable',
// The schema has to exist before the new code starts serving traffic. // The schema has to exist before the new code starts serving traffic.
'typo3:extension:setup', 'typo3:extension:setup',
'typo3:upgrade:run',
// deploy:publish == deploy:symlink, deploy:unlock, deploy:cleanup, deploy:success // deploy:publish == deploy:symlink, deploy:unlock, deploy:cleanup, deploy:success
'deploy:publish', 'deploy:publish',
]); ]);
+29 -24
View File
@@ -6,32 +6,35 @@ group house prices.
| What | Where | Shown for | MyE&P endpoint | | What | Where | Shown for | MyE&P endpoint |
|---|---|---|---| |---|---|---|---|
| **Price calendar** + price tables | product detail, tab "Termine/Preise" | products with a calendar hotel and season **summer** (`s`) | `contingents/calendar`, `contingents/prices` | | **Price calendar** + price tables | product detail, tab "Termine/Preise" | products with a calendar and season **summer** (`s`) | `contingents/calendar`, `contingents/prices` |
| **Belegungskalender** (availability calendar) | product detail, sidebar | products with a calendar hotel and season **not summer** | `contingents/availability` (+ `contingents/calendar` for the months to leave out) | | **Belegungskalender** (availability calendar) | product detail, sidebar | products with a calendar and season **not summer** | `contingents/availability` (+ `contingents/calendar` for the months to leave out) |
| **iCal feed** for booking portals | `https://www.ep-reisen.de/contingents/<hotel>.ical` | every hotel | `contingents/availability` | | **iCal feed** for booking portals | `https://www.ep-reisen.de/contingents/<hotel>.ical` | every hotel with a Kalender-Code | `contingents/availability` |
So every product with a calendar hotel shows exactly one calendar. The MyE&P side is documented in So every product with a calendar shows exactly one. The MyE&P side is documented in
its `docs/api-consumer-guide.md` (`EP/myep`). its `docs/api-consumer-guide.md` (`EP/myep`).
## The calendar hotel field ## Hotel codes
A product's **calendar hotel** (`calendar_hotel`) decides whose availability and prices it shows. Every field has one job:
TYPO3 sends that hotel's **code** to MyE&P, which only understands **BusPro calendar codes** (the
codes bpn-connect knows, e.g. `DGS`, `LPJ`, `DKS`).
Most hotel records carry the BusPro code. Group houses also have **content records** of their own | Field | Job |
(`DKSGRP`, `LPJGRP`, `SERASCSO`, …) whose code is the **CMS code** MyE&P uses to fetch content via
`/api/hotel`. These must **not** be used as calendar hotel: MyE&P and bpn-connect do not know
them, and the calendar shows its error message. This broke three example trips until 2026-10-29.
| Use as calendar hotel | Not |
|---|---| |---|---|
| `DKS` Sportclub Schweizerhaus (uid 193) | `DKSGRP` Davos Klosters - Gruppenhaus Schweizerhaus | | Hotel › **Import-Code** (`code`) and **Weitere Import-Codes** (matchcode aliases) | The BusPro codes whose imported dates land on this record, and by which `/api/hotel`, `/api/product?hotel=` and the Travelinfo page find it (`HotelCodeResolver`). A code belongs to one visible record; saving it on a second one is refused. Nothing to do with the calendars. |
| `LPJ` Sportclub Jenatsch (uid 37) | `LPJGRP` Lenzerheide - Gruppenhaus Jenatsch | | Hotel › **Kalender-Code** (`calendar_code`) | The BusPro code whose contingent this record shows: calendars, price tables, iCal feed. Empty = no calendar, the feed answers `404`. Records may share it: a house's summer record (`…GRP`) and its winter record both carry the house's code. |
| Product › **Kalender anzeigen** (`show_calendar`) | Whether the product page shows a calendar at all. |
| Product › **Saison** (`season`) | Which one: `s` the price calendar, anything else the Belegungskalender. |
`/api/calendar-hotels` lists all calendar hotels in use; every code in it should be a BusPro code. **The calendar on a product page is the Kalender-Code of the hotel that page shows**: the hotel
A hidden hotel record counts as no calendar hotel: the product shows no calendar and the code is pinned in the Produktdetail element, else the product's only Unterkunft, else the one picked in
not in the list (e.g. `ASB` Sportclub Bader). its hotel list (`Product::getCalendarHotelFor()`).
MyE&P only understands **BusPro codes** that it syncs (e.g. `DGS`, `LPJ`, `DKS`). When BusPro has
several entries for a house (Mitterlengau: nine), only one carries the house's contingent; the
office says which one, and that is the Kalender-Code.
The product's old "Unterkunft für Belegungskalender" (`calendar_hotel`) is no longer read. The
upgrade wizard `epProductsCalendarCode` filled the new fields from it; `vendor/bin/typo3
ep:calendar-codes` lists the product pages whose calendar differs from it, until it is removed.
## Price calendar (summer) ## Price calendar (summer)
@@ -62,7 +65,7 @@ not in the list (e.g. `ASB` Sportclub Bader).
- `IcalController::contingentsAction`, `IcalService`; route `/contingents/{hotel}.ical` on the - `IcalController::contingentsAction`, `IcalService`; route `/contingents/{hotel}.ical` on the
`ep-reisen` site (`config/sites/ep-reisen/config.yaml`, page 9, type 1710), `{hotel}` is the `ep-reisen` site (`config/sites/ep-reisen/config.yaml`, page 9, type 1710), `{hotel}` is the
hotel's path segment. hotel's path segment. The feed shows the record's Kalender-Code; without one it answers `404`.
- One `Unavailable` event per run of `BLOCKED` or `ON_REQUEST` days with the same status, as on - One `Unavailable` event per run of `BLOCKED` or `ON_REQUEST` days with the same status, as on
TYPO3 10. TYPO3 10.
- Never cached. When MyE&P has no availability it answers `503` with `Retry-After: 900` instead of - Never cached. When MyE&P has no availability it answers `503` with `Retry-After: 900` instead of
@@ -72,8 +75,9 @@ not in the list (e.g. `ASB` Sportclub Bader).
MyE&P syncs its snapshot from bpn-connect every 15 minutes during the day and hourly at night, for MyE&P syncs its snapshot from bpn-connect every 15 minutes during the day and hourly at night, for
the calendar codes of its accommodations **plus** every code in TYPO3's `/api/calendar-hotels` the calendar codes of its accommodations **plus** every code in TYPO3's `/api/calendar-hotels`
(see [cms-api.md](cms-api.md)). So a hotel offered only in winter needs nothing in MyE&P: setting (see [cms-api.md](cms-api.md)), which lists the Kalender-Code of every visible hotel record. So a
it as calendar hotel of a visible product is enough; it is synced with the next run. hotel offered only in winter needs nothing in MyE&P: giving the record a Kalender-Code is enough;
it is synced with the next run.
`contingents/availability` answers: `contingents/availability` answers:
- `400` for a code that is not synced (not an accommodation, not in TYPO3's list), - `400` for a code that is not synced (not an accommodation, not in TYPO3's list),
@@ -106,8 +110,9 @@ The message is "Der Kalender konnte aktuell nicht geladen werden."; the iCal fee
| Cause | How to tell | Fix | | Cause | How to tell | Fix |
|---|---|---| |---|---|---|
| Calendar hotel has a CMS code (`…GRP`, `…SO`) | code not BusPro; MyE&P `400`, bpn-connect `404` | set the hotel record with the BusPro code as calendar hotel | | No calendar at all | product's "Kalender anzeigen" off, or the shown hotel has no Kalender-Code | tick it / set the Kalender-Code of the hotel the page shows |
| Code not synced by MyE&P | not in `contingents/status`; MyE&P `400` | check that the product and its calendar hotel are visible (then it is in `/api/calendar-hotels`) | | Kalender-Code is not a BusPro code (`…GRP`, `…SO`) | MyE&P `400`, bpn-connect `404` | set the house's BusPro code as Kalender-Code |
| Code not synced by MyE&P | not in `contingents/status`; MyE&P `400` | check that the hotel record is visible (then its code is in `/api/calendar-hotels`) |
| Sync failing for the hotel | `contingents/status`: `available: false`, `lastError` | MyE&P / bpn-connect | | Sync failing for the hotel | `contingents/status`: `available: false`, `lastError` | MyE&P / bpn-connect |
| MyE&P unreachable or its OAuth failing | all hotels fail; TYPO3 log `EP.EpProducts.MyEP.ApiClient` | MyE&P | | MyE&P unreachable or its OAuth failing | all hotels fail; TYPO3 log `EP.EpProducts.MyEP.ApiClient` | MyE&P |
| Price calendar only: no accommodation or no prices | MyE&P `400` / empty | prices are maintained in MyE&P's Groups admin | | Price calendar only: no accommodation or no prices | MyE&P `400` / empty | prices are maintained in MyE&P's Groups admin |
+25 -15
View File
@@ -23,8 +23,9 @@ changed together.
Content of one hotel, for MyE&P's group house pages and booking flow. Content of one hotel, for MyE&P's group house pages and booking flow.
- `hotel`: the TYPO3 hotel code or one of its matchcode aliases. In MyE&P this is the - `hotel`: an import code of the record: its "Import-Code" or one of its "Weitere Import-Codes"
accommodation's **CMS code** (e.g. `DGSGRP`), which can differ from its calendar code. (matchcode aliases), resolved by `HotelCodeResolver`. In MyE&P this is the accommodation's
**CMS code** (e.g. `DGSGRP`), which can differ from its calendar code.
- `400` without `hotel`, `404 {"message": "Hotel not found"}` for an unknown code. - `400` without `hotel`, `404 {"message": "Hotel not found"}` for an unknown code.
```json ```json
@@ -42,15 +43,23 @@ Content of one hotel, for MyE&P's group house pages and booking flow.
## `GET /api/product?product=<code>[&hotel=<code>]` ## `GET /api/product?product=<code>[&hotel=<code>]`
Content of one product, optionally with a hotel. Content of one product with a hotel.
- `product`: the product code. `400` without it, `404 {"message": "Product not found"}` for an - `product`: the product code (default language). `400` without it, `404 {"message": "Product
unknown code. not found"}` for an unknown code.
- `hotel` (optional): adds `hotel` with the same content as `/api/hotel`. - Without `hotel` (MyE&P's group houses, linked by product code): the product's only visible
Unterkunft. Any other number of visible Unterkünfte answers `422 {"message": "Product <code>
links <n> hotels, expected exactly 1", "hotel_count": <n>}`.
- With `hotel` (MyE&P's booking flow): the record of that import code, as in `/api/hotel`; an
unknown code gives `"hotel": []`.
- `board_description`, `additional_services`: raw RTE values, `""` when empty.
- `calendar_hotel_code`: the Kalender-Code of the hotel when "Kalender anzeigen" is on, else
`null`. MyE&P compares it with its accommodation's calendar code.
```json ```json
{ {
"product": {"name": "…", "code": "…", "images": {…}}, "product": {"name": "…", "code": "…", "images": {…}, "board_description": "…",
"additional_services": "…", "calendar_hotel_code": "SST"},
"country": {"name": "…"}, "country": {"name": "…"},
"region": {…}, "region": {…},
"city": {"name": "…"}, "city": {"name": "…"},
@@ -60,12 +69,14 @@ Content of one product, optionally with a hotel.
## `GET /api/calendar-hotels` ## `GET /api/calendar-hotels`
The calendar hotel of every visible product: the hotel codes whose availability TYPO3 shows The Kalender-Codes of all visible hotel records: the codes whose availability TYPO3 shows (iCal
(iCal feed, availability calendar, price calendar). MyE&P syncs its contingent snapshot for feeds, availability calendar, price calendar). MyE&P syncs its contingent snapshot for these codes
these codes in addition to its accommodations, so hotels offered only in winter, which have no in addition to its accommodations, so hotels offered only in winter, which have no accommodation in
accommodation in MyE&P, have availability too. See [calendars.md](calendars.md). MyE&P, have availability too. See [calendars.md](calendars.md).
- Only products and hotels that are not hidden or deleted; hotels without a code are left out. - One entry per code; `name` of the record whose import code it is, else of the first record.
- `products`: visible products with "Kalender anzeigen" that link a record with the code under
Unterkünfte.
- Sorted by code; products by uid. Names have line breaks collapsed. - Sorted by code; products by uid. Names have line breaks collapsed.
- `season`: `"s"` (summer), `"w"` (winter) or `null`. - `season`: `"s"` (summer), `"w"` (winter) or `null`.
@@ -78,9 +89,8 @@ accommodation in MyE&P, have availability too. See [calendars.md](calendars.md).
] ]
``` ```
Every code in this list should be a **BusPro calendar code**. A group house's content record Every code in this list should be a **BusPro code** with a contingent (see
(`…GRP`, `…SO`) set as a product's calendar hotel puts its CMS code in here, which bpn-connect does [calendars.md](calendars.md#hotel-codes)).
not know (see [calendars.md](calendars.md#the-calendar-hotel-field)).
## `GET /api/content/manifest` and `GET /api/content/records?type=<type>&uids=<uids>` ## `GET /api/content/manifest` and `GET /api/content/records?type=<type>&uids=<uids>`
@@ -0,0 +1,47 @@
<?php
namespace EP\EpProducts\Command;
use EP\EpProducts\Service\CalendarCodeMigration;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
/**
* The editors' list after the switch to Kalender-Codes; goes away with calendar_hotel
*/
#[AsCommand(name: 'ep:calendar-codes', description: 'Lists product pages whose calendar differs from the old "Unterkunft für Belegungskalender"')]
class CalendarCodesCommand extends Command
{
public function __construct(
private readonly CalendarCodeMigration $calendarCodeMigration,
) {
parent::__construct();
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$differences = $this->calendarCodeMigration->findDifferences();
if ([] === $differences) {
$io->success('Every product page shows the same calendar as with "Unterkunft für Belegungskalender".');
return Command::SUCCESS;
}
$io->table(
['Produkt', 'Saison', 'Unterkunft', 'bisher', 'jetzt'],
array_map(static fn(array $row): array => [
sprintf('%d %s', $row['product'], $row['name']),
$row['season'],
0 === $row['hotel'] ? $row['hotelName'] : sprintf('%d %s', $row['hotel'], $row['hotelName']),
'' !== $row['before'] ? $row['before'] : '–',
'' !== $row['after'] ? $row['after'] : '–',
], $differences)
);
$io->writeln('bisher: Code der "Unterkunft für Belegungskalender"; jetzt: Kalender-Code der angezeigten Unterkunft, wenn "Kalender anzeigen" an ist.');
return Command::SUCCESS;
}
}
@@ -19,7 +19,7 @@ class AjaxCalendarController extends ActionController
public function priceCalendarAction(Hotel $hotel, int $months = 12): ResponseInterface public function priceCalendarAction(Hotel $hotel, int $months = 12): ResponseInterface
{ {
$hotelCode = trim($hotel->getCode() ?? ''); $hotelCode = trim($hotel->getCalendarCode());
$this->tagPageCacheForHotel($hotelCode); $this->tagPageCacheForHotel($hotelCode);
$dateRange = DateUtility::getDateRange(null, null, $months); $dateRange = DateUtility::getDateRange(null, null, $months);
@@ -120,7 +120,7 @@ class AjaxCalendarController extends ActionController
*/ */
public function availabilityAction(Hotel $hotel, int $months = 12): ResponseInterface public function availabilityAction(Hotel $hotel, int $months = 12): ResponseInterface
{ {
$hotelCode = trim($hotel->getCode() ?? ''); $hotelCode = trim($hotel->getCalendarCode());
$this->tagPageCacheForHotel($hotelCode); $this->tagPageCacheForHotel($hotelCode);
$period = DateUtility::getDateRange(null, null, $months)['period']; $period = DateUtility::getDateRange(null, null, $months)['period'];
@@ -206,7 +206,7 @@ class AjaxCalendarController extends ActionController
public function priceTableAction(Hotel $hotel, ?string $year = null): ResponseInterface public function priceTableAction(Hotel $hotel, ?string $year = null): ResponseInterface
{ {
$year ??= new \DateTimeImmutable()->format('Y'); $year ??= new \DateTimeImmutable()->format('Y');
$hotelCode = trim($hotel->getCode() ?? ''); $hotelCode = trim($hotel->getCalendarCode());
$this->tagPageCacheForHotel($hotelCode); $this->tagPageCacheForHotel($hotelCode);
$priceTable = [ $priceTable = [
@@ -21,6 +21,17 @@ class IcalController extends ActionController
*/ */
public function contingentsAction(Hotel $hotel): ResponseInterface public function contingentsAction(Hotel $hotel): ResponseInterface
{ {
// Without a Kalender-Code the hotel has no availability; an empty calendar would read as free
if ('' === trim($hotel->getCalendarCode())) {
throw new PropagateResponseException(
$this->responseFactory->createResponse(404)
->withHeader('Content-Type', 'text/plain; charset=utf-8')
->withHeader('Cache-Control', 'private, no-store')
->withBody($this->streamFactory->createStream('No availability for this hotel')),
1763309100
);
}
$calendar = $this->icalService->createContingentsFeed($hotel); $calendar = $this->icalService->createContingentsFeed($hotel);
// An empty calendar would show the portals every day as free; an error keeps their last import // An empty calendar would show the portals every day as free; an error keeps their last import
@@ -94,6 +94,7 @@ class ProductController extends ActionController
$this->view->assignMultiple([ $this->view->assignMultiple([
'hotel' => $hotel, 'hotel' => $hotel,
'product' => $product, 'product' => $product,
'calendarHotel' => $product->getCalendarHotelFor($hotel),
// Daytrip availability came from the contingent import, which is not ported // Daytrip availability came from the contingent import, which is not ported
'enabledDates' => [], 'enabledDates' => [],
'isProductWithExcludedConcept' => $isProductWithExcludedConcept, 'isProductWithExcludedConcept' => $isProductWithExcludedConcept,
@@ -6,6 +6,7 @@ use Psr\Http\Message\ResponseInterface;
use EP\EpProducts\Domain\Model\Hotel; use EP\EpProducts\Domain\Model\Hotel;
use EP\EpProducts\Domain\Model\Travelinfo; use EP\EpProducts\Domain\Model\Travelinfo;
use EP\EpProducts\Domain\Repository\HotelRepository; use EP\EpProducts\Domain\Repository\HotelRepository;
use EP\EpProducts\Service\HotelCodeResolver;
use EP\EpProducts\Domain\Repository\TravelinfoRepository; use EP\EpProducts\Domain\Repository\TravelinfoRepository;
use EP\EpProducts\MyEP\ApiClient; use EP\EpProducts\MyEP\ApiClient;
use EP\EpProducts\MyEP\ApiException; use EP\EpProducts\MyEP\ApiException;
@@ -22,6 +23,7 @@ class TravelinfoController extends ActionController
private readonly ApiClient $apiClient, private readonly ApiClient $apiClient,
private readonly TravelinfoRepository $travelinfoRepository, private readonly TravelinfoRepository $travelinfoRepository,
private readonly HotelRepository $hotelRepository, private readonly HotelRepository $hotelRepository,
private readonly HotelCodeResolver $hotelCodeResolver,
) { ) {
} }
@@ -101,7 +103,8 @@ class TravelinfoController extends ActionController
$hotel = null; $hotel = null;
$hotelCode = $travelData['hotel']['code'] ?? null; $hotelCode = $travelData['hotel']['code'] ?? null;
if (null !== $hotelCode && '' !== $hotelCode) { if (null !== $hotelCode && '' !== $hotelCode) {
$hotel = $this->hotelRepository->findOneByCodeOrAdditionalCode($hotelCode); $hotelUid = $this->hotelCodeResolver->findUid($hotelCode);
$hotel = null !== $hotelUid ? $this->hotelRepository->findByUid($hotelUid) : null;
} }
$hotelAddress = $hotel instanceof Hotel ? trim((string)$hotel->getAddress()) : ''; $hotelAddress = $hotel instanceof Hotel ? trim((string)$hotel->getAddress()) : '';
@@ -171,6 +171,12 @@ class Hotel extends AbstractEntity implements TeaserInterface
*/ */
protected $code = ''; protected $code = '';
/**
* BusPro code of the house whose availability this record shows, shared by its summer and
* winter records; empty = no calendar
*/
protected string $calendarCode = '';
/** /**
* @var ObjectStorage<MatchCode> * @var ObjectStorage<MatchCode>
*/ */
@@ -765,6 +771,16 @@ class Hotel extends AbstractEntity implements TeaserInterface
$this->code = $code; $this->code = $code;
} }
public function getCalendarCode(): string
{
return $this->calendarCode;
}
public function setCalendarCode(string $calendarCode): void
{
$this->calendarCode = $calendarCode;
}
public function addAdditionalCode(MatchCode $code): void public function addAdditionalCode(MatchCode $code): void
{ {
$this->additionalCodes->attach($code); $this->additionalCodes->attach($code);
@@ -239,6 +239,8 @@ class Product extends AbstractEntity implements TeaserInterface
*/ */
protected $calendarHotel; protected $calendarHotel;
protected bool $showCalendar = false;
/** /**
* @var Product * @var Product
*/ */
@@ -1024,6 +1026,29 @@ class Product extends AbstractEntity implements TeaserInterface
$this->calendarHotel = $calendarHotel; $this->calendarHotel = $calendarHotel;
} }
public function getShowCalendar(): bool
{
return $this->showCalendar;
}
public function setShowCalendar(bool $showCalendar): void
{
$this->showCalendar = $showCalendar;
}
/**
* The hotel whose calendar this product's page shows: the hotel the page shows, when
* "Kalender anzeigen" is on and that hotel has a Kalender-Code
*/
public function getCalendarHotelFor(?Hotel $hotel): ?Hotel
{
if (!$this->showCalendar || null === $hotel || '' === trim($hotel->getCalendarCode())) {
return null;
}
return $hotel;
}
/** /**
* @return Product * @return Product
*/ */
@@ -243,17 +243,4 @@ class HotelRepository extends AbstractRepository
return $query->execute(); return $query->execute();
} }
public function findOneByCodeOrAdditionalCode(string $code): ?Hotel
{
$query = $this->createQuery();
$query->matching(
$query->logicalOr(
$query->equals('code', $code),
$query->equals('additionalCodes.code', $code)
)
);
return $query->execute()->getFirst();
}
} }
@@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
namespace EP\EpProducts\Hooks;
use EP\EpProducts\Service\HotelCodeResolver;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\SysLog\Action\Database as DatabaseAction;
use TYPO3\CMS\Core\SysLog\Error as SystemLogErrorClassification;
/**
* A BusPro code is an import code ("Import-Code" or "Weitere Import-Codes") of at most one visible hotel
* record: a code already on another record is not saved, and the editor gets a message naming it.
* Hidden records don't count. The Kalender-Code is not checked, records share it on purpose.
*/
class ImportCodeCheck
{
private const string HOTEL_TABLE = 'tx_epproducts_domain_model_hotel';
private const string ALIAS_TABLE = 'tx_epproducts_domain_model_matchcode';
public function __construct(
private readonly HotelCodeResolver $hotelCodeResolver,
) {
}
public function processDatamap_preProcessFieldArray(array &$fieldArray, string $table, string|int $id, DataHandler $dataHandler): void
{
if (!isset($fieldArray['code']) || '' === trim((string)$fieldArray['code'])) {
return;
}
// Old duplicates are reported by the import's log, not on every save of an unchanged code
if (is_numeric($id) && strtoupper(trim((string)($dataHandler->recordInfo($table, (int)$id)['code'] ?? ''))) === strtoupper(trim((string)$fieldArray['code']))) {
return;
}
if (self::HOTEL_TABLE === $table) {
$ownHotelUids = [(int)$id];
} elseif (self::ALIAS_TABLE === $table && 'hotel' === ($fieldArray['entity_type'] ?? $dataHandler->recordInfo($table, (int)$id)['entity_type'] ?? 'hotel')) {
// A new alias gets its hotel only after this hook; every hotel saved with it may own the code
$ownHotelUids = array_map(intval(...), array_keys($dataHandler->datamap[self::HOTEL_TABLE] ?? []));
$entity = $fieldArray['entity'] ?? (is_numeric($id) ? ($dataHandler->recordInfo($table, (int)$id)['entity'] ?? 0) : 0);
$ownHotelUids[] = (int)$entity;
} else {
return;
}
$otherHotelUids = array_diff($this->hotelCodeResolver->findHotelUids((string)$fieldArray['code']), $ownHotelUids);
if ([] === $otherHotelUids) {
return;
}
$otherHotelUid = (int)reset($otherHotelUids);
$otherHotel = $dataHandler->recordInfo(self::HOTEL_TABLE, $otherHotelUid) ?? [];
$dataHandler->log(
$table,
is_numeric($id) ? (int)$id : 0,
DatabaseAction::UPDATE,
null,
SystemLogErrorClassification::USER_ERROR,
sprintf(
'Der Code "%s" wurde nicht gespeichert: er ist schon Import-Code von "%s" [%d]. Jeder BusPro-Code darf nur an einem Datensatz stehen; für den Kalender gibt es den Kalender-Code.',
trim((string)$fieldArray['code']),
trim((string)preg_replace('/\s+/', ' ', (string)($otherHotel['name'] ?? ''))),
$otherHotelUid
)
);
unset($fieldArray['code']);
}
}
@@ -7,6 +7,7 @@ use TYPO3\CMS\Core\Database\Connection;
use EP\EpProducts\ContentFeed\ContentFeedApi; use EP\EpProducts\ContentFeed\ContentFeedApi;
use EP\EpProducts\Http\ApiKeyAuthenticator; use EP\EpProducts\Http\ApiKeyAuthenticator;
use EP\EpProducts\JsonLd\JsonLdApi; use EP\EpProducts\JsonLd\JsonLdApi;
use EP\EpProducts\Service\HotelCodeResolver;
use EP\EpProducts\Service\MyEpImageService; use EP\EpProducts\Service\MyEpImageService;
use EP\EpProducts\Utility\HotelIconUtility; use EP\EpProducts\Utility\HotelIconUtility;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
@@ -30,6 +31,7 @@ class ApiMiddleware implements MiddlewareInterface
private readonly ContentFeedApi $contentFeedApi, private readonly ContentFeedApi $contentFeedApi,
private readonly ApiKeyAuthenticator $authenticator, private readonly ApiKeyAuthenticator $authenticator,
private readonly JsonLdApi $jsonLdApi, private readonly JsonLdApi $jsonLdApi,
private readonly HotelCodeResolver $hotelCodeResolver,
) { ) {
} }
@@ -100,17 +102,84 @@ class ApiMiddleware implements MiddlewareInterface
return new JsonResponse(['message' => 'Product not found'], 404); return new JsonResponse(['message' => 'Product not found'], 404);
} }
if (null !== $hotelCode) { $productUid = $data['productUid'];
$data['hotel'] = $this->fetchHotelData($hotelCode); $showCalendar = $data['showCalendar'];
unset($data['productUid'], $data['showCalendar']);
// Without a hotel code (MyE&P's group houses), the product's only Unterkunft is its hotel
if (null === $hotelCode) {
$hotelUids = $this->fetchVisibleHotelUids($productUid);
if (1 !== count($hotelUids)) {
return new JsonResponse([
'message' => sprintf('Product %s links %d hotels, expected exactly 1', $productCode, count($hotelUids)),
'hotel_count' => count($hotelUids),
], 422);
}
$hotelUid = $hotelUids[0];
} else {
$hotelUid = $this->hotelCodeResolver->findUid($hotelCode);
}
$calendarCode = $showCalendar && null !== $hotelUid ? $this->fetchCalendarCode($hotelUid) : '';
$data['product']['calendar_hotel_code'] = '' !== $calendarCode ? $calendarCode : null;
if (null !== $hotelUid) {
$data['hotel'] = $this->fetchHotelDataByUid($hotelUid);
} elseif (null !== $hotelCode) {
$data['hotel'] = [];
} }
return new JsonResponse($data); return new JsonResponse($data);
} }
/** /**
* The calendar hotels of all visible products, for the contingent sync of MyE&P: their * Uids from the MM table, then selected from the hotel table, so its restrictions apply
* availability is needed for the iCal feed and the availability calendar, whether or not *
* MyE&P has an accommodation with prices for them. * @return list<int>
*/
private function fetchVisibleHotelUids(int $productUid): array
{
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$queryBuilder = $connectionPool->getQueryBuilderForTable('tx_epproducts_product_hotel_mm');
$linkedUids = $queryBuilder
->select('uid_foreign')
->from('tx_epproducts_product_hotel_mm')
->where($queryBuilder->expr()->eq('uid_local', $queryBuilder->createNamedParameter($productUid, Connection::PARAM_INT)))
->executeQuery()
->fetchFirstColumn();
if ([] === $linkedUids) {
return [];
}
$queryBuilder = $connectionPool->getQueryBuilderForTable('tx_epproducts_domain_model_hotel');
return array_map(intval(...), $queryBuilder
->select('uid')
->from('tx_epproducts_domain_model_hotel')
->where($queryBuilder->expr()->in('uid', $queryBuilder->createNamedParameter(array_map(intval(...), $linkedUids), Connection::PARAM_INT_ARRAY)))
->executeQuery()
->fetchFirstColumn());
}
private function fetchCalendarCode(int $hotelUid): string
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_epproducts_domain_model_hotel');
return trim((string)$queryBuilder
->select('calendar_code')
->from('tx_epproducts_domain_model_hotel')
->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($hotelUid, Connection::PARAM_INT)))
->executeQuery()
->fetchOne());
}
/**
* The Kalender-Codes of all visible hotels, for the contingent sync of MyE&P: their availability
* is needed for the iCal feeds and the calendars, whether or not MyE&P has an accommodation with
* prices for them. Per code the visible products with "Kalender anzeigen" showing a hotel with it.
*/ */
private function handleCalendarHotelsRequest(ServerRequestInterface $request): ResponseInterface private function handleCalendarHotelsRequest(ServerRequestInterface $request): ResponseInterface
{ {
@@ -118,31 +187,50 @@ class ApiMiddleware implements MiddlewareInterface
return new JsonResponse(['message' => 'Invalid or missing api key'], 403); return new JsonResponse(['message' => 'Invalid or missing api key'], 403);
} }
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
->getQueryBuilderForTable('tx_epproducts_domain_model_product');
$rows = $queryBuilder $queryBuilder = $connectionPool->getQueryBuilderForTable('tx_epproducts_domain_model_hotel');
->select('hotel.code', 'hotel.name AS hotelName', 'product.uid', 'product.name', 'product.season') $hotelRows = $queryBuilder
->from('tx_epproducts_domain_model_product', 'product') ->select('calendar_code', 'code', 'name')
->join('product', 'tx_epproducts_domain_model_hotel', 'hotel', 'hotel.uid = product.calendar_hotel') ->from('tx_epproducts_domain_model_hotel')
->where( ->where($queryBuilder->expr()->neq('calendar_code', $queryBuilder->createNamedParameter('')))
$queryBuilder->expr()->eq('product.sys_language_uid', 0), ->orderBy('uid')
$queryBuilder->expr()->neq('hotel.code', $queryBuilder->createNamedParameter('')),
)
->orderBy('hotel.code')
->addOrderBy('product.uid')
->executeQuery() ->executeQuery()
->fetchAllAssociative(); ->fetchAllAssociative();
$hotels = []; $hotels = [];
foreach ($rows as $row) { foreach ($hotelRows as $row) {
$code = trim((string)$row['code']); $code = trim((string)$row['calendar_code']);
$hotels[$code] ??= [ // Named after the record whose import code it is, else the first one
if (isset($hotels[$code]) && $code !== trim((string)$row['code'])) {
continue;
}
$hotels[$code] = [
'code' => $code, 'code' => $code,
'name' => trim((string)preg_replace('/\s+/', ' ', (string)$row['hotelName'])), 'name' => trim((string)preg_replace('/\s+/', ' ', (string)$row['name'])),
'products' => [], 'products' => [],
]; ];
$hotels[$code]['products'][] = [ }
ksort($hotels);
$queryBuilder = $connectionPool->getQueryBuilderForTable('tx_epproducts_domain_model_product');
$productRows = $queryBuilder
->select('hotel.calendar_code', 'product.uid', 'product.name', 'product.season')
->from('tx_epproducts_domain_model_product', 'product')
->join('product', 'tx_epproducts_product_hotel_mm', 'mm', 'mm.uid_local = product.uid')
->join('mm', 'tx_epproducts_domain_model_hotel', 'hotel', 'hotel.uid = mm.uid_foreign')
->where(
$queryBuilder->expr()->eq('product.sys_language_uid', 0),
$queryBuilder->expr()->eq('product.show_calendar', 1),
$queryBuilder->expr()->neq('hotel.calendar_code', $queryBuilder->createNamedParameter('')),
)
->groupBy('hotel.calendar_code', 'product.uid', 'product.name', 'product.season')
->orderBy('product.uid')
->executeQuery()
->fetchAllAssociative();
foreach ($productRows as $row) {
$hotels[trim((string)$row['calendar_code'])]['products'][] = [
'uid' => (int)$row['uid'], 'uid' => (int)$row['uid'],
'name' => trim((string)preg_replace('/\s+/', ' ', (string)$row['name'])), 'name' => trim((string)preg_replace('/\s+/', ' ', (string)$row['name'])),
'season' => '' !== (string)$row['season'] ? (string)$row['season'] : null, 'season' => '' !== (string)$row['season'] ? (string)$row['season'] : null,
@@ -163,13 +251,19 @@ class ApiMiddleware implements MiddlewareInterface
'product.name as productName', 'product.name as productName',
'product.code as productCode', 'product.code as productCode',
'product.region as regionUid', 'product.region as regionUid',
'product.board_description as boardDescription',
'product.additional_services as additionalServices',
'product.show_calendar as showCalendar',
'country.name as countryName', 'country.name as countryName',
'city.name as cityName', 'city.name as cityName',
) )
->from('tx_epproducts_domain_model_product', 'product') ->from('tx_epproducts_domain_model_product', 'product')
->leftJoin('product', 'tx_epproducts_domain_model_country', 'country', 'product.country = country.uid') ->leftJoin('product', 'tx_epproducts_domain_model_country', 'country', 'product.country = country.uid')
->leftJoin('product', 'tx_epproducts_domain_model_city', 'city', 'product.city = city.uid') ->leftJoin('product', 'tx_epproducts_domain_model_city', 'city', 'product.city = city.uid')
->where($queryBuilder->expr()->eq('product.code', $queryBuilder->createNamedParameter($productCode))) ->where(
$queryBuilder->expr()->eq('product.code', $queryBuilder->createNamedParameter($productCode)),
$queryBuilder->expr()->in('product.sys_language_uid', [0, -1]),
)
->orderBy('product.uid') ->orderBy('product.uid')
->setMaxResults(1)->executeQuery() ->setMaxResults(1)->executeQuery()
->fetchAssociative() ->fetchAssociative()
@@ -182,10 +276,14 @@ class ApiMiddleware implements MiddlewareInterface
$images = $this->serializeImages($this->productImageService->getImages((int) $data['productUid'])); $images = $this->serializeImages($this->productImageService->getImages((int) $data['productUid']));
return [ return [
'productUid' => (int) $data['productUid'],
'showCalendar' => (bool) $data['showCalendar'],
'product' => [ 'product' => [
'name' => $data['productName'], 'name' => $data['productName'],
'code' => $data['productCode'], 'code' => $data['productCode'],
'images' => $images, 'images' => $images,
'board_description' => (string) $data['boardDescription'],
'additional_services' => (string) $data['additionalServices'],
], ],
'country' => [ 'country' => [
'name' => $data['countryName'], 'name' => $data['countryName'],
@@ -198,6 +296,13 @@ class ApiMiddleware implements MiddlewareInterface
} }
private function fetchHotelData(string $hotelCode): array private function fetchHotelData(string $hotelCode): array
{
$hotelUid = $this->hotelCodeResolver->findUid($hotelCode);
return null !== $hotelUid ? $this->fetchHotelDataByUid($hotelUid) : [];
}
private function fetchHotelDataByUid(int $hotelUid): array
{ {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_epproducts_domain_model_hotel'); ->getQueryBuilderForTable('tx_epproducts_domain_model_hotel');
@@ -225,10 +330,8 @@ class ApiMiddleware implements MiddlewareInterface
'hotel.region', 'hotel.region',
) )
->from('tx_epproducts_domain_model_hotel', 'hotel') ->from('tx_epproducts_domain_model_hotel', 'hotel')
->leftJoin('hotel', 'tx_epproducts_domain_model_matchcode', 'alias', 'hotel.uid = alias.entity AND alias.entity_type="hotel"') ->where($queryBuilder->expr()->eq('hotel.uid', $queryBuilder->createNamedParameter($hotelUid, Connection::PARAM_INT)))
->where( ->executeQuery()
$queryBuilder->expr()->or($queryBuilder->expr()->eq('hotel.code', $queryBuilder->createNamedParameter($hotelCode)), $queryBuilder->expr()->eq('alias.code', $queryBuilder->createNamedParameter($hotelCode)))
)->setMaxResults(1)->executeQuery()
->fetchAssociative() ->fetchAssociative()
; ;
@@ -0,0 +1,274 @@
<?php
declare(strict_types=1);
namespace EP\EpProducts\Service;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Moves the calendars from the product's "Unterkunft für Belegungskalender" (calendar_hotel) to the
* Kalender-Code of the hotel a product page shows (hotel calendar_code, product show_calendar), and
* compares the two while calendar_hotel still exists.
*
* The hotel a page shows is the hotel pinned in a Produktdetail element's flexform, else the product's
* single Unterkunft; a product with several Unterkünfte shows the one picked in its hotel list.
* Remove this class together with calendar_hotel.
*/
class CalendarCodeMigration
{
private const string PRODUCT_TABLE = 'tx_epproducts_domain_model_product';
private const string HOTEL_TABLE = 'tx_epproducts_domain_model_hotel';
private ?array $products = null;
public function __construct(
private readonly ConnectionPool $connectionPool,
) {
}
public function isFillNecessary(): bool
{
foreach ($this->getLegacyCalendarCodes() as $productUid => $code) {
if (!($this->getProducts()[$productUid]['show_calendar'] ?? false)) {
return true;
}
}
return false;
}
/**
* Additive: sets show_calendar and fills empty Kalender-Codes, never clears or overwrites one
*
* @return list<string> what the fill could not decide
*/
public function fill(): array
{
$legacyCodes = $this->getLegacyCalendarCodes();
$hotels = $this->getVisibleHotels();
$pinnedHotels = $this->getPinnedHotels();
$accommodations = $this->getVisibleAccommodations();
$notes = [];
// Today's behaviour: a calendar where the calendar hotel is visible and has a code
foreach (array_keys($legacyCodes) as $productUid) {
$this->connectionPool->getConnectionForTable(self::PRODUCT_TABLE)
->update(self::PRODUCT_TABLE, ['show_calendar' => 1], ['uid' => $productUid]);
}
// Who gets which code, by priority: 0 a calendar hotel its own code, 1 the hotel a product page
// shows (pinned in the Produktdetail element, else the single Unterkunft), 2 the other
// Unterkünfte, only when they have no code of their own (another house's record keeps none)
$candidates = [];
foreach ($legacyCodes as $productUid => $code) {
$candidates[$this->getProducts()[$productUid]['calendar_hotel']][0][$code][] = 0;
$productAccommodations = $accommodations[$productUid] ?? [];
$shownHotelUids = $pinnedHotels[$productUid] ?? (1 === count($productAccommodations) ? $productAccommodations : []);
foreach ($shownHotelUids as $hotelUid) {
$candidates[$hotelUid][1][$code][] = $productUid;
}
foreach (array_diff($productAccommodations, $shownHotelUids) as $hotelUid) {
if ('' === ($hotels[$hotelUid]['code'] ?? '')) {
$candidates[$hotelUid][2][$code][] = $productUid;
}
}
}
// Within a priority, the most frequent code wins, then the one of the lowest product uid
$hotelConnection = $this->connectionPool->getConnectionForTable(self::HOTEL_TABLE);
foreach ($candidates as $hotelUid => $codesByPriority) {
if (!isset($hotels[$hotelUid]) || '' !== $hotels[$hotelUid]['calendar_code']) {
continue;
}
ksort($codesByPriority);
$codes = reset($codesByPriority);
uasort($codes, static fn(array $a, array $b): int => count($b) <=> count($a) ?: min($a) <=> min($b));
$chosen = (string)array_key_first($codes);
$others = array_diff_key($codes, [$chosen => true]);
if ([] !== $others) {
$notes[] = sprintf(
'Hotel %d (%s) got %s; also wanted: %s',
$hotelUid,
$hotels[$hotelUid]['name'],
$chosen,
implode(', ', array_map(
static fn(string $code, array $productUids): string => sprintf('%s by products %s', $code, implode(', ', $productUids)),
array_keys($others),
$others
))
);
}
$hotelConnection->update(self::HOTEL_TABLE, ['calendar_code' => $chosen], ['uid' => $hotelUid]);
}
return $notes;
}
/**
* Product pages whose calendar differs between calendar_hotel and the Kalender-Code model, as long
* as calendar_hotel is still filled
*
* @return list<array{product: int, name: string, season: string, hotel: int, hotelName: string, before: string, after: string}>
*/
public function findDifferences(): array
{
$legacyCodes = $this->getLegacyCalendarCodes();
$hotels = $this->getVisibleHotels();
$pinnedHotels = $this->getPinnedHotels();
$accommodations = $this->getVisibleAccommodations();
$differences = [];
foreach ($this->getProducts() as $productUid => $product) {
if ($product['hidden']) {
continue;
}
$shownHotelUids = array_unique(array_merge($pinnedHotels[$productUid] ?? [], $accommodations[$productUid] ?? []));
$before = $legacyCodes[$productUid] ?? '';
if ([] === $shownHotelUids && '' !== $before) {
$differences[] = ['product' => $productUid, 'name' => $product['name'], 'season' => $product['season'], 'hotel' => 0, 'hotelName' => '(keine sichtbare Unterkunft)', 'before' => $before, 'after' => ''];
}
foreach ($shownHotelUids as $hotelUid) {
$after = $product['show_calendar'] ? ($hotels[$hotelUid]['calendar_code'] ?? '') : '';
if ($before !== $after) {
$differences[] = ['product' => $productUid, 'name' => $product['name'], 'season' => $product['season'], 'hotel' => $hotelUid, 'hotelName' => $hotels[$hotelUid]['name'] ?? '', 'before' => $before, 'after' => $after];
}
}
}
return $differences;
}
/**
* @return array<int, string> product uid => code of its calendar hotel, where that hotel is visible and has a code
*/
private function getLegacyCalendarCodes(): array
{
$hotels = $this->getVisibleHotels();
$codes = [];
foreach ($this->getProducts() as $productUid => $product) {
$code = $hotels[$product['calendar_hotel']]['code'] ?? '';
if ('' !== $code) {
$codes[$productUid] = $code;
}
}
return $codes;
}
/**
* Hidden products too: their calendar is there when they are shown again
*
* @return array<int, array{name: string, season: string, hidden: bool, calendar_hotel: int, show_calendar: bool}>
*/
private function getProducts(): array
{
if (null !== $this->products) {
return $this->products;
}
$queryBuilder = $this->connectionPool->getQueryBuilderForTable(self::PRODUCT_TABLE);
$queryBuilder->getRestrictions()->removeByType(HiddenRestriction::class);
$rows = $queryBuilder
->select('uid', 'name', 'season', 'hidden', 'calendar_hotel', 'show_calendar')
->from(self::PRODUCT_TABLE)
->where($queryBuilder->expr()->eq('sys_language_uid', 0))
->orderBy('uid')
->executeQuery()
->fetchAllAssociative();
$this->products = [];
foreach ($rows as $row) {
$this->products[(int)$row['uid']] = [
'name' => trim((string)preg_replace('/\s+/', ' ', (string)$row['name'])),
'season' => (string)$row['season'],
'hidden' => (bool)$row['hidden'],
'calendar_hotel' => (int)$row['calendar_hotel'],
'show_calendar' => (bool)$row['show_calendar'],
];
}
return $this->products;
}
/**
* @return array<int, array{name: string, code: string, calendar_code: string}>
*/
private function getVisibleHotels(): array
{
$queryBuilder = $this->connectionPool->getQueryBuilderForTable(self::HOTEL_TABLE);
$rows = $queryBuilder
->select('uid', 'name', 'code', 'calendar_code')
->from(self::HOTEL_TABLE)
->executeQuery()
->fetchAllAssociative();
$hotels = [];
foreach ($rows as $row) {
$hotels[(int)$row['uid']] = [
'name' => trim((string)preg_replace('/\s+/', ' ', (string)$row['name'])),
'code' => strtoupper(trim((string)$row['code'])),
'calendar_code' => trim((string)$row['calendar_code']),
];
}
return $hotels;
}
/**
* @return array<int, list<int>> product uid => its visible Unterkünfte
*/
private function getVisibleAccommodations(): array
{
$queryBuilder = $this->connectionPool->getQueryBuilderForTable(self::HOTEL_TABLE);
$rows = $queryBuilder
->select('mm.uid_local', 'mm.uid_foreign')
->from(self::HOTEL_TABLE, 'hotel')
->join('hotel', 'tx_epproducts_product_hotel_mm', 'mm', 'mm.uid_foreign = hotel.uid')
->orderBy('mm.uid_local')
->addOrderBy('mm.sorting')
->executeQuery()
->fetchAllAssociative();
$accommodations = [];
foreach ($rows as $row) {
$accommodations[(int)$row['uid_local']][] = (int)$row['uid_foreign'];
}
return $accommodations;
}
/**
* A hidden pinned hotel is left out: the page falls back to the Unterkünfte
*
* @return array<int, list<int>> product uid => visible hotels pinned in visible Produktdetail elements
*/
private function getPinnedHotels(): array
{
$hotels = $this->getVisibleHotels();
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('tt_content');
$rows = $queryBuilder
->select('content.pi_flexform')
->from('tt_content', 'content')
->join('content', 'pages', 'page', 'page.uid = content.pid')
->where($queryBuilder->expr()->eq('content.CType', $queryBuilder->createNamedParameter('epproducts_product_detail', Connection::PARAM_STR)))
->executeQuery()
->fetchAllAssociative();
$pinned = [];
foreach ($rows as $row) {
$flexform = GeneralUtility::xml2array((string)$row['pi_flexform']);
$fields = is_array($flexform) ? ($flexform['data']['sDEF']['lDEF'] ?? []) : [];
$productUid = (int)($fields['settings.productUid']['vDEF'] ?? 0);
$hotelUid = (int)($fields['settings.hotelUid']['vDEF'] ?? 0);
if (0 < $productUid && isset($hotels[$hotelUid]) && !in_array($hotelUid, $pinned[$productUid] ?? [], true)) {
$pinned[$productUid][] = $hotelUid;
}
}
return $pinned;
}
}
@@ -72,7 +72,8 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
ExtensionConfiguration $extensionConfiguration, ExtensionConfiguration $extensionConfiguration,
private CacheService $cacheService, private CacheService $cacheService,
private ProductImportSource $importSource, private ProductImportSource $importSource,
private RoomTypeResolver $roomTypeResolver private RoomTypeResolver $roomTypeResolver,
private HotelCodeResolver $hotelCodeResolver
) { ) {
// Extension configuration rather than TypoScript: the import runs on the CLI, where // Extension configuration rather than TypoScript: the import runs on the CLI, where
// TYPO3 13 has no frontend TypoScript (plugin.tx_epproducts.persistence.storagePid) // TYPO3 13 has no frontend TypoScript (plugin.tx_epproducts.persistence.storagePid)
@@ -426,13 +427,14 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
$code = $row['hotel']['code']; $code = $row['hotel']['code'];
$busProId = (int) $row['hotel']['busProId']; $busProId = (int) $row['hotel']['busProId'];
if (!array_key_exists((string) $code, $this->hotelMappings)) { $hotelUid = $this->hotelCodeResolver->findUid((string) $code);
if (null === $hotelUid || !isset($this->hotelMappings[$hotelUid])) {
$this->logger->warning('hotel not found', ['code' => $code]); $this->logger->warning('hotel not found', ['code' => $code]);
return false; return false;
} }
$hotel = $this->hotelMappings[$code]; $hotel = ['code' => $code] + $this->hotelMappings[$hotelUid];
$hotel['fact'] = $this->getTopFactForRecord('tx_epproducts_hotel_fact_mm', $hotel['uid']); $hotel['fact'] = $this->getTopFactForRecord('tx_epproducts_hotel_fact_mm', $hotel['uid']);
$services = []; $services = [];
@@ -751,31 +753,23 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
return (float) str_replace(['.', ','], ['', '.'], $price); return (float) str_replace(['.', ','], ['', '.'], $price);
} }
/**
* The visible hotel records by uid; which record a code belongs to says HotelCodeResolver
*/
private function getHotelMappings(): void private function getHotelMappings(): void
{ {
$sql = ' $sql = '
SELECT u.code code, u.uid uid, h.name name, h.type type, SELECT h.uid uid, h.name name, h.type type,
h.earlybird earlybird, h.new new, h.low_contingent low_contingent, h.earlybird earlybird, h.new new, h.low_contingent low_contingent,
h.keywords keywords, h.header_title header_title, h.keywords keywords, h.header_title header_title,
h.category category, h.teaser teaser, h.detail_page detail_page h.category category, h.teaser teaser, h.detail_page detail_page
FROM ( FROM tx_epproducts_domain_model_hotel h
SELECT hotel.code code, hotel.uid uid WHERE h.deleted = 0 AND h.hidden = 0
FROM tx_epproducts_domain_model_hotel hotel
WHERE hotel.code != "" AND hotel.deleted = 0 AND hotel.hidden = 0
UNION SELECT matchcode.code code, matchcode.entity uid
FROM tx_epproducts_domain_model_matchcode matchcode
INNER JOIN tx_epproducts_domain_model_hotel matchcode_hotel ON matchcode.entity = matchcode_hotel.uid
WHERE matchcode.deleted = 0 AND matchcode.hidden = 0
AND matchcode_hotel.deleted = 0 AND matchcode_hotel.hidden = 0
ORDER BY code
) u
LEFT JOIN tx_epproducts_domain_model_hotel h ON u.uid = h.uid
'; ';
$rows = $this->db->fetchAllAssociative($sql); $rows = $this->db->fetchAllAssociative($sql);
foreach ($rows as $row) { foreach ($rows as $row) {
$this->hotelMappings[$row['code']] = [ $this->hotelMappings[(int) $row['uid']] = [
'uid' => $row['uid'], 'uid' => $row['uid'],
'code' => $row['code'],
'type' => $row['type'], 'type' => $row['type'],
'name' => $row['name'], 'name' => $row['name'],
'earlybird' => $row['earlybird'], 'earlybird' => $row['earlybird'],
@@ -0,0 +1,110 @@
<?php
declare(strict_types=1);
namespace EP\EpProducts\Service;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\SingletonInterface;
/**
* Finds the hotel record of a BusPro code by its import codes: the record's code ("Import-Code") or
* one of its aliases ("Weitere Import-Codes"). Visible records only. A code belongs to one record; for
* old data with a code on several records, the record whose own code it is wins, then the lowest uid,
* and a warning names them. Availability does not go through here, it uses the Kalender-Code.
*/
class HotelCodeResolver implements SingletonInterface, LoggerAwareInterface
{
use LoggerAwareTrait;
/**
* @var array<string, int>|null
*/
private ?array $map = null;
public function __construct(
private readonly ConnectionPool $connectionPool,
) {
}
public function findUid(string $code): ?int
{
return $this->map()[strtoupper(trim($code))] ?? null;
}
/**
* Read fresh, not from the map: for the check on save
*
* @return list<int> the visible hotel records that have this import code
*/
public function findHotelUids(string $code): array
{
$code = strtoupper(trim($code));
$uids = [];
foreach ($this->findImportCodes() as $row) {
if ($code === strtoupper(trim((string)$row['code']))) {
$uids[] = (int)$row['uid'];
}
}
return array_values(array_unique($uids));
}
/**
* @return array<string, int> import code (upper case) => hotel uid
*/
public function map(): array
{
if (null !== $this->map) {
return $this->map;
}
$owners = [];
foreach ($this->findImportCodes() as $row) {
$owners[strtoupper(trim((string)$row['code']))][(int)$row['uid']] ??= (bool)$row['own'];
}
$this->map = [];
foreach ($owners as $code => $hotels) {
uksort($hotels, static fn(int $a, int $b): int => $hotels[$b] <=> $hotels[$a] ?: $a <=> $b);
$this->map[$code] = (int)array_key_first($hotels);
if (1 < count($hotels)) {
$this->logger?->warning(sprintf('Import code %s is on several hotel records (%s), using %d', $code, implode(', ', array_keys($hotels)), $this->map[$code]));
}
}
return $this->map;
}
/**
* @return list<array{code: string, uid: int, own: int}>
*/
private function findImportCodes(): array
{
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('tx_epproducts_domain_model_hotel');
$codes = $queryBuilder
->select('code', 'uid')
->addSelectLiteral('1 AS own')
->from('tx_epproducts_domain_model_hotel')
->where($queryBuilder->expr()->neq('code', $queryBuilder->createNamedParameter('')))
->executeQuery()
->fetchAllAssociative();
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('tx_epproducts_domain_model_matchcode');
$aliases = $queryBuilder
->select('alias.code', 'hotel.uid')
->addSelectLiteral('0 AS own')
->from('tx_epproducts_domain_model_matchcode', 'alias')
->join('alias', 'tx_epproducts_domain_model_hotel', 'hotel', 'hotel.uid = alias.entity')
->where(
$queryBuilder->expr()->eq('alias.entity_type', $queryBuilder->createNamedParameter('hotel')),
$queryBuilder->expr()->neq('alias.code', $queryBuilder->createNamedParameter('')),
)
->executeQuery()
->fetchAllAssociative();
return array_merge($codes, $aliases);
}
}
@@ -10,7 +10,7 @@ use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait; use Psr\Log\LoggerAwareTrait;
/** /**
* Contingent feed of a hotel for the booking portals * Contingent feed of a hotel for the booking portals, for its Kalender-Code
* *
* The availability comes from MyE&P (contingents/availability, the bpn-connect snapshot without the * The availability comes from MyE&P (contingents/availability, the bpn-connect snapshot without the
* price rule of contingents/calendar). Like the sidebar calendar, it has three levels: every run of * price rule of contingents/calendar). Like the sidebar calendar, it has three levels: every run of
@@ -36,17 +36,14 @@ class IcalService implements LoggerAwareInterface
*/ */
public function createContingentsFeed(Hotel $hotel): ?string public function createContingentsFeed(Hotel $hotel): ?string
{ {
$calendarRows = []; $hotelCode = trim($hotel->getCalendarCode());
$hotelCode = trim((string)$hotel->getCode());
if ('' !== $hotelCode) {
try { try {
$calendarRows = $this->apiClient->getContingentAvailability($hotelCode); $calendarRows = $this->apiClient->getContingentAvailability($hotelCode);
} catch (ApiException $e) { } catch (ApiException $e) {
$this->logger?->error(sprintf('iCal: no availability for hotel %s', $hotelCode), ['exception' => $e]); $this->logger?->error(sprintf('iCal: no availability for hotel %s', $hotelCode), ['exception' => $e]);
return null; return null;
} }
}
$vcalendar = Vcalendar::factory([Vcalendar::UNIQUE_ID => 'www.ep-reisen.de']); $vcalendar = Vcalendar::factory([Vcalendar::UNIQUE_ID => 'www.ep-reisen.de']);
$vcalendar->setXprop(Vcalendar::X_WR_TIMEZONE, 'Europe/Berlin'); $vcalendar->setXprop(Vcalendar::X_WR_TIMEZONE, 'Europe/Berlin');
@@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
namespace EP\EpProducts\Upgrades;
use EP\EpProducts\Service\CalendarCodeMigration;
use Symfony\Component\Console\Output\OutputInterface;
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
use TYPO3\CMS\Install\Updates\ChattyInterface;
use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* Fills the Kalender-Codes and "Kalender anzeigen" from the products' calendar hotels. Run by the
* deploy, between the schema update and the switch to the new release. Additive: calendar_hotel stays,
* so the previous release still works; rollback = clearing show_calendar and calendar_code.
*/
#[UpgradeWizard('epProductsCalendarCode')]
final class CalendarCodeUpdate implements UpgradeWizardInterface, ChattyInterface
{
private ?OutputInterface $output = null;
public function __construct(
private readonly CalendarCodeMigration $calendarCodeMigration,
) {
}
public function setOutput(OutputInterface $output): void
{
$this->output = $output;
}
public function getTitle(): string
{
return 'E&P Produkte: Kalender-Codes aus den Kalender-Unterkünften';
}
public function getDescription(): string
{
return 'Sets "Kalender anzeigen" on products with a calendar hotel and fills the Kalender-Code of the hotels their pages show. Check the result with ep:calendar-codes.';
}
public function updateNecessary(): bool
{
return $this->calendarCodeMigration->isFillNecessary();
}
public function executeUpdate(): bool
{
foreach ($this->calendarCodeMigration->fill() as $note) {
$this->output?->writeln($note);
}
return true;
}
public function getPrerequisites(): array
{
return [DatabaseUpdatedPrerequisite::class];
}
}
@@ -30,6 +30,8 @@ services:
public: true public: true
EP\EpProducts\Service\SearchResultService: EP\EpProducts\Service\SearchResultService:
public: true public: true
EP\EpProducts\Hooks\ImportCodeCheck:
public: true
cache.ep_cache: cache.ep_cache:
class: TYPO3\CMS\Core\Cache\Frontend\FrontendInterface class: TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
@@ -27,7 +27,7 @@ return [
'endtime' => 'endtime', 'endtime' => 'endtime',
], ],
'searchFields' => 'name,headline,teaser,description,features,room_types,additional_information,teaser_images, 'searchFields' => 'name,headline,teaser,description,features,room_types,additional_information,teaser_images,
header_images,images,reseller_images,code,type,category,country,region,city,teamer,products,external_link', header_images,images,reseller_images,code,calendar_code,type,category,country,region,city,teamer,products,external_link',
'iconfile' => 'EXT:ep_theme/Resources/Public/images/icon_ce.svg', 'iconfile' => 'EXT:ep_theme/Resources/Public/images/icon_ce.svg',
], ],
'types' => [ 'types' => [
@@ -43,7 +43,7 @@ return [
], ],
'palettes' => [ 'palettes' => [
'top' => ['showitem' => 'hidden,earlybird,new,--linebreak--,low_contingent,show_as_teaser, 'top' => ['showitem' => 'hidden,earlybird,new,--linebreak--,low_contingent,show_as_teaser,
--linebreak--,code,detail_page,--linebreak--,external_link,path_segment'], --linebreak--,code,calendar_code,--linebreak--,detail_page,--linebreak--,external_link,path_segment'],
'geolocation' => ['showitem' => 'address, longitude, latitude'], 'geolocation' => ['showitem' => 'address, longitude, latitude'],
'destinations' => ['showitem' => 'country,region,city'], 'destinations' => ['showitem' => 'country,region,city'],
'name' => ['showitem' => 'name,short_name,--linebreak--,header_title,header_subtitle,--linebreak--,headline'], 'name' => ['showitem' => 'name,short_name,--linebreak--,header_title,header_subtitle,--linebreak--,headline'],
@@ -425,13 +425,25 @@ return [
], ],
'code' => [ 'code' => [
'exclude' => 0, 'exclude' => 0,
'label' => 'Code', 'label' => 'Import-Code',
'description' => 'BusPro-Code, dessen Termine diesem Datensatz zugeordnet werden. Jeder Code darf nur an einem Datensatz stehen. Für den Kalender ohne Bedeutung.',
'config' => [ 'config' => [
'type' => 'input', 'type' => 'input',
'size' => 30, 'size' => 30,
'eval' => 'trim' 'eval' => 'trim'
], ],
], ],
'calendar_code' => [
'exclude' => 0,
'label' => 'Kalender-Code',
'description' => 'BusPro-Code des Hauses, dessen Belegung Belegungskalender, Preiskalender, Preistabelle und iCal-Feed zeigen. Leer = kein Kalender.',
'config' => [
'type' => 'input',
'size' => 16,
'max' => 16,
'eval' => 'trim,upper',
],
],
'external_link' => [ 'external_link' => [
'exclude' => 0, 'exclude' => 0,
'label' => 'Externer Link (Google MyBusiness)', 'label' => 'Externer Link (Google MyBusiness)',
@@ -569,7 +581,8 @@ return [
], ],
'additional_codes' => [ 'additional_codes' => [
'exclude' => 0, 'exclude' => 0,
'label' => 'Zusätzliche Codes', 'label' => 'Weitere Import-Codes',
'description' => 'BusPro-Codes, deren Termine diesem Datensatz zugeordnet werden. Jeder Code darf nur an einem Datensatz stehen. Für den Kalender ohne Bedeutung.',
'config' => [ 'config' => [
'type' => 'inline', 'type' => 'inline',
'foreign_table' => 'tx_epproducts_domain_model_matchcode', 'foreign_table' => 'tx_epproducts_domain_model_matchcode',
@@ -55,7 +55,7 @@ return [
'alternative' => ['showitem' => 'alt_product, alt_label'], 'alternative' => ['showitem' => 'alt_product, alt_label'],
'header' => ['showitem' => 'headline, subline, --linebreak--, header_title, header_subtitle'], 'header' => ['showitem' => 'headline, subline, --linebreak--, header_title, header_subtitle'],
'rating' => ['showitem' => 'rating_average, rating_votes_count'], 'rating' => ['showitem' => 'rating_average, rating_votes_count'],
'records' => ['showitem' => 'journey, concept, calendar_hotel, --linebreak--, officetip, badge'], 'records' => ['showitem' => 'journey, concept, show_calendar, --linebreak--, officetip, badge'],
'misc' => ['showitem' => 'feature,keywords'], 'misc' => ['showitem' => 'feature,keywords'],
], ],
'columns' => [ 'columns' => [
@@ -735,9 +735,17 @@ return [
'multiple' => 0, 'multiple' => 0,
], ],
], ],
'show_calendar' => [
'exclude' => 0,
'label' => 'Kalender anzeigen',
'description' => 'Zeigt den Kalender der Unterkunft, die auf der Produktseite angezeigt wird (deren Kalender-Code)',
'config' => [
'type' => 'check',
],
],
'calendar_hotel' => [ 'calendar_hotel' => [
'exclude' => 0, 'exclude' => 0,
'label' => 'Unterkunft für Belegungskalender', 'label' => 'Unterkunft für Belegungskalender (alt, nicht mehr verwendet)',
'config' => [ 'config' => [
'type' => 'select', 'type' => 'select',
'default' => 0, 'default' => 0,
+3
View File
@@ -26,6 +26,7 @@ use EP\EpProducts\Controller\AjaxWatchlistController;
use EP\EpProducts\Controller\AjaxCalendarController; use EP\EpProducts\Controller\AjaxCalendarController;
use EP\EpProducts\Controller\AjaxTeaserPopupController; use EP\EpProducts\Controller\AjaxTeaserPopupController;
use EP\EpProducts\Routing\Aspect\PassthroughMapper; use EP\EpProducts\Routing\Aspect\PassthroughMapper;
use EP\EpProducts\Hooks\ImportCodeCheck;
use TYPO3\CMS\Core\Log\LogLevel; use TYPO3\CMS\Core\Log\LogLevel;
use EP\EpProducts\Log\Writer; use EP\EpProducts\Log\Writer;
@@ -45,6 +46,8 @@ $boot = function (): void {
// Client-side callers pass these parameters in POST bodies, which cHash never inspects. // Client-side callers pass these parameters in POST bodies, which cHash never inspects.
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['requireCacheHashPresenceParameters'][] = '^tx_epproducts_ajax'; $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['requireCacheHashPresenceParameters'][] = '^tx_epproducts_ajax';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['ep_products_import_code'] = ImportCodeCheck::class;
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][TableGarbageCollectionTask::class]['options']['tables']['tx_epproducts_log'] = [ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][TableGarbageCollectionTask::class]['options']['tables']['tx_epproducts_log'] = [
'dateField' => 'time_micro', 'dateField' => 'time_micro',
'expirePeriod' => 180, 'expirePeriod' => 180,
+2
View File
@@ -56,6 +56,7 @@ CREATE TABLE tx_epproducts_domain_model_product
dates int(11) unsigned DEFAULT '0' NOT NULL, dates int(11) unsigned DEFAULT '0' NOT NULL,
hotels int(11) unsigned DEFAULT '0' NOT NULL, hotels int(11) unsigned DEFAULT '0' NOT NULL,
calendar_hotel int(11) unsigned DEFAULT '0' NOT NULL, calendar_hotel int(11) unsigned DEFAULT '0' NOT NULL,
show_calendar tinyint(4) unsigned DEFAULT '0' NOT NULL,
faqs int(11) unsigned DEFAULT '0' NOT NULL, faqs int(11) unsigned DEFAULT '0' NOT NULL,
officetip int(11) unsigned DEFAULT '0' NOT NULL, officetip int(11) unsigned DEFAULT '0' NOT NULL,
alt_product int(11) unsigned DEFAULT '0' NOT NULL, alt_product int(11) unsigned DEFAULT '0' NOT NULL,
@@ -238,6 +239,7 @@ CREATE TABLE tx_epproducts_domain_model_hotel
images int(11) unsigned NOT NULL default '0', images int(11) unsigned NOT NULL default '0',
reseller_images int(11) unsigned NOT NULL default '0', reseller_images int(11) unsigned NOT NULL default '0',
code varchar(255) DEFAULT '' NOT NULL, code varchar(255) DEFAULT '' NOT NULL,
calendar_code varchar(16) DEFAULT '' NOT NULL,
external_link varchar(255) DEFAULT '' NOT NULL, external_link varchar(255) DEFAULT '' NOT NULL,
path_segment varchar(255) DEFAULT '' NOT NULL, path_segment varchar(255) DEFAULT '' NOT NULL,
type varchar(255) DEFAULT '' NOT NULL, type varchar(255) DEFAULT '' NOT NULL,
@@ -4,18 +4,18 @@
xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"> xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers">
<div data-controller="price-calendar" <div data-controller="price-calendar"
data-price-calendar-hotel-code-value="{product.calendarHotel.code}" data-price-calendar-hotel-code-value="{calendarHotel.calendarCode}"
data-price-calendar-groups-booking-url-value="{settings.groupsBookingUrl}" data-price-calendar-groups-booking-url-value="{settings.groupsBookingUrl}"
class="relative p-4 bg-zinc-50"> class="relative p-4 bg-zinc-50">
<div class="pc-loading-indicator items-center justify-center space-x-4 text-sm p-4" <div class="pc-loading-indicator items-center justify-center space-x-4 text-sm p-4"
id="pc-loading-{product.calendarHotel.uid}"> id="pc-loading-{calendarHotel.uid}">
<f:image class="block w-4 h-4" src="EXT:ep_theme/Resources/Public/images/ajax-loader-white.gif" alt=""/> <f:image class="block w-4 h-4" src="EXT:ep_theme/Resources/Public/images/ajax-loader-white.gif" alt=""/>
<span>Preiskalender wird geladen …</span> <span>Preiskalender wird geladen …</span>
</div> </div>
<div data-price-calendar-target="mount" <div data-price-calendar-target="mount"
hx-get="{ep:uri.ajax(action: 'priceCalendar', controller: 'AjaxCalendar', extensionName: 'epproducts', pageUid: settings.defaultAjaxUid, arguments: '{hotel: product.calendarHotel}', format: 'html')}" hx-get="{ep:uri.ajax(action: 'priceCalendar', controller: 'AjaxCalendar', extensionName: 'epproducts', pageUid: settings.defaultAjaxUid, arguments: '{hotel: calendarHotel}', format: 'html')}"
hx-trigger="load" hx-trigger="load"
hx-indicator="#pc-loading-{product.calendarHotel.uid}"> hx-indicator="#pc-loading-{calendarHotel.uid}">
</div> </div>
<div class="flex justify-between items-center"> <div class="flex justify-between items-center">
<div class="h-8 text-sm" data-price-calendar-target="message"></div> <div class="h-8 text-sm" data-price-calendar-target="message"></div>
@@ -76,15 +76,15 @@
</div> </div>
</f:if> </f:if>
<f:if condition="{product.calendarHotel}"> <f:if condition="{calendarHotel}">
<f:if condition="{product.season} == 's'"> <f:if condition="{product.season} == 's'">
<f:render partial="Product/PriceCalendar" arguments="{_all}"/> <f:render partial="Product/PriceCalendar" arguments="{_all}"/>
<f:variable name="currentYear" value="{f:format.date(date: 'now', format: 'Y')}"/> <f:variable name="currentYear" value="{f:format.date(date: 'now', format: 'Y')}"/>
<f:render section="PriceTable" arguments="{product: product, settings: settings, year: currentYear}"/> <f:render section="PriceTable" arguments="{calendarHotel: calendarHotel, settings: settings, year: currentYear}"/>
<f:variable name="nextYear" value="{f:format.date(date: '+1 year', format: 'Y')}"/> <f:variable name="nextYear" value="{f:format.date(date: '+1 year', format: 'Y')}"/>
<f:render section="PriceTable" arguments="{product: product, settings: settings, year: nextYear}"/> <f:render section="PriceTable" arguments="{calendarHotel: calendarHotel, settings: settings, year: nextYear}"/>
</f:if> </f:if>
</f:if> </f:if>
@@ -171,7 +171,7 @@
<f:if condition="{showGallery}"> <f:if condition="{showGallery}">
<f:render section="SidebarGallery" arguments="{_all}"/> <f:render section="SidebarGallery" arguments="{_all}"/>
</f:if> </f:if>
<f:if condition="{product.calendarHotel} && {product.season} != 's'"> <f:if condition="{calendarHotel} && {product.season} != 's'">
<f:render section="AvailabilityCalendar" arguments="{_all}"/> <f:render section="AvailabilityCalendar" arguments="{_all}"/>
</f:if> </f:if>
<f:if condition="{product.tourLink}"> <f:if condition="{product.tourLink}">
@@ -360,7 +360,7 @@
paint that compete with the price calendar for PHP workers. The tables sit below paint that compete with the price calendar for PHP workers. The tables sit below
the fold, so fetch them when they actually come into view. the fold, so fetch them when they actually come into view.
--></f:comment> --></f:comment>
<div hx-get="{ep:uri.ajax(action: 'priceTable', controller: 'AjaxCalendar', extensionName: 'epproducts', pageUid: settings.defaultAjaxUid, arguments: '{hotel: product.calendarHotel, year: year}', format: 'html')}" <div hx-get="{ep:uri.ajax(action: 'priceTable', controller: 'AjaxCalendar', extensionName: 'epproducts', pageUid: settings.defaultAjaxUid, arguments: '{hotel: calendarHotel, year: year}', format: 'html')}"
hx-trigger="revealed"> hx-trigger="revealed">
<f:render section="TableLoadingIndicator"/> <f:render section="TableLoadingIndicator"/>
</div> </div>
@@ -371,7 +371,7 @@
<span class="block font-bold"> <span class="block font-bold">
Belegungskalender Belegungskalender
</span> </span>
<div hx-get="{ep:uri.ajax(action: 'availability', controller: 'AjaxCalendar', extensionName: 'epproducts', pageUid: settings.defaultAjaxUid, arguments: '{hotel: product.calendarHotel}', format: 'html')}" <div hx-get="{ep:uri.ajax(action: 'availability', controller: 'AjaxCalendar', extensionName: 'epproducts', pageUid: settings.defaultAjaxUid, arguments: '{hotel: calendarHotel}', format: 'html')}"
hx-trigger="intersect once"> hx-trigger="intersect once">
<div class="flex items-center justify-center space-x-4 text-sm p-4"> <div class="flex items-center justify-center space-x-4 text-sm p-4">
<f:image class="block w-4 h-4" src="EXT:ep_theme/Resources/Public/images/ajax-loader-white.gif" alt=""/> <f:image class="block w-4 h-4" src="EXT:ep_theme/Resources/Public/images/ajax-loader-white.gif" alt=""/>