From 8e33e37911c2e3a8ac44131486db9c958f98c9c0 Mon Sep 17 00:00:00 2001 From: vince Date: Tue, 7 Dec 2021 22:38:10 +0100 Subject: [PATCH] =?UTF-8?q?ajoute=20les=20liens=20de=20navigation=20entre?= =?UTF-8?q?=20=C3=A9v=C3=A9nements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.php | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index 3ff14c4..e1aa3cd 100644 --- a/index.php +++ b/index.php @@ -95,9 +95,10 @@ if ($action === 'config') { $hasEvent = isset($_REQUEST['event']); if (!$isConfig and $hasSupplier) { + $start = new \DateTime($config[$supplier]['start']); if (!$hasEvent) { $now = new \DateTime('now'); - $current = new \DateTime($config[$supplier]['start']); + $current = clone $start; $frequency = \DateInterval::createFromDateString($config[$supplier]['frequency']); $maxIterations = 1000; while ( @@ -107,10 +108,20 @@ if (!$isConfig and $hasSupplier) { $nextEvent = $current->format('Y-m-d'); header(sprintf('Location: %s?supplier=%s&event=%s', $requestUrl, $supplier, $nextEvent)); 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) { case 'insert' : case 'delete' : @@ -295,7 +306,32 @@ if (!$isConfig and $hasSupplier) {
-

+

+ + + +