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