This commit is contained in:
isUnknown 2024-09-10 13:47:04 +02:00
parent 2f0a8f36d8
commit e58e630f9b
5 changed files with 27 additions and 31 deletions

View file

@ -52,18 +52,6 @@ tabs:
icon: clock
width: 1/2
placeholder: 1h20
when:
isMapadoEvent: false
remoteDuration:
label: Durée
type: text
icon: clock
width: 1/2
placeholder: 1h20
disabled: true
help: Nécessite **qu'une séance au moins ait une heure de fin** sur Mapado.
when:
isMapadoEvent: true
- width: 1/2
fields:
public:
@ -84,9 +72,11 @@ tabs:
type: structure
columns:
date:
width: 1/2
width: 1/3
time:
width: 1/2
width: 1/3
timeComplement:
width: 1/3
when:
isMapadoEvent: false
fields:
@ -94,11 +84,18 @@ tabs:
type: date
icon: calendar
display: DD/MM/YYYY
width: 1/2
width: 1/3
time:
label: Horaire de début
type: text
width: 1/2
help: |
Format : 20h00 ou 20h (pas 20:00)
width: 1/3
timeComplement:
label: Complément
help: Affiché après l'horaire
type: text
width: 1/3
remoteSessions:
label: Séances
type: structure

View file

@ -45,7 +45,7 @@ return [
$dates[$day]['sessions'][] = array_merge($eventInfos, [
"color" => $event->color()->value(),
"day" => $day,
"time" => $session->time()->value(),
"time" => $session->timeComplement()->isEmpty() == 'true' ? $session->time()->value() : $session->time()->value() . ' ' . $session->timeComplement()->value(),
"place" => $event->place()->value(),
"duration" => $event->duration()->value(),
"eventUrl" => $event->url(),

View file

@ -34,7 +34,7 @@ function createArraySession($event, $session) {
$arraySession['place'] = $event->place();
$arraySession['public'] = $event->public();
$arraySession['event-url'] = $event->url();
$arraySession['duration'] = $isMapadoEvent ? $event->remoteDuration() : $event->duration();
$arraySession['duration'] = $event->duration();
$arraySession['ticketingUrl'] = $isMapadoEvent ? $session->ticketingUrl() : false;
$arraySession['bookableStock'] = $isMapadoEvent ? $session->bookableStock()->value() : 'free';
$arraySession['totalStock'] = $isMapadoEvent ? (int) $event->totalStock()->value() : 'free';

View file

@ -146,10 +146,6 @@ function saveMapadoEvent($mapadoEvent, $page) {
$eventDateId = $eventDateId[count($eventDateId) - 1];
$ticketingUrl = option('ticketingUrl') . 'event/' . $mapadoEvent->slug . '?eventDate=' . $eventDateId;
if (isset($session->endDate) && !$duration) {
$endTime = substr($session->endDate, 11 , 5);
$duration = getTimeDifference($startTime, $endTime);
}
$sessionsToSave[] = [
"date" => substr($session->startDate, 0, 10),
@ -161,7 +157,6 @@ function saveMapadoEvent($mapadoEvent, $page) {
$dataToSave = [
"mapadoSlug" => $mapadoEvent->slug,
"remoteDuration" => $duration,
"remoteSessions" => $sessionsToSave,
"eventDateId" => $eventDateId,
"totalStock" => $totalStock
@ -173,18 +168,22 @@ function saveMapadoEvent($mapadoEvent, $page) {
}
function getEndTime($session) {
$formattedTime = strlen($session['time']) < 4 ? $session['time'] . '00' : $session['time'];
$formattedTime = preg_replace('/[^0-9]/', '', $session['time']);
$formattedTime = strlen($formattedTime) < 4 ? str_pad($formattedTime, 4, '0', STR_PAD_RIGHT) : $formattedTime;
$time1 = DateTime::createFromFormat('Hi', $formattedTime);
if ($time1 === false) {
throw new Exception('format d\'heure invalide : ' . $session['time']);
throw new Exception('format d\'heure invalide : ' . $session['time']);
}
$formattedDuration = strlen($session['duration']) < 4 ? $session['duration'] . '00' : $session['duration'];
$formattedDuration = preg_replace('/[^0-9]/', '', $session['duration']);
$formattedDuration = strlen($formattedDuration) < 4 ? str_pad($formattedDuration, 4, '0', STR_PAD_RIGHT) : $formattedDuration;
$time2 = DateTime::createFromFormat('Hi', $formattedDuration);
if ($time2 === false) {
throw new Exception('format de durée invalide : ' . $session['duration']);
throw new Exception('format de durée invalide : ' . $session['duration']);
}
$time1->add(new DateInterval('PT' . $time2->format('H') . 'H' . $time2->format('i') . 'M'));
return $time1->format('H:i');

View file

@ -2,7 +2,7 @@
<section class="key-infos">
<ul>
<li><p class="key-infos__key">Dates</p><p class="key-infos__info"><?= $page->schedule() ?></p></li>
<li><p class="key-infos__key">Durée</p><p class="key-infos__info"><?= e($page->isMapadoEvent(), $page->remoteDuration(), $page->duration()) ?></p></li>
<li><p class="key-infos__key">Durée</p><p class="key-infos__info"><?= $page->duration() ?></p></li>
<li><p class="key-infos__key">Public</p><p class="key-infos__info"><?= $page->public() ?></p></li>
<li><p class="key-infos__key">Lieu</p><p class="key-infos__info"><?= $page->place() ?></p></li>
</ul>
@ -48,7 +48,7 @@
?>
<div class="session collapsable__item--padding grid">
<p><?= $formattedDate ?></p>
<p><?= $session->time() ?></p>
<p><?= e($session->timeComplement()->isEmpty() == 'true', $session->time(), $session->time() . ' ' . $session->timeComplement()) ?></p>
<p><?= $page->place() ?></p>
<?php if ($page->bookingUrl()->isEmpty()): ?>
<a class="ticket-link" title="Entrée libre" disabled><?php snippet('ticket') ?> Entrée libre</a>