results.php 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100
  1. <?php
  2. /* Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/opensurvey/results.php
  20. * \ingroup opensurvey
  21. * \brief Page to preview votes of a survey
  22. */
  23. $res=0;
  24. require_once('../main.inc.php');
  25. require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
  26. require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
  27. require_once(DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php");
  28. require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php");
  29. // Security check
  30. if (!$user->rights->opensurvey->read) accessforbidden();
  31. // Init vars
  32. $action=GETPOST('action','aZ09');
  33. $numsondage= GETPOST("id");
  34. $object=new Opensurveysondage($db);
  35. $result=$object->fetch(0,$numsondage);
  36. if ($result <= 0) dol_print_error('','Failed to get survey id '.$numsondage);
  37. $nblignes=$object->fetch_lines();
  38. /*
  39. * Actions
  40. */
  41. // Return to the results
  42. if (GETPOST('retoursondage')) {
  43. header('Location: results.php?id='.$_GET['id']);
  44. exit;
  45. }
  46. $nbcolonnes = substr_count($object->sujet, ',') + 1;
  47. // Add vote
  48. if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // boutonp for chrom, boutonp.x for firefox
  49. {
  50. if (GETPOST('nom'))
  51. {
  52. $erreur_prenom = false;
  53. $nouveauchoix = '';
  54. for ($i=0;$i<$nbcolonnes;$i++)
  55. {
  56. if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1')
  57. {
  58. $nouveauchoix.="1";
  59. }
  60. else if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2')
  61. {
  62. $nouveauchoix.="2";
  63. }
  64. else { // sinon c'est 0
  65. $nouveauchoix.="0";
  66. }
  67. }
  68. $nom=substr(GETPOST("nom"),0,64);
  69. // Check if vote already exists
  70. $sql = 'SELECT id_users, nom as name';
  71. $sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs';
  72. $sql.= " WHERE id_sondage='".$db->escape($numsondage)."' AND nom = '".$db->escape($nom)."'";
  73. $sql.= ' ORDER BY id_users';
  74. $resql = $db->query($sql);
  75. $num_rows = $db->num_rows($resql);
  76. if ($num_rows > 0)
  77. {
  78. setEventMessages($langs->trans("VoteNameAlreadyExists"), null, 'errors');
  79. $error++;
  80. }
  81. else
  82. {
  83. $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses)';
  84. $sql.= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."')";
  85. $resql=$db->query($sql);
  86. if (! $resql) dol_print_error($db);
  87. }
  88. }
  89. }
  90. // Update vote
  91. $testmodifier = false;
  92. $testligneamodifier = false;
  93. $ligneamodifier = -1;
  94. for ($i=0; $i<$nblignes; $i++)
  95. {
  96. if (isset($_POST['modifierligne'.$i]))
  97. {
  98. $ligneamodifier=$i;
  99. $testligneamodifier=true;
  100. }
  101. //test pour voir si une ligne est a modifier
  102. if (isset($_POST['validermodifier'.$i]))
  103. {
  104. $modifier=$i;
  105. $testmodifier=true;
  106. }
  107. }
  108. if ($testmodifier)
  109. {
  110. // Security check
  111. if (!$user->rights->opensurvey->write) accessforbidden();
  112. $nouveauchoix = '';
  113. for ($i = 0; $i < $nbcolonnes; $i++)
  114. {
  115. //var_dump($_POST["choix$i"]);
  116. if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1')
  117. {
  118. $nouveauchoix.="1";
  119. }
  120. else if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2')
  121. {
  122. $nouveauchoix.="2";
  123. }
  124. else { // sinon c'est 0
  125. $nouveauchoix.="0";
  126. }
  127. }
  128. $idtomodify=$_POST["idtomodify".$modifier];
  129. $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_user_studs";
  130. $sql.= " SET reponses = '".$db->escape($nouveauchoix)."'";
  131. $sql.= " WHERE id_users = '".$db->escape($idtomodify)."'";
  132. $resql = $db->query($sql);
  133. if (! $resql) dol_print_error($db);
  134. }
  135. // Add column (not for date)
  136. if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format == "A")
  137. {
  138. // Security check
  139. if (!$user->rights->opensurvey->write) accessforbidden();
  140. $nouveauxsujets=$object->sujet;
  141. //on rajoute la valeur a la fin de tous les sujets deja entrés
  142. $nouveauxsujets.=',';
  143. $nouveauxsujets.=str_replace(array(",","@"), " ", $_POST["nouvellecolonne"]).(empty($_POST["typecolonne"])?'':'@'.$_POST["typecolonne"]);
  144. //mise a jour avec les nouveaux sujets dans la base
  145. $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage";
  146. $sql.= " SET sujet = '".$db->escape($nouveauxsujets)."'";
  147. $sql.= " WHERE id_sondage = '".$db->escape($numsondage)."'";
  148. $resql = $db->query($sql);
  149. if (! $resql) dol_print_error($db);
  150. else {
  151. header('Location: results.php?id='.$object->id_sondage);
  152. }
  153. }
  154. // Add column (with format date)
  155. if (isset($_POST["ajoutercolonne"]) && $object->format == "D")
  156. {
  157. // Security check
  158. if (!$user->rights->opensurvey->write) accessforbidden();
  159. $nouveauxsujets=$object->sujet;
  160. if (isset($_POST["nouveaujour"]) && $_POST["nouveaujour"] != "vide" &&
  161. isset($_POST["nouveaumois"]) && $_POST["nouveaumois"] != "vide" &&
  162. isset($_POST["nouvelleannee"]) && $_POST["nouvelleannee"] != "vide") {
  163. $nouvelledate=dol_mktime(0, 0, 0, $_POST["nouveaumois"], $_POST["nouveaujour"], $_POST["nouvelleannee"]);
  164. if (isset($_POST["nouvelleheuredebut"]) && $_POST["nouvelleheuredebut"]!="vide"){
  165. $nouvelledate.="@";
  166. $nouvelledate.=$_POST["nouvelleheuredebut"];
  167. $nouvelledate.="h";
  168. if ($_POST["nouvelleminutedebut"]!="vide") {
  169. $nouvelledate.=$_POST["nouvelleminutedebut"];
  170. }
  171. }
  172. if (isset($_POST["nouvelleheurefin"]) && $_POST["nouvelleheurefin"]!="vide"){
  173. $nouvelledate.="-";
  174. $nouvelledate.=$_POST["nouvelleheurefin"];
  175. $nouvelledate.="h";
  176. if ($_POST["nouvelleminutefin"]!="vide") {
  177. $nouvelledate.=$_POST["nouvelleminutefin"];
  178. }
  179. }
  180. if($_POST["nouvelleheuredebut"] == "vide" || (isset($_POST["nouvelleheuredebut"]) && isset($_POST["nouvelleheurefin"]) && (($_POST["nouvelleheuredebut"] < $_POST["nouvelleheurefin"]) || (($_POST["nouvelleheuredebut"] == $_POST["nouvelleheurefin"]) && ($_POST["nouvelleminutedebut"] < $_POST["nouvelleminutefin"]))))) {
  181. $erreur_ajout_date = false;
  182. } else {
  183. $erreur_ajout_date = "yes";
  184. }
  185. //on rajoute la valeur dans les valeurs
  186. $datesbase = explode(",",$object->sujet);
  187. $taillebase = count($datesbase);
  188. //recherche de l'endroit de l'insertion de la nouvelle date dans les dates deja entrées dans le tableau
  189. if ($nouvelledate < $datesbase[0]) {
  190. $cleinsertion = 0;
  191. } elseif ($nouvelledate > $datesbase[$taillebase-1]) {
  192. $cleinsertion = count($datesbase);
  193. } else {
  194. $nbdatesbase=count($datesbase);
  195. for ($i = 0; $i < $nbdatesbase; $i++)
  196. {
  197. $j = $i + 1;
  198. if ($nouvelledate > $datesbase[$i] && $nouvelledate < $datesbase[$j]) {
  199. $cleinsertion = $j;
  200. }
  201. }
  202. }
  203. array_splice($datesbase, $cleinsertion, 0, $nouvelledate);
  204. $cle = array_search($nouvelledate, $datesbase);
  205. $dateinsertion = '';
  206. $nbofdates=count($datesbase);
  207. for ($i = 0; $i < $nbofdates; $i++) {
  208. $dateinsertion.=",";
  209. $dateinsertion.=$datesbase[$i];
  210. }
  211. $dateinsertion = substr("$dateinsertion", 1);
  212. //mise a jour avec les nouveaux sujets dans la base
  213. if (isset($erreur_ajout_date) && !$erreur_ajout_date)
  214. {
  215. $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage";
  216. $sql.= " SET sujet = '".$db->escape($dateinsertion)."'";
  217. $sql.= " WHERE id_sondage = '".$db->escape($numsondage)."'";
  218. $resql = $db->query($sql);
  219. if (! $resql) dol_print_error($db);
  220. else {
  221. header('Location: results.php?id='.$object->id_sondage);
  222. }
  223. }
  224. $adresseadmin = $object->mail_admin;
  225. }
  226. else
  227. {
  228. $erreur_ajout_date="yes";
  229. }
  230. }
  231. // Delete line
  232. for ($i = 0; $i < $nblignes; $i++)
  233. {
  234. if (GETPOST("effaceligne".$i) || GETPOST("effaceligne".$i."_x") || GETPOST("effaceligne".$i.".x")) // effacelignei for chrome, effacelignei_x for firefox
  235. {
  236. // Security check
  237. if (!$user->rights->opensurvey->write) accessforbidden();
  238. $compteur=0;
  239. // Loop on each answer
  240. $compteur = 0;
  241. $sql ="SELECT id_users, nom as name, id_sondage, reponses";
  242. $sql.=" FROM ".MAIN_DB_PREFIX."opensurvey_user_studs";
  243. $sql.=" WHERE id_sondage = '".$db->escape($numsondage)."'";
  244. $resql=$db->query($sql);
  245. if (! $resql) dol_print_error($db);
  246. $num=$db->num_rows($resql);
  247. while ($compteur < $num)
  248. {
  249. $obj=$db->fetch_object($resql);
  250. if ($compteur==$i)
  251. {
  252. $sql2 = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs';
  253. $sql2.= ' WHERE id_users = '.$db->escape($obj->id_users);
  254. $resql2 = $db->query($sql2);
  255. }
  256. $compteur++;
  257. }
  258. }
  259. }
  260. // Delete column
  261. for ($i = 0; $i < $nbcolonnes; $i++)
  262. {
  263. if ((GETPOST("effacecolonne".$i) || GETPOST("effacecolonne".$i."_x") || GETPOST("effacecolonne".$i.".x"))
  264. && $nbcolonnes > 1) // effacecolonnei for chrome, effacecolonnei_x for firefox
  265. {
  266. // Security check
  267. if (!$user->rights->opensurvey->write) accessforbidden();
  268. $db->begin();
  269. $toutsujet = explode(",",$object->sujet);
  270. $j = 0;
  271. $nouveauxsujets = '';
  272. //parcours de tous les sujets actuels
  273. while (isset($toutsujet[$j]))
  274. {
  275. //si le sujet n'est pas celui qui a été effacé alors on concatene
  276. if ($i != $j)
  277. {
  278. if (! empty($nouveauxsujets)) $nouveauxsujets .= ',';
  279. $nouveauxsujets .= $toutsujet[$j];
  280. }
  281. $j++;
  282. }
  283. // Mise a jour des sujets dans la base
  284. $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage";
  285. $sql.= " SET sujet = '".$db->escape($nouveauxsujets)."' WHERE id_sondage = '".$db->escape($numsondage)."'";
  286. $resql = $db->query($sql);
  287. if (! $resql) dol_print_error($db);
  288. // Clean current answer to remove deleted columns
  289. $compteur = 0;
  290. $sql ="SELECT id_users, nom as name, id_sondage, reponses";
  291. $sql.=" FROM ".MAIN_DB_PREFIX."opensurvey_user_studs";
  292. $sql.=" WHERE id_sondage = '".$db->escape($numsondage)."'";
  293. dol_syslog('sql='.$sql);
  294. $resql=$db->query($sql);
  295. if (! $resql)
  296. {
  297. dol_print_error($db);
  298. exit;
  299. }
  300. $num=$db->num_rows($resql);
  301. while ($compteur < $num)
  302. {
  303. $obj=$db->fetch_object($resql);
  304. $newcar = '';
  305. $ensemblereponses = $obj->reponses;
  306. // parcours de toutes les réponses actuelles
  307. for ($j = 0; $j < $nbcolonnes; $j++)
  308. {
  309. $car=substr($ensemblereponses, $j, 1);
  310. //si les reponses ne concerne pas la colonne effacée, on concatene
  311. if ($i != $j) {
  312. $newcar .= $car;
  313. }
  314. }
  315. // mise a jour des reponses utilisateurs dans la base
  316. $sql2 = 'UPDATE '.MAIN_DB_PREFIX.'opensurvey_user_studs';
  317. $sql2.= " SET reponses = '".$db->escape($newcar)."'";
  318. $sql2.= " WHERE id_users = '".$db->escape($obj->id_users)."'";
  319. //print $sql2;
  320. dol_syslog('sql='.$sql2);
  321. $resql2 = $db->query($sql2);
  322. $compteur++;
  323. }
  324. $db->commit();
  325. }
  326. }
  327. /*
  328. * View
  329. */
  330. if ($object->fk_user_creat) {
  331. $userstatic = new User($db);
  332. $userstatic->fetch($object->fk_user_creat);
  333. }
  334. $form=new Form($db);
  335. $result=$object->fetch(0,$numsondage);
  336. if ($result <= 0)
  337. {
  338. dol_print_error($db,$object->error);
  339. exit;
  340. }
  341. $title = $object->titre." - ".$langs->trans('Card');
  342. $helpurl = '';
  343. $arrayofjs=array();
  344. $arrayofcss=array('/opensurvey/css/style.css');
  345. llxHeader('',$title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss);
  346. // Define format of choices
  347. $toutsujet=explode(",",$object->sujet);
  348. $listofanswers=array();
  349. foreach ($toutsujet as $value)
  350. {
  351. $tmp=explode('@',$value);
  352. $listofanswers[]=array('label'=>$tmp[0],'format'=>($tmp[1]?$tmp[1]:'checkbox'));
  353. }
  354. $toutsujet=str_replace("@","<br>",$toutsujet);
  355. $toutsujet=str_replace("°","'",$toutsujet);
  356. print '<form name="formulaire4" action="#" method="POST">'."\n";
  357. $head = opensurvey_prepare_head($object);
  358. dol_fiche_head($head,'preview',$langs->trans("Survey"), -1, DOL_URL_ROOT.'/opensurvey/img/object_opensurvey.png', 1);
  359. $morehtmlref = '';
  360. $linkback = '<a href="'.DOL_URL_ROOT.'/opensurvey/list.php">'.$langs->trans("BackToList").'</a>';
  361. dol_banner_tab($object, 'id', $linkback, 1, 'id_sondage', 'id_sondage', $morehtmlref);
  362. print '<div class="fichecenter">';
  363. print '<div class="underbanner clearboth"></div>';
  364. print '<table class="border" width="100%">';
  365. // Type
  366. $type=($object->format=="A")?'classic':'date';
  367. print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="2">';
  368. print img_picto('',dol_buildpath('/opensurvey/img/'.($type == 'classic'?'chart-32.png':'calendar-32.png'),1),'width="16"',1);
  369. print ' '.$langs->trans($type=='classic'?"TypeClassic":"TypeDate").'</td></tr>';
  370. // Title
  371. print '<tr><td>';
  372. $adresseadmin=$object->mail_admin;
  373. print $langs->trans("Title") .'</td><td colspan="2">';
  374. if ($action == 'edit')
  375. {
  376. print '<input type="text" name="nouveautitre" size="40" value="'.dol_escape_htmltag(dol_htmlentities($object->titre)).'">';
  377. }
  378. else print dol_htmlentities($object->titre);
  379. print '</td></tr>';
  380. // Expire date
  381. print '<tr><td>'.$langs->trans('ExpireDate').'</td><td colspan="2">';
  382. if ($action == 'edit') print $form->select_date($expiredate?$expiredate:$object->date_fin,'expire',0,0,0,'',1,0,1);
  383. else print dol_print_date($object->date_fin,'day');
  384. print '</td></tr>';
  385. // Author
  386. print '<tr><td>';
  387. print $langs->trans("Author") .'</td><td colspan="2">';
  388. if ($object->fk_user_creat) {
  389. print $userstatic->getLoginUrl(1);
  390. } else {
  391. print dol_htmlentities($object->nom_admin);
  392. }
  393. print '</td></tr>';
  394. // Link
  395. print '<tr><td>'.img_picto('','object_globe.png').' '.$langs->trans("UrlForSurvey",'').'</td><td colspan="2">';
  396. // Define $urlwithroot
  397. $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
  398. $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
  399. //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
  400. $url=$urlwithouturlroot.dol_buildpath('/public/opensurvey/studs.php',1).'?sondage='.$object->id_sondage;
  401. $urllink='<input type="text" style="width: 60%" '.($action == 'edit' ? 'disabled' : '').' id="opensurveyurl" name="opensurveyurl" value="'.$url.'">';
  402. print $urllink;
  403. if ($action != 'edit')
  404. {
  405. print '<script type="text/javascript">
  406. jQuery(document).ready(function () {
  407. jQuery("#opensurveyurl").click(function() { jQuery(this).select(); } );
  408. });
  409. </script>';
  410. print ' <a href="'.$url.'" target="_blank">'.$langs->trans("Link").'</a>';
  411. }
  412. print '</td></tr>';
  413. print '</table>';
  414. print '</div>';
  415. dol_fiche_end();
  416. print '</form>'."\n";
  417. print '<div class="tabsAction">';
  418. print '<a class="butAction" href="exportcsv.php?id=' . $numsondage . '">'.$langs->trans("ExportSpreadsheet") .' (.CSV)' . '</a>';
  419. print '</div>';
  420. // Show form to add a new field/column
  421. if (GETPOST('ajoutsujet'))
  422. {
  423. // Security check
  424. if (!$user->rights->opensurvey->write) accessforbidden();
  425. print '<form name="formulaire" action="" method="POST">'."\n";
  426. print '<input type="hidden" name="backtopage" value="'.GETPOST('backtopage').'">';
  427. print '<div class="center">'."\n";
  428. print "<br><br>"."\n";
  429. // Add new column
  430. if ($object->format=="A")
  431. {
  432. print $langs->trans("AddNewColumn") .':<br><br>';
  433. print $langs->trans("Title").' <input type="text" name="nouvellecolonne" size="40"><br>';
  434. $tmparray=array('checkbox'=>$langs->trans("CheckBox"),'yesno'=>$langs->trans("YesNoList"),'foragainst'=>$langs->trans("PourContreList"));
  435. print $langs->trans("Type").' '.$form->selectarray("typecolonne", $tmparray, GETPOST('typecolonne')).'<br><br>';
  436. print '<input type="submit" class="button" name="ajoutercolonne" value="'.dol_escape_htmltag($langs->trans("Add")).'">';
  437. print ' &nbsp; &nbsp; ';
  438. print '<input type="submit" class="button" name="retoursondage" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
  439. print '<br><br>'."\n";
  440. }
  441. else
  442. {
  443. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  444. $formother=new FormOther($db);
  445. //ajout d'une date avec creneau horaire
  446. print $langs->trans("AddADate") .':<br><br>'."\n";
  447. print '<select name="nouveaujour"> '."\n";
  448. print '<OPTION VALUE="vide">&nbsp;</OPTION>'."\n";
  449. for ($i=1;$i<32;$i++){
  450. print '<OPTION VALUE="'.$i.'">'.$i.'</OPTION>'."\n";
  451. }
  452. print '</SELECT>'."\n";
  453. print $formother->select_month('', 'nouveaumois', 1);
  454. print '&nbsp;';
  455. print $formother->select_year('', 'nouvelleannee', 1, 0, 5, 0, 1);
  456. print '<br><br>'. $langs->trans("AddStartHour") .': <br><br>'."\n";
  457. print '<select name="nouvelleheuredebut"> '."\n";
  458. print '<OPTION VALUE="vide">&nbsp;</OPTION>'."\n";
  459. for ($i = 0; $i < 24; $i++) {
  460. print '<OPTION VALUE="'.$i.'">'.$i.' H</OPTION>'."\n";
  461. }
  462. print '</SELECT>'."\n";
  463. print '<select name="nouvelleminutedebut"> '."\n";
  464. print '<OPTION VALUE="vide">&nbsp;</OPTION>'."\n";
  465. print '<OPTION VALUE="00">00</OPTION>'."\n";
  466. print '<OPTION VALUE="15">15</OPTION>'."\n";
  467. print '<OPTION VALUE="30">30</OPTION>'."\n";
  468. print '<OPTION VALUE="45">45</OPTION>'."\n";
  469. print '</SELECT>'."\n";
  470. print '<br><br>'. $langs->trans("AddEndHour") .': <br><br>'."\n";
  471. print '<select name="nouvelleheurefin"> '."\n";
  472. print '<OPTION VALUE="vide">&nbsp;</OPTION>'."\n";
  473. for ($i = 0; $i < 24; $i++) {
  474. print '<OPTION VALUE="'.$i.'">'.$i.' H</OPTION>'."\n";
  475. }
  476. print '</SELECT>'."\n";
  477. print '<select name="nouvelleminutefin"> '."\n";
  478. print '<OPTION VALUE="vide">&nbsp;</OPTION>'."\n";
  479. print '<OPTION VALUE="00">00</OPTION>'."\n";
  480. print '<OPTION VALUE="15">15</OPTION>'."\n";
  481. print '<OPTION VALUE="30">30</OPTION>'."\n";
  482. print '<OPTION VALUE="45">45</OPTION>'."\n";
  483. print '</SELECT>'."\n";
  484. print '<br><br>';
  485. print' <input type="submit" class="button" name="ajoutercolonne" value="'.dol_escape_htmltag($langs->trans("Add")).'">'."\n";
  486. print '&nbsp; &nbsp;';
  487. print '<input type="submit" class="button" name="retoursondage" value="'.$langs->trans("Cancel").'">';
  488. }
  489. print '</form>'."\n";
  490. print '<br><br><br><br>'."\n";
  491. print '</div>'."\n";
  492. exit;
  493. }
  494. if ($user->rights->opensurvey->write) {
  495. print '<br />'.$langs->trans("PollAdminDesc", img_picto('','delete'), $langs->trans("Add")).'<br>';
  496. }
  497. $nbcolonnes=substr_count($object->sujet,',')+1;
  498. print '<form name="formulaire" action="" method="POST">'."\n";
  499. print '<div class="cadre"> '."\n";
  500. // Start to show survey result
  501. print '<table class="resultats">'."\n";
  502. //reformatage des données des sujets du sondage
  503. $toutsujet=explode(",",$object->sujet);
  504. $toutsujet=str_replace("°","'",$toutsujet);
  505. print '<tr>'."\n";
  506. print '<td></td>'."\n";
  507. print '<td></td>'."\n";
  508. //boucle pour l'affichage des boutons de suppression de colonne
  509. if ($user->rights->opensurvey->write) {
  510. for ($i = 0; isset($toutsujet[$i]); $i++) {
  511. print '<td class=somme><input type="image" name="effacecolonne'.$i.'" src="'.img_picto('','delete.png', '', false, 1).'"></td>'."\n";
  512. }
  513. }
  514. print '</tr>'."\n";
  515. // Show choice titles
  516. if ($object->format=="D")
  517. {
  518. //affichage des sujets du sondage
  519. print '<tr>'."\n";
  520. print '<td></td>'."\n";
  521. print '<td></td>'."\n";
  522. //affichage des années
  523. $colspan=1;
  524. $nbofsujet=count($toutsujet);
  525. for ($i=0;$i<$nbofsujet;$i++)
  526. {
  527. $current = $toutsujet[$i];
  528. if (strpos($toutsujet[$i], '@') !== false) {
  529. $current = substr($toutsujet[$i], 0, strpos($toutsujet[$i], '@'));
  530. }
  531. if (isset($toutsujet[$i+1]) && strpos($toutsujet[$i+1], '@') !== false) {
  532. $next = substr($toutsujet[$i+1], 0, strpos($toutsujet[$i+1], '@'));
  533. } elseif (isset($toutsujet[$i+1])) {
  534. $next = $toutsujet[$i+1];
  535. }
  536. $currenty = 0;
  537. if ($current) $currenty=strftime("%Y",$current);
  538. $next = 0;
  539. if ($next) $nexty=strftime("%Y",$next);
  540. if (isset($toutsujet[$i+1]) && ($currenty == $nexty))
  541. {
  542. $colspan++;
  543. } else {
  544. print '<td colspan='.$colspan.' class="annee">';
  545. if ($current) print strftime("%Y", $current);
  546. print '</td>'."\n";
  547. $colspan=1;
  548. }
  549. }
  550. if ($user->rights->opensurvey->write) {
  551. print '<td class="annee">';
  552. print '<a href="'.$_SERVER["PHP_SELF"].'?ajoutsujet=1&id='.$object->id_sondage.'">'.$langs->trans("Add").'</a></td>'."\n";
  553. }
  554. print '</tr>'."\n";
  555. print '<tr>'."\n";
  556. print '<td></td>'."\n";
  557. print '<td></td>'."\n";
  558. //affichage des mois
  559. $colspan = 1;
  560. for ($i = 0; $i < $nbofsujet; $i++) {
  561. $cur = intval($toutsujet[$i]); // intval() est utiliser pour supprimer le suffixe @* qui déplaît logiquement à strftime()
  562. if (isset($toutsujet[$i+1]) === false) {
  563. $next = false;
  564. } else {
  565. $next = intval($toutsujet[$i+1]);
  566. }
  567. if ($next && dol_print_date($cur, "%B") == dol_print_date($next, "%B") && dol_print_date($cur, "%Y") == dol_print_date($next, "%Y")){
  568. $colspan++;
  569. } else {
  570. print '<td colspan='.$colspan.' class="mois">'.dol_print_date($cur, "%B").'</td>'."\n";
  571. $colspan=1;
  572. }
  573. }
  574. if ($user->rights->opensurvey->write) {
  575. print '<td class="mois"><a href="'.$_SERVER["PHP_SELF"].'?ajoutsujet=1&id='.$object->id_sondage.'">'.$langs->trans("Add").'</a></td>'."\n";
  576. }
  577. print '</tr>'."\n";
  578. print '<tr>'."\n";
  579. print '<td></td>'."\n";
  580. print '<td></td>'."\n";
  581. //affichage des jours
  582. $colspan = 1;
  583. for ($i = 0; $i < $nbofsujet; $i++) {
  584. $cur = intval($toutsujet[$i]);
  585. if (isset($toutsujet[$i+1]) === false) {
  586. $next = false;
  587. } else {
  588. $next = intval($toutsujet[$i+1]);
  589. }
  590. if ($next && dol_print_date($cur, "%a %e") == dol_print_date($next,"%a %e") && dol_print_date($cur, "%B") == dol_print_date($next, "%B")) {
  591. $colspan++;
  592. } else {
  593. print '<td colspan='.$colspan.' class="jour">'.dol_print_date($cur, "%a %e").'</td>'."\n";
  594. $colspan=1;
  595. }
  596. }
  597. if ($user->rights->opensurvey->write) {
  598. print '<td class="jour"><a href="'.$_SERVER["PHP_SELF"].'?ajoutsujet=1&id='.$object->id_sondage.'">'.$langs->trans("Add").'</a></td>'."\n";
  599. }
  600. print '</tr>'."\n";
  601. //affichage des horaires
  602. if (strpos($object->sujet,'@') !== false) {
  603. print '<tr>'."\n";
  604. print '<td></td>'."\n";
  605. print '<td></td>'."\n";
  606. for ($i = 0; isset($toutsujet[$i]); $i++) {
  607. $heures=explode('@', $toutsujet[$i]);
  608. if (isset($heures[1])) {
  609. print '<td class="heure">'.dol_htmlentities($heures[1]).'</td>'."\n";
  610. } else {
  611. print '<td class="heure"></td>'."\n";
  612. }
  613. }
  614. if ($user->rights->opensurvey->write) {
  615. print '<td class="heure"><a href="'.$_SERVER["PHP_SELF"].'?ajoutsujet=1&id='.$object->id_sondage.'">'.$langs->trans("Add").'</a></td>'."\n";
  616. }
  617. print '</tr>'."\n";
  618. }
  619. }
  620. else
  621. {
  622. // Show titles
  623. print '<tr>'."\n";
  624. print '<td></td>'."\n";
  625. print '<td></td>'."\n";
  626. for ($i = 0; isset($toutsujet[$i]); $i++)
  627. {
  628. $tmp=explode('@',$toutsujet[$i]);
  629. print '<td class="sujet">'.dol_htmlentities($tmp[0]).'</td>'."\n";
  630. }
  631. print '<td class="sujet"><a href="'.$_SERVER["PHP_SELF"].'?id='.$numsondage.'&ajoutsujet=1&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_picto('',dol_buildpath('/opensurvey/img/add-16.png',1),'',1).'</a></td>'."\n";
  632. print '</tr>'."\n";
  633. }
  634. // Loop on each answer
  635. $sumfor = array();
  636. $sumagainst = array();
  637. $compteur = 0;
  638. $sql ="SELECT id_users, nom as name, id_sondage, reponses";
  639. $sql.=" FROM ".MAIN_DB_PREFIX."opensurvey_user_studs";
  640. $sql.=" WHERE id_sondage = '".$db->escape($numsondage)."'";
  641. dol_syslog('sql='.$sql);
  642. $resql=$db->query($sql);
  643. if (! $resql)
  644. {
  645. dol_print_error($db);
  646. exit;
  647. }
  648. $num=$db->num_rows($resql);
  649. while ($compteur < $num)
  650. {
  651. $obj=$db->fetch_object($resql);
  652. $ensemblereponses = $obj->reponses;
  653. print '<tr><td>'."\n";
  654. if ($user->rights->opensurvey->write) {
  655. print '<input type="image" name="effaceligne'.$compteur.'" src="'.img_picto('','delete.png', '', false, 1).'">'."\n";
  656. }
  657. // Name
  658. print '</td><td class="nom">'.dol_htmlentities($obj->name).'</td>'."\n";
  659. // si la ligne n'est pas a changer, on affiche les données
  660. if (! $testligneamodifier)
  661. {
  662. for ($i = 0; $i < $nbcolonnes; $i++)
  663. {
  664. $car = substr($ensemblereponses, $i, 1);
  665. //print 'xx'.$i."-".$car.'-'.$listofanswers[$i]['format'].'zz';
  666. if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst')))
  667. {
  668. if (((string) $car) == "1") print '<td class="ok">OK</td>'."\n";
  669. else print '<td class="non">KO</td>'."\n";
  670. // Total
  671. if (! isset($sumfor[$i])) $sumfor[$i] = 0;
  672. if (((string) $car) == "1") $sumfor[$i]++;
  673. }
  674. if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
  675. {
  676. if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("Yes").'</td>'."\n";
  677. else if (((string) $car) == "0") print '<td class="non">'.$langs->trans("No").'</td>'."\n";
  678. else print '<td class="vide">&nbsp;</td>'."\n";
  679. // Total
  680. if (! isset($sumfor[$i])) $sumfor[$i] = 0;
  681. if (! isset($sumagainst[$i])) $sumagainst[$i] = 0;
  682. if (((string) $car) == "1") $sumfor[$i]++;
  683. if (((string) $car) == "0") $sumagainst[$i]++;
  684. }
  685. if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
  686. {
  687. if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
  688. else if (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
  689. else print '<td class="vide">&nbsp;</td>'."\n";
  690. // Total
  691. if (! isset($sumfor[$i])) $sumfor[$i] = 0;
  692. if (! isset($sumagainst[$i])) $sumagainst[$i] = 0;
  693. if (((string) $car) == "1") $sumfor[$i]++;
  694. if (((string) $car) == "0") $sumagainst[$i]++;
  695. }
  696. }
  697. }
  698. else
  699. {
  700. //sinon on remplace les choix de l'utilisateur par une ligne de checkbox pour recuperer de nouvelles valeurs
  701. if ($compteur == $ligneamodifier)
  702. {
  703. for ($i = 0; $i < $nbcolonnes; $i++)
  704. {
  705. $car = substr($ensemblereponses, $i, 1);
  706. print '<td class="vide">';
  707. if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst')))
  708. {
  709. print '<input type="checkbox" name="choix'.$i.'" value="1" ';
  710. if ($car == '1') print 'checked';
  711. print '>';
  712. }
  713. if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
  714. {
  715. $arraychoice=array('2'=>'&nbsp;','0'=>$langs->trans("No"),'1'=>$langs->trans("Yes"));
  716. print $form->selectarray("choix".$i, $arraychoice, $car);
  717. }
  718. if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
  719. {
  720. $arraychoice=array('2'=>'&nbsp;','0'=>$langs->trans("Against"),'1'=>$langs->trans("For"));
  721. print $form->selectarray("choix".$i, $arraychoice, $car);
  722. }
  723. print '</td>'."\n";
  724. }
  725. }
  726. else
  727. {
  728. for ($i = 0; $i < $nbcolonnes; $i++)
  729. {
  730. $car = substr($ensemblereponses, $i, 1);
  731. if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst')))
  732. {
  733. if (((string) $car) == "1") print '<td class="ok">OK</td>'."\n";
  734. else print '<td class="non">KO</td>'."\n";
  735. // Total
  736. if (! isset($sumfor[$i])) $sumfor[$i] = 0;
  737. if (((string) $car) == "1") $sumfor[$i]++;
  738. }
  739. if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
  740. {
  741. if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
  742. else if (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
  743. else print '<td class="vide">&nbsp;</td>'."\n";
  744. // Total
  745. if (! isset($sumfor[$i])) $sumfor[$i] = 0;
  746. if (! isset($sumagainst[$i])) $sumagainst[$i] = 0;
  747. if (((string) $car) == "1") $sumfor[$i]++;
  748. if (((string) $car) == "0") $sumagainst[$i]++;
  749. }
  750. if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
  751. {
  752. if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
  753. else if (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
  754. else print '<td class="vide">&nbsp;</td>'."\n";
  755. // Total
  756. if (! isset($sumfor[$i])) $sumfor[$i] = 0;
  757. if (! isset($sumagainst[$i])) $sumagainst[$i] = 0;
  758. if (((string) $car) == "1") $sumfor[$i]++;
  759. if (((string) $car) == "0") $sumagainst[$i]++;
  760. }
  761. }
  762. }
  763. }
  764. // Button edit at end of line
  765. if ($compteur != $ligneamodifier && ($user->rights->opensurvey->write))
  766. {
  767. print '<td class="casevide"><input type="submit" class="button" name="modifierligne'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Edit")).'"></td>'."\n";
  768. }
  769. //demande de confirmation pour modification de ligne
  770. for ($i=0; $i<$nblignes; $i++)
  771. {
  772. if (isset($_POST["modifierligne".$i]))
  773. {
  774. if ($compteur == $i)
  775. {
  776. print '<td class="casevide">';
  777. print '<input type="hidden" name="idtomodify'.$compteur.'" value="'.$obj->id_users.'">';
  778. print '<input type="submit" class="button" name="validermodifier'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
  779. print '</td>'."\n";
  780. }
  781. }
  782. }
  783. $compteur++;
  784. print '</tr>'."\n";
  785. }
  786. // Add line to add new record
  787. if (empty($testligneamodifier))
  788. {
  789. print '<tr>'."\n";
  790. print '<td></td>'."\n";
  791. print '<td class="nom">'."\n";
  792. print '<input type="text" placeholder="'.dol_escape_htmltag($langs->trans("Name")).'" name="nom" maxlength="64" size="24">'."\n";
  793. print '</td>'."\n";
  794. for ($i = 0; $i < $nbcolonnes; $i++)
  795. {
  796. print '<td class="vide">';
  797. if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst')))
  798. {
  799. print '<input type="checkbox" name="choix'.$i.'" value="1"';
  800. if ( isset($_POST['choix'.$i]) && $_POST['choix'.$i] == '1' )
  801. {
  802. print ' checked';
  803. }
  804. print '>';
  805. }
  806. if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
  807. {
  808. $arraychoice=array('2'=>'&nbsp;','0'=>$langs->trans("No"),'1'=>$langs->trans("Yes"));
  809. print $form->selectarray("choix".$i, $arraychoice);
  810. }
  811. if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
  812. {
  813. $arraychoice=array('2'=>'&nbsp;','0'=>$langs->trans("Against"),'1'=>$langs->trans("For"));
  814. print $form->selectarray("choix".$i, $arraychoice);
  815. }
  816. print '</td>'."\n";
  817. }
  818. // Affichage du bouton de formulaire pour inscrire un nouvel utilisateur dans la base
  819. print '<td><input type="image" name="boutonp" value="'.$langs->trans("Vote").'" src="'.dol_buildpath('/opensurvey/img/add-24.png',1).'"></td>'."\n";
  820. print '</tr>'."\n";
  821. }
  822. // Select value of best choice (for checkbox columns only)
  823. $nbofcheckbox=0;
  824. for ($i=0; $i < $nbcolonnes + 1; $i++)
  825. {
  826. if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst')))
  827. $nbofcheckbox++;
  828. if (isset($sumfor[$i]))
  829. {
  830. if ($i == 0)
  831. {
  832. $meilleurecolonne = $sumfor[$i];
  833. }
  834. if (isset($sumfor[$i]) && $sumfor[$i] > $meilleurecolonne)
  835. {
  836. $meilleurecolonne = $sumfor[$i];
  837. }
  838. }
  839. }
  840. // Show line total
  841. print '<tr>'."\n";
  842. print '<td></td>'."\n";
  843. print '<td align="center">'. $langs->trans("Total") .'</td>'."\n";
  844. for ($i = 0; $i < $nbcolonnes; $i++)
  845. {
  846. $showsumfor = isset($sumfor[$i])?$sumfor[$i]:'';
  847. $showsumagainst = isset($sumagainst[$i])?$sumagainst[$i]:'';
  848. if (empty($showsumfor)) $showsumfor = 0;
  849. if (empty($showsumagainst)) $showsumagainst = 0;
  850. print '<td>';
  851. if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst'))) print $showsumfor;
  852. if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') print $langs->trans("Yes").': '.$showsumfor.'<br>'.$langs->trans("No").': '.$showsumagainst;
  853. if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') print $langs->trans("For").': '.$showsumfor.'<br>'.$langs->trans("Against").': '.$showsumagainst;
  854. print '</td>'."\n";
  855. }
  856. print '</tr>';
  857. // Show picto winner
  858. if ($nbofcheckbox >= 2)
  859. {
  860. print '<tr>'."\n";
  861. print '<td></td>'."\n";
  862. print '<td></td>'."\n";
  863. for ($i = 0; $i < $nbcolonnes; $i++) {
  864. if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne)
  865. {
  866. print '<td class="somme"><img src="'.dol_buildpath('/opensurvey/img/medaille.png',1).'"></td>'."\n";
  867. } else {
  868. print '<td class="somme"></td>'."\n";
  869. }
  870. }
  871. print '</tr>'."\n";
  872. }
  873. // S'il a oublié de remplir un nom
  874. if (isset($_POST["boutonp"]) && $_POST["nom"] == "") {
  875. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name")), null, 'errors');
  876. }
  877. if (isset($erreur_prenom) && $erreur_prenom) {
  878. setEventMessages($langs->trans('VoteNameAlreadyExists'), null, 'errors');
  879. }
  880. if (isset($erreur_ajout_date) && $erreur_ajout_date) {
  881. setEventMessages($langs->trans("ErrorWrongDate"), null, 'errors');
  882. }
  883. //fin du tableau
  884. print '</table>'."\n";
  885. print '</div>'."\n";
  886. $toutsujet = explode(",", $object->sujet); // With old versions, this field was not set
  887. $compteursujet = 0;
  888. $meilleursujet = '';
  889. for ($i = 0; $i < $nbcolonnes; $i++) {
  890. if (isset($sumfor[$i]) === true && isset($meilleurecolonne) === true && $sumfor[$i] == $meilleurecolonne) {
  891. $meilleursujet.=", ";
  892. if ($object->format == "D") {
  893. $meilleursujetexport = $toutsujet[$i];
  894. if (strpos($toutsujet[$i], '@') !== false) {
  895. $toutsujetdate = explode("@", $toutsujet[$i]);
  896. $meilleursujet .= dol_print_date($toutsujetdate[0],'daytext'). ' ('.dol_print_date($toutsujetdate[0],'%A').')' . ' - ' . $toutsujetdate[1];
  897. } else {
  898. $meilleursujet .= dol_print_date($toutsujet[$i],'daytext'). ' ('.dol_print_date($toutsujet[$i],'%A').')';
  899. }
  900. }
  901. else
  902. {
  903. $tmps=explode('@',$toutsujet[$i]);
  904. $meilleursujet .= dol_htmlentities($tmps[0]);
  905. }
  906. $compteursujet++;
  907. }
  908. }
  909. $meilleursujet = substr($meilleursujet, 1);
  910. $meilleursujet = str_replace("°", "'", $meilleursujet);
  911. // Show best choice
  912. if ($nbofcheckbox >= 2)
  913. {
  914. $vote_str = $langs->trans('votes');
  915. print '<p class="affichageresultats">'."\n";
  916. if (isset($meilleurecolonne) && $compteursujet == "1") {
  917. print "<img src=\"".DOL_URL_ROOT.'/opensurvey/img/medaille.png'."\"> " . $langs->trans('TheBestChoice') . ": <b>".$meilleursujet." </b>" . $langs->trans("with") . " <b>".$meilleurecolonne."</b>" . $vote_str . ".\n";
  918. } elseif (isset($meilleurecolonne)) {
  919. print "<img src=\"".DOL_URL_ROOT.'/opensurvey/img/medaille.png'."\"> " . $langs->trans('TheBestChoices') . ": <b>".$meilleursujet." </b>" . $langs->trans("with") . " <b>".$meilleurecolonne."</b>" . $vote_str . ".\n";
  920. }
  921. print '<br></p><br>'."\n";
  922. }
  923. print '</form>'."\n";
  924. print '<a name="bas"></a>'."\n";
  925. llxFooterSurvey();
  926. $db->close();