25 require
'../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
27 require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
28 require_once DOL_DOCUMENT_ROOT.
"/opensurvey/fonctions.php";
34 $_SESSION[
"formatsondage"] =
"D";
48 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
51 for ($i = 0; $i < $nbofchoice; $i++)
54 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++)
56 $_SESSION[
"horaires$i"][$j] = $_POST[
"horaires$i"][$j];
58 $tmphorairesi =
GETPOST(
'horaires'.$i,
'array');
60 if (!is_array($tmphorairesi) || empty($tmphorairesi[$j])) {
61 $errheure[$i][$j] =
true;
69 if (preg_match(
"/(\d{1,2}:\d{2})-(\d{1,2}:\d{2})/", $tmphorairesi[$j], $creneaux)) {
71 $debutcreneau = explode(
":", $creneaux[1]);
72 $fincreneau = explode(
":", $creneaux[2]);
76 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]))) {
77 $_SESSION[
"horaires$i"][$j] = $creneaux[1].
'-'.$creneaux[2];
79 $errheure[$i][$j] =
true;
82 } elseif (preg_match(
";^(\d{1,2}h\d{0,2})-(\d{1,2}h\d{0,2})$;i", $tmphorairesi[$j], $creneaux)) {
84 $debutcreneau = preg_split(
"/h/i", $creneaux[1]);
85 $fincreneau = preg_split(
"/h/i", $creneaux[2]);
89 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]))) {
90 $_SESSION[
"horaires$i"][$j] = $creneaux[1].
'-'.$creneaux[2];
92 $errheure[$i][$j] =
true;
95 } elseif (preg_match(
";^(\d{1,2}):(\d{2})$;", $tmphorairesi[$j], $heures)) {
97 if ($heures[1] < 24 && $heures[2] < 60) {
98 $_SESSION[
"horaires$i"][$j] = $heures[0];
100 $errheure[$i][$j] =
true;
103 } elseif (preg_match(
";^(\d{1,2})h(\d{0,2})$;i", $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})-(\d{1,2})$;", $tmphorairesi[$j], $heures)) {
113 if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) {
114 $_SESSION[
"horaires$i"][$j] = $heures[0];
116 $errheure[$i][$j] =
true;
119 } elseif (preg_match(
";^(\d{1,2})h-(\d{1,2})h$;", $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 ($tmphorairesi[$j] ==
"") {
128 unset($_SESSION[
"horaires$i"][$j]);
130 $errheure[$i][$j] =
true;
136 $_SESSION[
"horaires$i"][$j] =
'';
138 $_SESSION[
"horaires$i"] = array();
139 $_SESSION[
"horaires$i"][$j] =
'';
144 if ($_SESSION[
"horaires$i"][0] ==
"" && $_SESSION[
"horaires$i"][1] ==
"" && $_SESSION[
"horaires$i"][2] ==
"" && $_SESSION[
"horaires$i"][3] ==
"" && $_SESSION[
"horaires$i"][4] ==
"") {
146 $choixdate .= $_SESSION[
"totalchoixjour"][$i];
148 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
149 if ($_SESSION[
"horaires$i"][$j] !=
"") {
151 $choixdate .= $_SESSION[
"totalchoixjour"][$i];
154 $choixdate .= str_replace(array(
',',
'@'), array(
',',
'@'), $_SESSION[
"horaires$i"][$j]);
160 if (isset($errheure)) {
166 $tmphoraires0 =
GETPOST(
'horaires0',
'array');
167 if (count($_SESSION[
"totalchoixjour"]) ==
"1" && $tmphoraires0[0] ==
"" && $tmphoraires0[1] ==
"" && $tmphoraires0[2] ==
"" && $tmphoraires0[3] ==
"" && $tmphoraires0[4] ==
"") {
175 $_SESSION[
"toutchoix"] = substr(
"$choixdate", 1);
184 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
185 for ($i = 0; $i < $nbofchoice; $i++)
187 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
188 unset($_SESSION[
"horaires$i"][$j]);
192 unset($_SESSION[
"totalchoixjour"]);
193 unset($_SESSION[
"nbrecaseshoraires"]);
202 if (!isset($_SESSION[
'description']) && !isset($_SESSION[
'mail']))
208 $arrayofjs = array();
209 $arrayofcss = array(
'/opensurvey/css/style.css');
210 llxHeader(
'', $langs->trans(
"OpenSurvey"),
"",
'', 0, 0, $arrayofjs, $arrayofcss);
213 if (!isset($_SESSION[
"nbrecaseshoraires"]))
215 $_SESSION[
"nbrecaseshoraires"] = 5;
216 } elseif (
GETPOST(
'ajoutcases') && $_SESSION[
"nbrecaseshoraires"] == 5)
218 $_SESSION[
"nbrecaseshoraires"] = 10;
224 $anneeAJ = date(
"Y");
227 if (!isset($_SESSION[
'jour'])) $_SESSION[
'jour'] = date(
'j');
228 if (!isset($_SESSION[
'mois'])) $_SESSION[
'mois'] = date(
'n');
229 if (!isset($_SESSION[
'annee'])) $_SESSION[
'annee'] = date(
'Y');
233 $_SESSION[
"jour"] = date(
"j");
234 $_SESSION[
"mois"] = date(
"n");
235 $_SESSION[
"annee"] = date(
"Y");
240 if ($_SESSION[
"mois"] == 1) {
241 $_SESSION[
"mois"] = 12;
242 $_SESSION[
"annee"] = $_SESSION[
"annee"] - 1;
244 $_SESSION[
"mois"] -= 1;
250 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
251 for ($i = 0; $i < $nbofchoice; $i++) {
253 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
254 $_SESSION[
"horaires$i"][$j] = $_POST[
"horaires$i"][$j];
262 if ($_SESSION[
"mois"] == 12) {
263 $_SESSION[
"mois"] = 1;
264 $_SESSION[
"annee"] += 1;
266 $_SESSION[
"mois"] += 1;
272 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
273 for ($i = 0; $i < $nbofchoice; $i++)
276 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
277 $_SESSION[
"horaires$i"][$j] = $_POST[
"horaires$i"][$j];
285 $_SESSION[
"annee"] -= 1;
290 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
291 for ($i = 0; $i < $nbofchoice; $i++) {
293 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
294 $_SESSION[
"horaires$i"][$j] = $_POST[
"horaires$i"][$j];
302 $_SESSION[
"annee"] += 1;
307 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
308 for ($i = 0; $i < $nbofchoice; $i++) {
310 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
311 $_SESSION[
"horaires$i"][$j] = $_POST[
"horaires$i"][$j];
318 $nbrejourmois = date(
"t", mktime(0, 0, 0, $_SESSION[
"mois"], 1, $_SESSION[
"annee"]));
319 $premierjourmois = date(
"N", mktime(0, 0, 0, $_SESSION[
"mois"], 1, $_SESSION[
"annee"])) - 1;
322 if (is_integer($_SESSION[
"mois"]) && $_SESSION[
"mois"] > 0 && $_SESSION[
"mois"] < 13)
324 $motmois =
dol_print_date(mktime(0, 0, 0, $_SESSION[
"mois"], 10),
'%B');
331 print '<form name="formulaire" action="" method="POST">'.
"\n";
332 print '<input type="hidden" name="token" value="'.newToken().
'">';
337 print '<div class="bodydate">'.
"\n";
338 print $langs->trans(
"OpenSurveyStep2").
"\n";
342 print '<div class="corps">'.
"\n";
343 print '<div class="center">'.
"\n";
344 print '<table align="center">'.
"\n";
345 print '<tr><td><input type="image" name="anneeavant" value="<<" src="../img/rewind.png"></td><td><input type="image" name="moisavant" value="<" src="../img/previous.png"></td>';
346 print '<td width="150px" align="center"> '.$motmois.
' '.$_SESSION[
"annee"].
'<br>';
347 print '<input type="image" name="retourmois" alt="'.dol_escape_htmltag($langs->trans(
"BackToCurrentMonth")).
'" title="'.
dol_escape_htmltag($langs->trans(
"BackToCurrentMonth")).
'" value="" src="'.
img_picto(
'',
'refresh',
'', 0, 1).
'">';
348 print '</td><td><input type="image" name="moisapres" value=">" src="../img/next.png"></td>';
349 print '<td><input type="image" name="anneeapres" value=">>" src="../img/fforward.png"></td><td></td><td></td><td></td><td></td><td></td><td>';
350 print '</td></tr>'.
"\n";
351 print '</table>'.
"\n";
354 print '<div class="center calendrier">'.
"\n";
355 print '<table align="center">'.
"\n";
359 for ($i = 0; $i < 7; $i++)
361 print '<td align="center" class="joursemaine">'.dol_print_date(mktime(0, 0, 0, 0, $i, 10),
'%A').
'</td>';
368 if (!isset($_SESSION[
"totalchoixjour"])) {
369 $_SESSION[
"totalchoixjour"] = array();
376 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
377 for ($i = 0; $i < $nbofchoice; $i++) {
378 if ($_SESSION[
"totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION[
"mois"], $_POST[
"choixjourajout"][0], $_SESSION[
"annee"])) {
386 array_push($_SESSION[
"totalchoixjour"],
dol_mktime(0, 0, 0, $_SESSION[
"mois"], $_POST[
"choixjourajout"][0], $_SESSION[
"annee"]));
387 sort($_SESSION[
"totalchoixjour"]);
388 $cle = array_search(
dol_mktime(0, 0, 0, $_SESSION[
"mois"], $_POST[
"choixjourajout"][0], $_SESSION[
"annee"]), $_SESSION[
"totalchoixjour"]);
391 for ($i = 0; $i < $cle; $i++) {
392 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
394 $_SESSION[
"horaires$i"][$j] = $_POST[
"horaires$i"][$j];
399 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
400 for ($i = $cle; $i < $nbofchoice; $i++) {
403 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
404 $_SESSION[
"horaires$k"][$j] = $_POST[
"horaires$i"][$j];
409 unset($_SESSION[
"horaires$cle"]);
416 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
417 for ($i = 0; $i < $nbofchoice; $i++) {
419 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
420 $_SESSION[
"horaires$i"][$j] = $_POST[
"horaires$i"][$j];
424 for ($i = 0; $i < $nbofchoice; $i++)
426 if ($_SESSION[
"totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION[
"mois"], $_POST[
"choixjourretrait"][0], $_SESSION[
"annee"]))
428 for ($j = $i; $j < $nbofchoice; $j++) {
430 $_SESSION[
"horaires$j"] = $_SESSION[
"horaires$k"];
433 array_splice($_SESSION[
"totalchoixjour"], $i, 1);
440 $_SESSION[
"horaires0"] = $_POST[
"horaires0"];
441 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
442 for ($i = 0; $i < $nbofchoice; $i++) {
444 $_SESSION[
"horaires$j"] = $_SESSION[
"horaires$i"];
450 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
451 for ($i = 0; $i < $nbofchoice; $i++) {
452 unset($_SESSION[
"horaires$i"]);
459 for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) {
460 $numerojour = $i - $premierjourmois + 1;
463 if (($i % 7) == 0 && $i != 0) {
464 print '</tr><tr>'.
"\n";
468 if ($i < $premierjourmois) {
469 print '<td class="avant"></td>'.
"\n";
473 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
474 for ($j = 0; $j < $nbofchoice; $j++) {
476 if (date(
"j", $_SESSION[
"totalchoixjour"][$j]) == $numerojour && date(
"n", $_SESSION[
"totalchoixjour"][$j]) == $_SESSION[
"mois"] && date(
"Y", $_SESSION[
"totalchoixjour"][$j]) == $_SESSION[
"annee"]) {
477 print '<td align="center" class="choisi"><input type="submit" class="bouton OFF" name="choixjourretrait[]" value="'.$numerojour.
'"></td>'.
"\n";
478 $dejafait = $numerojour;
484 if (isset($dejafait) ===
false || $dejafait != $numerojour) {
486 if (($numerojour >= $jourAJ && $_SESSION[
"mois"] == $moisAJ && $_SESSION[
"annee"] == $anneeAJ) || ($_SESSION[
"mois"] > $moisAJ && $_SESSION[
"annee"] == $anneeAJ) || $_SESSION[
"annee"] > $anneeAJ) {
487 print '<td align="center" class="libre"><input type="submit" class="bouton ON" name="choixjourajout[]" value="'.$numerojour.
'"></td>'.
"\n";
490 print '<td align="center" class="avant">'.$numerojour.
'</td>'.
"\n";
498 print '</table>'.
"\n";
499 print '</div></div>'.
"\n";
501 print '<div class="bodydate"><div class="center">'.
"\n";
508 print '<div align="left">';
509 print '<strong>'.$langs->trans(
"SelectedDays").
':</strong>'.
"<br>\n";
510 print $langs->trans(
"SelectDayDesc").
"<br>\n";
513 print '<table>'.
"\n";
515 print '<td></td>'.
"\n";
517 for ($i = 0; $i < $_SESSION[
"nbrecaseshoraires"]; $i++) {
519 print '<td classe="somme"><div class="center">'.$langs->trans(
"Time").
' '.$j.
'</div></td>'.
"\n";
522 if ($_SESSION[
"nbrecaseshoraires"] < 10) {
523 print '<td classe="somme"><input type="image" name="ajoutcases" src="../img/add-16.png"></td>'.
"\n";
529 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
531 for ($i = 0; $i < $nbofchoice; $i++)
534 print '<td>'.dol_print_date($_SESSION[
"totalchoixjour"][$i],
'daytext').
' ('.
dol_print_date($_SESSION[
"totalchoixjour"][$i],
'%A').
')</td>';
537 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
539 if (isset($errheure[$i][$j]) && $errheure[$i][$j]) {
540 print '<td><input type=text size="10" maxlength="11" name=horaires'.$i.
'[] value="'.$_SESSION[
"horaires$i"][$j].
'" style="background-color:#FF6666;"></td>'.
"\n";
543 print '<td><input type=text size="10" maxlength="11" name=horaires'.$i.
'[] value="'.$_SESSION[
"horaires$i"][$j].
'"></td>'.
"\n";
549 print '</table>'.
"\n";
552 print '<table>'.
"\n";
554 print '<td><input type="submit" class="button" name="reset" value="'.dol_escape_htmltag($langs->trans(
"RemoveAllDays")).
'"></td><td><input type="submit" class="button" name="reporterhoraires" value="'.
dol_escape_htmltag($langs->trans(
"CopyHoursOfFirstDay")).
'"></td><td><input type="submit" class="button" name="resethoraires" value="'.
dol_escape_htmltag($langs->trans(
"RemoveAllHours")).
'"></td></tr>'.
"\n";
555 print'<tr><td colspan="3"><br><br></td></tr>'.
"\n";
556 print '<tr><td colspan="3" align="center"><input type="submit" class="button" name="confirmation" value="'.$langs->trans(
"CreatePoll").
'"></td></tr>'.
"\n";
557 print '</table>'.
"\n";
561 print '</table>'.
"\n";
562 print '<a name=bas></a>'.
"\n";
564 print '</form>'.
"\n";
566 print '<br><br><br><br>'.
"\n";
567 print '</div></div>'.
"\n";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
dol_now($mode= 'auto')
Return date for now.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
issetAndNoEmpty($name, $tableau=null)
Fonction vérifiant l'existance et la valeur non vide d'une clé d'un tableau.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print
Draft customers invoices.
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_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
ajouter_sondage()
Add a poll.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...