FIX: when adding new times on a survey, all hours would be erased.

This commit is contained in:
tnegre 2023-08-30 12:18:06 +02:00
parent 9b960b684d
commit 3cea3c86f8

View File

@ -218,8 +218,20 @@ if (!isset($_SESSION["nbrecaseshoraires"])) {
$_SESSION["nbrecaseshoraires"] = 5;
} elseif ((GETPOST('ajoutcases') || GETPOST("ajoutcases_y")) && $_SESSION["nbrecaseshoraires"] == 5) {
$_SESSION["nbrecaseshoraires"] = 10;
//On sauvegarde les heures deja entrées
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
$nbofchoice = count($_SESSION["totalchoixjour"]);
for ($i = 0; $i < $nbofchoice; $i++) {
//affichage des 5 cases horaires
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
$horairesi = GETPOST("horaires".$i);
$_SESSION["horaires$i"][$j] = $horairesi[$j];
}
}
}
}
//valeurs de la date du jour actuel
$jourAJ = date("j");
$moisAJ = date("n");
@ -408,7 +420,7 @@ if (issetAndNoEmpty('choixjourajout')) {
$k = $i + 1;
if (issetAndNoEmpty('horaires'.$i) === true && issetAndNoEmpty($i, $_POST['horaires'.$i]) === true) {
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
$horairesi = GETPOST("horaires".$i);
$horairesi = GETPOST("horaires".$i, 'array');
$_SESSION["horaires$i"][$j] = $horairesi[$j];
}
}
@ -453,7 +465,7 @@ if (issetAndNoEmpty('reporterhoraires')) {
}
}
//report des horaires dans toutes les cases
//effacer les horaires dans toutes les cases
if (issetAndNoEmpty('resethoraires')) {
$nbofchoice = count($_SESSION["totalchoixjour"]);
for ($i = 0; $i < $nbofchoice; $i++) {