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