nouveau-theatre-de-besancon/site/templates/program.php

136 lines
5.9 KiB
PHP
Raw Normal View History

2024-08-28 19:11:58 +02:00
<?php snippet('header') ?>
2024-08-30 14:37:13 +02:00
<div
2024-08-30 15:16:41 +02:00
class="program-methods"
2024-08-30 14:37:13 +02:00
x-data="{
setInitialTab() {
const queryString = window.location.search;
if (queryString.length === 0) return 'Programme';
const urlParams = new URLSearchParams(queryString);
const tab = urlParams.get('tab');
return tab;
2024-09-02 17:09:53 +02:00
},
goTo(event, href) {
if (event.target.tagName === 'A') return
location.href = href
2024-08-30 14:37:13 +02:00
}
}"
>
2024-08-30 15:16:41 +02:00
<div class="program-data"
2024-08-30 14:37:13 +02:00
x-data="{
2024-09-02 18:02:46 +02:00
tab: setInitialTab(),
filter: null
2024-08-30 14:37:13 +02:00
}"
>
2024-08-30 15:16:41 +02:00
<?php if ($page->categories()->isNotEmpty()): ?>
2024-08-30 15:16:41 +02:00
<section class="filters">
<button
x-data="{title: 'Calendrier'}"
x-text="title"
2024-09-02 18:02:46 +02:00
:class="tab === title ? 'strong' : ''"
2024-09-02 18:10:52 +02:00
@click="if (tab === title) { tab = 'Programme' } else {tab = title}"
2024-08-30 15:16:41 +02:00
></button>
2024-09-04 15:56:19 +02:00
<?php foreach($page->categories()->split() as $filter): ?>
<button
x-data="{
title: '<?= $filter ?>',
get filterTitle() {
return 'Calendrier — ' + this.title
}
}"
x-text="title"
:class="tab === filterTitle ? 'strong' : ''"
@click="if (tab === filterTitle) { tab = 'Programme' } else { tab = filterTitle; filter = title }"
></button>
<?php endforeach ?>
<?php endif ?>
2024-08-30 15:16:41 +02:00
</section>
2024-08-30 14:37:13 +02:00
<section class="page-title">
<h1 x-text="tab"></h1>
</section>
2024-08-30 15:16:41 +02:00
<!-- Programme -->
<template x-if="tab === 'Programme'">
<div class="program-content__events">
<section class="yellow">
<h2>À venir <?= $page->children()->first()->title() ?></h2>
</section>
<?php snippet('events-grid', ['events' => $nextEvents, 'columns' => 3]) ?>
<section class="yellow">
<h2>Événements passés</h2>
</section>
<?php snippet('events-grid', ['events' => $previousEvents, 'columns' => 3]) ?>
</div>
</template>
<!-- Calendrier -->
2024-09-02 18:02:46 +02:00
<template x-if="tab.includes('Calendrier')">
2024-08-30 15:16:41 +02:00
<div class="program-content__events">
<section class="collapsable-sections">
<?php foreach($currentSeasonSessions as $month => $sessions): ?>
<?php if (count($sessions) > 0): ?>
2024-09-03 12:02:57 +02:00
<?php snippet('collapsable-section', ['title' => $month, 'padding' => false], slots: true) ?>
2024-08-30 15:16:41 +02:00
<?php slot('content') ?>
2024-09-02 16:32:21 +02:00
<ul class="sessions sessions--detailed">
<?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");
2024-09-02 14:02:13 +02:00
2024-09-02 16:32:21 +02:00
try {
$endTime = strlen($session['duration']) > 0 ? getEndTime($session) : false;
} catch (\Throwable $th) {
throw new Exception($session['title'], 1);
}
2024-09-04 15:56:19 +02:00
?>
<template x-if="tab === 'Calendrier' || ('<?= $session['category'] ?>'.length > 0 && tab.includes('<?= $session['category'] ?>'))">
2024-09-03 13:21:23 +02:00
<li class="collapsable__item--padding session grid js-link" style="--color: <?= $session['color'] ?>" @click="goTo(event, '<?= $session['event-url'] ?>')" title="En savoir plus">
2024-09-02 17:09:53 +02:00
<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">
<?php if (strlen($session['duration']) > 0 || strlen($session['public']) > 0): ?>
<p>
<?php if (strlen($session['duration']) > 0): ?>
Durée : <?= $session['duration'] ?><br />
2024-09-02 16:32:21 +02:00
<?php endif ?>
2024-09-02 17:09:53 +02:00
<?php if (strlen($session['public']) > 0): ?>
<?= $session['public'] ?>
<?php endif ?>
</p>
<?php endif ?>
</div>
<div class="session__info">
<p><?= $session['place'] ?></p>
</div>
<div class="session__info">
<?php if ($session['bookableStock'] === 'free'): ?>
<a class="ticket-link" title="Entrée libre" disabled><?php snippet('ticket') ?>Entrée libre</a>
<?php elseif ($session['bookableStock'] == 0): ?>
<a class="ticket-link" title="Séance complète" disabled><?php snippet('ticket') ?>Complet</a>
<?php elseif ($session['bookableStock'] < option('stockThreshold')): ?>
<a class="ticket-link" title="Plateforme de réservation" href="<?= $session['ticketingUrl'] ?>" target="_blank"><?php snippet('ticket') ?>Plus que quelques places !</a>
<?php else: ?>
<a class="ticket-link" title="Plateforme de réservation" href="<?= $session['ticketingUrl'] ?>" target="_blank"><?php snippet('ticket') ?>Billetterie</a>
<?php endif ?>
</div>
2024-09-02 16:32:21 +02:00
</li>
2024-09-04 15:56:19 +02:00
</template>
2024-09-02 14:02:13 +02:00
<?php endforeach ?>
2024-09-02 16:32:21 +02:00
</ul>
2024-08-30 15:16:41 +02:00
<?php endslot() ?>
<?php endsnippet() ?>
<?php endif ?>
<?php endforeach ?>
</section>
</div>
</template>
2024-08-30 14:37:13 +02:00
</div>
</div>
2024-08-28 19:11:58 +02:00
<?php snippet('footer') ?>