Browse Source

ajoute les liens de navigation entre événements

master
vince vince 3 years ago
parent
commit
8e33e37911
1 changed files with 40 additions and 4 deletions
  1. +40
    -4
      index.php

+ 40
- 4
index.php View File

@ -95,9 +95,10 @@ if ($action === 'config') {
$hasEvent = isset($_REQUEST['event']); $hasEvent = isset($_REQUEST['event']);
if (!$isConfig and $hasSupplier) { if (!$isConfig and $hasSupplier) {
$start = new \DateTime($config[$supplier]['start']);
if (!$hasEvent) { if (!$hasEvent) {
$now = new \DateTime('now'); $now = new \DateTime('now');
$current = new \DateTime($config[$supplier]['start']);
$current = clone $start;
$frequency = \DateInterval::createFromDateString($config[$supplier]['frequency']); $frequency = \DateInterval::createFromDateString($config[$supplier]['frequency']);
$maxIterations = 1000; $maxIterations = 1000;
while ( while (
@ -107,10 +108,20 @@ if (!$isConfig and $hasSupplier) {
$nextEvent = $current->format('Y-m-d'); $nextEvent = $current->format('Y-m-d');
header(sprintf('Location: %s?supplier=%s&event=%s', $requestUrl, $supplier, $nextEvent)); header(sprintf('Location: %s?supplier=%s&event=%s', $requestUrl, $supplier, $nextEvent));
die(); die();
} else {
$event = $_REQUEST['event'];
$current = new \DateTimeImmutable($event);
$frequency = \DateInterval::createFromDateString($config[$supplier]['frequency']);
$previous = $current->sub($frequency);
$previousEvent = $previous->format('Y-m-d');
if (false and !array_key_exists($previousEvent, $data[$supplier]))
unset($previousEvent);
$next = $current->add($frequency);
$nextEvent = $next->format('Y-m-d');
if (false and !array_key_exists($nextEvent, $data[$supplier]))
unset($nextEvent);
} }
$event = $_REQUEST['event'];
switch ($action) { switch ($action) {
case 'insert' : case 'insert' :
case 'delete' : case 'delete' :
@ -295,7 +306,32 @@ if (!$isConfig and $hasSupplier) {
<section class="container-fluid"> <section class="container-fluid">
<div class="row my-3"> <div class="row my-3">
<div class="col"> <div class="col">
<h1><?php echo $config[$supplier]['title']; ?></h1>
<h1>
<?php echo $config[$supplier]['title']; ?>
<div class="btn-group float-end" role="group">
<?php if (isset($previousEvent)) : ?>
<a class="btn btn-outline-primary" href="<?php printf('%s?supplier=%s&event=%s', $requestUrl, $supplier, $previousEvent); ?>" title="Événement précédent">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8z"/>
</svg>
</a>
<?php endif; ?>
<a class="btn btn-outline-primary" href="<?php printf('%s?supplier=%s&event=%s', $requestUrl, $supplier, $event); ?>" title="Cet événement">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-link" viewBox="0 0 16 16">
<path d="M6.354 5.5H4a3 3 0 0 0 0 6h3a3 3 0 0 0 2.83-4H9c-.086 0-.17.01-.25.031A2 2 0 0 1 7 10.5H4a2 2 0 1 1 0-4h1.535c.218-.376.495-.714.82-1z"/>
<path d="M9 5.5a3 3 0 0 0-2.83 4h1.098A2 2 0 0 1 9 6.5h3a2 2 0 1 1 0 4h-1.535a4.02 4.02 0 0 1-.82 1H12a3 3 0 1 0 0-6H9z"/>
</svg>
</a>
<?php if (isset($nextEvent)) : ?>
<a class="btn btn-outline-primary" href="<?php printf('%s?supplier=%s&event=%s', $requestUrl, $supplier, $nextEvent); ?>" title="Événement suivant">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-right" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8z"/>
</svg>
</a>
<?php endif; ?>
</div>
</h1>
<?php if (!empty($config[$supplier]['description'])) : ?> <?php if (!empty($config[$supplier]['description'])) : ?>
<p class="lead"><?php echo $config[$supplier]['description']; ?></p> <p class="lead"><?php echo $config[$supplier]['description']; ?></p>
<?php endif; ?> <?php endif; ?>


Loading…
Cancel
Save