dolibarr  x.y.z
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");
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('retoursondage')) {
57  header('Location: results.php?id='.(GETPOSTISSET('id_sondage') ? GETPOST('id_sondage', 'aZ09') : GETPOST('id', 'int')));
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 llxHeader('', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss);
431 
432 
433 // Define format of choices
434 $toutsujet = explode(",", $object->sujet);
435 $listofanswers = array();
436 foreach ($toutsujet as $value) {
437  $tmp = explode('@', $value);
438  $listofanswers[] = array('label'=>$tmp[0], 'format'=>(!empty($tmp[1]) ? $tmp[1] : 'checkbox'));
439 }
440 $toutsujet = str_replace("@", "<br>", $toutsujet);
441 $toutsujet = str_replace("°", "'", $toutsujet);
442 
443 
444 print '<form name="formulaire4" action="#" method="POST">'."\n";
445 print '<input type="hidden" name="token" value="'.newToken().'">';
446 
447 $head = opensurvey_prepare_head($object);
448 
449 print dol_get_fiche_head($head, 'preview', $langs->trans("Survey"), -1, 'poll');
450 
451 $morehtmlref = '';
452 
453 $linkback = '<a href="'.DOL_URL_ROOT.'/opensurvey/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
454 
455 dol_banner_tab($object, 'id', $linkback, 1, 'id_sondage', 'id_sondage', $morehtmlref);
456 
457 
458 print '<div class="fichecenter">';
459 
460 print '<div class="fichehalfleft">';
461 print '<div class="underbanner clearboth"></div>';
462 print '<table class="border tableforfield centpercent">';
463 
464 // Type
465 $type = ($object->format == "A") ? 'classic' : 'date';
466 print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td>';
467 print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic' ? 'chart-32.png' : 'calendar-32.png'), 1), 'width="16"', 1);
468 print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate").'</td></tr>';
469 
470 // Title
471 print '<tr><td>';
472 $adresseadmin = $object->mail_admin;
473 print $langs->trans("Title").'</td><td>';
474 if ($action == 'edit') {
475  print '<input type="text" name="nouveautitre" size="40" value="'.dol_escape_htmltag($object->title).'">';
476 } else {
477  print dol_htmlentities($object->title);
478 }
479 print '</td></tr>';
480 
481 // Description
482 print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
483 if ($action == 'edit') {
484  $doleditor = new DolEditor('nouveauxcommentaires', $object->description, '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%');
485  $doleditor->Create(0, '');
486 } else {
487  print (dol_textishtml($object->description) ? $object->description : dol_nl2br($object->description, 1, true));
488 }
489 print '</td></tr>';
490 
491 // EMail
492 //If linked user, then emails are going to be sent to users' email
493 if (!$object->fk_user_creat) {
494  print '<tr><td>'.$langs->trans("EMail").'</td><td>';
495  if ($action == 'edit') {
496  print '<input type="text" name="nouvelleadresse" class="minwith200" value="'.$object->mail_admin.'">';
497  } else {
498  print dol_print_email($object->mail_admin, 0, 0, 1, 0, 1, 1);
499  }
500  print '</td></tr>';
501 }
502 
503 print '</table>';
504 
505 print '</div>';
506 print '<div class="fichehalfright">';
507 print '<div class="underbanner clearboth"></div>';
508 
509 print '<table class="border tableforfield centpercent">';
510 
511 
512 // Expire date
513 print '<tr><td>'.$langs->trans('ExpireDate').'</td><td>';
514 if ($action == 'edit') {
515  print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0);
516 } else {
517  print dol_print_date($object->date_fin, 'day');
518  if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) {
519  print img_warning($langs->trans("Expired"));
520  }
521 }
522 print '</td></tr>';
523 
524 // Author
525 print '<tr><td>';
526 print $langs->trans("Author").'</td><td>';
527 if ($object->fk_user_creat) {
528  print $userstatic->getLoginUrl(1);
529 } else {
530  print dol_htmlentities($object->nom_admin);
531 }
532 print '</td></tr>';
533 
534 // Link
535 print '<tr><td>'.$langs->trans("UrlForSurvey", '').'</td><td>';
536 
537 // Define $urlwithroot
538 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
539 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
540 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
541 
542 $url = $urlwithouturlroot.dol_buildpath('/public/opensurvey/studs.php', 1).'?sondage='.$object->id_sondage;
543 $urllink = '<input type="text" class="quatrevingtpercent" '.($action == 'edit' ? 'disabled' : '').' id="opensurveyurl" name="opensurveyurl" value="'.$url.'">';
544 print $urllink;
545 if ($action != 'edit') {
546  print ajax_autoselect("opensurveyurl", $url, 'image');
547 }
548 
549 print '</td></tr>';
550 
551 print '</table>';
552 print '</div>';
553 
554 print '</div>';
555 print '<div class="clearboth"></div>';
556 
557 print dol_get_fiche_end();
558 
559 print '</form>'."\n";
560 
561 
562 // Buttons
563 
564 print '<div class="tabsAction">';
565 
566 print '<a class="butAction" href="exportcsv.php?id='.urlencode($numsondage).'">'.$langs->trans("ExportSpreadsheet").' (.CSV)</a>';
567 
568 print '</div>';
569 
570 
571 // Show form to add a new field/column
572 if (GETPOST('ajoutsujet')) {
573  // Security check
574  if (!$user->rights->opensurvey->write) {
575  accessforbidden();
576  }
577 
578  print '<form name="formulaire" action="" method="POST">'."\n";
579  print '<input type="hidden" name="token" value="'.newToken().'">';
580  print '<input type="hidden" name="backtopage" value="'.GETPOST('backtopage', 'alpha').'">';
581 
582  print '<div class="center">'."\n";
583  print "<br><br>\n";
584 
585  // Add new column
586  if ($object->format == "A") {
587  print $langs->trans("AddNewColumn").':<br><br>';
588  print $langs->trans("Title").' <input type="text" name="nouvellecolonne" size="40"><br>';
589  $tmparray = array('checkbox'=>$langs->trans("CheckBox"), 'yesno'=>$langs->trans("YesNoList"), 'foragainst'=>$langs->trans("PourContreList"));
590  print $langs->trans("Type").' '.$form->selectarray("typecolonne", $tmparray, GETPOST('typecolonne')).'<br><br>';
591  print '<input type="submit" class="button" name="ajoutercolonne" value="'.dol_escape_htmltag($langs->trans("Add")).'">';
592  print '<input type="hidden" name="id_sondage" value="'.dol_escape_htmltag($object->id_sondage).'">';
593  print ' &nbsp; &nbsp; ';
594  print '<input type="submit" class="button button-cancel" name="retoursondage" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
595  print '<br><br>'."\n";
596  } else {
597  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
598 
599  $formother = new FormOther($db);
600  //ajout d'une date avec creneau horaire
601  print $langs->trans("AddADate").':<br><br>'."\n";
602  print '<select name="nouveaujour"> '."\n";
603  print '<OPTION VALUE="vide">&nbsp;</OPTION>'."\n";
604  for ($i = 1; $i < 32; $i++) {
605  print '<OPTION VALUE="'.$i.'">'.$i.'</OPTION>'."\n";
606  }
607  print '</select>'."\n";
608 
609  print $formother->select_month('', 'nouveaumois', 1);
610 
611  print '&nbsp;';
612 
613  print $formother->selectyear('', 'nouvelleannee', 1, 0, 5, 0, 1);
614 
615  print '<br><br>'.$langs->trans("AddStartHour").': <br><br>'."\n";
616  print '<select name="nouvelleheuredebut"> '."\n";
617  print '<OPTION VALUE="vide">&nbsp;</OPTION>'."\n";
618  for ($i = 0; $i < 24; $i++) {
619  print '<OPTION VALUE="'.$i.'">'.$i.' H</OPTION>'."\n";
620  }
621  print '</select>'."\n";
622  print '<select name="nouvelleminutedebut"> '."\n";
623  print '<OPTION VALUE="vide">&nbsp;</OPTION>'."\n";
624  print '<OPTION VALUE="00">00</OPTION>'."\n";
625  print '<OPTION VALUE="15">15</OPTION>'."\n";
626  print '<OPTION VALUE="30">30</OPTION>'."\n";
627  print '<OPTION VALUE="45">45</OPTION>'."\n";
628  print '</select>'."\n";
629  print '<br><br>'.$langs->trans("AddEndHour").': <br><br>'."\n";
630  print '<select name="nouvelleheurefin"> '."\n";
631  print '<OPTION VALUE="vide">&nbsp;</OPTION>'."\n";
632  for ($i = 0; $i < 24; $i++) {
633  print '<OPTION VALUE="'.$i.'">'.$i.' H</OPTION>'."\n";
634  }
635  print '</SELECT>'."\n";
636  print '<select name="nouvelleminutefin"> '."\n";
637  print '<OPTION VALUE="vide">&nbsp;</OPTION>'."\n";
638  print '<OPTION VALUE="00">00</OPTION>'."\n";
639  print '<OPTION VALUE="15">15</OPTION>'."\n";
640  print '<OPTION VALUE="30">30</OPTION>'."\n";
641  print '<OPTION VALUE="45">45</OPTION>'."\n";
642  print '</select>'."\n";
643 
644  print '<br><br>';
645  print' <input type="submit" class="button" name="ajoutercolonne" value="'.dol_escape_htmltag($langs->trans("Add")).'">'."\n";
646  print '&nbsp; &nbsp;';
647  print '<input type="submit" class="button button-cancel" name="retoursondage" value="'.$langs->trans("Cancel").'">';
648  }
649 
650  print '</form>'."\n";
651  print '<br><br><br><br>'."\n";
652  print '</div>'."\n";
653 
654  exit;
655 }
656 
657 if ($user->rights->opensurvey->write) {
658  print '<span class="opacitymedium">';
659  $s = $langs->trans("PollAdminDesc", '{s1}', $langs->trans("Add"));
660  print str_replace('{s1}', img_picto('', 'delete'), $s);
661  print '</span><br>';
662 }
663 
664 $nbcolonnes = substr_count($object->sujet, ',') + 1;
665 
666 print '<form name="formulaire" action="" method="POST">'."\n";
667 print '<input type="hidden" name="token" value="'.newToken().'">';
668 print '<input type="hidden" name="page_y" value="">';
669 
670 print '<div class="cadre div-table-responsive-no-min"> '."\n";
671 
672 // Start to show survey result
673 print '<table class="resultats">'."\n";
674 
675 //reformatage des données des sujets du sondage
676 $toutsujet = explode(",", $object->sujet);
677 $toutsujet = str_replace("°", "'", $toutsujet);
678 
679 print '<tr>'."\n";
680 print '<td></td>'."\n";
681 print '<td></td>'."\n";
682 
683 // loop to show the delete link
684 if ($user->rights->opensurvey->write) {
685  for ($i = 0; isset($toutsujet[$i]); $i++) {
686  print '<td class=somme><input type="image" name="effacecolonne'.$i.'" src="'.img_picto('', 'delete.png', '', false, 1).'"></td>'."\n";
687  }
688 }
689 
690 print '</tr>'."\n";
691 
692 
693 // Show choice titles
694 if ($object->format == "D") {
695  //affichage des sujets du sondage
696  print '<tr>'."\n";
697  print '<td></td>'."\n";
698  print '<td></td>'."\n";
699 
700  //affichage des années
701  $colspan = 1;
702  $nbofsujet = count($toutsujet);
703  for ($i = 0; $i < $nbofsujet; $i++) {
704  if (isset($toutsujet[$i + 1]) && date('Y', intval($toutsujet[$i])) == date('Y', intval($toutsujet[$i + 1]))) {
705  $colspan++;
706  } else {
707  print '<td colspan='.$colspan.' class="annee">'.date('Y', intval($toutsujet[$i])).'</td>'."\n";
708  $colspan = 1;
709  }
710  }
711 
712  if ($user->rights->opensurvey->write) {
713  print '<td class="annee">';
714  print '<a href="'.$_SERVER["PHP_SELF"].'?ajoutsujet=1&id='.$object->id_sondage.'">'.$langs->trans("Add").'</a></td>'."\n";
715  }
716 
717  print '</tr>'."\n";
718  print '<tr>'."\n";
719  print '<td></td>'."\n";
720  print '<td></td>'."\n";
721 
722  //affichage des mois
723  $colspan = 1;
724  for ($i = 0; $i < $nbofsujet; $i++) {
725  $cur = intval($toutsujet[$i]); // intval() est utiliser pour supprimer le suffixe @* qui déplaît logiquement à strftime()
726 
727  if (isset($toutsujet[$i + 1]) === false) {
728  $next = false;
729  } else {
730  $next = intval($toutsujet[$i + 1]);
731  }
732 
733  if ($next && dol_print_date($cur, "%B") == dol_print_date($next, "%B") && dol_print_date($cur, "%Y") == dol_print_date($next, "%Y")) {
734  $colspan++;
735  } else {
736  print '<td colspan='.$colspan.' class="mois">'.dol_print_date($cur, "%B").'</td>'."\n";
737 
738  $colspan = 1;
739  }
740  }
741 
742  if ($user->rights->opensurvey->write) {
743  print '<td class="mois"><a href="'.$_SERVER["PHP_SELF"].'?ajoutsujet=1&id='.$object->id_sondage.'">'.$langs->trans("Add").'</a></td>'."\n";
744  }
745 
746  print '</tr>'."\n";
747  print '<tr>'."\n";
748  print '<td></td>'."\n";
749  print '<td></td>'."\n";
750 
751  //affichage des jours
752  $colspan = 1;
753  for ($i = 0; $i < $nbofsujet; $i++) {
754  $cur = intval($toutsujet[$i]);
755  if (isset($toutsujet[$i + 1]) === false) {
756  $next = false;
757  } else {
758  $next = intval($toutsujet[$i + 1]);
759  }
760  if ($next && dol_print_date($cur, "%a %e") == dol_print_date($next, "%a %e") && dol_print_date($cur, "%B") == dol_print_date($next, "%B")) {
761  $colspan++;
762  } else {
763  print '<td colspan='.$colspan.' class="jour">'.dol_print_date($cur, "%a %e").'</td>'."\n";
764 
765  $colspan = 1;
766  }
767  }
768 
769  if ($user->rights->opensurvey->write) {
770  print '<td class="jour"><a href="'.$_SERVER["PHP_SELF"].'?ajoutsujet=1&id='.$object->id_sondage.'">'.$langs->trans("Add").'</a></td>'."\n";
771  }
772  print '</tr>'."\n";
773 
774  //affichage des horaires
775  if (strpos($object->sujet, '@') !== false) {
776  print '<tr>'."\n";
777  print '<td></td>'."\n";
778  print '<td></td>'."\n";
779 
780  for ($i = 0; isset($toutsujet[$i]); $i++) {
781  $heures = explode('@', $toutsujet[$i]);
782  if (isset($heures[1])) {
783  print '<td class="heure">'.dol_htmlentities($heures[1]).'</td>'."\n";
784  } else {
785  print '<td class="heure"></td>'."\n";
786  }
787  }
788 
789  if ($user->rights->opensurvey->write) {
790  print '<td class="heure"><a href="'.$_SERVER["PHP_SELF"].'?ajoutsujet=1&id='.$object->id_sondage.'">'.$langs->trans("Add").'</a></td>'."\n";
791  }
792 
793  print '</tr>'."\n";
794  }
795 } else {
796  // Show titles
797  print '<tr>'."\n";
798  print '<td></td>'."\n";
799  print '<td></td>'."\n";
800 
801  for ($i = 0; isset($toutsujet[$i]); $i++) {
802  $tmp = explode('@', $toutsujet[$i]);
803  print '<td class="sujet">'.dol_htmlentities($tmp[0]).'</td>'."\n";
804  }
805 
806  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";
807  print '</tr>'."\n";
808 }
809 
810 
811 // Loop on each answer
812 $sumfor = array();
813 $sumagainst = array();
814 $compteur = 0;
815 $sql = "SELECT id_users, nom as name, id_sondage, reponses";
816 $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs";
817 $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'";
818 dol_syslog('sql='.$sql);
819 $resql = $db->query($sql);
820 if (!$resql) {
821  dol_print_error($db);
822  exit;
823 }
824 $num = $db->num_rows($resql);
825 while ($compteur < $num) {
826  $obj = $db->fetch_object($resql);
827 
828  $ensemblereponses = $obj->reponses;
829 
830  print '<tr><td>'."\n";
831 
832  if ($user->rights->opensurvey->write) {
833  print '<input type="image" class="reposition" name="effaceligne'.$compteur.'" src="'.img_picto('', 'delete.png', '', false, 1).'">'."\n";
834  }
835 
836  // Name
837  print '</td><td class="nom">'.dol_htmlentities($obj->name).'</td>'."\n";
838 
839  // si la ligne n'est pas a changer, on affiche les données
840  if (!$testligneamodifier) {
841  for ($i = 0; $i < $nbcolonnes; $i++) {
842  $car = substr($ensemblereponses, $i, 1);
843  //print 'xx'.$i."-".$car.'-'.$listofanswers[$i]['format'].'zz';
844 
845  if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
846  if (((string) $car) == "1") {
847  print '<td class="ok">OK</td>'."\n";
848  } else {
849  print '<td class="non">KO</td>'."\n";
850  }
851  // Total
852  if (!isset($sumfor[$i])) {
853  $sumfor[$i] = 0;
854  }
855  if (((string) $car) == "1") {
856  $sumfor[$i]++;
857  }
858  }
859  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') {
860  if (((string) $car) == "1") {
861  print '<td class="ok">'.$langs->trans("Yes").'</td>'."\n";
862  } elseif (((string) $car) == "0") {
863  print '<td class="non">'.$langs->trans("No").'</td>'."\n";
864  } else {
865  print '<td class="vide">&nbsp;</td>'."\n";
866  }
867  // Total
868  if (!isset($sumfor[$i])) {
869  $sumfor[$i] = 0;
870  }
871  if (!isset($sumagainst[$i])) {
872  $sumagainst[$i] = 0;
873  }
874  if (((string) $car) == "1") {
875  $sumfor[$i]++;
876  }
877  if (((string) $car) == "0") {
878  $sumagainst[$i]++;
879  }
880  }
881  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') {
882  if (((string) $car) == "1") {
883  print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
884  } elseif (((string) $car) == "0") {
885  print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
886  } else {
887  print '<td class="vide">&nbsp;</td>'."\n";
888  }
889  // Total
890  if (!isset($sumfor[$i])) {
891  $sumfor[$i] = 0;
892  }
893  if (!isset($sumagainst[$i])) {
894  $sumagainst[$i] = 0;
895  }
896  if (((string) $car) == "1") {
897  $sumfor[$i]++;
898  }
899  if (((string) $car) == "0") {
900  $sumagainst[$i]++;
901  }
902  }
903  }
904  } else {
905  //sinon on remplace les choix de l'utilisateur par une ligne de checkbox pour recuperer de nouvelles valeurs
906  if ($compteur == $ligneamodifier) {
907  for ($i = 0; $i < $nbcolonnes; $i++) {
908  $car = substr($ensemblereponses, $i, 1);
909  print '<td class="vide">';
910  if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
911  print '<input type="checkbox" name="choix'.$i.'" value="1" ';
912  if ($car == '1') {
913  print 'checked';
914  }
915  print '>';
916  }
917  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') {
918  $arraychoice = array('2'=>'&nbsp;', '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes"));
919  print $form->selectarray("choix".$i, $arraychoice, $car);
920  }
921  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') {
922  $arraychoice = array('2'=>'&nbsp;', '0'=>$langs->trans("Against"), '1'=>$langs->trans("For"));
923  print $form->selectarray("choix".$i, $arraychoice, $car);
924  }
925  print '</td>'."\n";
926  }
927  } else {
928  for ($i = 0; $i < $nbcolonnes; $i++) {
929  $car = substr($ensemblereponses, $i, 1);
930  if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
931  if (((string) $car) == "1") {
932  print '<td class="ok">OK</td>'."\n";
933  } else {
934  print '<td class="non">KO</td>'."\n";
935  }
936  // Total
937  if (!isset($sumfor[$i])) {
938  $sumfor[$i] = 0;
939  }
940  if (((string) $car) == "1") {
941  $sumfor[$i]++;
942  }
943  }
944  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') {
945  if (((string) $car) == "1") {
946  print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
947  } elseif (((string) $car) == "0") {
948  print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
949  } else {
950  print '<td class="vide">&nbsp;</td>'."\n";
951  }
952  // Total
953  if (!isset($sumfor[$i])) {
954  $sumfor[$i] = 0;
955  }
956  if (!isset($sumagainst[$i])) {
957  $sumagainst[$i] = 0;
958  }
959  if (((string) $car) == "1") {
960  $sumfor[$i]++;
961  }
962  if (((string) $car) == "0") {
963  $sumagainst[$i]++;
964  }
965  }
966  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') {
967  if (((string) $car) == "1") {
968  print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
969  } elseif (((string) $car) == "0") {
970  print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
971  } else {
972  print '<td class="vide">&nbsp;</td>'."\n";
973  }
974  // Total
975  if (!isset($sumfor[$i])) {
976  $sumfor[$i] = 0;
977  }
978  if (!isset($sumagainst[$i])) {
979  $sumagainst[$i] = 0;
980  }
981  if (((string) $car) == "1") {
982  $sumfor[$i]++;
983  }
984  if (((string) $car) == "0") {
985  $sumagainst[$i]++;
986  }
987  }
988  }
989  }
990  }
991 
992  // Button edit at end of line
993  if ($compteur != $ligneamodifier && ($user->rights->opensurvey->write)) {
994  print '<td class="casevide"><input type="submit" class="button reposition" name="modifierligne'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Edit")).'"></td>'."\n";
995  }
996 
997  //demande de confirmation pour modification de ligne
998  for ($i = 0; $i < $nblines; $i++) {
999  if (GETPOSTISSET("modifierligne".$i)) {
1000  if ($compteur == $i) {
1001  print '<td class="casevide">';
1002  print '<input type="hidden" name="idtomodify'.$compteur.'" value="'.$obj->id_users.'">';
1003  print '<input type="submit" class="button button-save reposition" name="validermodifier'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
1004  print '</td>'."\n";
1005  }
1006  }
1007  }
1008 
1009  $compteur++;
1010  print '</tr>'."\n";
1011 }
1012 
1013 // Add line to add new record
1014 if (empty($testligneamodifier)) {
1015  print '<tr>'."\n";
1016  print '<td></td>'."\n";
1017  print '<td class="nom">'."\n";
1018  print '<input type="text" class="maxwidthonsmartphone" placeholder="'.dol_escape_htmltag($langs->trans("Name")).'" name="nom" maxlength="64">'."\n";
1019  print '</td>'."\n";
1020 
1021  for ($i = 0; $i < $nbcolonnes; $i++) {
1022  print '<td class="vide">';
1023  if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
1024  print '<input type="checkbox" name="choix'.$i.'" value="1"';
1025  if (GETPOSTISSET('choix'.$i) && GETPOST('choix'.$i) == '1') {
1026  print ' checked';
1027  }
1028  print '>';
1029  }
1030  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') {
1031  $arraychoice = array('2'=>'&nbsp;', '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes"));
1032  print $form->selectarray("choix".$i, $arraychoice);
1033  }
1034  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') {
1035  $arraychoice = array('2'=>'&nbsp;', '0'=>$langs->trans("Against"), '1'=>$langs->trans("For"));
1036  print $form->selectarray("choix".$i, $arraychoice);
1037  }
1038  print '</td>'."\n";
1039  }
1040 
1041  // Affichage du bouton de formulaire pour inscrire un nouvel utilisateur dans la base
1042  print '<td><input type="image" name="boutonp" class="borderimp" value="'.$langs->trans("Vote").'" src="'.img_picto('', 'edit_add', '', false, 1).'"></td>'."\n";
1043  print '</tr>'."\n";
1044 }
1045 
1046 // Select value of best choice (for checkbox columns only)
1047 $nbofcheckbox = 0;
1048 for ($i = 0; $i < $nbcolonnes + 1; $i++) {
1049  if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
1050  $nbofcheckbox++;
1051  }
1052  if (isset($sumfor[$i])) {
1053  if ($i == 0) {
1054  $meilleurecolonne = $sumfor[$i];
1055  }
1056  if (isset($sumfor[$i]) && $sumfor[$i] > $meilleurecolonne) {
1057  $meilleurecolonne = $sumfor[$i];
1058  }
1059  }
1060 }
1061 
1062 
1063 // Show line total
1064 print '<tr>'."\n";
1065 print '<td></td>'."\n";
1066 print '<td class="center">'.$langs->trans("Total").'</td>'."\n";
1067 for ($i = 0; $i < $nbcolonnes; $i++) {
1068  $showsumfor = isset($sumfor[$i]) ? $sumfor[$i] : '';
1069  $showsumagainst = isset($sumagainst[$i]) ? $sumagainst[$i] : '';
1070  if (empty($showsumfor)) {
1071  $showsumfor = 0;
1072  }
1073  if (empty($showsumagainst)) {
1074  $showsumagainst = 0;
1075  }
1076 
1077  print '<td>';
1078  if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
1079  print $showsumfor;
1080  }
1081  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') {
1082  print $langs->trans("Yes").': '.$showsumfor.'<br>'.$langs->trans("No").': '.$showsumagainst;
1083  }
1084  if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') {
1085  print $langs->trans("For").': '.$showsumfor.'<br>'.$langs->trans("Against").': '.$showsumagainst;
1086  }
1087  print '</td>'."\n";
1088 }
1089 print '</tr>';
1090 // Show picto winner
1091 if ($nbofcheckbox >= 2) {
1092  print '<tr>'."\n";
1093  print '<td></td>'."\n";
1094  print '<td></td>'."\n";
1095  for ($i = 0; $i < $nbcolonnes; $i++) {
1096  if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) {
1097  print '<td class="somme"><img src="'.dol_buildpath('/opensurvey/img/medaille.png', 1).'"></td>'."\n";
1098  } else {
1099  print '<td class="somme"></td>'."\n";
1100  }
1101  }
1102  print '</tr>'."\n";
1103 }
1104 
1105 // S'il a oublié de remplir un nom
1106 if (GETPOSTISSET("boutonp") && GETPOST("nom") == "") {
1107  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name")), null, 'errors');
1108 }
1109 
1110 if (isset($erreur_prenom) && $erreur_prenom) {
1111  setEventMessages($langs->trans('VoteNameAlreadyExists'), null, 'errors');
1112 }
1113 
1114 if (isset($erreur_ajout_date) && $erreur_ajout_date) {
1115  setEventMessages($langs->trans("ErrorWrongDate"), null, 'errors');
1116 }
1117 
1118 //fin du tableau
1119 print '</table>'."\n";
1120 print '</div>'."\n";
1121 
1122 
1123 $toutsujet = explode(",", $object->sujet); // With old versions, this field was not set
1124 
1125 $compteursujet = 0;
1126 $meilleursujet = '';
1127 for ($i = 0; $i < $nbcolonnes; $i++) {
1128  if (isset($sumfor[$i]) === true && isset($meilleurecolonne) === true && $sumfor[$i] == $meilleurecolonne) {
1129  $meilleursujet .= ($meilleursujet ? ", " : "");
1130 
1131  if ($object->format == "D") {
1132  $meilleursujetexport = $toutsujet[$i];
1133  //var_dump($toutsujet);
1134  if (strpos($toutsujet[$i], '@') !== false) {
1135  $toutsujetdate = explode("@", $toutsujet[$i]);
1136  $meilleursujet .= dol_print_date($toutsujetdate[0], 'daytext').($toutsujetdate[0] ? ' ('.dol_print_date($toutsujetdate[0], '%A').')' : '').' - '.$toutsujetdate[1];
1137  } else {
1138  $meilleursujet .= dol_print_date((empty($toutsujet[$i]) ? 0 : $toutsujet[$i]), 'daytext').' ('.dol_print_date((empty($toutsujet[$i]) ? 0 : $toutsujet[$i]), '%A').')';
1139  }
1140  } else {
1141  $tmps = explode('@', $toutsujet[$i]);
1142  $meilleursujet .= dol_htmlentities($tmps[0]);
1143  }
1144 
1145  $compteursujet++;
1146  }
1147 }
1148 $meilleursujet = substr($meilleursujet, 1);
1149 $meilleursujet = str_replace("°", "'", $meilleursujet);
1150 
1151 // Show best choice
1152 if ($nbofcheckbox >= 2) {
1153  $vote_str = $langs->trans('votes');
1154  print '<p class="affichageresultats">'."\n";
1155 
1156  if (isset($meilleurecolonne) && $compteursujet == "1") {
1157  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";
1158  } elseif (isset($meilleurecolonne)) {
1159  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";
1160  }
1161  print '<br></p><br>'."\n";
1162 }
1163 
1164 print '</form>'."\n";
1165 
1166 print '<a name="bas"></a>'."\n";
1167 
1168 llxFooter();
1169 
1170 $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:45
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.