26 require
'../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
28 require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
29 require_once DOL_DOCUMENT_ROOT.
"/opensurvey/lib/opensurvey.lib.php";
32 if (!$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);
189 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
190 for ($i = 0; $i < $nbofchoice; $i++) {
191 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
192 unset($_SESSION[
"horaires$i"][$j]);
196 unset($_SESSION[
"totalchoixjour"]);
197 unset($_SESSION[
"nbrecaseshoraires"]);
206 if (!isset($_SESSION[
'description']) && !isset($_SESSION[
'mail'])) {
211 $arrayofjs = array();
212 $arrayofcss = array(
'/opensurvey/css/style.css');
213 llxHeader(
'', $langs->trans(
"OpenSurvey"),
"",
'', 0, 0, $arrayofjs, $arrayofcss);
216 if (!isset($_SESSION[
"nbrecaseshoraires"])) {
217 $_SESSION[
"nbrecaseshoraires"] = 5;
218 } elseif (
GETPOST(
'ajoutcases') && $_SESSION[
"nbrecaseshoraires"] == 5) {
219 $_SESSION[
"nbrecaseshoraires"] = 10;
225 $anneeAJ = date(
"Y");
228 if (!isset($_SESSION[
'jour'])) {
229 $_SESSION[
'jour'] = date(
'j');
231 if (!isset($_SESSION[
'mois'])) {
232 $_SESSION[
'mois'] = date(
'n');
234 if (!isset($_SESSION[
'annee'])) {
235 $_SESSION[
'annee'] = date(
'Y');
239 if (!issetAndNoEmpty(
'choixjourajout') && !issetAndNoEmpty(
'choixjourretrait') && (issetAndNoEmpty(
'retourmois') || issetAndNoEmpty(
'retourmois_x'))) {
240 $_SESSION[
"jour"] = date(
"j");
241 $_SESSION[
"mois"] = date(
"n");
242 $_SESSION[
"annee"] = date(
"Y");
246 if (issetAndNoEmpty(
'moisavant_x') || issetAndNoEmpty(
'moisavant')) {
247 if ($_SESSION[
"mois"] == 1) {
248 $_SESSION[
"mois"] = 12;
249 $_SESSION[
"annee"] = $_SESSION[
"annee"] - 1;
251 $_SESSION[
"mois"] -= 1;
255 if (issetAndNoEmpty(
'totalchoixjour', $_SESSION) ===
true) {
256 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
257 for ($i = 0; $i < $nbofchoice; $i++) {
259 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
260 $horairesi =
GETPOST(
"horaires".$i);
261 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
268 if (issetAndNoEmpty(
'moisapres_x') || issetAndNoEmpty(
'moisapres')) {
269 if ($_SESSION[
"mois"] == 12) {
270 $_SESSION[
"mois"] = 1;
271 $_SESSION[
"annee"] += 1;
273 $_SESSION[
"mois"] += 1;
277 if (issetAndNoEmpty(
'totalchoixjour', $_SESSION) ===
true) {
278 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
279 for ($i = 0; $i < $nbofchoice; $i++) {
281 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
282 $horairesi =
GETPOST(
"horaires".$i);
283 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
290 if (issetAndNoEmpty(
'anneeavant_x') || issetAndNoEmpty(
'anneeavant')) {
291 $_SESSION[
"annee"] -= 1;
294 if (issetAndNoEmpty(
'totalchoixjour', $_SESSION) ===
true) {
295 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
296 for ($i = 0; $i < $nbofchoice; $i++) {
298 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
299 $horairesi =
GETPOST(
"horaires".$i);
300 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
307 if (issetAndNoEmpty(
'anneeapres_x') || issetAndNoEmpty(
'anneeapres')) {
308 $_SESSION[
"annee"] += 1;
311 if (issetAndNoEmpty(
'totalchoixjour', $_SESSION) ===
true) {
312 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
313 for ($i = 0; $i < $nbofchoice; $i++) {
315 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
316 $horairesi =
GETPOST(
"horaires".$i);
317 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
324 $nbrejourmois = date(
"t", mktime(0, 0, 0, $_SESSION[
"mois"], 1, $_SESSION[
"annee"]));
325 $premierjourmois = date(
"N", mktime(0, 0, 0, $_SESSION[
"mois"], 1, $_SESSION[
"annee"])) - 1;
328 if (is_integer($_SESSION[
"mois"]) && $_SESSION[
"mois"] > 0 && $_SESSION[
"mois"] < 13) {
329 $motmois =
dol_print_date(mktime(0, 0, 0, $_SESSION[
"mois"], 10),
'%B');
336 print
'<form name="formulaire" action="" method="POST">'.
"\n";
337 print
'<input type="hidden" name="token" value="'.newToken().
'">';
342 print
'<div class="bodydate">'.
"\n";
343 print $langs->trans(
"OpenSurveyStep2").
"\n";
347 print
'<div class="corps">'.
"\n";
348 print
'<div class="center">'.
"\n";
349 print
'<table align="center">'.
"\n";
350 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>';
351 print
'<td width="150px" align="center"> '.$motmois.
' '.$_SESSION[
"annee"].
'<br>';
352 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).
'">';
353 print
'</td><td><input type="image" name="moisapres" value=">" src="../img/next.png"></td>';
354 print
'<td><input type="image" name="anneeapres" value=">>" src="../img/fforward.png"></td><td></td><td></td><td></td><td></td><td></td><td>';
355 print
'</td></tr>'.
"\n";
356 print
'</table>'.
"\n";
359 print
'<div class="center calendrier">'.
"\n";
360 print
'<table align="center">'.
"\n";
364 for ($i = 0; $i < 7; $i++) {
365 print
'<td align="center" class="joursemaine">'.dol_print_date(mktime(0, 0, 0, 0, $i, 10),
'%A').
'</td>';
371 if (issetAndNoEmpty(
'choixjourajout')) {
372 if (!isset($_SESSION[
"totalchoixjour"])) {
373 $_SESSION[
"totalchoixjour"] = array();
378 if (issetAndNoEmpty(
'totalchoixjour', $_SESSION) ===
true && issetAndNoEmpty(
'choixjourajout') ===
true) {
379 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
380 for ($i = 0; $i < $nbofchoice; $i++) {
381 $choixjourajout =
GETPOST(
"choixjourajout");
382 if ($_SESSION[
"totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION[
"mois"], $choixjourajout[0], $_SESSION[
"annee"])) {
389 if ($journeuf && issetAndNoEmpty(
'choixjourajout') ===
true) {
390 $choixjourajout =
GETPOST(
"choixjourajout");
391 array_push($_SESSION[
"totalchoixjour"],
dol_mktime(0, 0, 0, $_SESSION[
"mois"], $choixjourajout[0], $_SESSION[
"annee"]));
392 sort($_SESSION[
"totalchoixjour"]);
393 $cle = array_search(
dol_mktime(0, 0, 0, $_SESSION[
"mois"], $choixjourajout[0], $_SESSION[
"annee"]), $_SESSION[
"totalchoixjour"]);
396 for ($i = 0; $i < $cle; $i++) {
397 $horairesi =
GETPOST(
"horaires".$i);
398 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
399 if (issetAndNoEmpty(
'horaires'.$i) ===
true && issetAndNoEmpty($i, $_POST[
'horaires'.$i]) ===
true) {
400 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
405 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
406 for ($i = $cle; $i < $nbofchoice; $i++) {
408 if (issetAndNoEmpty(
'horaires'.$i) ===
true && issetAndNoEmpty($i, $_POST[
'horaires'.$i]) ===
true) {
409 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
410 $horairesi =
GETPOST(
"horaires".$i);
411 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
416 unset($_SESSION[
"horaires$cle"]);
421 if (issetAndNoEmpty(
'choixjourretrait')) {
423 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
424 for ($i = 0; $i < $nbofchoice; $i++) {
426 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
427 $horairesi =
GETPOST(
"horaires".$i);
428 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
432 for ($i = 0; $i < $nbofchoice; $i++) {
433 $choixjourretrait =
GETPOST(
'choixjourretrait');
434 if ($_SESSION[
"totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION[
"mois"], $choixjourretrait[0], $_SESSION[
"annee"])) {
435 for ($j = $i; $j < $nbofchoice; $j++) {
437 $_SESSION[
"horaires$j"] = $_SESSION[
"horaires$k"];
440 array_splice($_SESSION[
"totalchoixjour"], $i, 1);
446 if (issetAndNoEmpty(
'reporterhoraires')) {
447 $_SESSION[
"horaires0"] =
GETPOST(
"horaires0");
448 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
449 for ($i = 0; $i < $nbofchoice; $i++) {
451 $_SESSION[
"horaires$j"] = $_SESSION[
"horaires$i"];
456 if (issetAndNoEmpty(
'resethoraires')) {
457 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
458 for ($i = 0; $i < $nbofchoice; $i++) {
459 unset($_SESSION[
"horaires$i"]);
466 for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) {
467 $numerojour = $i - $premierjourmois + 1;
470 if (($i % 7) == 0 && $i != 0) {
471 print
'</tr><tr>'.
"\n";
475 if ($i < $premierjourmois) {
476 print
'<td class="avant"></td>'.
"\n";
478 if (issetAndNoEmpty(
'totalchoixjour', $_SESSION) ===
true) {
479 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
480 for ($j = 0; $j < $nbofchoice; $j++) {
482 if (date(
"j", $_SESSION[
"totalchoixjour"][$j]) == $numerojour && date(
"n", $_SESSION[
"totalchoixjour"][$j]) == $_SESSION[
"mois"] && date(
"Y", $_SESSION[
"totalchoixjour"][$j]) == $_SESSION[
"annee"]) {
483 print
'<td align="center" class="choisi"><input type="submit" class="bouton OFF" name="choixjourretrait[]" value="'.$numerojour.
'"></td>'.
"\n";
484 $dejafait = $numerojour;
490 if (isset($dejafait) ===
false || $dejafait != $numerojour) {
492 if (($numerojour >= $jourAJ && $_SESSION[
"mois"] == $moisAJ && $_SESSION[
"annee"] == $anneeAJ) || ($_SESSION[
"mois"] > $moisAJ && $_SESSION[
"annee"] == $anneeAJ) || $_SESSION[
"annee"] > $anneeAJ) {
493 print
'<td align="center" class="libre"><input type="submit" class="bouton ON" name="choixjourajout[]" value="'.$numerojour.
'"></td>'.
"\n";
496 print
'<td align="center" class="avant">'.$numerojour.
'</td>'.
"\n";
504 print
'</table>'.
"\n";
505 print
'</div></div>'.
"\n";
507 print
'<div class="bodydate"><div class="center">'.
"\n";
510 if (issetAndNoEmpty(
'totalchoixjour', $_SESSION) || $erreur) {
513 print
'<div align="left">';
514 print
'<strong>'.$langs->trans(
"SelectedDays").
':</strong>'.
"<br>\n";
515 print $langs->trans(
"SelectDayDesc").
"<br>\n";
518 print
'<table>'.
"\n";
520 print
'<td></td>'.
"\n";
522 for ($i = 0; $i < $_SESSION[
"nbrecaseshoraires"]; $i++) {
524 print
'<td classe="somme"><div class="center">'.$langs->trans(
"Time").
' '.$j.
'</div></td>'.
"\n";
527 if ($_SESSION[
"nbrecaseshoraires"] < 10) {
528 print
'<td classe="somme"><input type="image" name="ajoutcases" src="../img/add-16.png"></td>'.
"\n";
534 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
536 for ($i = 0; $i < $nbofchoice; $i++) {
538 print
'<td>'.dol_print_date($_SESSION[
"totalchoixjour"][$i],
'daytext').
' ('.
dol_print_date($_SESSION[
"totalchoixjour"][$i],
'%A').
')</td>';
541 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
543 if (isset($errheure[$i][$j]) && $errheure[$i][$j]) {
544 print
'<td><input type=text size="10" maxlength="11" name=horaires'.$i.
'[] value="'.$_SESSION[
"horaires$i"][$j].
'" style="background-color:#FF6666;"></td>'.
"\n";
547 print
'<td><input type=text size="10" maxlength="11" name=horaires'.$i.
'[] value="'.$_SESSION[
"horaires$i"][$j].
'"></td>'.
"\n";
553 print
'</table>'.
"\n";
556 print
'<table>'.
"\n";
558 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";
559 print
'<tr><td colspan="3"><br><br></td></tr>'.
"\n";
560 print
'<tr><td colspan="3" align="center"><input type="submit" class="button" name="confirmation" value="'.$langs->trans(
"CreatePoll").
'"></td></tr>'.
"\n";
561 print
'</table>'.
"\n";
565 print
'</table>'.
"\n";
566 print
'<a name=bas></a>'.
"\n";
568 print
'</form>'.
"\n";
570 print
'<br><br><br><br>'.
"\n";
571 print
'</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_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.