From 919ece382ce4e53b48dc31f64664af8e0262ee06 Mon Sep 17 00:00:00 2001 From: vince Date: Wed, 29 Dec 2021 16:38:27 +0100 Subject: [PATCH] =?UTF-8?q?g=C3=A8re=20les=20dates=20de=20fin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index 26067ec..555a589 100644 --- a/index.php +++ b/index.php @@ -101,6 +101,7 @@ if ($hasSupplier) { 'description' => '', 'choices' => [], 'start' => 'now 00:00:00', + 'end' => '+1 year 23:59:59', 'frequency' => '1 day', 'password' => '', 'excludes' => [], @@ -212,7 +213,6 @@ try { if (!$isConfig and !$supplierIsNew and $hasSupplier) { $start = new \DateTime($config[$supplier]['start']); if (!$hasEvent) { - $next = findNext($start, $config[$supplier]['frequency'], $config[$supplier]['excludes'], true); $nextEvent = $next->format('Y-m-d'); header('Location: ' . generateUrl($supplier, $nextEvent)); @@ -223,10 +223,16 @@ if (!$isConfig and !$supplierIsNew and $hasSupplier) { $previousEvent = $previous->format('Y-m-d'); if (false and !array_key_exists($previousEvent, $data[$supplier])) unset($previousEvent); + $first = new \DateTime($config[$supplier]['start']); + if (true and ($previous->getTimestamp() < $first->getTimestamp())) + unset($previousEvent); $next = findNext($current, $config[$supplier]['frequency'], $config[$supplier]['excludes'], false); $nextEvent = $next->format('Y-m-d'); if (false and !array_key_exists($nextEvent, $data[$supplier])) unset($nextEvent); + $last = new \DateTime($config[$supplier]['end']); + if (true and ($next->getTimestamp() > $last->getTimestamp())) + unset($nextEvent); } switch ($action) {