Dealing in PHP with the suppressed dates

This commit is contained in:
Antonin 2016-08-07 12:23:57 +02:00
parent d762c38e81
commit 4d14dd1b70

View File

@ -120,6 +120,17 @@ switch ($step) {
// Clear previous choices
$_SESSION['form']->clearChoices();
// Reorder moments to deal with suppressed dates
$moments = array();
$i = 0;
while(count($moments) < count($_POST['days'])) {
if (!empty($_POST['horaires' . $i])) {
$moments[] = $_POST['horaires' . $i];
}
$i++;
}
for ($i = 0; $i < count($_POST['days']); $i++) {
$day = $_POST['days'][$i];
@ -130,7 +141,7 @@ switch ($step) {
$choice = new Choice($time);
$_SESSION['form']->addChoice($choice);
$schedules = $inputService->filterArray($_POST['horaires' . $i], FILTER_DEFAULT);
$schedules = $inputService->filterArray($moments[$i], FILTER_DEFAULT);
for ($j = 0; $j < count($schedules); $j++) {
if (!empty($schedules[$j])) {
$choice->addSlot(strip_tags($schedules[$j]));