dolibarr  16.0.5
results.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2020 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
4  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
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/class/opensurveysondage.class.php";
30 require_once DOL_DOCUMENT_ROOT."/opensurvey/lib/opensurvey.lib.php";
31 
32 // Security check
33 if (empty($user->rights->opensurvey->read)) {
35 }
36 
37 // Init vars
38 $action = GETPOST('action', 'aZ09');
39 $numsondage = GETPOST("id");
40 
41 $object = new Opensurveysondage($db);
42 $result = $object->fetch(0, $numsondage);
43 if ($result <= 0) {
44  dol_print_error('', 'Failed to get survey id '.$numsondage);
45 }
46 
47 $nblines = $object->fetch_lines();
48 
49 
50 /*
51  * Actions
52  */
53 
54 // Return to the results
55 if (GETPOST('retoursondage')) {
56  header('Location: results.php?id='.(GETPOSTISSET('id_sondage') ? GETPOST('id_sondage', 'aZ09') : GETPOST('id', 'int')));
57  exit;
58 }
59 
60 $nbcolonnes = substr_count($object->sujet, ',') + 1;
61 
62 // Add vote
63 if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) { // boutonp for chrome, boutonp.x for firefox
64  if (GETPOST('nom')) {
65  $erreur_prenom = false;
66 
67  $nouveauchoix = '';
68  for ($i = 0; $i < $nbcolonnes; $i++) {
69  if (GETPOSTISSET("choix$i") && GETPOST("choix$i") == '1') {
70  $nouveauchoix .= "1";
71  } elseif (GETPOSTISSET("choix$i") && GETPOST("choix$i") == '2') {
72  $nouveauchoix .= "2";
73  } else { // sinon c'est 0
74  $nouveauchoix .= "0";
75  }
76  }
77 
78  $nom = substr(GETPOST("nom", 'alphanohtml'), 0, 64);
79 
80  // Check if vote already exists
81  $sql = 'SELECT id_users, nom as name';
82  $sql .= ' FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs';
83  $sql .= " WHERE id_sondage='".$db->escape($numsondage)."' AND nom = '".$db->escape($nom)."'";
84  $sql .= ' ORDER BY id_users';
85  $resql = $db->query($sql);
86  $num_rows = $db->num_rows($resql);
87  if ($num_rows > 0) {
88  setEventMessages($langs->trans("VoteNameAlreadyExists"), null, 'errors');
89  $error++;
90  } else {
91  $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses)';
92  $sql .= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."')";
93  $resql = $db->query($sql);
94  if (!$resql) {
95  dol_print_error($db);
96  }
97  }
98  }
99 }
100 
101 // Update vote
102 $testmodifier = false;
103 $testligneamodifier = false;
104 $ligneamodifier = -1;
105 for ($i = 0; $i < $nblines; $i++) {
106  if (GETPOSTISSET('modifierligne'.$i)) {
107  $ligneamodifier = $i;
108  $testligneamodifier = true;
109  }
110 
111  //test pour voir si une ligne est a modifier
112  if (GETPOSTISSET('validermodifier'.$i)) {
113  $modifier = $i;
114  $testmodifier = true;
115  }
116 }
117 if ($testmodifier) {
118  // Security check
119  if (!$user->rights->opensurvey->write) {
120  accessforbidden();
121  }
122 
123  $nouveauchoix = '';
124  for ($i = 0; $i < $nbcolonnes; $i++) {
125  if (GETPOSTISSET("choix$i") && GETPOST("choix$i") == '1') {
126  $nouveauchoix .= "1";
127  } elseif (GETPOSTISSET("choix$i") && GETPOST("choix$i") == '2') {
128  $nouveauchoix .= "2";
129  } else { // sinon c'est 0
130  $nouveauchoix .= "0";
131  }
132  }
133 
134  $idtomodify = GETPOST("idtomodify".$modifier);
135  $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_user_studs";
136  $sql .= " SET reponses = '".$db->escape($nouveauchoix)."'";
137  $sql .= " WHERE id_users = '".$db->escape($idtomodify)."'";
138 
139  $resql = $db->query($sql);
140  if (!$resql) {
141  dol_print_error($db);
142  }
143 }
144 
145 // Add column (not for date)
146 if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format == "A") {
147  // Security check
148  if (!$user->rights->opensurvey->write) {
149  accessforbidden();
150  }
151 
152  $nouveauxsujets = $object->sujet;
153 
154  //on rajoute la valeur a la fin de tous les sujets deja entrés
155  $nouveauxsujets .= ',';
156  $nouveauxsujets .= str_replace(array(",", "@"), " ", GETPOST("nouvellecolonne")).(!GETPOST("typecolonne") ? '' : '@'.GETPOST("typecolonne"));
157 
158  //mise a jour avec les nouveaux sujets dans la base
159  $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage";
160  $sql .= " SET sujet = '".$db->escape($nouveauxsujets)."'";
161  $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'";
162  $resql = $db->query($sql);
163  if (!$resql) {
164  dol_print_error($db);
165  } else {
166  header('Location: results.php?id='.$object->id_sondage);
167  }
168 }
169 
170 // Add column (with format date)
171 if (GETPOSTISSET("ajoutercolonne") && $object->format == "D") {
172  // Security check
173  if (!$user->rights->opensurvey->write) {
174  accessforbidden();
175  }
176 
177  $nouveauxsujets = $object->sujet;
178 
179  if (GETPOSTISSET("nouveaujour") && GETPOST("nouveaujour") != "vide" &&
180  GETPOSTISSET("nouveaumois") && GETPOST("nouveaumois") != "vide" &&
181  GETPOSTISSET("nouvelleannee") && GETPOST("nouvelleannee") != "vide") {
182  $nouvelledate = dol_mktime(0, 0, 0, GETPOST("nouveaumois"), GETPOST("nouveaujour"), GETPOST("nouvelleannee"));
183 
184  if (GETPOSTISSET("nouvelleheuredebut") && GETPOST("nouvelleheuredebut") != "vide") {
185  $nouvelledate .= "@";
186  $nouvelledate .= GETPOST("nouvelleheuredebut");
187  $nouvelledate .= "h";
188 
189  if (GETPOST("nouvelleminutedebut") != "vide") {
190  $nouvelledate .= GETPOST("nouvelleminutedebut");
191  }
192  }
193 
194  if (GETPOSTISSET("nouvelleheurefin") && GETPOST("nouvelleheurefin") != "vide") {
195  $nouvelledate .= "-";
196  $nouvelledate .= GETPOST("nouvelleheurefin");
197  $nouvelledate .= "h";
198 
199  if (GETPOST("nouvelleminutefin") != "vide") {
200  $nouvelledate .= GETPOST("nouvelleminutefin");
201  }
202  }
203 
204  if (GETPOST("nouvelleheuredebut") == "vide" || (GETPOSTISSET("nouvelleheuredebut") && GETPOSTISSET("nouvelleheurefin")
205  && (GETPOST("nouvelleheuredebut") < GETPOST("nouvelleheurefin") || (GETPOST("nouvelleheuredebut") == GETPOST("nouvelleheurefin")
206  && (GETPOST("nouvelleminutedebut") < GETPOST("nouvelleminutefin")))))) {
207  $erreur_ajout_date = false;
208  } else {
209  $erreur_ajout_date = "yes";
210  }
211 
212  //on rajoute la valeur dans les valeurs
213  $datesbase = explode(",", $object->sujet);
214  $taillebase = count($datesbase);
215 
216  //recherche de l'endroit de l'insertion de la nouvelle date dans les dates deja entrées dans le tableau
217  if ($nouvelledate < $datesbase[0]) {
218  $cleinsertion = 0;
219  } elseif ($nouvelledate > $datesbase[$taillebase - 1]) {
220  $cleinsertion = count($datesbase);
221  } else {
222  $nbdatesbase = count($datesbase);
223  for ($i = 0; $i < $nbdatesbase; $i++) {
224  $j = $i + 1;
225  if ($nouvelledate > $datesbase[$i] && $nouvelledate < $datesbase[$j]) {
226  $cleinsertion = $j;
227  }
228  }
229  }
230 
231  array_splice($datesbase, $cleinsertion, 0, $nouvelledate);
232  $cle = array_search($nouvelledate, $datesbase);
233  $dateinsertion = '';
234  $nbofdates = count($datesbase);
235  for ($i = 0; $i < $nbofdates; $i++) {
236  $dateinsertion .= ",";
237  $dateinsertion .= $datesbase[$i];
238  }
239 
240  $dateinsertion = substr("$dateinsertion", 1);
241 
242  // update with new topics into database
243  if (isset($erreur_ajout_date) && empty($erreur_ajout_date)) {
244  $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage";
245  $sql .= " SET sujet = '".$db->escape($dateinsertion)."'";
246  $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'";
247  $resql = $db->query($sql);
248  if (!$resql) {
249  dol_print_error($db);
250  } else {
251  header('Location: results.php?id='.$object->id_sondage);
252  }
253  }
254  if ($cleinsertion >= 0) {
255  $sql = 'SELECT s.reponses';
256  $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs as s";
257  $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'";
258  $resql = $db->query($sql);
259  if (!$resql) {
260  dol_print_error($db);
261  } else {
262  $num = $db->num_rows($resql);
263  $compteur = 0;
264  while ($compteur < $num) {
265  $obj = $db->fetch_object($resql);
266  $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_user_studs";
267  if ($cleinsertion == 0) {
268  $sql .= " SET reponses = '0".$db->escape($obj->reponses)."'";
269  } else {
270  $reponsesadd = str_split($obj->reponses);
271  $lengthresponses = count($reponsesadd);
272  for ($cpt = $lengthresponses; $cpt > $cleinsertion; $cpt--) {
273  $reponsesadd[$cpt] = $reponsesadd[$cpt-1];
274  }
275  $reponsesadd[$cleinsertion] = '0';
276  $reponsesadd = implode($reponsesadd);
277  $sql .= " SET reponses = '".$db->escape($reponsesadd)."'";
278  }
279  $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'";
280  $resql = $db->query($sql);
281  if (!$resql) {
282  dol_print_error($db);
283  }
284  $compteur++;
285  }
286  }
287  }
288  $adresseadmin = $object->mail_admin;
289  } else {
290  $erreur_ajout_date = "yes";
291  }
292 }
293 
294 // Delete line
295 for ($i = 0; $i < $nblines; $i++) {
296  if (GETPOST("effaceligne".$i) || GETPOST("effaceligne".$i."_x") || GETPOST("effaceligne".$i.".x")) { // effacelignei for chrome, effacelignei_x for firefox
297  // Security check
298  if (!$user->rights->opensurvey->write) {
299  accessforbidden();
300  }
301 
302  $compteur = 0;
303 
304  // Loop on each answer
305  $compteur = 0;
306  $sql = "SELECT id_users, nom as name, id_sondage, reponses";
307  $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs";
308  $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'";
309  $resql = $db->query($sql);
310  if (!$resql) {
311  dol_print_error($db);
312  }
313  $num = $db->num_rows($resql);
314  while ($compteur < $num) {
315  $obj = $db->fetch_object($resql);
316 
317  if ($compteur == $i) {
318  $sql2 = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs';
319  $sql2 .= " WHERE id_users = ".((int) $obj->id_users);
320  $resql2 = $db->query($sql2);
321  }
322 
323  $compteur++;
324  }
325  }
326 }
327 
328 // Delete column
329 for ($i = 0; $i < $nbcolonnes; $i++) {
330  if ((GETPOST("effacecolonne".$i) || GETPOST("effacecolonne".$i."_x") || GETPOST("effacecolonne".$i.".x"))
331  && $nbcolonnes > 1) { // effacecolonnei for chrome, effacecolonnei_x for firefox
332  // Security check
333  if (!$user->rights->opensurvey->write) {
334  accessforbidden();
335  }
336 
337  $db->begin();
338 
339  $toutsujet = explode(",", $object->sujet);
340  $j = 0;
341  $nouveauxsujets = '';
342 
343  //parcours de tous les sujets actuels
344  while (isset($toutsujet[$j])) {
345  //si le sujet n'est pas celui qui a été effacé alors on concatene
346  if ($i != $j) {
347  if (!empty($nouveauxsujets)) {
348  $nouveauxsujets .= ',';
349  }
350  $nouveauxsujets .= $toutsujet[$j];
351  }
352 
353  $j++;
354  }
355 
356  // Mise a jour des sujets dans la base
357  $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage";
358  $sql .= " SET sujet = '".$db->escape($nouveauxsujets)."' WHERE id_sondage = '".$db->escape($numsondage)."'";
359  $resql = $db->query($sql);
360  if (!$resql) {
361  dol_print_error($db);
362  }
363 
364  // Clean current answer to remove deleted columns
365  $compteur = 0;
366  $sql = "SELECT id_users, nom as name, id_sondage, reponses";
367  $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs";
368  $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'";
369  dol_syslog('sql='.$sql);
370  $resql = $db->query($sql);
371  if (!$resql) {
372  dol_print_error($db);
373  exit;
374  }
375  $num = $db->num_rows($resql);
376  while ($compteur < $num) {
377  $obj = $db->fetch_object($resql);
378 
379  $newcar = '';
380  $ensemblereponses = $obj->reponses;
381 
382  // parcours de toutes les réponses actuelles
383  for ($j = 0; $j < $nbcolonnes; $j++) {
384  $car = substr($ensemblereponses, $j, 1);
385  //si les reponses ne concerne pas la colonne effacée, on concatene
386  if ($i != $j) {
387  $newcar .= $car;
388  }
389  }
390 
391  // mise a jour des reponses utilisateurs dans la base
392  $sql2 = 'UPDATE '.MAIN_DB_PREFIX.'opensurvey_user_studs';
393  $sql2 .= " SET reponses = '".$db->escape($newcar)."'";
394  $sql2 .= " WHERE id_users = '".$db->escape($obj->id_users)."'";
395  //print $sql2;
396  dol_syslog('sql='.$sql2);
397  $resql2 = $db->query($sql2);
398 
399  $compteur++;
400  }
401 
402  $db->commit();
403  }
404 }
405 
406 
407 
408 /*
409  * View
410  */
411 
412 $form = new Form($db);
413 
414 if ($object->fk_user_creat) {
415  $userstatic = new User($db);
416  $userstatic->fetch($object->fk_user_creat);
417 }
418 
419 $result = $object->fetch(0, $numsondage);
420 if ($result <= 0) {
421  dol_print_error($db, $object->error);
422  exit;
423 }
424 
425 $title = $object->title." - ".$langs->trans('Card');
426 $helpurl = '';
427 $arrayofjs = array();
428 $arrayofcss = array('/opensurvey/css/style.css');
429 llxHeader('', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss);
430 
431 
432 // Define format of choices
433 $toutsujet = explode(",", $object->sujet);
434 $listofanswers = array();
435 foreach ($toutsujet as $value) {
436  $tmp = explode('@', $value);
437  $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox'));
438 }
439 $toutsujet = str_replace("@", "<br>", $toutsujet);
440 $toutsujet = str_replace("°", "'", $toutsujet);
441 
442 
443 print '<form name="formulaire4" action="#" method="POST">'."\n";
444 print '<input type="hidden" name="token" value="'.newToken().'">';
445 
446 $head = opensurvey_prepare_head($object);
447 
448 print dol_get_fiche_head($head, 'preview', $langs->trans("Survey"), -1, 'poll');
449 
450 $morehtmlref = '';
451 
452 $linkback = '<a href="'.DOL_URL_ROOT.'/opensurvey/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
453 
454 dol_banner_tab($object, 'id', $linkback, 1, 'id_sondage', 'id_sondage', $morehtmlref);
455 
456 
457 print '<div class="fichecenter">';
458 
459 print '<div class="fichehalfleft">';
460 print '<div class="underbanner clearboth"></div>';
461 print '<table class="border tableforfield centpercent">';
462 
463 // Type
464 $type = ($object->format == "A") ? 'classic' : 'date';
465 print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td>';
466 print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic' ? 'chart-32.png' : 'calendar-32.png'), 1), 'width="16"', 1);
467 print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate").'</td></tr>';
468 
469 // Title
470 print '<tr><td>';
471 $adresseadmin = $object->mail_admin;
472 print $langs->trans("Title").'</td><td>';
473 if ($action == 'edit') {
474  print '<input type="text" name="nouveautitre" size="40" value="'.dol_escape_htmltag($object->title).'">';
475 } else {
476  print dol_htmlentities($object->title);
477 }
478 print '</td></tr>';
479 
480 // Description
481 print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
482 if ($action == 'edit') {
483  $doleditor = new DolEditor('nouveauxcommentaires', $object->description, '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%');
484  $doleditor->Create(0, '');
485 } else {
486  print (dol_textishtml($object->description) ? $object->description : dol_nl2br($object->description, 1, true));
487 }
488 print '</td></tr>';
489 
490 // EMail
491 //If linked user, then emails are going to be sent to users' email
492 if (!$object->fk_user_creat) {
493  print '<tr><td>'.$langs->trans("EMail").'</td><td>';
494  if ($action == 'edit') {
495  print '<input type="text" name="nouvelleadresse" class="minwith200" value="'.$object->mail_admin.'">';
496  } else {
497  print dol_print_email($object->mail_admin, 0, 0, 1, 0, 1, 1);
498  }
499  print '</td></tr>';
500 }
501 
502 print '</table>';
503 
504 print '</div>';
505 print '<div class="fichehalfright">';
506 print '<div class="underbanner clearboth"></div>';
507 
508 print '<table class="border tableforfield centpercent">';
509 
510 
511 // Expire date
512 print '<tr><td>'.$langs->trans('ExpireDate').'</td><td>';
513 if ($action == 'edit') {
514  print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0);
515 } else {
516  print dol_print_date($object->date_fin, 'day');
517  if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) {
518  print img_warning($langs->trans("Expired"));
519  }
520 }
521 print '</td></tr>';
522 
523 // Author
524 print '<tr><td>';
525 print $langs->trans("Author").'</td><td>';
526 if ($object->fk_user_creat) {
527  print $userstatic->getLoginUrl(1);
528 } else {
529  print dol_htmlentities($object->nom_admin);
530 }
531 print '</td></tr>';
532 
533 // Link
534 print '<tr><td>'.$langs->trans("UrlForSurvey", '').'</td><td>';
535 
536 // Define $urlwithroot
537 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
538 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
539 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
540 
541 $url = $urlwithouturlroot.dol_buildpath('/public/opensurvey/studs.php', 1).'?sondage='.$object->id_sondage;
542 $urllink = '<input type="text" class="quatrevingtpercent" '.($action == 'edit' ? 'disabled' : '').' id="opensurveyurl" name="opensurveyurl" value="'.$url.'">';
543 print $urllink;
544 if ($action != 'edit') {
545  print ajax_autoselect("opensurveyurl", $url, 'image');
546 }
547 
548 print '</td></tr>';
549 
550 print '</table>';
551 print '</div>';
552 
553 print '</div>';
554 print '<div class="clearboth"></div>';
555 
556 print dol_get_fiche_end();
557 
558 print '</form>'."\n";
559 
560 
561 // Buttons
562 
563 print '<div class="tabsAction">';
564 
565 print '<a class="butAction" href="exportcsv.php?id='.urlencode($numsondage).'">'.$langs->trans("ExportSpreadsheet").' (.CSV)</a>';
566 
567 print '</div>';
568 
569 
570 // Show form to add a new field/column
571 if (GETPOST('ajoutsujet')) {
572  // Security check
573  if (!$user->rights->opensurvey->write) {
574  accessforbidden();
575  }
576 
577  print '<form name="formulaire" action="" method="POST">'."\n";
578  print '<input type="hidden" name="token" value="'.newToken().'">';
579  print '<input type="hidden" name="backtopage" value="'.GETPOST('backtopage', 'alpha').'">';
580 
581  print '<div class="center">'."\n";
582  print "<br><br>\n";
583 
584  // Add new column
585  if ($object->format == "A") {
586  print $langs->trans("AddNewColumn").':<br><br>';
587  print $langs->trans("Title").' <input type="text" name="nouvellecolonne" size="40"><br>';
588  $tmparray = array('checkbox'=>$langs->trans("CheckBox"), 'yesno'=>$langs->trans("YesNoList"), 'foragainst'=>$langs->trans("PourContreList"));
589  print $langs->trans("Type").' '.$form->selectarray("typecolonne", $tmparray, GETPOST('typecolonne')).'<br><br>';
590  print '<input type="submit" class="button" name="ajoutercolonne" value="'.dol_escape_htmltag($langs->trans("Add")).'">';
591  print '<input type="hidden" name="id_sondage" value="'.dol_escape_htmltag($object->id_sondage).'">';
592  print ' &nbsp; &nbsp; ';
593  print '<input type="submit" class="button button-cancel" name="retoursondage" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
594  print '<br><br>'."\n";
595  } else {
596  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
597 
598  $formother = new FormOther($db);
599  //ajout d'une date avec creneau horaire
600  print $langs->trans("AddADate").':<br><br>'."\n";
601  print '<select name="nouveaujour"> '."\n";
602  print '<OPTION VALUE="vide">&nbsp;</OPTION>'."\n";
603  for ($i = 1; $i < 32; $i++) {
604  print '<OPTION VALUE="'.$i.'">'.$i.'</OPTION>'."\n";
605  }
606  print '</select>'."\n";
607 
608  print $formother->select_month('', 'nouveaumois', 1);
609 
610  print '&nbsp;';
611 
612  print $formother->selectyear('', 'nouvelleannee', 1, 0, 5, 0, 1);
613 
614  print '<br><br>'.$langs->trans("AddStartHour").': <br><br>'."\n";
615  print '<select name="nouvelleheuredebut"> '."\n";
616  print '<OPTION VALUE="vide">&nbsp;</OPTION>'."\n";
617  for ($i = 0; $i < 24; $i++) {
618  print '<OPTION VALUE="'.$i.'">'.$i.' H</OPTION>'."\n";
619  }
620  print '</select>'."\n";
621  print '<select name="nouvelleminutedebut"> '."\n";
622  print '<OPTION VALUE="vide">&nbsp;</OPTION>'."\n";
623  print '<OPTION VALUE="00">00</OPTION>'."\n";
624  print '<OPTION VALUE="15">15</OPTION>'."\n";
625  print '<OPTION VALUE="30">30</OPTION>'."\n";
626  print '<OPTION VALUE="45">45</OPTION>'."\n";
627  print '</select>'."\n";
628  print '<br><br>'.$langs->trans("AddEndHour").': <br><br>'."\n";
629  print '<select name="nouvelleheurefin"> '."\n";
630  print '<OPTION VALUE="vide">&nbsp;</OPTION>'."\n";
631  for ($i = 0; $i < 24; $i++) {
632  print '<OPTION VALUE="'.$i.'">'.$i.' H</OPTION>'."\n";
633  }
634  print '</SELECT>'."\n";
635  print '<select name="nouvelleminutefin"> '."\n";
636  print '<OPTION VALUE="vide">&nbsp;</OPTION>'."\n";
637  print '<OPTION VALUE="00">00</OPTION>'."\n";
638  print '<OPTION VALUE="15">15</OPTION>'."\n";
639  print '<OPTION VALUE="30">30</OPTION>'."\n";
640  print '<OPTION VALUE="45">45</OPTION>'."\n";
641  print '</select>'."\n";
642 
643  print '<br><br>';
644  print' <input type="submit" class="button" name="ajoutercolonne" value="'.dol_escape_htmltag($langs->trans("Add")).'">'."\n";
645  print '&nbsp; &nbsp;';
646  print '<input type="submit" class="button button-cancel" name="retoursondage" value="'.$langs->trans("Cancel").'">';
647  }
648 
649  print '</form>'."\n";
650  print '<br><br><br><br>'."\n";
651  print '</div>'."\n";
652 
653  exit;
654 }
655 
656 if ($user->rights->opensurvey->write) {
657  print '<span class="opacitymedium">';
658  $s = $langs->trans("PollAdminDesc", '{s1}', $langs->trans("Add"));
659  print str_replace('{s1}', img_picto('', 'delete'), $s);
660  print '</span><br>';
661 }
662 
663 $nbcolonnes = substr_count($object->sujet, ',') + 1;
664 
665 print '<form name="formulaire" action="" method="POST">'."\n";
666 print '<input type="hidden" name="token" value="'.newToken().'">';
667 print '<input type="hidden" name="page_y" value="">';
668 
669 print '<div class="cadre div-table-responsive-no-min"> '."\n";
670 
671 // Start to show survey result
672 print '<table class="resultats">'."\n";
673 
674 //reformatage des données des sujets du sondage
675 $toutsujet = explode(",", $object->sujet);
676 $toutsujet = str_replace("°", "'", $toutsujet);
677 
678 print '<tr>'."\n";
679 print '<td></td>'."\n";
680 print '<td></td>'."\n";
681 
682 // loop to show the delete link
683 if ($user->rights->opensurvey->write) {
684  for ($i = 0; isset($toutsujet[$i]); $i++) {
685  print '<td class=somme><input type="image" name="effacecolonne'.$i.'" src="'.img_picto('', 'delete.png', '', false, 1).'"></td>'."\n";
686  }
687 }
688 
689 print '</tr>'."\n";
690 
691 
692 // Show choice titles
693 if ($object->format == "D") {
694  //affichage des sujets du sondage
695  print '<tr>'."\n";
696  print '<td></td>'."\n";
697  print '<td></td>'."\n";
698 
699  //affichage des années
700  $colspan = 1;
701  $nbofsujet = count($toutsujet);
702  for ($i = 0; $i < $nbofsujet; $i++) {
703  $current = $toutsujet[$i];
704 
705  if (strpos($toutsujet[$i], '@') !== false) {
706  $current = substr($toutsujet[$i], 0, strpos($toutsujet[$i], '@'));
707  }
708 
709  if (isset($toutsujet[$i + 1]) && strpos($toutsujet[$i + 1], '@') !== false) {
710  $next = substr($toutsujet[$i + 1], 0, strpos($toutsujet[$i + 1], '@'));
711  } elseif (isset($toutsujet[$i + 1])) {
712  $next = $toutsujet[$i + 1];
713  }
714 
715  $currenty = 0;
716  if ($current) {
717  $currenty = strftime("%Y", $current);
718  }
719  $next = 0;
720  if ($next) {
721  $nexty = strftime("%Y", $next);
722  }
723  if (isset($toutsujet[$i + 1]) && ($currenty == $nexty)) {
724  $colspan++;
725  } else {
726  print '<td colspan='.$colspan.' class="annee">';
727  if ($current) {
728  print strftime("%Y", $current);
729  }
730  print '</td>'."\n";
731  $colspan = 1;
732  }
733  }
734 
735  if ($user->rights->opensurvey->write) {
736  print '<td class="annee">';
737  print '<a href="'.$_SERVER["PHP_SELF"].'?ajoutsujet=1&id='.$object->id_sondage.'">'.$langs->trans("Add").'</a></td>'."\n";
738  }
739 
740  print '</tr>'."\n";
741  print '<tr>'."\n";
742  print '<td></td>'."\n";
743  print '<td></td>'."\n";
744 
745  //affichage des mois
746  $colspan = 1;
747  for ($i = 0; $i < $nbofsujet; $i++) {
748  $cur = intval($toutsujet[$i]); // intval() est utiliser pour supprimer le suffixe @* qui déplaît logiquement à strftime()
749 
750  if (isset($toutsujet[$i + 1]) === false) {
751  $next = false;
752  } else {
753  $next = intval($toutsujet[$i + 1]);
754  }
755 
756  if ($next && dol_print_date($cur, "%B") == dol_print_date($next, "%B") && dol_print_date($cur, "%Y") == dol_print_date($next, "%Y")) {
757  $colspan++;
758  } else {
759  print '<td colspan='.$colspan.' class="mois">'.dol_print_date($cur, "%B").'</td>'."\n";
760 
761  $colspan = 1;
762  }
763  }
764 
765  if ($user->rights->opensurvey->write) {
766  print '<td class="mois"><a href="'.$_SERVER["PHP_SELF"].'?ajoutsujet=1&id='.$object->id_sondage.'">'.$langs->trans("Add").'</a></td>'."\n";
767  }
768 
769  print '</tr>'."\n";
770  print '<tr>'."\n";
771  print '<td></td>'."\n";
772  print '<td></td>'."\n";
773 
774  //affichage des jours
775  $colspan = 1;
776  for ($i = 0; $i < $nbofsujet; $i++) {
777  $cur = intval($toutsujet[$i]);
778  if (isset($toutsujet[$i + 1]) === false) {
779  $next = false;
780  } else {
781  $next = intval($toutsujet[$i + 1]);
782  }
783  if ($next && dol_print_date($cur, "%a %e") == dol_print_date($next, "%a %e") && dol_print_date($cur, "%B") == dol_print_date($next, "%B")) {
784  $colspan++;
785  } else {
786  print '<td colspan='.$colspan.' class="jour">'.dol_print_date($cur, "%a %e").'</td>'."\n";
787 
788  $colspan = 1;
789  }
790  }
791 
792  if ($user->rights->opensurvey->write) {
793  print '<td class="jour"><a href="'.$_SERVER["PHP_SELF"].'?ajoutsujet=1&id='.$object->id_sondage.'">'.$langs->trans("Add").'</a></td>'."\n";
794  }
795  print '</tr>'."\n";
796 
797  //affichage des horaires
798  if (strpos($object->sujet, '@') !== false) {
799  print '<tr>'."\n";
800  print '<td></td>'."\n";
801  print '<td></td>'."\n";
802 
803  for ($i = 0; isset($toutsujet[$i]); $i++) {
804  $heures = explode('@', $toutsujet[$i]);
805  if (isset($heures[1])) {
806  print '<td class="heure">'.dol_htmlentities($heures[1]).'</td>'."\n";
807  } else {
808  print '<td class="heure"></td>'."\n";
809  }
810  }
811 
812  if ($user->rights->opensurvey->write) {
813  print '<td class="heure"><a href="'.$_SERVER["PHP_SELF"].'?ajoutsujet=1&id='.$object->id_sondage.'">'.$langs->trans("Add").'</a></td>'."\n";
814  }
815 
816  print '</tr>'."\n";
817  }
818 } else {
819  // Show titles
820  print '<tr>'."\n";
821  print '<td></td>'."\n";
822  print '<td></td>'."\n";
823 
824  for ($i = 0; isset($toutsujet[$i]); $i++) {
825  $tmp = explode('@', $toutsujet[$i]);
826  print '<td class="sujet">'.dol_htmlentities($tmp[0]).'</td>'."\n";
827  }
828 
829  print '<td class="sujet"><a href="'.$_SERVER["PHP_SELF"].'?id='.$numsondage.'&ajoutsujet=1&backtopage='.urlencode($_SERVER["PHP_SELF"]).'"><span class="fa fa-plus-circle valignmiddle btnTitle-icon"></span></a></td>'."\n";
830  print '</tr>'."\n";
831 }
832 
833 
834 // Loop on each answer
835 $sumfor = array();
836 $sumagainst = array();
837 $compteur = 0;
838 $sql = "SELECT id_users, nom as name, id_sondage, reponses";
839 $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs";
840 $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'";
841 dol_syslog('sql='.$sql);
842 $resql = $db->query($sql);
843 if (!$resql) {
844  dol_print_error($db);
845  exit;
846 }
847 $num = $db->num_rows($resql);
848 while ($compteur < $num) {
849  $obj = $db->fetch_object($resql);
850 
851  $ensemblereponses = $obj->reponses;
852 
853  print '<tr><td>'."\n";
854 
855  if ($user->rights->opensurvey->write) {
856  print '<input type="image" class="reposition" name="effaceligne'.$compteur.'" src="'.img_picto('', 'delete.png', '', false, 1).'">'."\n";
857  }
858 
859  // Name
860  print '</td><td class="nom">'.dol_htmlentities($obj->name).'</td>'."\n";
861 
862  // si la ligne n'est pas a changer, on affiche les données
863  if (!$testligneamodifier) {
864  for ($i = 0; $i < $nbcolonnes; $i++) {
865  $car = substr($ensemblereponses, $i, 1);
866  //print 'xx'.$i."-".$car.'-'.$listofanswers[$i]['format'].'zz';
867 
868  if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
869  if (((string) $car) == "1") {
870  print '<td class="ok">OK</td>'."\n";
871  } else {
872  print '<td class="non">KO</td>'."\n";
873  }
874  // Total
875  if (!isset($sumfor[$i])) {
876  $sumfor[$i] = 0;
877  }
878  if (((string) $car) == "1") {
879  $sumfor[$i]++;
880  }
881  }
882  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') {
883  if (((string) $car) == "1") {
884  print '<td class="ok">'.$langs->trans("Yes").'</td>'."\n";
885  } elseif (((string) $car) == "0") {
886  print '<td class="non">'.$langs->trans("No").'</td>'."\n";
887  } else {
888  print '<td class="vide">&nbsp;</td>'."\n";
889  }
890  // Total
891  if (!isset($sumfor[$i])) {
892  $sumfor[$i] = 0;
893  }
894  if (!isset($sumagainst[$i])) {
895  $sumagainst[$i] = 0;
896  }
897  if (((string) $car) == "1") {
898  $sumfor[$i]++;
899  }
900  if (((string) $car) == "0") {
901  $sumagainst[$i]++;
902  }
903  }
904  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') {
905  if (((string) $car) == "1") {
906  print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
907  } elseif (((string) $car) == "0") {
908  print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
909  } else {
910  print '<td class="vide">&nbsp;</td>'."\n";
911  }
912  // Total
913  if (!isset($sumfor[$i])) {
914  $sumfor[$i] = 0;
915  }
916  if (!isset($sumagainst[$i])) {
917  $sumagainst[$i] = 0;
918  }
919  if (((string) $car) == "1") {
920  $sumfor[$i]++;
921  }
922  if (((string) $car) == "0") {
923  $sumagainst[$i]++;
924  }
925  }
926  }
927  } else {
928  //sinon on remplace les choix de l'utilisateur par une ligne de checkbox pour recuperer de nouvelles valeurs
929  if ($compteur == $ligneamodifier) {
930  for ($i = 0; $i < $nbcolonnes; $i++) {
931  $car = substr($ensemblereponses, $i, 1);
932  print '<td class="vide">';
933  if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
934  print '<input type="checkbox" name="choix'.$i.'" value="1" ';
935  if ($car == '1') {
936  print 'checked';
937  }
938  print '>';
939  }
940  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') {
941  $arraychoice = array('2'=>'&nbsp;', '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes"));
942  print $form->selectarray("choix".$i, $arraychoice, $car);
943  }
944  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') {
945  $arraychoice = array('2'=>'&nbsp;', '0'=>$langs->trans("Against"), '1'=>$langs->trans("For"));
946  print $form->selectarray("choix".$i, $arraychoice, $car);
947  }
948  print '</td>'."\n";
949  }
950  } else {
951  for ($i = 0; $i < $nbcolonnes; $i++) {
952  $car = substr($ensemblereponses, $i, 1);
953  if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
954  if (((string) $car) == "1") {
955  print '<td class="ok">OK</td>'."\n";
956  } else {
957  print '<td class="non">KO</td>'."\n";
958  }
959  // Total
960  if (!isset($sumfor[$i])) {
961  $sumfor[$i] = 0;
962  }
963  if (((string) $car) == "1") {
964  $sumfor[$i]++;
965  }
966  }
967  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') {
968  if (((string) $car) == "1") {
969  print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
970  } elseif (((string) $car) == "0") {
971  print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
972  } else {
973  print '<td class="vide">&nbsp;</td>'."\n";
974  }
975  // Total
976  if (!isset($sumfor[$i])) {
977  $sumfor[$i] = 0;
978  }
979  if (!isset($sumagainst[$i])) {
980  $sumagainst[$i] = 0;
981  }
982  if (((string) $car) == "1") {
983  $sumfor[$i]++;
984  }
985  if (((string) $car) == "0") {
986  $sumagainst[$i]++;
987  }
988  }
989  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') {
990  if (((string) $car) == "1") {
991  print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
992  } elseif (((string) $car) == "0") {
993  print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
994  } else {
995  print '<td class="vide">&nbsp;</td>'."\n";
996  }
997  // Total
998  if (!isset($sumfor[$i])) {
999  $sumfor[$i] = 0;
1000  }
1001  if (!isset($sumagainst[$i])) {
1002  $sumagainst[$i] = 0;
1003  }
1004  if (((string) $car) == "1") {
1005  $sumfor[$i]++;
1006  }
1007  if (((string) $car) == "0") {
1008  $sumagainst[$i]++;
1009  }
1010  }
1011  }
1012  }
1013  }
1014 
1015  // Button edit at end of line
1016  if ($compteur != $ligneamodifier && ($user->rights->opensurvey->write)) {
1017  print '<td class="casevide"><input type="submit" class="button reposition" name="modifierligne'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Edit")).'"></td>'."\n";
1018  }
1019 
1020  //demande de confirmation pour modification de ligne
1021  for ($i = 0; $i < $nblines; $i++) {
1022  if (GETPOSTISSET("modifierligne".$i)) {
1023  if ($compteur == $i) {
1024  print '<td class="casevide">';
1025  print '<input type="hidden" name="idtomodify'.$compteur.'" value="'.$obj->id_users.'">';
1026  print '<input type="submit" class="button button-save reposition" name="validermodifier'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
1027  print '</td>'."\n";
1028  }
1029  }
1030  }
1031 
1032  $compteur++;
1033  print '</tr>'."\n";
1034 }
1035 
1036 // Add line to add new record
1037 if (empty($testligneamodifier)) {
1038  print '<tr>'."\n";
1039  print '<td></td>'."\n";
1040  print '<td class="nom">'."\n";
1041  print '<input type="text" class="maxwidthonsmartphone" placeholder="'.dol_escape_htmltag($langs->trans("Name")).'" name="nom" maxlength="64">'."\n";
1042  print '</td>'."\n";
1043 
1044  for ($i = 0; $i < $nbcolonnes; $i++) {
1045  print '<td class="vide">';
1046  if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
1047  print '<input type="checkbox" name="choix'.$i.'" value="1"';
1048  if (GETPOSTISSET('choix'.$i) && GETPOST('choix'.$i) == '1') {
1049  print ' checked';
1050  }
1051  print '>';
1052  }
1053  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') {
1054  $arraychoice = array('2'=>'&nbsp;', '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes"));
1055  print $form->selectarray("choix".$i, $arraychoice);
1056  }
1057  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') {
1058  $arraychoice = array('2'=>'&nbsp;', '0'=>$langs->trans("Against"), '1'=>$langs->trans("For"));
1059  print $form->selectarray("choix".$i, $arraychoice);
1060  }
1061  print '</td>'."\n";
1062  }
1063 
1064  // Affichage du bouton de formulaire pour inscrire un nouvel utilisateur dans la base
1065  print '<td><input type="image" name="boutonp" class="borderimp" value="'.$langs->trans("Vote").'" src="'.img_picto('', 'edit_add', '', false, 1).'"></td>'."\n";
1066  print '</tr>'."\n";
1067 }
1068 
1069 // Select value of best choice (for checkbox columns only)
1070 $nbofcheckbox = 0;
1071 for ($i = 0; $i < $nbcolonnes + 1; $i++) {
1072  if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
1073  $nbofcheckbox++;
1074  }
1075  if (isset($sumfor[$i])) {
1076  if ($i == 0) {
1077  $meilleurecolonne = $sumfor[$i];
1078  }
1079  if (isset($sumfor[$i]) && $sumfor[$i] > $meilleurecolonne) {
1080  $meilleurecolonne = $sumfor[$i];
1081  }
1082  }
1083 }
1084 
1085 
1086 // Show line total
1087 print '<tr>'."\n";
1088 print '<td></td>'."\n";
1089 print '<td class="center">'.$langs->trans("Total").'</td>'."\n";
1090 for ($i = 0; $i < $nbcolonnes; $i++) {
1091  $showsumfor = isset($sumfor[$i]) ? $sumfor[$i] : '';
1092  $showsumagainst = isset($sumagainst[$i]) ? $sumagainst[$i] : '';
1093  if (empty($showsumfor)) {
1094  $showsumfor = 0;
1095  }
1096  if (empty($showsumagainst)) {
1097  $showsumagainst = 0;
1098  }
1099 
1100  print '<td>';
1101  if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
1102  print $showsumfor;
1103  }
1104  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') {
1105  print $langs->trans("Yes").': '.$showsumfor.'<br>'.$langs->trans("No").': '.$showsumagainst;
1106  }
1107  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') {
1108  print $langs->trans("For").': '.$showsumfor.'<br>'.$langs->trans("Against").': '.$showsumagainst;
1109  }
1110  print '</td>'."\n";
1111 }
1112 print '</tr>';
1113 // Show picto winner
1114 if ($nbofcheckbox >= 2) {
1115  print '<tr>'."\n";
1116  print '<td></td>'."\n";
1117  print '<td></td>'."\n";
1118  for ($i = 0; $i < $nbcolonnes; $i++) {
1119  if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) {
1120  print '<td class="somme"><img src="'.dol_buildpath('/opensurvey/img/medaille.png', 1).'"></td>'."\n";
1121  } else {
1122  print '<td class="somme"></td>'."\n";
1123  }
1124  }
1125  print '</tr>'."\n";
1126 }
1127 
1128 // S'il a oublié de remplir un nom
1129 if (GETPOSTISSET("boutonp") && GETPOST("nom") == "") {
1130  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name")), null, 'errors');
1131 }
1132 
1133 if (isset($erreur_prenom) && $erreur_prenom) {
1134  setEventMessages($langs->trans('VoteNameAlreadyExists'), null, 'errors');
1135 }
1136 
1137 if (isset($erreur_ajout_date) && $erreur_ajout_date) {
1138  setEventMessages($langs->trans("ErrorWrongDate"), null, 'errors');
1139 }
1140 
1141 //fin du tableau
1142 print '</table>'."\n";
1143 print '</div>'."\n";
1144 
1145 
1146 $toutsujet = explode(",", $object->sujet); // With old versions, this field was not set
1147 
1148 $compteursujet = 0;
1149 $meilleursujet = '';
1150 for ($i = 0; $i < $nbcolonnes; $i++) {
1151  if (isset($sumfor[$i]) === true && isset($meilleurecolonne) === true && $sumfor[$i] == $meilleurecolonne) {
1152  $meilleursujet .= ($meilleursujet ? ", " : "");
1153 
1154  if ($object->format == "D") {
1155  $meilleursujetexport = $toutsujet[$i];
1156  //var_dump($toutsujet);
1157  if (strpos($toutsujet[$i], '@') !== false) {
1158  $toutsujetdate = explode("@", $toutsujet[$i]);
1159  $meilleursujet .= dol_print_date($toutsujetdate[0], 'daytext').($toutsujetdate[0] ? ' ('.dol_print_date($toutsujetdate[0], '%A').')' : '').' - '.$toutsujetdate[1];
1160  } else {
1161  $meilleursujet .= dol_print_date((empty($toutsujet[$i]) ? 0 : $toutsujet[$i]), 'daytext').' ('.dol_print_date((empty($toutsujet[$i]) ? 0 : $toutsujet[$i]), '%A').')';
1162  }
1163  } else {
1164  $tmps = explode('@', $toutsujet[$i]);
1165  $meilleursujet .= dol_htmlentities($tmps[0]);
1166  }
1167 
1168  $compteursujet++;
1169  }
1170 }
1171 $meilleursujet = substr($meilleursujet, 1);
1172 $meilleursujet = str_replace("°", "'", $meilleursujet);
1173 
1174 // Show best choice
1175 if ($nbofcheckbox >= 2) {
1176  $vote_str = $langs->trans('votes');
1177  print '<p class="affichageresultats">'."\n";
1178 
1179  if (isset($meilleurecolonne) && $compteursujet == "1") {
1180  print "<img src=\"".DOL_URL_ROOT.'/opensurvey/img/medaille.png'."\"> ".$langs->trans('TheBestChoice').": <b>".$meilleursujet." </b>".$langs->trans("with")." <b>".$meilleurecolonne."</b> ".$vote_str.".\n";
1181  } elseif (isset($meilleurecolonne)) {
1182  print "<img src=\"".DOL_URL_ROOT.'/opensurvey/img/medaille.png'."\"> ".$langs->trans('TheBestChoices').": <b>".$meilleursujet." </b>".$langs->trans("with")." <b>".$meilleurecolonne."</b> ".$vote_str.".\n";
1183  }
1184  print '<br></p><br>'."\n";
1185 }
1186 
1187 print '</form>'."\n";
1188 
1189 print '<a name="bas"></a>'."\n";
1190 
1191 llxFooter();
1192 
1193 $db->close();
Opensurveysondage
Put here description of your class.
Definition: opensurveysondage.class.php:36
dol_escape_htmltag
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.
Definition: functions.lib.php:1468
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_nl2br
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
Definition: functions.lib.php:6963
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1062
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4521
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormOther
Classe permettant la generation de composants html autre Only common components are here.
Definition: html.formother.class.php:39
dol_banner_tab
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
Definition: functions.lib.php:2046
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
img_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)
Definition: functions.lib.php:3880
Opensurveysondage\STATUS_VALIDATED
const STATUS_VALIDATED
Validated/Opened status.
Definition: opensurveysondage.class.php:124
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
User
Class to manage Dolibarr users.
Definition: user.class.php:44
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_print_email
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
Definition: functions.lib.php:2960
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
dol_textishtml
dol_textishtml($msg, $option=0)
Return if a text is a html content.
Definition: functions.lib.php:7185
accessforbidden
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 ...
Definition: security.lib.php:933
ajax_autoselect
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
Definition: functions.lib.php:9681
dol_mktime
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...
Definition: functions.lib.php:2757
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
DolEditor
Class to manage a WYSIWYG editor.
Definition: doleditor.class.php:30
dol_htmlentities
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
Definition: functions.lib.php:7075
if
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
Definition: journals_list.php:25