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