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