26require
'../../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
28require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
29require_once DOL_DOCUMENT_ROOT.
"/opensurvey/lib/opensurvey.lib.php";
32if (!$user->rights->opensurvey->write) {
37$_SESSION[
"formatsondage"] =
"D";
49 if (issetAndNoEmpty(
'totalchoixjour', $_SESSION) ===
true && issetAndNoEmpty(
'nbrecaseshoraires', $_SESSION) ===
true) {
50 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
53 if ($nbofchoice * $_SESSION[
"nbrecaseshoraires"] > 200) {
57 for ($i = 0; $i < $nbofchoice; $i++) {
59 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
60 $horairesi =
GETPOST(
"horaires".$i);
61 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
63 $tmphorairesi =
GETPOST(
'horaires'.$i,
'array');
65 if (!is_array($tmphorairesi)) {
66 $errheure[$i][$j] =
true;
74 if (preg_match(
"/(\d{1,2}:\d{2})-(\d{1,2}:\d{2})/", $tmphorairesi[$j], $creneaux)) {
76 $debutcreneau = explode(
":", $creneaux[1]);
77 $fincreneau = explode(
":", $creneaux[2]);
81 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]))) {
82 $_SESSION[
"horaires$i"][$j] = $creneaux[1].
'-'.$creneaux[2];
84 $errheure[$i][$j] =
true;
87 } elseif (preg_match(
";^(\d{1,2}h\d{0,2})-(\d{1,2}h\d{0,2})$;i", $tmphorairesi[$j], $creneaux)) {
89 $debutcreneau = preg_split(
"/h/i", $creneaux[1]);
90 $fincreneau = preg_split(
"/h/i", $creneaux[2]);
94 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]))) {
95 $_SESSION[
"horaires$i"][$j] = $creneaux[1].
'-'.$creneaux[2];
97 $errheure[$i][$j] =
true;
100 } elseif (preg_match(
";^(\d{1,2}):(\d{2})$;", $tmphorairesi[$j], $heures)) {
102 if ($heures[1] < 24 && $heures[2] < 60) {
103 $_SESSION[
"horaires$i"][$j] = $heures[0];
105 $errheure[$i][$j] =
true;
108 } elseif (preg_match(
";^(\d{1,2})h(\d{0,2})$;i", $tmphorairesi[$j], $heures)) {
110 if ($heures[1] < 24 && $heures[2] < 60) {
111 $_SESSION[
"horaires$i"][$j] = $heures[0];
113 $errheure[$i][$j] =
true;
116 } elseif (preg_match(
";^(\d{1,2})-(\d{1,2})$;", $tmphorairesi[$j], $heures)) {
118 if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) {
119 $_SESSION[
"horaires$i"][$j] = $heures[0];
121 $errheure[$i][$j] =
true;
124 } elseif (preg_match(
";^(\d{1,2})h-(\d{1,2})h$;", $tmphorairesi[$j], $heures)) {
126 if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) {
127 $_SESSION[
"horaires$i"][$j] = $heures[0];
129 $errheure[$i][$j] =
true;
132 } elseif ($tmphorairesi[$j] ==
"") {
133 unset($_SESSION[
"horaires$i"][$j]);
135 $errheure[$i][$j] =
true;
139 if (issetAndNoEmpty(
'horaires'.$i, $_SESSION) ===
false || issetAndNoEmpty($j, $_SESSION[
'horaires'.$i]) ===
false) {
140 if (issetAndNoEmpty(
'horaires'.$i, $_SESSION) ===
true) {
141 $_SESSION[
"horaires$i"][$j] =
'';
143 $_SESSION[
"horaires$i"] = array();
144 $_SESSION[
"horaires$i"][$j] =
'';
149 if ($_SESSION[
"horaires$i"][0] ==
"" && $_SESSION[
"horaires$i"][1] ==
"" && $_SESSION[
"horaires$i"][2] ==
"" && $_SESSION[
"horaires$i"][3] ==
"" && $_SESSION[
"horaires$i"][4] ==
"") {
151 $choixdate .= $_SESSION[
"totalchoixjour"][$i];
153 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
154 if ($_SESSION[
"horaires$i"][$j] !=
"") {
156 $choixdate .= $_SESSION[
"totalchoixjour"][$i];
159 $choixdate .= str_replace(array(
',',
'@'), array(
',',
'@'), $_SESSION[
"horaires$i"][$j]);
167 if (!empty($errheure)) {
173 $tmphoraires0 =
GETPOST(
'horaires0',
'array');
174 if (count($_SESSION[
"totalchoixjour"]) ==
"1" && $tmphoraires0[0] ==
"" && $tmphoraires0[1] ==
"" && $tmphoraires0[2] ==
"" && $tmphoraires0[3] ==
"" && $tmphoraires0[4] ==
"") {
180 if (!$erreur && $erreurNb == 0) {
181 $_SESSION[
"toutchoix"] = substr(
"$choixdate", 1);
182 unset($_SESSION[
"nbrecaseshoraires"]);
190 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
191 for ($i = 0; $i < $nbofchoice; $i++) {
192 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
193 unset($_SESSION[
"horaires$i"][$j]);
197 unset($_SESSION[
"totalchoixjour"]);
198 unset($_SESSION[
"nbrecaseshoraires"]);
207if (!isset($_SESSION[
'description']) && !isset($_SESSION[
'mail'])) {
213$arrayofcss = array(
'/opensurvey/css/style.css');
214llxHeader(
'', $langs->trans(
"OpenSurvey"),
"",
'', 0, 0, $arrayofjs, $arrayofcss);
217if (!isset($_SESSION[
"nbrecaseshoraires"])) {
218 $_SESSION[
"nbrecaseshoraires"] = 5;
219} elseif ((
GETPOST(
'ajoutcases') ||
GETPOST(
"ajoutcases_y")) && $_SESSION[
"nbrecaseshoraires"] == 5) {
220 $_SESSION[
"nbrecaseshoraires"] = 10;
222 if (issetAndNoEmpty(
'totalchoixjour', $_SESSION) ===
true) {
223 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
224 for ($i = 0; $i < $nbofchoice; $i++) {
226 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
227 $horairesi =
GETPOST(
"horaires".$i);
228 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
241if (!isset($_SESSION[
'jour'])) {
242 $_SESSION[
'jour'] = date(
'j');
244if (!isset($_SESSION[
'mois'])) {
245 $_SESSION[
'mois'] = date(
'n');
247if (!isset($_SESSION[
'annee'])) {
248 $_SESSION[
'annee'] = date(
'Y');
252if (!issetAndNoEmpty(
'choixjourajout') && !issetAndNoEmpty(
'choixjourretrait') && (issetAndNoEmpty(
'retourmois') || issetAndNoEmpty(
'retourmois_x'))) {
253 $_SESSION[
"jour"] = date(
"j");
254 $_SESSION[
"mois"] = date(
"n");
255 $_SESSION[
"annee"] = date(
"Y");
259if (issetAndNoEmpty(
'moisavant_x') || issetAndNoEmpty(
'moisavant')) {
260 if ($_SESSION[
"mois"] == 1) {
261 $_SESSION[
"mois"] = 12;
262 $_SESSION[
"annee"] = $_SESSION[
"annee"] - 1;
264 $_SESSION[
"mois"] -= 1;
268 if (issetAndNoEmpty(
'totalchoixjour', $_SESSION) ===
true) {
269 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
270 for ($i = 0; $i < $nbofchoice; $i++) {
272 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
273 $horairesi =
GETPOST(
"horaires".$i);
274 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
281if (issetAndNoEmpty(
'moisapres_x') || issetAndNoEmpty(
'moisapres')) {
282 if ($_SESSION[
"mois"] == 12) {
283 $_SESSION[
"mois"] = 1;
284 $_SESSION[
"annee"] += 1;
286 $_SESSION[
"mois"] += 1;
290 if (issetAndNoEmpty(
'totalchoixjour', $_SESSION) ===
true) {
291 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
292 for ($i = 0; $i < $nbofchoice; $i++) {
294 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
295 $horairesi =
GETPOST(
"horaires".$i);
296 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
303if (issetAndNoEmpty(
'anneeavant_x') || issetAndNoEmpty(
'anneeavant')) {
304 $_SESSION[
"annee"] -= 1;
307 if (issetAndNoEmpty(
'totalchoixjour', $_SESSION) ===
true) {
308 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
309 for ($i = 0; $i < $nbofchoice; $i++) {
311 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
312 $horairesi =
GETPOST(
"horaires".$i);
313 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
320if (issetAndNoEmpty(
'anneeapres_x') || issetAndNoEmpty(
'anneeapres')) {
321 $_SESSION[
"annee"] += 1;
324 if (issetAndNoEmpty(
'totalchoixjour', $_SESSION) ===
true) {
325 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
326 for ($i = 0; $i < $nbofchoice; $i++) {
328 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
329 $horairesi =
GETPOST(
"horaires".$i);
330 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
337$nbrejourmois = date(
"t", mktime(0, 0, 0, $_SESSION[
"mois"], 1, $_SESSION[
"annee"]));
338$premierjourmois = date(
"N", mktime(0, 0, 0, $_SESSION[
"mois"], 1, $_SESSION[
"annee"])) - 1;
341if (is_integer($_SESSION[
"mois"]) && $_SESSION[
"mois"] > 0 && $_SESSION[
"mois"] < 13) {
342 $motmois =
dol_print_date(mktime(0, 0, 0, $_SESSION[
"mois"], 10),
'%B');
349print
'<form name="formulaire" action="" method="POST">'.
"\n";
350print
'<input type="hidden" name="token" value="'.newToken().
'">';
355print
'<div class="bodydate">'.
"\n";
356print $langs->trans(
"OpenSurveyStep2").
"\n";
360print
'<div class="corps">'.
"\n";
361print
'<div class="center">'.
"\n";
362print
'<table align="center">'.
"\n";
363print
'<tr><td><input type="image" class="buttonwebsite" name="anneeavant" value="<<" src="../img/rewind.png"></td>';
364print
'<td><input type="image" class="buttonwebsite" name="moisavant" value="<" src="../img/previous.png"></td>';
365print
'<td width="150px" class="center"> '.$motmois.
' '.$_SESSION[
"annee"].
'<br>';
366print
'<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).
'">';
368print
'<td><input type="image" class="buttonwebsite" name="moisapres" value=">" src="../img/next.png"></td>';
369print
'<td><input type="image" class="buttonwebsite" name="anneeapres" value=">>" src="../img/fforward.png"></td><td></td><td></td><td></td><td></td><td></td><td>';
370print
'</td></tr>'.
"\n";
371print
'</table>'.
"\n";
374print
'<div class="center calendrier">'.
"\n";
375print
'<table align="center">'.
"\n";
379for ($i = 0; $i < 7; $i++) {
380 print
'<td align="center" class="joursemaine">'.dol_print_date(mktime(0, 0, 0, 0, $i, 10),
'%A').
'</td>';
386if (issetAndNoEmpty(
'choixjourajout')) {
387 if (!isset($_SESSION[
"totalchoixjour"])) {
388 $_SESSION[
"totalchoixjour"] = array();
393 if (issetAndNoEmpty(
'totalchoixjour', $_SESSION) ===
true && issetAndNoEmpty(
'choixjourajout') ===
true) {
394 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
395 for ($i = 0; $i < $nbofchoice; $i++) {
396 $choixjourajout =
GETPOST(
"choixjourajout");
397 if ($_SESSION[
"totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION[
"mois"], $choixjourajout[0], $_SESSION[
"annee"])) {
404 if ($journeuf && issetAndNoEmpty(
'choixjourajout') ===
true) {
405 $choixjourajout =
GETPOST(
"choixjourajout");
406 array_push($_SESSION[
"totalchoixjour"],
dol_mktime(0, 0, 0, $_SESSION[
"mois"], $choixjourajout[0], $_SESSION[
"annee"]));
407 sort($_SESSION[
"totalchoixjour"]);
408 $cle = array_search(
dol_mktime(0, 0, 0, $_SESSION[
"mois"], $choixjourajout[0], $_SESSION[
"annee"]), $_SESSION[
"totalchoixjour"]);
411 for ($i = 0; $i < $cle; $i++) {
412 $horairesi =
GETPOST(
"horaires".$i);
413 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
414 if (issetAndNoEmpty(
'horaires'.$i) ===
true && issetAndNoEmpty($i, $_POST[
'horaires'.$i]) ===
true) {
415 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
420 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
421 for ($i = $cle; $i < $nbofchoice; $i++) {
423 if (issetAndNoEmpty(
'horaires'.$i) ===
true && issetAndNoEmpty($i, $_POST[
'horaires'.$i]) ===
true) {
424 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
425 $horairesi =
GETPOST(
"horaires".$i,
'array');
426 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
431 unset($_SESSION[
"horaires$cle"]);
436if (issetAndNoEmpty(
'choixjourretrait')) {
438 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
439 for ($i = 0; $i < $nbofchoice; $i++) {
441 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
442 $horairesi =
GETPOST(
"horaires".$i);
443 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
447 for ($i = 0; $i < $nbofchoice; $i++) {
448 $choixjourretrait =
GETPOST(
'choixjourretrait');
449 if ($_SESSION[
"totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION[
"mois"], $choixjourretrait[0], $_SESSION[
"annee"])) {
450 for ($j = $i; $j < $nbofchoice; $j++) {
452 $_SESSION[
"horaires$j"] = $_SESSION[
"horaires$k"];
455 array_splice($_SESSION[
"totalchoixjour"], $i, 1);
461if (issetAndNoEmpty(
'reporterhoraires')) {
462 $_SESSION[
"horaires0"] =
GETPOST(
"horaires0");
463 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
464 for ($i = 0; $i < $nbofchoice; $i++) {
466 $_SESSION[
"horaires$j"] = $_SESSION[
"horaires$i"];
471if (issetAndNoEmpty(
'resethoraires')) {
472 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
473 for ($i = 0; $i < $nbofchoice; $i++) {
474 unset($_SESSION[
"horaires$i"]);
481for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) {
482 $numerojour = $i - $premierjourmois + 1;
485 if (($i % 7) == 0 && $i != 0) {
486 print
'</tr><tr>'.
"\n";
490 if ($i < $premierjourmois) {
491 print
'<td class="avant"></td>'.
"\n";
493 if (issetAndNoEmpty(
'totalchoixjour', $_SESSION) ===
true) {
494 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
495 for ($j = 0; $j < $nbofchoice; $j++) {
497 if (date(
"j", $_SESSION[
"totalchoixjour"][$j]) == $numerojour && date(
"n", $_SESSION[
"totalchoixjour"][$j]) == $_SESSION[
"mois"] && date(
"Y", $_SESSION[
"totalchoixjour"][$j]) == $_SESSION[
"annee"]) {
498 print
'<td align="center" class="choisi"><input type="submit" class="bouton OFF centpercent nomarginleft buttonwebsite" name="choixjourretrait[]" value="'.$numerojour.
'"></td>'.
"\n";
499 $dejafait = $numerojour;
505 if (isset($dejafait) ===
false || $dejafait != $numerojour) {
507 if (($numerojour >= $jourAJ && $_SESSION[
"mois"] == $moisAJ && $_SESSION[
"annee"] == $anneeAJ) || ($_SESSION[
"mois"] > $moisAJ && $_SESSION[
"annee"] == $anneeAJ) || $_SESSION[
"annee"] > $anneeAJ) {
508 print
'<td class="center libre"><input type="submit" class="bouton ON centpercent nomarginleft buttonwebsite" name="choixjourajout[]" value="'.$numerojour.
'"></td>'.
"\n";
511 print
'<td class="center avant">'.$numerojour.
'</td>'.
"\n";
519print
'</table>'.
"\n";
520print
'</div></div>'.
"\n";
522print
'<div class="bodydate"><div class="center">'.
"\n";
525if (issetAndNoEmpty(
'totalchoixjour', $_SESSION) || $erreur) {
528 print
'<div align="left">';
529 print
'<strong>'.$langs->trans(
"SelectedDays").
':</strong>'.
"<br>\n";
530 print $langs->trans(
"SelectDayDesc").
"<br>\n";
533 print
'<table>'.
"\n";
535 print
'<td></td>'.
"\n";
537 for ($i = 0; $i < $_SESSION[
"nbrecaseshoraires"]; $i++) {
539 print
'<td classe="somme"><div class="center">'.$langs->trans(
"Time").
' '.$j.
'</div></td>'.
"\n";
542 if ($_SESSION[
"nbrecaseshoraires"] < 10) {
543 print
'<td classe="somme"><input type="image" name="ajoutcases" src="../img/add-16.png"></td>'.
"\n";
550 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
552 for ($i = 0; $i < $nbofchoice; $i++) {
554 print
'<td class="left">'.dol_print_date($_SESSION[
"totalchoixjour"][$i],
'daytext').
' <span class="opacitymedium">('.
dol_print_date($_SESSION[
"totalchoixjour"][$i],
'%A').
')</span></td>';
557 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
559 if (isset($errheure[$i][$j]) && $errheure[$i][$j]) {
560 print
'<td><input type=text size="10" maxlength="11" name=horaires'.$i.
'[] value="'.$_SESSION[
"horaires$i"][$j].
'" style="background-color:#FF6666;"></td>'.
"\n";
563 print
'<td><input type=text size="10" maxlength="11" name=horaires'.$i.
'[] value="'.$_SESSION[
"horaires$i"][$j].
'"></td>'.
"\n";
569 print
'</table>'.
"\n";
572 print
'<table>'.
"\n";
574 print
'<td><input type="submit" class="button small" name="reset" value="'.dol_escape_htmltag($langs->trans(
"RemoveAllDays")).
'"></td>';
575 print
'<td><input type="submit" class="button small" name="reporterhoraires" value="'.dol_escape_htmltag($langs->trans(
"CopyHoursOfFirstDay")).
'"></td>';
576 print
'<td><input type="submit" class="button small" name="resethoraires" value="'.dol_escape_htmltag($langs->trans(
"RemoveAllHours")).
'"></td></tr>'.
"\n";
577 print
'<tr><td colspan="3"><br><br></td></tr>'.
"\n";
578 print
'<tr><td colspan="3" align="center"><input type="submit" class="button" name="confirmation" value="'.$langs->trans(
"CreatePoll").
'"></td></tr>'.
"\n";
579 print
'</table>'.
"\n";
583print
'</table>'.
"\n";
584print
'<a name=bas></a>'.
"\n";
588print
'<br><br><br><br>'.
"\n";
589print
'</div></div>'.
"\n";
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.