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";
42if (!$user->hasRight(
'opensurvey',
'write')) {
47$_SESSION[
"formatsondage"] =
"D";
62 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
65 if ($nbofchoice * $_SESSION[
"nbrecaseshoraires"] > 200) {
69 for ($i = 0; $i < $nbofchoice; $i++) {
71 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
72 $horairesi =
GETPOST(
"horaires".$i);
73 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
75 $tmphorairesi =
GETPOST(
'horaires'.$i,
'array');
77 if (!is_array($tmphorairesi)) {
78 $errheure[$i][$j] =
true;
86 if (preg_match(
"/(\d{1,2}:\d{2})-(\d{1,2}:\d{2})/", $tmphorairesi[$j], $creneaux)) {
88 $debutcreneau = explode(
":", $creneaux[1]);
89 $fincreneau = explode(
":", $creneaux[2]);
93 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]))) {
94 $_SESSION[
"horaires$i"][$j] = $creneaux[1].
'-'.$creneaux[2];
96 $errheure[$i][$j] =
true;
99 } elseif (preg_match(
";^(\d{1,2}h\d{0,2})-(\d{1,2}h\d{0,2})$;i", $tmphorairesi[$j], $creneaux)) {
101 $debutcreneau = preg_split(
"/h/i", $creneaux[1]);
102 $fincreneau = preg_split(
"/h/i", $creneaux[2]);
106 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]))) {
107 $_SESSION[
"horaires$i"][$j] = $creneaux[1].
'-'.$creneaux[2];
109 $errheure[$i][$j] =
true;
112 } elseif (preg_match(
";^(\d{1,2}):(\d{2})$;", $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})h(\d{0,2})$;i", $tmphorairesi[$j], $heures)) {
122 if ($heures[1] < 24 && $heures[2] < 60) {
123 $_SESSION[
"horaires$i"][$j] = $heures[0];
125 $errheure[$i][$j] =
true;
128 } elseif (preg_match(
";^(\d{1,2})-(\d{1,2})$;", $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 (preg_match(
";^(\d{1,2})h-(\d{1,2})h$;", $tmphorairesi[$j], $heures)) {
138 if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) {
139 $_SESSION[
"horaires$i"][$j] = $heures[0];
141 $errheure[$i][$j] =
true;
144 } elseif ($tmphorairesi[$j] ==
"") {
145 unset($_SESSION[
"horaires$i"][$j]);
147 $errheure[$i][$j] =
true;
153 $_SESSION[
"horaires$i"][$j] =
'';
155 $_SESSION[
"horaires$i"] = array();
156 $_SESSION[
"horaires$i"][$j] =
'';
162 if ($_SESSION[
"horaires$i"][0] ==
"" && $_SESSION[
"horaires$i"][1] ==
"" && $_SESSION[
"horaires$i"][2] ==
"" && $_SESSION[
"horaires$i"][3] ==
"" && $_SESSION[
"horaires$i"][4] ==
"") {
164 $choixdate .= $_SESSION[
"totalchoixjour"][$i];
166 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
167 if ($_SESSION[
"horaires$i"][$j] !=
"") {
169 $choixdate .= $_SESSION[
"totalchoixjour"][$i];
172 $choixdate .= str_replace(array(
',',
'@'), array(
',',
'@'), $_SESSION[
"horaires$i"][$j]);
180 if (!empty($errheure)) {
186 $tmphoraires0 =
GETPOST(
'horaires0',
'array');
187 if (count($_SESSION[
"totalchoixjour"]) ==
"1" && $tmphoraires0[0] ==
"" && $tmphoraires0[1] ==
"" && $tmphoraires0[2] ==
"" && $tmphoraires0[3] ==
"" && $tmphoraires0[4] ==
"") {
193 if (!$erreur && $erreurNb == 0) {
194 $_SESSION[
"toutchoix"] = substr($choixdate, 1);
195 unset($_SESSION[
"nbrecaseshoraires"]);
203 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
204 for ($i = 0; $i < $nbofchoice; $i++) {
205 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
206 unset($_SESSION[
"horaires$i"][$j]);
210 unset($_SESSION[
"totalchoixjour"]);
211 unset($_SESSION[
"nbrecaseshoraires"]);
220if (!isset($_SESSION[
'description']) && !isset($_SESSION[
'mail'])) {
221 dol_print_error(
null, $langs->trans(
'ErrorOpenSurveyFillFirstSection'));
226$arrayofcss = array(
'/opensurvey/css/style.css');
227llxHeader(
'', $langs->trans(
"OpenSurvey"),
"",
'', 0, 0, $arrayofjs, $arrayofcss);
230if (!isset($_SESSION[
"nbrecaseshoraires"])) {
231 $_SESSION[
"nbrecaseshoraires"] = 5;
232} elseif ((
GETPOST(
'ajoutcases') ||
GETPOST(
"ajoutcases_y")) && $_SESSION[
"nbrecaseshoraires"] == 5) {
233 $_SESSION[
"nbrecaseshoraires"] = 10;
236 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
237 for ($i = 0; $i < $nbofchoice; $i++) {
239 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
240 $horairesi =
GETPOST(
"horaires".$i);
241 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
254if (!isset($_SESSION[
'jour'])) {
255 $_SESSION[
'jour'] = date(
'j');
257if (!isset($_SESSION[
'mois'])) {
258 $_SESSION[
'mois'] = date(
'n');
260if (!isset($_SESSION[
'annee'])) {
261 $_SESSION[
'annee'] = date(
'Y');
266 $_SESSION[
"jour"] = date(
"j");
267 $_SESSION[
"mois"] = date(
"n");
268 $_SESSION[
"annee"] = date(
"Y");
273 if ($_SESSION[
"mois"] == 1) {
274 $_SESSION[
"mois"] = 12;
275 $_SESSION[
"annee"] -= 1;
277 $_SESSION[
"mois"] -= 1;
282 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
283 for ($i = 0; $i < $nbofchoice; $i++) {
285 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
286 $horairesi =
GETPOST(
"horaires".$i);
287 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
295 if ($_SESSION[
"mois"] == 12) {
296 $_SESSION[
"mois"] = 1;
297 $_SESSION[
"annee"] += 1;
299 $_SESSION[
"mois"] += 1;
304 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
305 for ($i = 0; $i < $nbofchoice; $i++) {
307 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
308 $horairesi =
GETPOST(
"horaires".$i);
309 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
317 $_SESSION[
"annee"] -= 1;
321 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
322 for ($i = 0; $i < $nbofchoice; $i++) {
324 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
325 $horairesi =
GETPOST(
"horaires".$i);
326 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
334 $_SESSION[
"annee"] += 1;
338 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
339 for ($i = 0; $i < $nbofchoice; $i++) {
341 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
342 $horairesi =
GETPOST(
"horaires".$i);
343 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
350$nbrejourmois = idate(
"t",
dol_get_first_day((
int) $_SESSION[
"annee"], (
int) $_SESSION[
"mois"]));
358if (is_int($_SESSION[
"mois"]) && $_SESSION[
"mois"] > 0 && $_SESSION[
"mois"] < 13) {
359 $motmois =
dol_print_date(mktime(0, 0, 0, (
int) $_SESSION[
"mois"], 10),
'%B');
366print
'<form name="formulaire" action="" method="POST">'.
"\n";
367print
'<input type="hidden" name="token" value="'.newToken().
'">';
372print
'<div class="bodydate">'.
"\n";
373print $langs->trans(
"OpenSurveyStep2").
"\n";
377print
'<div class="corps">'.
"\n";
378print
'<div class="center">'.
"\n";
379print
'<table class="center">'.
"\n";
382print
'<button type="submit" name="anneeavant" value="<<">'.img_picto($langs->trans(
"PreviousYear"),
'chevron-double-left',
'class="double"').
'</button>';
386print
'<button type="submit" name="moisavant" value="<">'.img_picto($langs->trans(
"PreviousMonth"),
'chevron-left',
'class="double"').
'</button>';
389print
'<td width="150px" class="center size15x">'.$motmois.
' '.$_SESSION[
"annee"].
'<br>';
393print
'<button type="submit" name="moisapres" value=">">'.img_picto($langs->trans(
"NextMonth"),
'chevron-right',
'class="double"').
'</button>';
397print
'<button type="submit" name="anneeapres" value=">>">'.img_picto($langs->trans(
"NextYear"),
'chevron-double-right',
'class="double"').
'</button>';
399print
'</td></tr>'.
"\n";
400print
'</table>'.
"\n";
405print
'<div class="center calendrier">'.
"\n";
406print
'<table class="center">'.
"\n";
410for ($i = 0; $i < 7; $i++) {
411 print
'<td class="center joursemaine">';
412 print
dol_print_date(mktime(0, 0, 0, 0, $i, 10), (empty(
$conf->dol_optimize_smallscreen) ?
'%A' :
'%a'));
420 if (!isset($_SESSION[
"totalchoixjour"])) {
421 $_SESSION[
"totalchoixjour"] = array();
427 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
428 for ($i = 0; $i < $nbofchoice; $i++) {
429 $choixjourajout =
GETPOST(
"choixjourajout");
430 if ($_SESSION[
"totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION[
"mois"], $choixjourajout[0], $_SESSION[
"annee"])) {
438 $choixjourajout =
GETPOST(
"choixjourajout");
439 array_push($_SESSION[
"totalchoixjour"],
dol_mktime(0, 0, 0, $_SESSION[
"mois"], $choixjourajout[0], $_SESSION[
"annee"]));
440 sort($_SESSION[
"totalchoixjour"]);
441 $cle = array_search(
dol_mktime(0, 0, 0, $_SESSION[
"mois"], $choixjourajout[0], $_SESSION[
"annee"]), $_SESSION[
"totalchoixjour"]);
444 for ($i = 0; $i < $cle; $i++) {
445 $horairesi =
GETPOST(
"horaires".$i);
446 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
448 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
453 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
454 for ($i = $cle; $i < $nbofchoice; $i++) {
457 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
458 $horairesi =
GETPOST(
"horaires".$i,
'array');
459 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
464 unset($_SESSION[
"horaires$cle"]);
471 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
472 for ($i = 0; $i < $nbofchoice; $i++) {
474 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
475 $horairesi =
GETPOST(
"horaires".$i);
476 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
480 for ($i = 0; $i < $nbofchoice; $i++) {
481 $choixjourretrait =
GETPOST(
'choixjourretrait');
482 if ($_SESSION[
"totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION[
"mois"], $choixjourretrait[0], $_SESSION[
"annee"])) {
483 for ($j = $i; $j < $nbofchoice; $j++) {
485 $_SESSION[
"horaires$j"] = $_SESSION[
"horaires$k"];
488 array_splice($_SESSION[
"totalchoixjour"], $i, 1);
495 $_SESSION[
"horaires0"] =
GETPOST(
"horaires0");
496 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
497 for ($i = 0; $i < $nbofchoice; $i++) {
499 $_SESSION[
"horaires$j"] = $_SESSION[
"horaires$i"];
505 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
506 for ($i = 0; $i < $nbofchoice; $i++) {
507 unset($_SESSION[
"horaires$i"]);
514for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) {
515 $numerojour = $i - $premierjourmois + 1;
518 if (($i % 7) == 0 && $i != 0) {
519 print
'</tr><tr>'.
"\n";
523 if ($i < $premierjourmois) {
524 print
'<td class="avant"></td>'.
"\n";
527 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
528 for ($j = 0; $j < $nbofchoice; $j++) {
530 if (date(
"j", $_SESSION[
"totalchoixjour"][$j]) == $numerojour && date(
"n", $_SESSION[
"totalchoixjour"][$j]) == $_SESSION[
"mois"] && date(
"Y", $_SESSION[
"totalchoixjour"][$j]) == $_SESSION[
"annee"]) {
531 print
'<td align="center" class="choisi"><input type="submit" class="bouton OFF centpercent nomarginleft buttonwebsite" name="choixjourretrait[]" value="'.$numerojour.
'"></td>'.
"\n";
532 $dejafait = $numerojour;
538 if (!isset($dejafait) || $dejafait != $numerojour) {
540 if (($numerojour >= $jourAJ && $_SESSION[
"mois"] == $moisAJ && $_SESSION[
"annee"] == $anneeAJ) || ($_SESSION[
"mois"] > $moisAJ && $_SESSION[
"annee"] == $anneeAJ) || $_SESSION[
"annee"] > $anneeAJ) {
541 print
'<td class="center libre"><input type="submit" class="bouton ON centpercent nomarginleft buttonwebsite" name="choixjourajout[]" value="'.$numerojour.
'"></td>'.
"\n";
544 print
'<td class="center avant">'.$numerojour.
'</td>'.
"\n";
552print
'</table>'.
"\n";
553print
'</div></div>'.
"\n";
555print
'<div class="bodydate"><div class="center">'.
"\n";
561 print
'<div align="left">';
562 print
'<strong>'.$langs->trans(
"SelectedDays").
':</strong>'.
"<br>\n";
563 print $langs->trans(
"SelectDayDesc").
"<br>\n";
566 print
'<div class="div-table-responsive">';
567 print
'<table>'.
"\n";
569 print
'<td></td>'.
"\n";
571 for ($i = 0; $i < $_SESSION[
"nbrecaseshoraires"]; $i++) {
573 print
'<td class="somme"><div class="center">'.$langs->trans(
"Time").
' '.$j.
'</div></td>'.
"\n";
576 if ($_SESSION[
"nbrecaseshoraires"] < 10) {
577 print
'<td class="somme"><input type="image" name="ajoutcases" src="../img/add-16.png"></td>'.
"\n";
584 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
586 for ($i = 0; $i < $nbofchoice; $i++) {
588 print
'<td class="left">'.dol_print_date($_SESSION[
"totalchoixjour"][$i],
'daytext').
' <span class="opacitymedium">('.
dol_print_date($_SESSION[
"totalchoixjour"][$i],
'%A').
')</span></td>';
591 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
592 if (isset($errheure[$i][$j]) && $errheure[$i][$j]) {
594 print
'<td><input type=text size="10" maxlength="11" name=horaires'.$i.
'[] value="'.$_SESSION[
"horaires$i"][$j].
'" style="background-color:#FF6666;"></td>'.
"\n";
597 print
'<td><input type=text size="10" maxlength="11" name=horaires'.$i.
'[] value="'.$_SESSION[
"horaires$i"][$j].
'"></td>'.
"\n";
603 print
'</table>'.
"\n";
607 print
'<br><div class="div-table-responsive">';
608 print
'<input type="submit" class="button small" name="reset" value="'.dol_escape_htmltag($langs->trans(
"RemoveAllDays")).
'">';
609 print
'<input type="submit" class="button small" name="reporterhoraires" value="'.dol_escape_htmltag($langs->trans(
"CopyHoursOfFirstDay")).
'">';
610 print
'<input type="submit" class="button small" name="resethoraires" value="'.dol_escape_htmltag($langs->trans(
"RemoveAllHours")).
'">'.
"\n";
611 print
'<br><br>'.
"\n";
612 print
'<input type="submit" class="button" name="confirmation" value="'.$langs->trans(
"CreatePoll").
'">'.
"\n";
617print
'</table>'.
"\n";
618print
'<a name="bas"></a>'.
"\n";
622print
'<br><br><br><br>'.
"\n";
623print
'</div></div>'.
"\n";
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.