dolibarr 21.0.0-alpha
choix_date.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
30require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
31require_once DOL_DOCUMENT_ROOT."/opensurvey/lib/opensurvey.lib.php";
32
33// Security check
34if (!$user->hasRight('opensurvey', 'write')) {
36}
37
38// Survey type is DATE
39$_SESSION["formatsondage"] = "D";
40
41$erreur = false;
42$erreurNb = 0;
43$choixdate = '';
44
45
46/*
47 * Actions
48 */
49
50// Insert survey
51if (GETPOST('confirmation')) {
52 // We save hours entered
53 if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('nbrecaseshoraires', $_SESSION) === true) {
54 $nbofchoice = count($_SESSION["totalchoixjour"]);
55 $errheure = array();
56
57 if ($nbofchoice * $_SESSION["nbrecaseshoraires"] > 200) {
58 setEventMessages($langs->trans("ErrorFieldTooLong"), null, 'errors');
59 $erreurNb++;
60 } else {
61 for ($i = 0; $i < $nbofchoice; $i++) {
62 // Show hours choices
63 for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
64 $horairesi = GETPOST("horaires".$i);
65 $_SESSION["horaires$i"][$j] = $horairesi[$j];
66
67 $tmphorairesi = GETPOST('horaires'.$i, 'array');
68
69 if (!is_array($tmphorairesi)) {
70 $errheure[$i][$j] = true;
71 $erreur = true;
72 continue;
73 }
74
75 // A range like 8:00-11:00
76 $creneaux = array();
77 $heures = array();
78 if (preg_match("/(\d{1,2}:\d{2})-(\d{1,2}:\d{2})/", $tmphorairesi[$j], $creneaux)) {
79 //on recupere les deux parties du preg_match qu'on redécoupe autour des ":"
80 $debutcreneau = explode(":", $creneaux[1]);
81 $fincreneau = explode(":", $creneaux[2]);
82
83 // Compare hours for start and end
84 // If correct, add the data in the session variables
85 if ($debutcreneau[0] < 24 && $fincreneau[0] < 24 && $debutcreneau[1] < 60 && $fincreneau[1] < 60 && ($debutcreneau[0] < $fincreneau[0] || ($debutcreneau[0] == $fincreneau[0] && $debutcreneau[1] < $fincreneau[1]))) {
86 $_SESSION["horaires$i"][$j] = $creneaux[1].'-'.$creneaux[2];
87 } else { //sinon message d'erreur et nettoyage de la case
88 $errheure[$i][$j] = true;
89 $erreur = true;
90 }
91 } elseif (preg_match(";^(\d{1,2}h\d{0,2})-(\d{1,2}h\d{0,2})$;i", $tmphorairesi[$j], $creneaux)) { //si c'est un creneau type 8h00-11h00
92 //on recupere les deux parties du preg_match qu'on redécoupe autour des "H"
93 $debutcreneau = preg_split("/h/i", $creneaux[1]);
94 $fincreneau = preg_split("/h/i", $creneaux[2]);
95
96 // Compare hours for start and end
97 // If correct, add the data in the session variables
98 if ($debutcreneau[0] < 24 && $fincreneau[0] < 24 && $debutcreneau[1] < 60 && $fincreneau[1] < 60 && ($debutcreneau[0] < $fincreneau[0] || ($debutcreneau[0] == $fincreneau[0] && $debutcreneau[1] < $fincreneau[1]))) {
99 $_SESSION["horaires$i"][$j] = $creneaux[1].'-'.$creneaux[2];
100 } else { //sinon message d'erreur et nettoyage de la case
101 $errheure[$i][$j] = true;
102 $erreur = true;
103 }
104 } elseif (preg_match(";^(\d{1,2}):(\d{2})$;", $tmphorairesi[$j], $heures)) { //si c'est une heure simple type 8:00
105 //si valeures correctes, on entre les données dans la variables de session
106 if ($heures[1] < 24 && $heures[2] < 60) {
107 $_SESSION["horaires$i"][$j] = $heures[0];
108 } else { //sinon message d'erreur et nettoyage de la case
109 $errheure[$i][$j] = true;
110 $erreur = true;
111 }
112 } elseif (preg_match(";^(\d{1,2})h(\d{0,2})$;i", $tmphorairesi[$j], $heures)) { //si c'est une heure encore plus simple type 8h
113 //si valeures correctes, on entre les données dans la variables de session
114 if ($heures[1] < 24 && $heures[2] < 60) {
115 $_SESSION["horaires$i"][$j] = $heures[0];
116 } else { //sinon message d'erreur et nettoyage de la case
117 $errheure[$i][$j] = true;
118 $erreur = true;
119 }
120 } elseif (preg_match(";^(\d{1,2})-(\d{1,2})$;", $tmphorairesi[$j], $heures)) { //si c'est un creneau simple type 8-11
121 //si valeures correctes, on entre les données dans la variables de session
122 if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) {
123 $_SESSION["horaires$i"][$j] = $heures[0];
124 } else { //sinon message d'erreur et nettoyage de la case
125 $errheure[$i][$j] = true;
126 $erreur = true;
127 }
128 } elseif (preg_match(";^(\d{1,2})h-(\d{1,2})h$;", $tmphorairesi[$j], $heures)) { //si c'est un creneau H type 8h-11h
129 //si valeures correctes, on entre les données dans la variables de session
130 if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) {
131 $_SESSION["horaires$i"][$j] = $heures[0];
132 } else { //sinon message d'erreur et nettoyage de la case
133 $errheure[$i][$j] = true;
134 $erreur = true;
135 }
136 } elseif ($tmphorairesi[$j] == "") { //Si la case est vide
137 unset($_SESSION["horaires$i"][$j]);
138 } else { //pour tout autre format, message d'erreur
139 $errheure[$i][$j] = true;
140 $erreur = true;
141 }
142
143 if (issetAndNoEmpty('horaires'.$i, $_SESSION) === false || issetAndNoEmpty((string) $j, $_SESSION['horaires'.$i]) === false) {
144 if (issetAndNoEmpty('horaires'.$i, $_SESSION) === true) {
145 $_SESSION["horaires$i"][$j] = '';
146 } else {
147 $_SESSION["horaires$i"] = array();
148 $_SESSION["horaires$i"][$j] = '';
149 }
150 }
151 }
152
153 // @phan-suppress-next-line PhanTypeInvalidDimOffset
154 if ($_SESSION["horaires$i"][0] == "" && $_SESSION["horaires$i"][1] == "" && $_SESSION["horaires$i"][2] == "" && $_SESSION["horaires$i"][3] == "" && $_SESSION["horaires$i"][4] == "") {
155 $choixdate .= ",";
156 $choixdate .= $_SESSION["totalchoixjour"][$i];
157 } else {
158 for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
159 if ($_SESSION["horaires$i"][$j] != "") {
160 $choixdate .= ",";
161 $choixdate .= $_SESSION["totalchoixjour"][$i];
162 $choixdate .= "@";
163 // Replace the comma and the '@' token to avoid issues
164 $choixdate .= str_replace(array(',', '@'), array('&#44;', '&#64;'), $_SESSION["horaires$i"][$j]);
165 }
166 }
167 }
168 }
169 }
170
171
172 if (!empty($errheure)) {
173 setEventMessages($langs->trans("ErrorBadFormat"), null, 'errors');
174 }
175 }
176
177 //If just one day and no other time options, error message
178 $tmphoraires0 = GETPOST('horaires0', 'array');
179 if (count($_SESSION["totalchoixjour"]) == "1" && $tmphoraires0[0] == "" && $tmphoraires0[1] == "" && $tmphoraires0[2] == "" && $tmphoraires0[3] == "" && $tmphoraires0[4] == "") {
180 setEventMessages($langs->trans("MoreChoices"), null, 'errors');
181 $erreur = true;
182 }
183
184 // Add survey into database
185 if (!$erreur && $erreurNb == 0) {
186 $_SESSION["toutchoix"] = substr($choixdate, 1);
187 unset($_SESSION["nbrecaseshoraires"]);
188
190 }
191}
192
193// Reset days
194if (GETPOST('reset')) {
195 $nbofchoice = count($_SESSION["totalchoixjour"]);
196 for ($i = 0; $i < $nbofchoice; $i++) {
197 for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
198 unset($_SESSION["horaires$i"][$j]);
199 }
200 }
201
202 unset($_SESSION["totalchoixjour"]);
203 unset($_SESSION["nbrecaseshoraires"]);
204}
205
206
207
208/*
209 * View
210 */
211
212if (!isset($_SESSION['description']) && !isset($_SESSION['mail'])) {
213 dol_print_error(null, $langs->trans('ErrorOpenSurveyFillFirstSection'));
214 exit;
215}
216
217$arrayofjs = array();
218$arrayofcss = array('/opensurvey/css/style.css');
219llxHeader('', $langs->trans("OpenSurvey"), "", '', 0, 0, $arrayofjs, $arrayofcss);
220
221//nombre de cases par défaut
222if (!isset($_SESSION["nbrecaseshoraires"])) {
223 $_SESSION["nbrecaseshoraires"] = 5;
224} elseif ((GETPOST('ajoutcases') || GETPOST("ajoutcases_y")) && $_SESSION["nbrecaseshoraires"] == 5) {
225 $_SESSION["nbrecaseshoraires"] = 10;
226 //On sauvegarde les heures deja entrées
227 if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
228 $nbofchoice = count($_SESSION["totalchoixjour"]);
229 for ($i = 0; $i < $nbofchoice; $i++) {
230 //affichage des 5 cases horaires
231 for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
232 $horairesi = GETPOST("horaires".$i);
233 $_SESSION["horaires$i"][$j] = $horairesi[$j];
234 }
235 }
236 }
237}
238
239
240//valeurs de la date du jour actuel
241$jourAJ = date("j");
242$moisAJ = date("n");
243$anneeAJ = date("Y");
244
245// Initialisation des jour, mois et année
246if (!isset($_SESSION['jour'])) {
247 $_SESSION['jour'] = date('j');
248}
249if (!isset($_SESSION['mois'])) {
250 $_SESSION['mois'] = date('n');
251}
252if (!isset($_SESSION['annee'])) {
253 $_SESSION['annee'] = date('Y');
254}
255
256// Update value of date period into the session
257if (!issetAndNoEmpty('choixjourajout') && !issetAndNoEmpty('choixjourretrait') && (issetAndNoEmpty('retourmois') || issetAndNoEmpty('retourmois_x'))) {
258 $_SESSION["jour"] = date("j");
259 $_SESSION["mois"] = date("n");
260 $_SESSION["annee"] = date("Y");
261}
262
263// Update value of date period into the session
264if (issetAndNoEmpty('moisavant_x') || issetAndNoEmpty('moisavant')) {
265 if ($_SESSION["mois"] == 1) {
266 $_SESSION["mois"] = 12;
267 $_SESSION["annee"] -= 1;
268 } else {
269 $_SESSION["mois"] -= 1;
270 }
271
272 //On sauvegarde les heures deja entrées
273 if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
274 $nbofchoice = count($_SESSION["totalchoixjour"]);
275 for ($i = 0; $i < $nbofchoice; $i++) {
276 //affichage des 5 cases horaires
277 for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
278 $horairesi = GETPOST("horaires".$i);
279 $_SESSION["horaires$i"][$j] = $horairesi[$j];
280 }
281 }
282 }
283}
284
285// Update value of date period into the session
286if (issetAndNoEmpty('moisapres_x') || issetAndNoEmpty('moisapres')) {
287 if ($_SESSION["mois"] == 12) {
288 $_SESSION["mois"] = 1;
289 $_SESSION["annee"] += 1;
290 } else {
291 $_SESSION["mois"] += 1;
292 }
293
294 // On sauvegarde les heures deja entrées
295 if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
296 $nbofchoice = count($_SESSION["totalchoixjour"]);
297 for ($i = 0; $i < $nbofchoice; $i++) {
298 //affichage des 5 cases horaires
299 for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
300 $horairesi = GETPOST("horaires".$i);
301 $_SESSION["horaires$i"][$j] = $horairesi[$j];
302 }
303 }
304 }
305}
306
307// Update value of date period into the session
308if (issetAndNoEmpty('anneeavant_x') || issetAndNoEmpty('anneeavant')) {
309 $_SESSION["annee"] -= 1;
310
311 //On sauvegarde les heures deja entrées
312 if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
313 $nbofchoice = count($_SESSION["totalchoixjour"]);
314 for ($i = 0; $i < $nbofchoice; $i++) {
315 //affichage des 5 cases horaires
316 for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
317 $horairesi = GETPOST("horaires".$i);
318 $_SESSION["horaires$i"][$j] = $horairesi[$j];
319 }
320 }
321 }
322}
323
324// Update value of date period into the session
325if (issetAndNoEmpty('anneeapres_x') || issetAndNoEmpty('anneeapres')) {
326 $_SESSION["annee"] += 1;
327
328 //On sauvegarde les heures deja entrées
329 if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
330 $nbofchoice = count($_SESSION["totalchoixjour"]);
331 for ($i = 0; $i < $nbofchoice; $i++) {
332 //affichage des 5 cases horaires
333 for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
334 $horairesi = GETPOST("horaires".$i);
335 $_SESSION["horaires$i"][$j] = $horairesi[$j];
336 }
337 }
338 }
339}
340
341// valeurs du nombre de jour dans le mois et du premier jour du mois
342$nbrejourmois = idate("t", dol_get_first_day((int) $_SESSION["annee"], (int) $_SESSION["mois"]));
343$premierjourmois = (int) dol_print_date(dol_get_first_day((int) $_SESSION["annee"], (int) $_SESSION["mois"]), "%w") - 1;
344//var_dump(dol_get_first_day((int) $_SESSION["annee"], (int) $_SESSION["mois"]));
345//var_dump($premierjourmois);
346
347// TODO Support option getDolGlobalString('MAIN_START_WEEK') == 0 (sunday = first day of week)
348
349// translate month
350if (is_int($_SESSION["mois"]) && $_SESSION["mois"] > 0 && $_SESSION["mois"] < 13) {
351 $motmois = dol_print_date(mktime(0, 0, 0, (int) $_SESSION["mois"], 10), '%B');
352} else {
353 $motmois = dol_print_date(dol_now(), '%B');
354}
355
356
357// Start form
358print '<form name="formulaire" action="" method="POST">'."\n";
359print '<input type="hidden" name="token" value="'.newToken().'">';
360
361print load_fiche_titre($langs->trans("CreatePoll").' (2 / 2)');
362
363// Show help for days
364print '<div class="bodydate">'."\n";
365print $langs->trans("OpenSurveyStep2")."\n";
366print '</div>'."\n";
367
368// Show array with the calendar
369print '<div class="corps">'."\n";
370print '<div class="center">'."\n";
371print '<table class="center">'."\n"; // The div class=center has no effect on table, so we must keep the align=center for table
372print '<tr>';
373print '<td>';
374print '<button type="submit" name="anneeavant" value="<<">'.img_picto($langs->trans("PreviousYear"), 'chevron-double-left', 'class="double"').'</button>';
375//print '<input type="image" class="buttonwebsite" name="anneeavant" value="<<" src="../img/rewind.png">';
376print '</td>';
377print '<td>';
378print '<button type="submit" name="moisavant" value="<">'.img_picto($langs->trans("PreviousMonth"), 'chevron-left', 'class="double"').'</button>';
379//print '<input type="image" class="buttonwebsite" name="moisavant" value="<" src="../img/previous.png">';
380print '</td>';
381print '<td width="150px" class="center size15x">'.$motmois.' '.$_SESSION["annee"].'<br>';
382//print '<input type="image" name="retourmois" class="buttonreset" alt="'.dol_escape_htmltag($langs->trans("BackToCurrentMonth")).'" title="'.dol_escape_htmltag($langs->trans("BackToCurrentMonth")).'" value="" src="'.img_picto('', 'refresh', '', 0, 1).'">';
383print '</td>';
384print '<td>';
385print '<button type="submit" name="moisapres" value=">">'.img_picto($langs->trans("NextMonth"), 'chevron-right', 'class="double"').'</button>';
386//print '<input type="image" class="buttonwebsite" name="moisapres" value=">" src="../img/next.png">';
387print '</td>';
388print '<td>';
389print '<button type="submit" name="anneeapres" value=">>">'.img_picto($langs->trans("NextYear"), 'chevron-double-right', 'class="double"').'</button>';
390//print '<input type="image" class="buttonwebsite" name="anneeapres" value=">>" src="../img/fforward.png">';
391print '</td></tr>'."\n";
392print '</table>'."\n";
393print '</div>'."\n";
394
395print '<br>';
396
397print '<div class="center calendrier">'."\n";
398print '<table class="center">'."\n"; // The div class=center has no effect on table, so we must keep the align=center for table
399print '<tr>'."\n";
400
401// show list of days in title line
402for ($i = 0; $i < 7; $i++) {
403 print '<td class="center joursemaine">';
404 print dol_print_date(mktime(0, 0, 0, 0, $i, 10), (empty($conf->dol_optimize_smallscreen) ? '%A' : '%a'));
405 print '</td>';
406}
407
408print '</tr>'."\n";
409
410//ajout d'une entrée dans la variable de session qui contient toutes les dates
411if (issetAndNoEmpty('choixjourajout')) {
412 if (!isset($_SESSION["totalchoixjour"])) {
413 $_SESSION["totalchoixjour"] = array();
414 }
415
416 // Test pour éviter les doublons dans la variable qui contient toutes les dates
417 $journeuf = true;
418 if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('choixjourajout') === true) {
419 $nbofchoice = count($_SESSION["totalchoixjour"]);
420 for ($i = 0; $i < $nbofchoice; $i++) {
421 $choixjourajout = GETPOST("choixjourajout");
422 if ($_SESSION["totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION["mois"], $choixjourajout[0], $_SESSION["annee"])) {
423 $journeuf = false;
424 }
425 }
426 }
427
428 // Si le test est passé, alors on insere la valeur dans la variable de session qui contient les dates
429 if ($journeuf && issetAndNoEmpty('choixjourajout') === true) {
430 $choixjourajout = GETPOST("choixjourajout");
431 array_push($_SESSION["totalchoixjour"], dol_mktime(0, 0, 0, $_SESSION["mois"], $choixjourajout[0], $_SESSION["annee"]));
432 sort($_SESSION["totalchoixjour"]);
433 $cle = array_search(dol_mktime(0, 0, 0, $_SESSION["mois"], $choixjourajout[0], $_SESSION["annee"]), $_SESSION["totalchoixjour"]);
434
435 //On sauvegarde les heures deja entrées
436 for ($i = 0; $i < $cle; $i++) {
437 $horairesi = GETPOST("horaires".$i);
438 for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
439 if (issetAndNoEmpty('horaires'.$i) === true && issetAndNoEmpty((string) $i, $_POST['horaires'.$i]) === true) {
440 $_SESSION["horaires$i"][$j] = $horairesi[$j];
441 }
442 }
443 }
444
445 $nbofchoice = count($_SESSION["totalchoixjour"]);
446 for ($i = $cle; $i < $nbofchoice; $i++) {
447 $k = $i + 1;
448 if (issetAndNoEmpty('horaires'.$i) === true && issetAndNoEmpty((string) $i, $_POST['horaires'.$i]) === true) {
449 for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
450 $horairesi = GETPOST("horaires".$i, 'array');
451 $_SESSION["horaires$i"][$j] = $horairesi[$j];
452 }
453 }
454 }
455
456 unset($_SESSION["horaires$cle"]);
457 }
458}
459
460//retrait d'une entrée dans la variable de session qui contient toutes les dates
461if (issetAndNoEmpty('choixjourretrait')) {
462 //On sauvegarde les heures deja entrées
463 $nbofchoice = count($_SESSION["totalchoixjour"]);
464 for ($i = 0; $i < $nbofchoice; $i++) {
465 //affichage des 5 cases horaires
466 for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
467 $horairesi = GETPOST("horaires".$i);
468 $_SESSION["horaires$i"][$j] = $horairesi[$j];
469 }
470 }
471
472 for ($i = 0; $i < $nbofchoice; $i++) {
473 $choixjourretrait = GETPOST('choixjourretrait');
474 if ($_SESSION["totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION["mois"], $choixjourretrait[0], $_SESSION["annee"])) {
475 for ($j = $i; $j < $nbofchoice; $j++) {
476 $k = $j + 1;
477 $_SESSION["horaires$j"] = $_SESSION["horaires$k"];
478 }
479
480 array_splice($_SESSION["totalchoixjour"], $i, 1);
481 }
482 }
483}
484
485//report des horaires dans toutes les cases
486if (issetAndNoEmpty('reporterhoraires')) {
487 $_SESSION["horaires0"] = GETPOST("horaires0");
488 $nbofchoice = count($_SESSION["totalchoixjour"]);
489 for ($i = 0; $i < $nbofchoice; $i++) {
490 $j = $i + 1;
491 $_SESSION["horaires$j"] = $_SESSION["horaires$i"];
492 }
493}
494
495//effacer les horaires dans toutes les cases
496if (issetAndNoEmpty('resethoraires')) {
497 $nbofchoice = count($_SESSION["totalchoixjour"]);
498 for ($i = 0; $i < $nbofchoice; $i++) {
499 unset($_SESSION["horaires$i"]);
500 }
501}
502
503// affichage du calendrier
504print '<tr>'."\n";
505
506for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) {
507 $numerojour = $i - $premierjourmois + 1;
508
509 // On saute a la ligne tous les 7 jours
510 if (($i % 7) == 0 && $i != 0) {
511 print '</tr><tr>'."\n";
512 }
513
514 // On affiche les jours precedants en gris et incliquables
515 if ($i < $premierjourmois) {
516 print '<td class="avant"></td>'."\n";
517 } else {
518 if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
519 $nbofchoice = count($_SESSION["totalchoixjour"]);
520 for ($j = 0; $j < $nbofchoice; $j++) {
521 // show red buttons
522 if (date("j", $_SESSION["totalchoixjour"][$j]) == $numerojour && date("n", $_SESSION["totalchoixjour"][$j]) == $_SESSION["mois"] && date("Y", $_SESSION["totalchoixjour"][$j]) == $_SESSION["annee"]) {
523 print '<td align="center" class="choisi"><input type="submit" class="bouton OFF centpercent nomarginleft buttonwebsite" name="choixjourretrait[]" value="'.$numerojour.'"></td>'."\n";
524 $dejafait = $numerojour;
525 }
526 }
527 }
528
529 // If no red button, we show green or grey button with number of day
530 if (!isset($dejafait) || $dejafait != $numerojour) {
531 // green button
532 if (($numerojour >= $jourAJ && $_SESSION["mois"] == $moisAJ && $_SESSION["annee"] == $anneeAJ) || ($_SESSION["mois"] > $moisAJ && $_SESSION["annee"] == $anneeAJ) || $_SESSION["annee"] > $anneeAJ) {
533 print '<td class="center libre"><input type="submit" class="bouton ON centpercent nomarginleft buttonwebsite" name="choixjourajout[]" value="'.$numerojour.'"></td>'."\n";
534 } else {
535 // grey button
536 print '<td class="center avant">'.$numerojour.'</td>'."\n";
537 }
538 }
539 }
540}
541
542//fin du tableau
543print '</tr>'."\n";
544print '</table>'."\n";
545print '</div></div>'."\n";
546
547print '<div class="bodydate"><div class="center">'."\n";
548
549// affichage de tous les jours choisis
550if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) {
551 //affichage des jours
552 print '<br>'."\n";
553 print '<div align="left">';
554 print '<strong>'.$langs->trans("SelectedDays").':</strong>'."<br>\n";
555 print $langs->trans("SelectDayDesc")."<br>\n";
556 print '</div><br>';
557
558 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
559 print '<table>'."\n";
560 print '<tr>'."\n";
561 print '<td></td>'."\n";
562
563 for ($i = 0; $i < $_SESSION["nbrecaseshoraires"]; $i++) {
564 $j = $i + 1;
565 print '<td class="somme"><div class="center">'.$langs->trans("Time").' '.$j.'</div></td>'."\n";
566 }
567
568 if ($_SESSION["nbrecaseshoraires"] < 10) {
569 print '<td class="somme"><input type="image" name="ajoutcases" src="../img/add-16.png"></td>'."\n";
570 }
571
572 print '</tr>'."\n";
573
574 // Show list of selected days
575
576 $nbofchoice = count($_SESSION["totalchoixjour"]);
577
578 for ($i = 0; $i < $nbofchoice; $i++) {
579 print '<tr>'."\n";
580 print '<td class="left">'.dol_print_date($_SESSION["totalchoixjour"][$i], 'daytext').' <span class="opacitymedium">('.dol_print_date($_SESSION["totalchoixjour"][$i], '%A').')</span></td>';
581
582 //affichage des cases d'horaires
583 for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
584 if (isset($errheure[$i][$j]) && $errheure[$i][$j]) {
585 // When an error is found, the checkbox background is red
586 print '<td><input type=text size="10" maxlength="11" name=horaires'.$i.'[] value="'.$_SESSION["horaires$i"][$j].'" style="background-color:#FF6666;"></td>'."\n";
587 } else {
588 // Else the color is empty (in principle)
589 print '<td><input type=text size="10" maxlength="11" name=horaires'.$i.'[] value="'.$_SESSION["horaires$i"][$j].'"></td>'."\n";
590 }
591 }
592 print '</tr>'."\n";
593 }
594
595 print '</table>'."\n";
596 print '</div>';
597
598 // show buttons to cancel, delete days or create survey
599 print '<br><div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
600 print '<input type="submit" class="button small" name="reset" value="'.dol_escape_htmltag($langs->trans("RemoveAllDays")).'">';
601 print '<input type="submit" class="button small" name="reporterhoraires" value="'.dol_escape_htmltag($langs->trans("CopyHoursOfFirstDay")).'">';
602 print '<input type="submit" class="button small" name="resethoraires" value="'.dol_escape_htmltag($langs->trans("RemoveAllHours")).'">'."\n";
603 print '<br><br>'."\n";
604 print '<input type="submit" class="button" name="confirmation" value="'.$langs->trans("CreatePoll").'">'."\n";
605 print '</div>';
606}
607
608print '</tr>'."\n";
609print '</table>'."\n";
610print '<a name="bas"></a>'."\n";
611//fin du formulaire et bandeau de pied
612print '</form>'."\n";
613//bandeau de pied
614print '<br><br><br><br>'."\n";
615print '</div></div>'."\n";
616
617// End of page
618llxFooter();
619$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition date.lib.php:595
llxFooter()
Footer empty.
Definition document.php:107
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
issetAndNoEmpty($name, $tableau=null)
Fonction vérifiant l'existance et la valeur non vide d'une clé d'un tableau.
ajouter_sondage()
Add a poll.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.