dolibarr 23.0.3
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-2025 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$errheure = array();
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
64 if ($nbofchoice * $_SESSION["nbrecaseshoraires"] > 200) {
65 setEventMessages($langs->trans("ErrorFieldTooLong"), null, 'errors');
66 $erreurNb++;
67 } else {
68 for ($i = 0; $i < $nbofchoice; $i++) {
69 // Show hours choices
70 for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
71 $horairesi = GETPOST("horaires".$i);
72 $_SESSION["horaires$i"][$j] = $horairesi[$j];
73
74 $tmphorairesi = GETPOST('horaires'.$i, 'array');
75
76 if (!is_array($tmphorairesi)) {
77 $errheure[$i][$j] = true;
78 $erreur = true;
79 continue;
80 }
81
82 // A range like 8:00-11:00
83 $creneaux = array();
84 $heures = array();
85 if (preg_match("/(\d{1,2}:\d{2})-(\d{1,2}:\d{2})/", $tmphorairesi[$j], $creneaux)) {
86 //on recupere les deux parties du preg_match qu'on redécoupe autour des ":"
87 $debutcreneau = explode(":", $creneaux[1]);
88 $fincreneau = explode(":", $creneaux[2]);
89
90 // Compare hours for start and end
91 // If correct, add the data in the session variables
92 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]))) {
93 $_SESSION["horaires$i"][$j] = $creneaux[1].'-'.$creneaux[2];
94 } else { //sinon message d'erreur et nettoyage de la case
95 $errheure[$i][$j] = true;
96 $erreur = true;
97 }
98 } 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
99 //on recupere les deux parties du preg_match qu'on redécoupe autour des "H"
100 $debutcreneau = preg_split("/h/i", $creneaux[1]);
101 $fincreneau = preg_split("/h/i", $creneaux[2]);
102
103 // Compare hours for start and end
104 // If correct, add the data in the session variables
105 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]))) {
106 $_SESSION["horaires$i"][$j] = $creneaux[1].'-'.$creneaux[2];
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}):(\d{2})$;", $tmphorairesi[$j], $heures)) { //si c'est une heure simple type 8:00
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})h(\d{0,2})$;i", $tmphorairesi[$j], $heures)) { //si c'est une heure encore plus simple type 8h
120 //si valeures correctes, on entre les données dans la variables de session
121 if ($heures[1] < 24 && $heures[2] < 60) {
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})-(\d{1,2})$;", $tmphorairesi[$j], $heures)) { //si c'est un creneau simple type 8-11
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 (preg_match(";^(\d{1,2})h-(\d{1,2})h$;", $tmphorairesi[$j], $heures)) { //si c'est un creneau H type 8h-11h
136 //si valeures correctes, on entre les données dans la variables de session
137 if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) {
138 $_SESSION["horaires$i"][$j] = $heures[0];
139 } else { //sinon message d'erreur et nettoyage de la case
140 $errheure[$i][$j] = true;
141 $erreur = true;
142 }
143 } elseif ($tmphorairesi[$j] == "") { //Si la case est vide
144 unset($_SESSION["horaires$i"][$j]);
145 } else { //pour tout autre format, message d'erreur
146 $errheure[$i][$j] = true;
147 $erreur = true;
148 }
149
150 // Suppress notice regarding $_SESSION @phan-suppress-next-line PhanTypeMismatchArgument
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" id="surveyform" 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 $dejafait = null;
527 if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
528 $nbofchoice = count($_SESSION["totalchoixjour"]);
529 for ($j = 0; $j < $nbofchoice; $j++) {
530 // show red buttons
531 if (date("j", $_SESSION["totalchoixjour"][$j]) == $numerojour && date("n", $_SESSION["totalchoixjour"][$j]) == $_SESSION["mois"] && date("Y", $_SESSION["totalchoixjour"][$j]) == $_SESSION["annee"]) {
532 print '<td align="center" class="choisi"><input type="submit" class="bouton OFF centpercent nomarginleft buttonwebsite" name="choixjourretrait[]" value="'.$numerojour.'"></td>'."\n";
533 $dejafait = $numerojour;
534 }
535 }
536 }
537
538 // If no red button, we show green or grey button with number of day
539 if (!isset($dejafait) || $dejafait != $numerojour) {
540 // green button
541 if (($numerojour >= $jourAJ && $_SESSION["mois"] == $moisAJ && $_SESSION["annee"] == $anneeAJ) || ($_SESSION["mois"] > $moisAJ && $_SESSION["annee"] == $anneeAJ) || $_SESSION["annee"] > $anneeAJ) {
542 print '<td class="center libre"><input type="submit" class="bouton ON centpercent nomarginleft buttonwebsite" name="choixjourajout[]" value="'.$numerojour.'"></td>'."\n";
543 } else {
544 // grey button
545 print '<td class="center avant">'.$numerojour.'</td>'."\n";
546 }
547 }
548 }
549}
550
551//fin du tableau
552print '</tr>'."\n";
553print '</table>'."\n";
554print '</div></div>'."\n";
555
556print '<div class="bodydate"><div class="center">'."\n";
557
558// affichage de tous les jours choisis
559if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) {
560 //affichage des jours
561 print '<br>'."\n";
562 print '<div align="left">';
563 print '<strong>'.$langs->trans("SelectedDays").':</strong>'."<br>\n";
564 print $langs->trans("SelectDayDesc")."<br>\n";
565 print '</div><br>';
566
567 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
568 print '<table>'."\n";
569 print '<tr>'."\n";
570 print '<td></td>'."\n";
571
572 for ($i = 0; $i < $_SESSION["nbrecaseshoraires"]; $i++) {
573 $j = $i + 1;
574 print '<td class="somme"><div class="center">'.$langs->trans("Time").' '.$j.'</div></td>'."\n";
575 }
576
577 if ($_SESSION["nbrecaseshoraires"] < 10) {
578 print '<td class="somme">';
579 if ($conf->use_javascript_ajax) {
580 print '<div id="addchoice" class="inline-block">';
581 print img_picto('', 'add', '', 0, 0, 0, '', 'valignmiddle btnTitle-icon cursorpointer');
582 print '</div>';
583
584 print '<input type="hidden" name="ajoutcases" id="ajoutcases" value="">';
585 print '<script>
586 // jQuery code to handle the div click event
587 $(document).ready(function() {
588 $("#addchoice").on("click", function() {
589 console.log("Click on adchoice");
590 $("#ajoutcases").val("ajoutcases");
591 $("#surveyform").submit();
592 });
593 });
594 </script>';
595 } else {
596 print '<input type="image" name="ajoutcases" src="../img/add-16.png">';
597 }
598 //print '<input type="image" name="ajoutcases" src="../img/add-16.png">';
599 print'</td>'."\n";
600 }
601
602 print '</tr>'."\n";
603
604 // Show list of selected days
605
606 $nbofchoice = count($_SESSION["totalchoixjour"]);
607
608 for ($i = 0; $i < $nbofchoice; $i++) {
609 print '<tr>'."\n";
610 print '<td class="left">'.dol_print_date($_SESSION["totalchoixjour"][$i], 'daytext').' <span class="opacitymedium">('.dol_print_date($_SESSION["totalchoixjour"][$i], '%A').')</span></td>';
611
612 //affichage des cases d'horaires
613 for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
614 if (isset($errheure[$i][$j]) /* && $errheure[$i][$j] */) {
615 // When an error is found, the checkbox background is red
616 print '<td><input type=text size="10" maxlength="11" name=horaires'.$i.'[] value="'.$_SESSION["horaires$i"][$j].'" style="background-color:#FF6666;"></td>'."\n";
617 } else {
618 // Else the color is empty (in principle)
619 print '<td><input type=text size="10" maxlength="11" name=horaires'.$i.'[] value="'.$_SESSION["horaires$i"][$j].'"></td>'."\n";
620 }
621 }
622 print '</tr>'."\n";
623 }
624
625 print '</table>'."\n";
626 print '</div>';
627
628 // show buttons to cancel, delete days or create survey
629 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
630 print '<input type="submit" class="button small" name="reset" value="'.dol_escape_htmltag($langs->trans("RemoveAllDays")).'">';
631 print '<input type="submit" class="button small" name="reporterhoraires" value="'.dol_escape_htmltag($langs->trans("CopyHoursOfFirstDay")).'">';
632 print '<input type="submit" class="button small" name="resethoraires" value="'.dol_escape_htmltag($langs->trans("RemoveAllHours")).'">'."\n";
633 print '<br><br>'."\n";
634 print '<input type="submit" class="button" name="confirmation" value="'.$langs->trans("CreatePoll").'">'."\n";
635 print '</div>';
636}
637
638print '</tr>'."\n";
639print '</table>'."\n";
640print '<a name="bas"></a>'."\n";
641//fin du formulaire et bandeau de pied
642print '</form>'."\n";
643//bandeau de pied
644print '<br><br><br><br>'."\n";
645print '</div></div>'."\n";
646
647// End of page
648llxFooter();
649$db->close();
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition date.lib.php:603
dol_now($mode='gmt')
Return date for now.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.
if(getDolGlobalString( 'TAKEPOS_SHOW_CUSTOMER')) print $langs trans('Date')." left Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
Definition receipt.php:464
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.