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