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";
33if (!$user->hasRight(
'opensurvey',
'write')) {
38$_SESSION[
"formatsondage"] =
"D";
53 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
56 if ($nbofchoice * $_SESSION[
"nbrecaseshoraires"] > 200) {
60 for ($i = 0; $i < $nbofchoice; $i++) {
62 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
63 $horairesi =
GETPOST(
"horaires".$i);
64 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
66 $tmphorairesi =
GETPOST(
'horaires'.$i,
'array');
68 if (!is_array($tmphorairesi)) {
69 $errheure[$i][$j] =
true;
77 if (preg_match(
"/(\d{1,2}:\d{2})-(\d{1,2}:\d{2})/", $tmphorairesi[$j], $creneaux)) {
79 $debutcreneau = explode(
":", $creneaux[1]);
80 $fincreneau = explode(
":", $creneaux[2]);
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];
87 $errheure[$i][$j] =
true;
90 } elseif (preg_match(
";^(\d{1,2}h\d{0,2})-(\d{1,2}h\d{0,2})$;i", $tmphorairesi[$j], $creneaux)) {
92 $debutcreneau = preg_split(
"/h/i", $creneaux[1]);
93 $fincreneau = preg_split(
"/h/i", $creneaux[2]);
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];
100 $errheure[$i][$j] =
true;
103 } elseif (preg_match(
";^(\d{1,2}):(\d{2})$;", $tmphorairesi[$j], $heures)) {
105 if ($heures[1] < 24 && $heures[2] < 60) {
106 $_SESSION[
"horaires$i"][$j] = $heures[0];
108 $errheure[$i][$j] =
true;
111 } elseif (preg_match(
";^(\d{1,2})h(\d{0,2})$;i", $tmphorairesi[$j], $heures)) {
113 if ($heures[1] < 24 && $heures[2] < 60) {
114 $_SESSION[
"horaires$i"][$j] = $heures[0];
116 $errheure[$i][$j] =
true;
119 } elseif (preg_match(
";^(\d{1,2})-(\d{1,2})$;", $tmphorairesi[$j], $heures)) {
121 if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) {
122 $_SESSION[
"horaires$i"][$j] = $heures[0];
124 $errheure[$i][$j] =
true;
127 } elseif (preg_match(
";^(\d{1,2})h-(\d{1,2})h$;", $tmphorairesi[$j], $heures)) {
129 if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) {
130 $_SESSION[
"horaires$i"][$j] = $heures[0];
132 $errheure[$i][$j] =
true;
135 } elseif ($tmphorairesi[$j] ==
"") {
136 unset($_SESSION[
"horaires$i"][$j]);
138 $errheure[$i][$j] =
true;
144 $_SESSION[
"horaires$i"][$j] =
'';
146 $_SESSION[
"horaires$i"] = array();
147 $_SESSION[
"horaires$i"][$j] =
'';
152 if ($_SESSION[
"horaires$i"][0] ==
"" && $_SESSION[
"horaires$i"][1] ==
"" && $_SESSION[
"horaires$i"][2] ==
"" && $_SESSION[
"horaires$i"][3] ==
"" && $_SESSION[
"horaires$i"][4] ==
"") {
154 $choixdate .= $_SESSION[
"totalchoixjour"][$i];
156 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
157 if ($_SESSION[
"horaires$i"][$j] !=
"") {
159 $choixdate .= $_SESSION[
"totalchoixjour"][$i];
162 $choixdate .= str_replace(array(
',',
'@'), array(
',',
'@'), $_SESSION[
"horaires$i"][$j]);
170 if (!empty($errheure)) {
176 $tmphoraires0 =
GETPOST(
'horaires0',
'array');
177 if (count($_SESSION[
"totalchoixjour"]) ==
"1" && $tmphoraires0[0] ==
"" && $tmphoraires0[1] ==
"" && $tmphoraires0[2] ==
"" && $tmphoraires0[3] ==
"" && $tmphoraires0[4] ==
"") {
183 if (!$erreur && $erreurNb == 0) {
184 $_SESSION[
"toutchoix"] = substr($choixdate, 1);
185 unset($_SESSION[
"nbrecaseshoraires"]);
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]);
200 unset($_SESSION[
"totalchoixjour"]);
201 unset($_SESSION[
"nbrecaseshoraires"]);
210if (!isset($_SESSION[
'description']) && !isset($_SESSION[
'mail'])) {
211 dol_print_error(
null, $langs->trans(
'ErrorOpenSurveyFillFirstSection'));
216$arrayofcss = array(
'/opensurvey/css/style.css');
217llxHeader(
'', $langs->trans(
"OpenSurvey"),
"",
'', 0, 0, $arrayofjs, $arrayofcss);
220if (!isset($_SESSION[
"nbrecaseshoraires"])) {
221 $_SESSION[
"nbrecaseshoraires"] = 5;
222} elseif ((
GETPOST(
'ajoutcases') ||
GETPOST(
"ajoutcases_y")) && $_SESSION[
"nbrecaseshoraires"] == 5) {
223 $_SESSION[
"nbrecaseshoraires"] = 10;
226 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
227 for ($i = 0; $i < $nbofchoice; $i++) {
229 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
230 $horairesi =
GETPOST(
"horaires".$i);
231 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
244if (!isset($_SESSION[
'jour'])) {
245 $_SESSION[
'jour'] = date(
'j');
247if (!isset($_SESSION[
'mois'])) {
248 $_SESSION[
'mois'] = date(
'n');
250if (!isset($_SESSION[
'annee'])) {
251 $_SESSION[
'annee'] = date(
'Y');
256 $_SESSION[
"jour"] = date(
"j");
257 $_SESSION[
"mois"] = date(
"n");
258 $_SESSION[
"annee"] = date(
"Y");
263 if ($_SESSION[
"mois"] == 1) {
264 $_SESSION[
"mois"] = 12;
265 $_SESSION[
"annee"] -= 1;
267 $_SESSION[
"mois"] -= 1;
272 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
273 for ($i = 0; $i < $nbofchoice; $i++) {
275 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
276 $horairesi =
GETPOST(
"horaires".$i);
277 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
285 if ($_SESSION[
"mois"] == 12) {
286 $_SESSION[
"mois"] = 1;
287 $_SESSION[
"annee"] += 1;
289 $_SESSION[
"mois"] += 1;
294 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
295 for ($i = 0; $i < $nbofchoice; $i++) {
297 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
298 $horairesi =
GETPOST(
"horaires".$i);
299 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
307 $_SESSION[
"annee"] -= 1;
311 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
312 for ($i = 0; $i < $nbofchoice; $i++) {
314 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
315 $horairesi =
GETPOST(
"horaires".$i);
316 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
324 $_SESSION[
"annee"] += 1;
328 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
329 for ($i = 0; $i < $nbofchoice; $i++) {
331 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
332 $horairesi =
GETPOST(
"horaires".$i);
333 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
340$nbrejourmois = idate(
"t",
dol_get_first_day((
int) $_SESSION[
"annee"], (
int) $_SESSION[
"mois"]));
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');
356print
'<form name="formulaire" action="" method="POST">'.
"\n";
357print
'<input type="hidden" name="token" value="'.newToken().
'">';
362print
'<div class="bodydate">'.
"\n";
363print $langs->trans(
"OpenSurveyStep2").
"\n";
367print
'<div class="corps">'.
"\n";
368print
'<div class="center">'.
"\n";
369print
'<table class="center">'.
"\n";
372print
'<button type="submit" name="anneeavant" value="<<">'.img_picto($langs->trans(
"PreviousYear"),
'chevron-double-left',
'class="double"').
'</button>';
376print
'<button type="submit" name="moisavant" value="<">'.img_picto($langs->trans(
"PreviousMonth"),
'chevron-left',
'class="double"').
'</button>';
379print
'<td width="150px" class="center size15x">'.$motmois.
' '.$_SESSION[
"annee"].
'<br>';
383print
'<button type="submit" name="moisapres" value=">">'.img_picto($langs->trans(
"NextMonth"),
'chevron-right',
'class="double"').
'</button>';
387print
'<button type="submit" name="anneeapres" value=">>">'.img_picto($langs->trans(
"NextYear"),
'chevron-double-right',
'class="double"').
'</button>';
389print
'</td></tr>'.
"\n";
390print
'</table>'.
"\n";
395print
'<div class="center calendrier">'.
"\n";
396print
'<table class="center">'.
"\n";
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'));
410 if (!isset($_SESSION[
"totalchoixjour"])) {
411 $_SESSION[
"totalchoixjour"] = array();
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"])) {
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"]);
434 for ($i = 0; $i < $cle; $i++) {
435 $horairesi =
GETPOST(
"horaires".$i);
436 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
438 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
443 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
444 for ($i = $cle; $i < $nbofchoice; $i++) {
447 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
448 $horairesi =
GETPOST(
"horaires".$i,
'array');
449 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
454 unset($_SESSION[
"horaires$cle"]);
461 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
462 for ($i = 0; $i < $nbofchoice; $i++) {
464 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
465 $horairesi =
GETPOST(
"horaires".$i);
466 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
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++) {
475 $_SESSION[
"horaires$j"] = $_SESSION[
"horaires$k"];
478 array_splice($_SESSION[
"totalchoixjour"], $i, 1);
485 $_SESSION[
"horaires0"] =
GETPOST(
"horaires0");
486 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
487 for ($i = 0; $i < $nbofchoice; $i++) {
489 $_SESSION[
"horaires$j"] = $_SESSION[
"horaires$i"];
495 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
496 for ($i = 0; $i < $nbofchoice; $i++) {
497 unset($_SESSION[
"horaires$i"]);
504for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) {
505 $numerojour = $i - $premierjourmois + 1;
508 if (($i % 7) == 0 && $i != 0) {
509 print
'</tr><tr>'.
"\n";
513 if ($i < $premierjourmois) {
514 print
'<td class="avant"></td>'.
"\n";
517 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
518 for ($j = 0; $j < $nbofchoice; $j++) {
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;
528 if (isset($dejafait) ===
false || $dejafait != $numerojour) {
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";
534 print
'<td class="center avant">'.$numerojour.
'</td>'.
"\n";
542print
'</table>'.
"\n";
543print
'</div></div>'.
"\n";
545print
'<div class="bodydate"><div class="center">'.
"\n";
551 print
'<div align="left">';
552 print
'<strong>'.$langs->trans(
"SelectedDays").
':</strong>'.
"<br>\n";
553 print $langs->trans(
"SelectDayDesc").
"<br>\n";
556 print
'<div class="div-table-responsive">';
557 print
'<table>'.
"\n";
559 print
'<td></td>'.
"\n";
561 for ($i = 0; $i < $_SESSION[
"nbrecaseshoraires"]; $i++) {
563 print
'<td class="somme"><div class="center">'.$langs->trans(
"Time").
' '.$j.
'</div></td>'.
"\n";
566 if ($_SESSION[
"nbrecaseshoraires"] < 10) {
567 print
'<td class="somme"><input type="image" name="ajoutcases" src="../img/add-16.png"></td>'.
"\n";
574 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
576 for ($i = 0; $i < $nbofchoice; $i++) {
578 print
'<td class="left">'.dol_print_date($_SESSION[
"totalchoixjour"][$i],
'daytext').
' <span class="opacitymedium">('.
dol_print_date($_SESSION[
"totalchoixjour"][$i],
'%A').
')</span></td>';
581 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
582 if (isset($errheure[$i][$j]) && $errheure[$i][$j]) {
584 print
'<td><input type=text size="10" maxlength="11" name=horaires'.$i.
'[] value="'.$_SESSION[
"horaires$i"][$j].
'" style="background-color:#FF6666;"></td>'.
"\n";
587 print
'<td><input type=text size="10" maxlength="11" name=horaires'.$i.
'[] value="'.$_SESSION[
"horaires$i"][$j].
'"></td>'.
"\n";
593 print
'</table>'.
"\n";
597 print
'<br><div class="div-table-responsive">';
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";
607print
'</table>'.
"\n";
608print
'<a name="bas"></a>'.
"\n";
612print
'<br><br><br><br>'.
"\n";
613print
'</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_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
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.