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"]);
64 if ($nbofchoice * $_SESSION[
"nbrecaseshoraires"] > 200) {
68 for ($i = 0; $i < $nbofchoice; $i++) {
70 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
71 $horairesi =
GETPOST(
"horaires".$i);
72 $_SESSION[
"horaires$i"][$j] = $horairesi[$j];
74 $tmphorairesi =
GETPOST(
'horaires'.$i,
'array');
76 if (!is_array($tmphorairesi)) {
77 $errheure[$i][$j] =
true;
85 if (preg_match(
"/(\d{1,2}:\d{2})-(\d{1,2}:\d{2})/", $tmphorairesi[$j], $creneaux)) {
87 $debutcreneau = explode(
":", $creneaux[1]);
88 $fincreneau = explode(
":", $creneaux[2]);
92 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]))) {
93 $_SESSION[
"horaires$i"][$j] = $creneaux[1].
'-'.$creneaux[2];
95 $errheure[$i][$j] =
true;
98 } elseif (preg_match(
";^(\d{1,2}h\d{0,2})-(\d{1,2}h\d{0,2})$;i", $tmphorairesi[$j], $creneaux)) {
100 $debutcreneau = preg_split(
"/h/i", $creneaux[1]);
101 $fincreneau = preg_split(
"/h/i", $creneaux[2]);
105 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]))) {
106 $_SESSION[
"horaires$i"][$j] = $creneaux[1].
'-'.$creneaux[2];
108 $errheure[$i][$j] =
true;
111 } elseif (preg_match(
";^(\d{1,2}):(\d{2})$;", $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})h(\d{0,2})$;i", $tmphorairesi[$j], $heures)) {
121 if ($heures[1] < 24 && $heures[2] < 60) {
122 $_SESSION[
"horaires$i"][$j] = $heures[0];
124 $errheure[$i][$j] =
true;
127 } elseif (preg_match(
";^(\d{1,2})-(\d{1,2})$;", $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 (preg_match(
";^(\d{1,2})h-(\d{1,2})h$;", $tmphorairesi[$j], $heures)) {
137 if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) {
138 $_SESSION[
"horaires$i"][$j] = $heures[0];
140 $errheure[$i][$j] =
true;
143 } elseif ($tmphorairesi[$j] ==
"") {
144 unset($_SESSION[
"horaires$i"][$j]);
146 $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" id="surveyform" 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"], (
int) $choixjourajout[0], $_SESSION[
"annee"])) {
438 $choixjourajout =
GETPOST(
"choixjourajout");
439 array_push($_SESSION[
"totalchoixjour"],
dol_mktime(0, 0, 0, $_SESSION[
"mois"], (
int) $choixjourajout[0], $_SESSION[
"annee"]));
440 sort($_SESSION[
"totalchoixjour"]);
441 $cle = array_search(
dol_mktime(0, 0, 0, $_SESSION[
"mois"], (
int) $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"], (
int) $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";
528 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
529 for ($j = 0; $j < $nbofchoice; $j++) {
531 if (
date(
"j", $_SESSION[
"totalchoixjour"][$j]) == $numerojour &&
date(
"n", $_SESSION[
"totalchoixjour"][$j]) == $_SESSION[
"mois"] &&
date(
"Y", $_SESSION[
"totalchoixjour"][$j]) == $_SESSION[
"annee"]) {
532 print
'<td align="center" class="choisi"><input type="submit" class="bouton OFF centpercent nomarginleft buttonwebsite" name="choixjourretrait[]" value="'.$numerojour.
'"></td>'.
"\n";
533 $dejafait = $numerojour;
539 if (!isset($dejafait) || $dejafait != $numerojour) {
541 if (($numerojour >= $jourAJ && $_SESSION[
"mois"] == $moisAJ && $_SESSION[
"annee"] == $anneeAJ) || ($_SESSION[
"mois"] > $moisAJ && $_SESSION[
"annee"] == $anneeAJ) || $_SESSION[
"annee"] > $anneeAJ) {
542 print
'<td class="center libre"><input type="submit" class="bouton ON centpercent nomarginleft buttonwebsite" name="choixjourajout[]" value="'.$numerojour.
'"></td>'.
"\n";
545 print
'<td class="center avant">'.$numerojour.
'</td>'.
"\n";
553print
'</table>'.
"\n";
554print
'</div></div>'.
"\n";
556print
'<div class="bodydate"><div class="center">'.
"\n";
562 print
'<div align="left">';
563 print
'<strong>'.$langs->trans(
"SelectedDays").
':</strong>'.
"<br>\n";
564 print $langs->trans(
"SelectDayDesc").
"<br>\n";
567 print
'<div class="div-table-responsive">';
568 print
'<table>'.
"\n";
570 print
'<td></td>'.
"\n";
572 for ($i = 0; $i < $_SESSION[
"nbrecaseshoraires"]; $i++) {
574 print
'<td class="somme"><div class="center">'.$langs->trans(
"Time").
' '.$j.
'</div></td>'.
"\n";
577 if ($_SESSION[
"nbrecaseshoraires"] < 10) {
578 print
'<td class="somme">';
579 if (
$conf->use_javascript_ajax) {
580 print
'<div id="addchoice" class="inline-block">';
581 print
img_picto(
'',
'add',
'', 0, 0, 0,
'',
'valignmiddle btnTitle-icon cursorpointer');
584 print
'<input type="hidden" name="ajoutcases" id="ajoutcases" value="">';
586 // jQuery code to handle the div click event
587 $(document).ready(function() {
588 $("#addchoice").on("click", function() {
589 console.log("Click on adchoice");
590 $("#ajoutcases").val("ajoutcases");
591 $("#surveyform").submit();
596 print
'<input type="image" name="ajoutcases" src="../img/add-16.png">';
606 $nbofchoice = count($_SESSION[
"totalchoixjour"]);
608 for ($i = 0; $i < $nbofchoice; $i++) {
610 print
'<td class="left">'.dol_print_date($_SESSION[
"totalchoixjour"][$i],
'daytext').
' <span class="opacitymedium">('.
dol_print_date($_SESSION[
"totalchoixjour"][$i],
'%A').
')</span></td>';
613 for ($j = 0; $j < $_SESSION[
"nbrecaseshoraires"]; $j++) {
614 if (isset($errheure[$i][$j]) ) {
616 print
'<td><input type=text size="10" maxlength="11" name=horaires'.$i.
'[] value="'.$_SESSION[
"horaires$i"][$j].
'" style="background-color:#FF6666;"></td>'.
"\n";
619 print
'<td><input type=text size="10" maxlength="11" name=horaires'.$i.
'[] value="'.$_SESSION[
"horaires$i"][$j].
'"></td>'.
"\n";
625 print
'</table>'.
"\n";
629 print
'<br><div class="div-table-responsive">';
630 print
'<input type="submit" class="button small" name="reset" value="'.dol_escape_htmltag($langs->trans(
"RemoveAllDays")).
'">';
631 print
'<input type="submit" class="button small" name="reporterhoraires" value="'.dol_escape_htmltag($langs->trans(
"CopyHoursOfFirstDay")).
'">';
632 print
'<input type="submit" class="button small" name="resethoraires" value="'.dol_escape_htmltag($langs->trans(
"RemoveAllHours")).
'">'.
"\n";
633 print
'<br><br>'.
"\n";
634 print
'<input type="submit" class="button" name="confirmation" value="'.$langs->trans(
"CreatePoll").
'">'.
"\n";
639print
'</table>'.
"\n";
640print
'<a name="bas"></a>'.
"\n";
644print
'<br><br><br><br>'.
"\n";
645print
'</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_now($mode='gmt')
Return date for now.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
issetAndNoEmpty($name, $tableau=null)
Function to verify that an array key exists and is not empty.
ajouter_sondage()
Add a poll.
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.