fix bookableStock

This commit is contained in:
isUnknown 2024-09-02 14:02:13 +02:00
parent ea052d22f0
commit 9b4e35f3af
8 changed files with 79 additions and 28 deletions

View file

@ -66,27 +66,27 @@
max-height: 20rem;
}
.calendar-strip__session:first-child > a {
.session:first-child > a {
border-top: var(--border) !important;
}
.calendar-strip__session:not(:last-child) {
.session:not(:last-child) {
border-bottom: var(--border);
}
.calendar-strip__session > a {
.session__event-link {
display: grid;
grid-template-columns: repeat(5, 1fr);
padding: var(--padding-vertical) var(--space-m);
}
.calendar-strip__session:hover {
.session:hover {
background-color: var(--color);
}
.calendar-strip__session:not(:last-child) {
margin-bottom: 4rem;
}
.calendar-strip__session > div {
.session__info {
width: 100%;
}
.session__info > p:not(:last-child) {
margin-bottom: 1rem;
}

View file

@ -4,8 +4,8 @@
padding: 0 !important;
}
.collapsable:not(:first-child) > *,
.collapsable:first-child > button,
.collapsable:not(.sessions) > *,
.collapsable.sessions > button,
.collapsable .session {
padding: var(--row-padding);
box-sizing: border-box;

View file

@ -40,7 +40,13 @@ return function($page) {
$isStillShowing = false;
foreach ($sessions->toStructure() as $session) {
$currentSeasonSessions[] = $session->toArray();
$arraySession = $session->toArray();
$arraySession['title'] = $event->title()->value();
$arraySession['authors'] = $event->authors();
$arraySession['place'] = $event->place();
$arraySession['duration'] = $event->isMapadoEvent() == 'true' ? $event->remoteDuration() : $event->duration();
$arraySession['ticketingUrl'] = '';
$currentSeasonSessions[] = $arraySession;
$sessionDate = str_replace('-', '', $session->date()->toDate('YMMdd'));

View file

@ -102,7 +102,7 @@ function createMapadoEventRequest($page) {
"subfields" => [
["name" => "startDate"],
["name" => "endDate"],
["name" => "bookableStock"]
["name" => "notInStockContingentBookableStock"]
]
],
]
@ -150,7 +150,7 @@ function saveMapadoEvent($mapadoEvent, $page) {
"date" => substr($session->startDate, 0, 10),
"time" => str_replace(':', 'h', $startTime),
"ticketingUrl" => $ticketingUrl,
"bookableStock" => $session->bookableStock
"bookableStock" => $session->notInStockContingentBookableStock
];
}
@ -164,4 +164,14 @@ function saveMapadoEvent($mapadoEvent, $page) {
$page->update($dataToSave);
return $dataToSave;
}
}
function getEndTime($session) {
$formattedTime = strlen($session['time']) < 4 ? $session['time'] . '00' : $session['time'];
$time1 = DateTime::createFromFormat('G\hi', $formattedTime);
$formattedDuration = strlen($session['duration']) < 4 ? $session['duration'] . '00' : $session['duration'];
$time2 = DateTime::createFromFormat('G\hi', $formattedDuration);
$time1->add(new DateInterval('PT' . $time2->format('H') . 'H' . $time2->format('i') . 'M'));
$endTime = $time1->format('G\hi');
return $endTime;
}

View file

@ -62,24 +62,27 @@
</ul>
<button class="calendar-strip__calendar-btn">calendrier</button>
<div class="calendar-strip__date" :class="open ? 'open' : ''">
<ul class="calendar-strip__sessions">
<ul class="sessions sessions--detailed">
<template x-for="session in targetSessions">
<li class="calendar-strip__session" :style="'--color: ' + session.color">
<a :href="session.eventUrl" title="En savoir plus">
<div x-html="`${session.day} ${monthName}<br><br>${session.time}`"></div>
<div>
<li class="session" :style="'--color: ' + session.color">
<a class="session__event-link" :href="session.eventUrl" title="En savoir plus">
<div class="session__info">
<p x-html="`${session.day} ${monthName}`"></p>
<p x-html="session.time"></p>
</div>
<div class="session__info">
<p><strong x-html="`<strong>${session.title}</strong>`"></strong></p>
<p x-html="session.authors"></p>
</div>
<div x-text="`${session.duration}`"></div>
<div x-text="`${session.place}`"></div>
<template x-if="session.ticketingUrl">
<div>
<div class="session__info">
<a class="ticket-link" :href="session.ticketingUrl" target="_blank" title="Aller à la billetterie"><?php snippet('ticket') ?> Billetterie</a>
</div>
</template>
<template x-if="!session.ticketingUrl">
<div>
<div class="session__info">
<a class="ticket-link" target="_blank" title="Entrée libre" disabled><?php snippet('ticket') ?> Entrée libre</a>
</div>
</template>

View file

@ -1,4 +1,4 @@
<section class="collapsable" x-data="{
<section class="collapsable<?php e(isset($sessions), ' sessions') ?>" x-data="{
open: false
}">
<button class="toggle" :class="open ? 'open' : ''" @click="open = !open" :title="open ? 'Fermer la section': 'Ouvrir la section'" :aria-expanded="open ? true : false">

View file

@ -30,7 +30,7 @@
</section>
<section class="collapsable-sections">
<?php snippet('collapsable-section', ['title' => 'Prenez vos places !'], slots: true) ?>
<?php snippet('collapsable-section', ['title' => 'Prenez vos places !', 'sessions' => true], slots: true) ?>
<?php if ($page->isMapadoEvent() != 'true'): ?>
<?php slot('content') ?>
@ -87,10 +87,10 @@
<a class="ticket-link" title="Plus de places disponibles" disabled><?php snippet('ticket') ?> Complet</a>
</template>
<template x-if="session.bookableStock > stockThreshold">
<a class="ticket-link" title="Plateforme de réservation" :href="'https://cdn-besancon.mapado.com/event/' + slug + '?eventDate=' + eventDateId" target="_blank"><?php snippet('ticket') ?> Billetterie</a>
<a class="ticket-link" title="Plateforme de réservation" :href="session.ticketingUrl" target="_blank"><?php snippet('ticket') ?> Billetterie</a>
</template>
<template x-if="session.bookableStock < stockThreshold">
<a class="ticket-link" title="Plateforme de réservation" :href="'https://cdn-besancon.mapado.com/event/' + slug + '?eventDate=' + eventDateId" target="_blank"><?php snippet('ticket') ?> Plus que quelques places !</a>
<template x-if="session.bookableStock !== 0 && session.bookableStock < stockThreshold">
<a class="ticket-link" title="Plateforme de réservation" :href="session.ticketingUrl" target="_blank"><?php snippet('ticket') ?> Plus que quelques places !</a>
</template>
</div>
</template>

View file

@ -67,12 +67,44 @@
<div class="program-content__events">
<section class="collapsable-sections">
<?php foreach($currentSeasonSessions as $month => $sessions): ?>
<?php if (count($sessions) > 0): ?>
<?php snippet('collapsable-section', ['title' => $month], slots: true) ?>
<?php snippet('collapsable-section', ['title' => $month, 'sessions' => true], slots: true) ?>
<?php slot('content') ?>
<div class="session grid">
<?php
foreach($sessions as $session):
$date = new DateTime($session['date']);
$formatter = new IntlDateFormatter('fr_FR', IntlDateFormatter::NONE, IntlDateFormatter::NONE);
$formattedDate = $formatter->formatObject($date, "d MMMM");
try {
$endTime = strlen($session['duration']) > 0 ? getEndTime($session) : false;
} catch (\Throwable $th) {
throw new Exception($session['title'], 1);
}
?>
<div class="session__info">
<p><?= $formattedDate ?></p>
<p><?= $session['time'] ?><?php e($endTime, ' - ' . $endTime) ?></p>
</div>
<div class="session__info">
<p><strong><?= $session['title'] ?></strong></p>
<p><?= $session['authors'] ?></p>
</div>
<div class="session__info">
<p><?= $session['place'] ?></p>
</div>
<div class="session__info">
<a class="ticket-link" title="Entrée libre"><?php snippet('ticket') ?> Entrée libre</a>
</div>
<?php endforeach ?>
</div>
<?php endslot() ?>
<?php endsnippet() ?>
<?php endif ?>
<?php endforeach ?>
</section>
</div>