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";
34if (!$user->hasRight(
'opensurvey',
'write')) {
39$_SESSION[
"formatsondage"] =
"D";
54 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
57 if ($nbofchoice * $_SESSION[
"nbrecaseshoraires"] > 200) {
61 for ($i = 0; $i < $nbofchoice; $i++) {
63 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
64 $horairesi =
GETPOST(
"horaires".$i);
65 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
67 $tmphorairesi =
GETPOST(
'horaires'.$i,
'array');
69 if (!is_array($tmphorairesi)) {
70 $errheure[$i][$j] =
true;
78 if (preg_match(
"/(\d{1,2}:\d{2})-(\d{1,2}:\d{2})/", $tmphorairesi[$j], $creneaux)) {
80 $debutcreneau = explode(
":", $creneaux[1]);
81 $fincreneau = explode(
":", $creneaux[2]);
85 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]))) {
86 $_SESSION[
"horaires$i"][$j] = $creneaux[1].
'-'.$creneaux[2];
88 $errheure[$i][$j] =
true;
91 } elseif (preg_match(
";^(\d{1,2}h\d{0,2})-(\d{1,2}h\d{0,2})$;i", $tmphorairesi[$j], $creneaux)) {
93 $debutcreneau = preg_split(
"/h/i", $creneaux[1]);
94 $fincreneau = preg_split(
"/h/i", $creneaux[2]);
98 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]))) {
99 $_SESSION[
"horaires$i"][$j] = $creneaux[1].
'-'.$creneaux[2];
101 $errheure[$i][$j] =
true;
104 } elseif (preg_match(
";^(\d{1,2}):(\d{2})$;", $tmphorairesi[$j], $heures)) {
106 if ($heures[1] < 24 && $heures[2] < 60) {
107 $_SESSION[
"horaires$i"][$j] = $heures[0];
109 $errheure[$i][$j] =
true;
112 } elseif (preg_match(
";^(\d{1,2})h(\d{0,2})$;i", $tmphorairesi[$j], $heures)) {
114 if ($heures[1] < 24 && $heures[2] < 60) {
115 $_SESSION[
"horaires$i"][$j] = $heures[0];
117 $errheure[$i][$j] =
true;
120 } elseif (preg_match(
";^(\d{1,2})-(\d{1,2})$;", $tmphorairesi[$j], $heures)) {
122 if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) {
123 $_SESSION[
"horaires$i"][$j] = $heures[0];
125 $errheure[$i][$j] =
true;
128 } elseif (preg_match(
";^(\d{1,2})h-(\d{1,2})h$;", $tmphorairesi[$j], $heures)) {
130 if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) {
131 $_SESSION[
"horaires$i"][$j] = $heures[0];
133 $errheure[$i][$j] =
true;
136 } elseif ($tmphorairesi[$j] ==
"") {
137 unset($_SESSION[
"horaires$i"][$j]);
139 $errheure[$i][$j] =
true;
145 $_SESSION[
"horaires$i"][$j] =
'';
147 $_SESSION[
"horaires$i"] = array();
148 $_SESSION[
"horaires$i"][$j] =
'';
154 if ($_SESSION[
"horaires$i"][0] ==
"" && $_SESSION[
"horaires$i"][1] ==
"" && $_SESSION[
"horaires$i"][2] ==
"" && $_SESSION[
"horaires$i"][3] ==
"" && $_SESSION[
"horaires$i"][4] ==
"") {
156 $choixdate .= $_SESSION[
"totalchoixjour"][$i];
158 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
159 if ($_SESSION[
"horaires$i"][$j] !=
"") {
161 $choixdate .= $_SESSION[
"totalchoixjour"][$i];
164 $choixdate .= str_replace(array(
',',
'@'), array(
',',
'@'), $_SESSION[
"horaires$i"][$j]);
172 if (!empty($errheure)) {
178 $tmphoraires0 =
GETPOST(
'horaires0',
'array');
179 if (count($_SESSION[
"totalchoixjour"]) ==
"1" && $tmphoraires0[0] ==
"" && $tmphoraires0[1] ==
"" && $tmphoraires0[2] ==
"" && $tmphoraires0[3] ==
"" && $tmphoraires0[4] ==
"") {
185 if (!$erreur && $erreurNb == 0) {
186 $_SESSION[
"toutchoix"] = substr($choixdate, 1);
187 unset($_SESSION[
"nbrecaseshoraires"]);
195 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
196 for ($i = 0; $i < $nbofchoice; $i++) {
197 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
198 unset($_SESSION[
"horaires$i"][$j]);
202 unset($_SESSION[
"totalchoixjour"]);
203 unset($_SESSION[
"nbrecaseshoraires"]);
212if (!isset($_SESSION[
'description']) && !isset($_SESSION[
'mail'])) {
213 dol_print_error(
null, $langs->trans(
'ErrorOpenSurveyFillFirstSection'));
218$arrayofcss = array(
'/opensurvey/css/style.css');
219llxHeader(
'', $langs->trans(
"OpenSurvey"),
"",
'', 0, 0, $arrayofjs, $arrayofcss);
222if (!isset($_SESSION[
"nbrecaseshoraires"])) {
223 $_SESSION[
"nbrecaseshoraires"] = 5;
224} elseif ((
GETPOST(
'ajoutcases') ||
GETPOST(
"ajoutcases_y")) && $_SESSION[
"nbrecaseshoraires"] == 5) {
225 $_SESSION[
"nbrecaseshoraires"] = 10;
228 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
229 for ($i = 0; $i < $nbofchoice; $i++) {
231 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
232 $horairesi =
GETPOST(
"horaires".$i);
233 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
246if (!isset($_SESSION[
'jour'])) {
247 $_SESSION[
'jour'] = date(
'j');
249if (!isset($_SESSION[
'mois'])) {
250 $_SESSION[
'mois'] = date(
'n');
252if (!isset($_SESSION[
'annee'])) {
253 $_SESSION[
'annee'] = date(
'Y');
258 $_SESSION[
"jour"] = date(
"j");
259 $_SESSION[
"mois"] = date(
"n");
260 $_SESSION[
"annee"] = date(
"Y");
265 if ($_SESSION[
"mois"] == 1) {
266 $_SESSION[
"mois"] = 12;
267 $_SESSION[
"annee"] -= 1;
269 $_SESSION[
"mois"] -= 1;
274 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
275 for ($i = 0; $i < $nbofchoice; $i++) {
277 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
278 $horairesi =
GETPOST(
"horaires".$i);
279 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
287 if ($_SESSION[
"mois"] == 12) {
288 $_SESSION[
"mois"] = 1;
289 $_SESSION[
"annee"] += 1;
291 $_SESSION[
"mois"] += 1;
296 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
297 for ($i = 0; $i < $nbofchoice; $i++) {
299 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
300 $horairesi =
GETPOST(
"horaires".$i);
301 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
309 $_SESSION[
"annee"] -= 1;
313 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
314 for ($i = 0; $i < $nbofchoice; $i++) {
316 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
317 $horairesi =
GETPOST(
"horaires".$i);
318 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
326 $_SESSION[
"annee"] += 1;
330 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
331 for ($i = 0; $i < $nbofchoice; $i++) {
333 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
334 $horairesi =
GETPOST(
"horaires".$i);
335 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
342$nbrejourmois = idate(
"t",
dol_get_first_day((
int) $_SESSION[
"annee"], (
int) $_SESSION[
"mois"]));
350if (is_int($_SESSION[
"mois"]) && $_SESSION[
"mois"] > 0 && $_SESSION[
"mois"] < 13) {
351 $motmois =
dol_print_date(mktime(0, 0, 0, (
int) $_SESSION[
"mois"], 10),
'%B');
358print
'<form name="formulaire" action="" method="POST">'.
"\n";
359print
'<input type="hidden" name="token" value="'.newToken().
'">';
364print
'<div class="bodydate">'.
"\n";
365print $langs->trans(
"OpenSurveyStep2").
"\n";
369print
'<div class="corps">'.
"\n";
370print
'<div class="center">'.
"\n";
371print
'<table class="center">'.
"\n";
374print
'<button type="submit" name="anneeavant" value="<<">'.img_picto($langs->trans(
"PreviousYear"),
'chevron-double-left',
'class="double"').
'</button>';
378print
'<button type="submit" name="moisavant" value="<">'.img_picto($langs->trans(
"PreviousMonth"),
'chevron-left',
'class="double"').
'</button>';
381print
'<td width="150px" class="center size15x">'.$motmois.
' '.$_SESSION[
"annee"].
'<br>';
385print
'<button type="submit" name="moisapres" value=">">'.img_picto($langs->trans(
"NextMonth"),
'chevron-right',
'class="double"').
'</button>';
389print
'<button type="submit" name="anneeapres" value=">>">'.img_picto($langs->trans(
"NextYear"),
'chevron-double-right',
'class="double"').
'</button>';
391print
'</td></tr>'.
"\n";
392print
'</table>'.
"\n";
397print
'<div class="center calendrier">'.
"\n";
398print
'<table class="center">'.
"\n";
402for ($i = 0; $i < 7; $i++) {
403 print
'<td class="center joursemaine">';
404 print
dol_print_date(mktime(0, 0, 0, 0, $i, 10), (empty($conf->dol_optimize_smallscreen) ?
'%A' :
'%a'));
412 if (!isset($_SESSION[
"totalchoixjour"])) {
413 $_SESSION[
"totalchoixjour"] = array();
419 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
420 for ($i = 0; $i < $nbofchoice; $i++) {
421 $choixjourajout =
GETPOST(
"choixjourajout");
422 if ($_SESSION[
"totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION[
"mois"], $choixjourajout[0], $_SESSION[
"annee"])) {
430 $choixjourajout =
GETPOST(
"choixjourajout");
431 array_push($_SESSION[
"totalchoixjour"],
dol_mktime(0, 0, 0, $_SESSION[
"mois"], $choixjourajout[0], $_SESSION[
"annee"]));
432 sort($_SESSION[
"totalchoixjour"]);
433 $cle = array_search(
dol_mktime(0, 0, 0, $_SESSION[
"mois"], $choixjourajout[0], $_SESSION[
"annee"]), $_SESSION[
"totalchoixjour"]);
436 for ($i = 0; $i < $cle; $i++) {
437 $horairesi =
GETPOST(
"horaires".$i);
438 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
440 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
445 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
446 for ($i = $cle; $i < $nbofchoice; $i++) {
449 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
450 $horairesi =
GETPOST(
"horaires".$i,
'array');
451 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
456 unset($_SESSION[
"horaires$cle"]);
463 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
464 for ($i = 0; $i < $nbofchoice; $i++) {
466 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
467 $horairesi =
GETPOST(
"horaires".$i);
468 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
472 for ($i = 0; $i < $nbofchoice; $i++) {
473 $choixjourretrait =
GETPOST(
'choixjourretrait');
474 if ($_SESSION[
"totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION[
"mois"], $choixjourretrait[0], $_SESSION[
"annee"])) {
475 for ($j = $i; $j < $nbofchoice; $j++) {
477 $_SESSION[
"horaires$j"] = $_SESSION[
"horaires$k"];
480 array_splice($_SESSION[
"totalchoixjour"], $i, 1);
487 $_SESSION[
"horaires0"] =
GETPOST(
"horaires0");
488 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
489 for ($i = 0; $i < $nbofchoice; $i++) {
491 $_SESSION[
"horaires$j"] = $_SESSION[
"horaires$i"];
497 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
498 for ($i = 0; $i < $nbofchoice; $i++) {
499 unset($_SESSION[
"horaires$i"]);
506for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) {
507 $numerojour = $i - $premierjourmois + 1;
510 if (($i % 7) == 0 && $i != 0) {
511 print
'</tr><tr>'.
"\n";
515 if ($i < $premierjourmois) {
516 print
'<td class="avant"></td>'.
"\n";
519 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
520 for ($j = 0; $j < $nbofchoice; $j++) {
522 if (date(
"j", $_SESSION[
"totalchoixjour"][$j]) == $numerojour && date(
"n", $_SESSION[
"totalchoixjour"][$j]) == $_SESSION[
"mois"] && date(
"Y", $_SESSION[
"totalchoixjour"][$j]) == $_SESSION[
"annee"]) {
523 print
'<td align="center" class="choisi"><input type="submit" class="bouton OFF centpercent nomarginleft buttonwebsite" name="choixjourretrait[]" value="'.$numerojour.
'"></td>'.
"\n";
524 $dejafait = $numerojour;
530 if (!isset($dejafait) || $dejafait != $numerojour) {
532 if (($numerojour >= $jourAJ && $_SESSION[
"mois"] == $moisAJ && $_SESSION[
"annee"] == $anneeAJ) || ($_SESSION[
"mois"] > $moisAJ && $_SESSION[
"annee"] == $anneeAJ) || $_SESSION[
"annee"] > $anneeAJ) {
533 print
'<td class="center libre"><input type="submit" class="bouton ON centpercent nomarginleft buttonwebsite" name="choixjourajout[]" value="'.$numerojour.
'"></td>'.
"\n";
536 print
'<td class="center avant">'.$numerojour.
'</td>'.
"\n";
544print
'</table>'.
"\n";
545print
'</div></div>'.
"\n";
547print
'<div class="bodydate"><div class="center">'.
"\n";
553 print
'<div align="left">';
554 print
'<strong>'.$langs->trans(
"SelectedDays").
':</strong>'.
"<br>\n";
555 print $langs->trans(
"SelectDayDesc").
"<br>\n";
558 print
'<div class="div-table-responsive">';
559 print
'<table>'.
"\n";
561 print
'<td></td>'.
"\n";
563 for ($i = 0; $i < $_SESSION[
"nbrecaseshoraires"]; $i++) {
565 print
'<td class="somme"><div class="center">'.$langs->trans(
"Time").
' '.$j.
'</div></td>'.
"\n";
568 if ($_SESSION[
"nbrecaseshoraires"] < 10) {
569 print
'<td class="somme"><input type="image" name="ajoutcases" src="../img/add-16.png"></td>'.
"\n";
576 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
578 for ($i = 0; $i < $nbofchoice; $i++) {
580 print
'<td class="left">'.dol_print_date($_SESSION[
"totalchoixjour"][$i],
'daytext').
' <span class="opacitymedium">('.
dol_print_date($_SESSION[
"totalchoixjour"][$i],
'%A').
')</span></td>';
583 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
584 if (isset($errheure[$i][$j]) && $errheure[$i][$j]) {
586 print
'<td><input type=text size="10" maxlength="11" name=horaires'.$i.
'[] value="'.$_SESSION[
"horaires$i"][$j].
'" style="background-color:#FF6666;"></td>'.
"\n";
589 print
'<td><input type=text size="10" maxlength="11" name=horaires'.$i.
'[] value="'.$_SESSION[
"horaires$i"][$j].
'"></td>'.
"\n";
595 print
'</table>'.
"\n";
599 print
'<br><div class="div-table-responsive">';
600 print
'<input type="submit" class="button small" name="reset" value="'.dol_escape_htmltag($langs->trans(
"RemoveAllDays")).
'">';
601 print
'<input type="submit" class="button small" name="reporterhoraires" value="'.dol_escape_htmltag($langs->trans(
"CopyHoursOfFirstDay")).
'">';
602 print
'<input type="submit" class="button small" name="resethoraires" value="'.dol_escape_htmltag($langs->trans(
"RemoveAllHours")).
'">'.
"\n";
603 print
'<br><br>'.
"\n";
604 print
'<input type="submit" class="button" name="confirmation" value="'.$langs->trans(
"CreatePoll").
'">'.
"\n";
609print
'</table>'.
"\n";
610print
'<a name="bas"></a>'.
"\n";
614print
'<br><br><br><br>'.
"\n";
615print
'</div></div>'.
"\n";
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.
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.
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...
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.