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