wip: integrate with bpn-connect for admin crud, calendars
This commit is contained in:
1 parent
d0511ba2cd
commit
a9bd46be4a
12 files changed
+481
-35
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { Controller } from '@hotwired/stimulus'
|
||||
import tippy from 'tippy.js'
|
||||
import tippy, { hideAll } from 'tippy.js'
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ['trigger', 'template']
|
||||
@@ -27,6 +27,7 @@ export default class extends Controller {
|
||||
allowHTML: true,
|
||||
interactive: true,
|
||||
appendTo: document.body,
|
||||
onShow(instance) { hideAll({ exclude: instance }) },
|
||||
}
|
||||
}
|
||||
if (this.hasTriggerTarget) {
|
||||
|
||||
@@ -29,7 +29,7 @@ class AccommodationController extends AbstractController
|
||||
#[Route('/admin/accommodation', name: 'app_admin_accommodation')]
|
||||
public function index(): Response
|
||||
{
|
||||
$accommodations = $this->accommodationRepository->findAll();
|
||||
$accommodations = $this->accommodationRepository->findBy([], ['code' => 'ASC']);
|
||||
|
||||
return $this->render('admin/accommodation/index.html.twig', [
|
||||
'accommodations' => $accommodations,
|
||||
@@ -41,7 +41,7 @@ class AccommodationController extends AbstractController
|
||||
{
|
||||
$accommodation = new Accommodation();
|
||||
|
||||
$form = $this->createForm(AccommodationType::class, $accommodation);
|
||||
$form = $this->createForm(AccommodationType::class, $accommodation, ['hx_post' => $request->getRequestUri()]);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
@@ -55,10 +55,11 @@ class AccommodationController extends AbstractController
|
||||
'code' => $accommodation->getCode(),
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_admin_accommodation');
|
||||
return new HxRedirectResponse($this->generateUrl('app_admin_accommodation'));
|
||||
}
|
||||
|
||||
return $this->render('admin/accommodation/create.html.twig', [
|
||||
return $this->render('admin/accommodation/modal_create.html.twig', [
|
||||
'accommodation' => $accommodation,
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
@@ -97,6 +98,15 @@ class AccommodationController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/admin/accommodation/{id}/calendar', name: 'app_admin_accommodation_calendar', methods: ['GET'])]
|
||||
public function calendar(Accommodation $accommodation, Request $request): Response
|
||||
{
|
||||
return $this->render('admin/accommodation/_calendar_section.html.twig', [
|
||||
'accommodation' => $accommodation,
|
||||
'startMonth' => $request->query->get('month'),
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/admin/accommodation/{id}/delete', name: 'app_admin_accommodation_delete')]
|
||||
public function delete(Accommodation $accommodation, Request $request): Response
|
||||
{
|
||||
|
||||
@@ -200,25 +200,4 @@ class AccommodationPrice implements BlameableEntityInterface, TimestampableEntit
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
#[Assert\Callback]
|
||||
public function assertDatesValid(ExecutionContextInterface $context): void
|
||||
{
|
||||
// we only check new entities
|
||||
if (null !== $this->getId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// come on, we need something to work with
|
||||
if (null === $this->getDateFrom() || null === $this->getDateTo()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->getDateFrom() < new \DateTimeImmutable()) {
|
||||
$context
|
||||
->buildViolation('Das Von-Datum darf nicht in der Vergangenheit liegen')
|
||||
->atPath('dateFrom')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Extension;
|
||||
|
||||
use Symfony\Component\Form\AbstractTypeExtension;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class ModalSubmitExtension extends AbstractTypeExtension
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'hx_post' => null,
|
||||
'hx_target' => '#htmx-modal',
|
||||
'hx_swap' => 'outerHTML',
|
||||
]);
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options): void
|
||||
{
|
||||
if (null !== $options['hx_post']) {
|
||||
$attr = [
|
||||
'hx-post' => $options['hx_post'],
|
||||
'hx-target' => $options['hx_target'],
|
||||
'hx-swap' => $options['hx_swap'],
|
||||
'hx-indicator' => '#htmx-modal-indicator',
|
||||
];
|
||||
$view->vars['attr'] = array_merge($view->vars['attr'], $attr);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getExtendedTypes(): iterable
|
||||
{
|
||||
return [FormType::class];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,289 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Twig\Components;
|
||||
|
||||
use App\BpnConnect\ContingentsClient;
|
||||
use App\BpnConnect\Exception\BpnConnectException;
|
||||
use App\BpnConnect\Model\ContingentStatus;
|
||||
use App\Entity\Groups\Accommodation;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Psr\Cache\InvalidArgumentException;
|
||||
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
|
||||
use Symfony\Contracts\Cache\CacheInterface;
|
||||
use Symfony\Contracts\Cache\ItemInterface;
|
||||
|
||||
#[AsTwigComponent('calendar', template: 'components/calendar/index.html.twig')]
|
||||
class Calendar
|
||||
{
|
||||
private const MONTHS = [
|
||||
1 => 'Januar', 2 => 'Februar', 3 => 'März', 4 => 'April',
|
||||
5 => 'Mai', 6 => 'Juni', 7 => 'Juli', 8 => 'August',
|
||||
9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Dezember',
|
||||
];
|
||||
|
||||
private const TYPE_LABELS = [
|
||||
'flat' => 'pauschal',
|
||||
'per_person' => 'p.P.',
|
||||
'per_night' => 'p.Nacht',
|
||||
'per_person_per_night' => 'p.P./Nacht',
|
||||
];
|
||||
|
||||
public Accommodation $accommodation;
|
||||
public ?string $startMonth = null;
|
||||
|
||||
public array $months = [];
|
||||
public string $prevMonth = '';
|
||||
public string $nextMonth = '';
|
||||
public string $prevLabel = '';
|
||||
public string $nextLabel = '';
|
||||
|
||||
public function __construct(
|
||||
private readonly ContingentsClient $contingentsClient,
|
||||
private readonly CacheInterface $cache,
|
||||
) {
|
||||
}
|
||||
|
||||
public function mount(Accommodation $accommodation, ?string $startMonth = null): void
|
||||
{
|
||||
$this->accommodation = $accommodation;
|
||||
$this->startMonth = $startMonth;
|
||||
|
||||
if ($startMonth !== null && preg_match('/^\d{4}-\d{2}$/', $startMonth)) {
|
||||
$start = CarbonImmutable::createFromFormat('Y-m-d', $startMonth . '-01');
|
||||
} else {
|
||||
$allDates = $this->collectAllDates();
|
||||
$start = empty($allDates)
|
||||
? CarbonImmutable::now()->startOfMonth()
|
||||
: $this->determineStartMonth($allDates);
|
||||
}
|
||||
|
||||
$map = $this->buildCoverageMap();
|
||||
$blockedDates = $this->fetchBlockedDates(
|
||||
$accommodation->getCode() ?? '',
|
||||
$start->format('Y-m-d'),
|
||||
$start->addMonths(3)->subDay()->format('Y-m-d'),
|
||||
);
|
||||
|
||||
$months = [];
|
||||
$current = $start;
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$months[] = $this->buildMonth($current, $map, $blockedDates);
|
||||
$current = $current->addMonth();
|
||||
}
|
||||
|
||||
$this->months = $months;
|
||||
|
||||
$prevStart = $start->subMonths(3);
|
||||
$prevEnd = $prevStart->addMonths(2);
|
||||
$this->prevMonth = $prevStart->format('Y-m');
|
||||
$this->prevLabel = self::MONTHS[$prevStart->month] . ' – ' . self::MONTHS[$prevEnd->month] . ' ' . $prevEnd->year;
|
||||
|
||||
$nextStart = $start->addMonths(3);
|
||||
$nextEnd = $nextStart->addMonths(2);
|
||||
$this->nextMonth = $nextStart->format('Y-m');
|
||||
$this->nextLabel = self::MONTHS[$nextStart->month] . ' – ' . self::MONTHS[$nextEnd->month] . ' ' . $nextEnd->year;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, true> keyed by Y-m-d, only BLOCKED dates present
|
||||
*/
|
||||
private function fetchBlockedDates(string $hotelCode, string $dateFrom, string $dateTo): array
|
||||
{
|
||||
if ($hotelCode === '') {
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
$cacheKey = sprintf('contingents_calendar_%s_%s_%s', $hotelCode, $dateFrom, $dateTo);
|
||||
$response = $this->cache->get(
|
||||
$cacheKey,
|
||||
function (ItemInterface $item) use ($hotelCode, $dateFrom, $dateTo) {
|
||||
$item->expiresAfter(3600);
|
||||
|
||||
return $this->contingentsClient->getContingentCalendar($hotelCode, $dateFrom, $dateTo);
|
||||
},
|
||||
);
|
||||
} catch (BpnConnectException|InvalidArgumentException) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$blocked = [];
|
||||
foreach ($response->data as $entry) {
|
||||
if ($entry->status === ContingentStatus::Blocked) {
|
||||
$blocked[(new \DateTimeImmutable($entry->date))->format('Y-m-d')] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $blocked;
|
||||
}
|
||||
|
||||
private function collectAllDates(): array
|
||||
{
|
||||
$dates = [];
|
||||
|
||||
foreach ($this->accommodation->getAccommodationPrices() as $price) {
|
||||
if ($price->getDateFrom() !== null) {
|
||||
$dates[] = CarbonImmutable::instance($price->getDateFrom());
|
||||
}
|
||||
if ($price->getDateTo() !== null) {
|
||||
$dates[] = CarbonImmutable::instance($price->getDateTo());
|
||||
}
|
||||
}
|
||||
foreach ($this->accommodation->getBoardServices() as $service) {
|
||||
if ($service->getDateFrom() !== null) {
|
||||
$dates[] = CarbonImmutable::instance($service->getDateFrom());
|
||||
}
|
||||
if ($service->getDateTo() !== null) {
|
||||
$dates[] = CarbonImmutable::instance($service->getDateTo());
|
||||
}
|
||||
}
|
||||
foreach ($this->accommodation->getAdditionalServices() as $service) {
|
||||
if ($service->getDateFrom() !== null) {
|
||||
$dates[] = CarbonImmutable::instance($service->getDateFrom());
|
||||
}
|
||||
if ($service->getDateTo() !== null) {
|
||||
$dates[] = CarbonImmutable::instance($service->getDateTo());
|
||||
}
|
||||
}
|
||||
|
||||
return $dates;
|
||||
}
|
||||
|
||||
private function determineStartMonth(array $dates): CarbonImmutable
|
||||
{
|
||||
$earliest = min($dates);
|
||||
$cutoff = CarbonImmutable::now()->subDays(60);
|
||||
|
||||
if ($earliest >= $cutoff) {
|
||||
return $earliest->startOfMonth();
|
||||
}
|
||||
|
||||
return CarbonImmutable::now()->startOfMonth();
|
||||
}
|
||||
|
||||
private function buildCoverageMap(): array
|
||||
{
|
||||
$map = [];
|
||||
|
||||
foreach ($this->accommodation->getAccommodationPrices() as $price) {
|
||||
if ($price->getDateFrom() === null || $price->getDateTo() === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$priceFormatted = number_format($price->getEffectivePricePerNight() / 100, 2, ',', '.') . ' €';
|
||||
$label = sprintf('Preis: %s/Nacht (min. %d Nächte)', $priceFormatted, $price->getMinNights());
|
||||
|
||||
$day = CarbonImmutable::instance($price->getDateFrom());
|
||||
$end = CarbonImmutable::instance($price->getDateTo());
|
||||
$span = $day->diffInDays($end);
|
||||
$limit = $day->addYears(3);
|
||||
|
||||
while ($day <= $end && $day <= $limit) {
|
||||
$key = $day->format('Y-m-d');
|
||||
$map[$key] ??= ['price' => null, 'board' => null, 'additional' => null];
|
||||
if ($map[$key]['price'] === null || $span < $map[$key]['price']['span']) {
|
||||
$map[$key]['price'] = ['label' => $label, 'span' => $span];
|
||||
}
|
||||
$day = $day->addDay();
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->accommodation->getBoardServices() as $service) {
|
||||
if ($service->getDateFrom() === null || $service->getDateTo() === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$label = 'Verpflegung: ' . $service->getLabel();
|
||||
|
||||
$day = CarbonImmutable::instance($service->getDateFrom());
|
||||
$end = CarbonImmutable::instance($service->getDateTo());
|
||||
$span = $day->diffInDays($end);
|
||||
$limit = $day->addYears(3);
|
||||
|
||||
while ($day <= $end && $day <= $limit) {
|
||||
$key = $day->format('Y-m-d');
|
||||
$map[$key] ??= ['price' => null, 'board' => null, 'additional' => null];
|
||||
if ($map[$key]['board'] === null || $span < $map[$key]['board']['span']) {
|
||||
$map[$key]['board'] = ['label' => $label, 'span' => $span];
|
||||
}
|
||||
$day = $day->addDay();
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->accommodation->getAdditionalServices() as $service) {
|
||||
if ($service->getDateFrom() === null || $service->getDateTo() === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$typeLabel = $service->getType() !== null
|
||||
? (self::TYPE_LABELS[$service->getType()->value] ?? $service->getType()->value)
|
||||
: '';
|
||||
$label = sprintf('Zusatz: %s%s', $service->getLabel(), $typeLabel !== '' ? ' (' . $typeLabel . ')' : '');
|
||||
|
||||
$day = CarbonImmutable::instance($service->getDateFrom());
|
||||
$end = CarbonImmutable::instance($service->getDateTo());
|
||||
$span = $day->diffInDays($end);
|
||||
$limit = $day->addYears(3);
|
||||
|
||||
while ($day <= $end && $day <= $limit) {
|
||||
$key = $day->format('Y-m-d');
|
||||
$map[$key] ??= ['price' => null, 'board' => null, 'additional' => null];
|
||||
if ($map[$key]['additional'] === null || $span < $map[$key]['additional']['span']) {
|
||||
$map[$key]['additional'] = ['label' => $label, 'span' => $span];
|
||||
}
|
||||
$day = $day->addDay();
|
||||
}
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
private function buildMonth(CarbonImmutable $month, array $map, array $blockedDates): array
|
||||
{
|
||||
$start = $month->startOfMonth();
|
||||
$today = CarbonImmutable::now()->format('Y-m-d');
|
||||
|
||||
// Mon=0 … Sun=6 (Carbon: 0=Sunday, 1=Monday … 6=Saturday)
|
||||
$firstDow = ($start->dayOfWeek + 6) % 7;
|
||||
|
||||
$days = [];
|
||||
for ($d = 1; $d <= $start->daysInMonth; $d++) {
|
||||
$dateStr = $month->format('Y-m') . '-' . str_pad((string) $d, 2, '0', STR_PAD_LEFT);
|
||||
$coverage = $map[$dateStr] ?? [];
|
||||
|
||||
$parts = [];
|
||||
if (isset($coverage['price'])) {
|
||||
$parts[] = $coverage['price']['label'];
|
||||
}
|
||||
if (isset($coverage['board'])) {
|
||||
$parts[] = $coverage['board']['label'];
|
||||
}
|
||||
if (isset($coverage['additional'])) {
|
||||
$parts[] = $coverage['additional']['label'];
|
||||
}
|
||||
|
||||
$isBlocked = isset($blockedDates[$dateStr]);
|
||||
if ($isBlocked) {
|
||||
$parts[] = 'Buchungsstopp';
|
||||
}
|
||||
|
||||
$days[$d] = [
|
||||
'date' => $dateStr,
|
||||
'hasPrice' => isset($coverage['price']),
|
||||
'hasBoard' => isset($coverage['board']),
|
||||
'hasAdditional' => isset($coverage['additional']),
|
||||
'isBlocked' => $isBlocked,
|
||||
'tooltip' => !empty($parts) ? implode(' | ', $parts) : null,
|
||||
'isToday' => $dateStr === $today,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'label' => self::MONTHS[$month->month] . ' ' . $month->year,
|
||||
'firstDow' => $firstDow,
|
||||
'days' => $days,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<twig:calendar :accommodation="accommodation" :startMonth="startMonth ?? null"/>
|
||||
@@ -25,6 +25,10 @@
|
||||
|
||||
<hr class="my-8">
|
||||
|
||||
<twig:calendar :accommodation="accommodation"/>
|
||||
|
||||
<hr class="my-8">
|
||||
|
||||
<h2 class="text-xl font-bold">
|
||||
Preise
|
||||
</h2>
|
||||
@@ -41,7 +45,7 @@
|
||||
Preis pro Nacht
|
||||
</th>
|
||||
<th>
|
||||
Preise weitere Person
|
||||
Preis weitere Person
|
||||
</th>
|
||||
<th>
|
||||
Mindestbelegung (Nächte)
|
||||
@@ -95,7 +99,7 @@
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<td colspan="7" class="text-center">
|
||||
Keine Daten
|
||||
</td>
|
||||
</tr>
|
||||
@@ -165,7 +169,7 @@
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
<td colspan="5" class="text-center">
|
||||
Keine Daten
|
||||
</td>
|
||||
</tr>
|
||||
@@ -241,7 +245,7 @@
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="6">
|
||||
<td colspan="6" class="text-center">
|
||||
Keine Daten
|
||||
</td>
|
||||
</tr>
|
||||
@@ -256,9 +260,9 @@
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<hr class="my-8">
|
||||
{% if cmsData is defined and cmsData.success is true %}
|
||||
<hr class="my-8">
|
||||
|
||||
{% if cmsData is defined %}
|
||||
<h2 class="text-xl font-bold">
|
||||
CMS-Daten
|
||||
</h2>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<td colspan="5" class="text-center">
|
||||
Keine Daten...
|
||||
</td>
|
||||
</tr>
|
||||
@@ -64,8 +64,12 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<a href="{{ path('app_admin_accommodation_create') }}" class="button button--primary button--small">
|
||||
<button type="button"
|
||||
hx-get="{{ path('app_admin_accommodation_create') }}"
|
||||
hx-target="body"
|
||||
hx-swap="beforeend"
|
||||
class="button button--primary button--small">
|
||||
neu
|
||||
</a>
|
||||
</button>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,23 @@
|
||||
{% extends 'htmx_modal_admin.html.twig' %}
|
||||
{% form_theme form 'forms_admin.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="text-xl font-bold pb-4">
|
||||
Neues Gruppenhaus
|
||||
</div>
|
||||
{{ form_start(form) }}
|
||||
<div class="grid lg:grid-cols-2 gap-y-4 lg:gap-x-8">
|
||||
{{ form_row(form.name) }}
|
||||
{{ form_row(form.code) }}
|
||||
{{ form_row(form.minPaxSummer) }}
|
||||
{{ form_row(form.maxAdolescentAge) }}
|
||||
{{ form_row(form.currency) }}
|
||||
</div>
|
||||
<div class="flex justify-end pt-8">
|
||||
<button type="submit" class="button button--primary button--small">
|
||||
speichern
|
||||
</button>
|
||||
</div>
|
||||
{{ form_rest(form) }}
|
||||
{{ form_end(form) }}
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,56 @@
|
||||
<div class="flex justify-around items-center gap-6 mb-4 text-sm text-gray-600">
|
||||
<div class="flex items-center gap-1.5">
|
||||
<span class="inline-block w-3 h-3 rounded-full bg-blue-500"></span> Preiskonfigurationen
|
||||
</div>
|
||||
<div class="flex items-center gap-1.5">
|
||||
<span class="inline-block w-3 h-3 rounded-full bg-green-500"></span> Verpflegungsleistungen
|
||||
</div>
|
||||
<div class="flex items-center gap-1.5">
|
||||
<span class="inline-block w-3 h-3 rounded-full bg-amber-500"></span> optionale Zusatzleistungen
|
||||
</div>
|
||||
<div class="flex items-center gap-1.5">
|
||||
<span class="inline-block w-3 h-3 rounded-full bg-red-500"></span> Buchungsstopp
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-3 gap-8">
|
||||
{% for month in months %}
|
||||
<div>
|
||||
<div class="text-sm font-semibold text-center mb-2">{{ month.label }}</div>
|
||||
|
||||
<div class="grid grid-cols-7 rounded-md overflow-hidden ring-1 ring-gray-300">
|
||||
{% for header in ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'] %}
|
||||
<div class="text-center text-xs text-gray-400 font-medium py-1 bg-gray-50 border-r border-b border-gray-200">{{ header }}</div>
|
||||
{% endfor %}
|
||||
|
||||
{% if month.firstDow > 0 %}
|
||||
{% for i in 1..month.firstDow %}
|
||||
<div class="h-8 border-r border-b border-gray-200 bg-gray-50/40"></div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% for dayNum, day in month.days %}
|
||||
<div class="{{ html_classes('h-8 flex flex-col items-center justify-between py-1 border-r border-b border-gray-200 cursor-default', { 'bg-secondary/25': day.isToday }) }}"
|
||||
{% if day.tooltip %}{{ stimulus_controller('tooltip', {'content': day.tooltip}) }}{% endif %}
|
||||
>
|
||||
<span class="text-xs text-gray-700 leading-none">{{ dayNum }}</span>
|
||||
<div class="flex gap-px">
|
||||
{% if day.hasPrice %}
|
||||
<span class="w-1.5 h-1.5 rounded-full bg-blue-500"></span>
|
||||
{% endif %}
|
||||
{% if day.hasBoard %}
|
||||
<span class="w-1.5 h-1.5 rounded-full bg-green-500"></span>
|
||||
{% endif %}
|
||||
{% if day.hasAdditional %}
|
||||
<span class="w-1.5 h-1.5 rounded-full bg-amber-500"></span>
|
||||
{% endif %}
|
||||
{% if day.isBlocked %}
|
||||
<span class="w-1.5 h-1.5 rounded-full bg-red-500"></span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
@@ -0,0 +1,17 @@
|
||||
<div id="calendar-wrapper">
|
||||
<twig:calendar:grid :months="months"/>
|
||||
<div class="flex items-center justify-between mt-4">
|
||||
<button class="button button--secondary button--small"
|
||||
hx-get="{{ path('app_admin_accommodation_calendar', {id: accommodation.id, month: prevMonth}) }}"
|
||||
hx-target="#calendar-wrapper"
|
||||
hx-swap="outerHTML">
|
||||
← {{ prevLabel }}
|
||||
</button>
|
||||
<button class="button button--secondary button--small"
|
||||
hx-get="{{ path('app_admin_accommodation_calendar', {id: accommodation.id, month: nextMonth}) }}"
|
||||
hx-target="#calendar-wrapper"
|
||||
hx-swap="outerHTML">
|
||||
{{ nextLabel }} →
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,23 @@
|
||||
<div id="htmx-modal"
|
||||
class="fixed inset-0 w-full h-full z-50" {{ stimulus_controller('modal') }} {{ stimulus_action('modal', 'close', 'modal-close@window') }}>
|
||||
<div class="absolute inset-0 w-full h-full bg-black/70" {{ stimulus_action('modal', 'close', 'click') }}></div>
|
||||
<div class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 px-4 w-full max-w-3xl">
|
||||
<div class="relative bg-white py-8 rounded-md">
|
||||
<div class="flex justify-between pb-4 px-8">
|
||||
<div class="text-2xl font-bold">
|
||||
{% block title %}{% endblock %}
|
||||
</div>
|
||||
<button type="button"
|
||||
class="inline-flex items-center justify-center bg-gray-200 rounded-md w-10 h-10"
|
||||
{{ stimulus_action('modal', 'close') }}>
|
||||
<svg class="w-8 h-8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"/><line x1="200" y1="56" x2="56" y2="200" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><line x1="200" y1="200" x2="56" y2="56" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="max-h-svh overflow-y-auto">
|
||||
<div class="px-8">
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in new issue
Block a user