26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
28 require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
29 require_once DOL_DOCUMENT_ROOT.
"/opensurvey/class/opensurveysondage.class.php";
30 require_once DOL_DOCUMENT_ROOT.
"/opensurvey/lib/opensurvey.lib.php";
33 if (empty($user->rights->opensurvey->read)) {
38 $action =
GETPOST(
'action',
'aZ09');
42 $result = $object->fetch(0, $numsondage);
47 $nblines = $object->fetch_lines();
60 $nbcolonnes = substr_count($object->sujet,
',') + 1;
65 $erreur_prenom =
false;
68 for ($i = 0; $i < $nbcolonnes; $i++) {
78 $nom = substr(
GETPOST(
"nom",
'alphanohtml'), 0, 64);
81 $sql =
'SELECT id_users, nom as name';
82 $sql .=
' FROM '.MAIN_DB_PREFIX.
'opensurvey_user_studs';
83 $sql .=
" WHERE id_sondage='".$db->escape($numsondage).
"' AND nom = '".$db->escape($nom).
"'";
84 $sql .=
' ORDER BY id_users';
86 $num_rows = $db->num_rows(
$resql);
91 $sql =
'INSERT INTO '.MAIN_DB_PREFIX.
'opensurvey_user_studs (nom, id_sondage, reponses)';
92 $sql .=
" VALUES ('".$db->escape($nom).
"', '".$db->escape($numsondage).
"','".$db->escape($nouveauchoix).
"')";
102 $testmodifier =
false;
103 $testligneamodifier =
false;
104 $ligneamodifier = -1;
105 for ($i = 0; $i < $nblines; $i++) {
107 $ligneamodifier = $i;
108 $testligneamodifier =
true;
114 $testmodifier =
true;
119 if (!$user->rights->opensurvey->write) {
124 for ($i = 0; $i < $nbcolonnes; $i++) {
126 $nouveauchoix .=
"1";
128 $nouveauchoix .=
"2";
130 $nouveauchoix .=
"0";
134 $idtomodify =
GETPOST(
"idtomodify".$modifier);
135 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_user_studs";
136 $sql .=
" SET reponses = '".$db->escape($nouveauchoix).
"'";
137 $sql .=
" WHERE id_users = '".$db->escape($idtomodify).
"'";
139 $resql = $db->query($sql);
146 if (
GETPOST(
"ajoutercolonne") &&
GETPOST(
'nouvellecolonne') && $object->format ==
"A") {
148 if (!$user->rights->opensurvey->write) {
152 $nouveauxsujets = $object->sujet;
155 $nouveauxsujets .=
',';
156 $nouveauxsujets .= str_replace(array(
",",
"@"),
" ",
GETPOST(
"nouvellecolonne")).(!
GETPOST(
"typecolonne") ?
'' :
'@'.GETPOST(
"typecolonne"));
159 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_sondage";
160 $sql .=
" SET sujet = '".$db->escape($nouveauxsujets).
"'";
161 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
162 $resql = $db->query($sql);
166 header(
'Location: results.php?id='.$object->id_sondage);
171 if (
GETPOSTISSET(
"ajoutercolonne") && $object->format ==
"D") {
173 if (!$user->rights->opensurvey->write) {
177 $nouveauxsujets = $object->sujet;
185 $nouvelledate .=
"@";
186 $nouvelledate .=
GETPOST(
"nouvelleheuredebut");
187 $nouvelledate .=
"h";
189 if (
GETPOST(
"nouvelleminutedebut") !=
"vide") {
190 $nouvelledate .=
GETPOST(
"nouvelleminutedebut");
195 $nouvelledate .=
"-";
196 $nouvelledate .=
GETPOST(
"nouvelleheurefin");
197 $nouvelledate .=
"h";
199 if (
GETPOST(
"nouvelleminutefin") !=
"vide") {
200 $nouvelledate .=
GETPOST(
"nouvelleminutefin");
206 && (
GETPOST(
"nouvelleminutedebut") <
GETPOST(
"nouvelleminutefin")))))) {
207 $erreur_ajout_date =
false;
209 $erreur_ajout_date =
"yes";
213 $datesbase = explode(
",", $object->sujet);
214 $taillebase = count($datesbase);
217 if ($nouvelledate < $datesbase[0]) {
219 } elseif ($nouvelledate > $datesbase[$taillebase - 1]) {
220 $cleinsertion = count($datesbase);
222 $nbdatesbase = count($datesbase);
223 for ($i = 0; $i < $nbdatesbase; $i++) {
225 if ($nouvelledate > $datesbase[$i] && $nouvelledate < $datesbase[$j]) {
231 array_splice($datesbase, $cleinsertion, 0, $nouvelledate);
232 $cle = array_search($nouvelledate, $datesbase);
234 $nbofdates = count($datesbase);
235 for ($i = 0; $i < $nbofdates; $i++) {
236 $dateinsertion .=
",";
237 $dateinsertion .= $datesbase[$i];
240 $dateinsertion = substr(
"$dateinsertion", 1);
243 if (isset($erreur_ajout_date) && empty($erreur_ajout_date)) {
244 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_sondage";
245 $sql .=
" SET sujet = '".$db->escape($dateinsertion).
"'";
246 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
247 $resql = $db->query($sql);
251 header(
'Location: results.php?id='.$object->id_sondage);
254 if ($cleinsertion >= 0) {
255 $sql =
'SELECT s.reponses';
256 $sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs as s";
257 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
258 $resql = $db->query($sql);
262 $num = $db->num_rows(
$resql);
264 while ($compteur < $num) {
265 $obj = $db->fetch_object(
$resql);
266 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_user_studs";
267 if ($cleinsertion == 0) {
268 $sql .=
" SET reponses = '0".$db->escape($obj->reponses).
"'";
270 $reponsesadd = str_split($obj->reponses);
271 $lengthresponses = count($reponsesadd);
272 for ($cpt = $lengthresponses; $cpt > $cleinsertion; $cpt--) {
273 $reponsesadd[$cpt] = $reponsesadd[$cpt-1];
275 $reponsesadd[$cleinsertion] =
'0';
276 $reponsesadd = implode($reponsesadd);
277 $sql .=
" SET reponses = '".$db->escape($reponsesadd).
"'";
279 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
280 $resql = $db->query($sql);
288 $adresseadmin = $object->mail_admin;
290 $erreur_ajout_date =
"yes";
295 for ($i = 0; $i < $nblines; $i++) {
298 if (!$user->rights->opensurvey->write) {
306 $sql =
"SELECT id_users, nom as name, id_sondage, reponses";
307 $sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs";
308 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
309 $resql = $db->query($sql);
313 $num = $db->num_rows(
$resql);
314 while ($compteur < $num) {
315 $obj = $db->fetch_object(
$resql);
317 if ($compteur == $i) {
318 $sql2 =
'DELETE FROM '.MAIN_DB_PREFIX.
'opensurvey_user_studs';
319 $sql2 .=
" WHERE id_users = ".((int) $obj->id_users);
320 $resql2 = $db->query($sql2);
329 for ($i = 0; $i < $nbcolonnes; $i++) {
330 if ((
GETPOST(
"effacecolonne".$i) ||
GETPOST(
"effacecolonne".$i.
"_x") ||
GETPOST(
"effacecolonne".$i.
".x"))
331 && $nbcolonnes > 1) {
333 if (!$user->rights->opensurvey->write) {
339 $toutsujet = explode(
",", $object->sujet);
341 $nouveauxsujets =
'';
344 while (isset($toutsujet[$j])) {
347 if (!empty($nouveauxsujets)) {
348 $nouveauxsujets .=
',';
350 $nouveauxsujets .= $toutsujet[$j];
357 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_sondage";
358 $sql .=
" SET sujet = '".$db->escape($nouveauxsujets).
"' WHERE id_sondage = '".$db->escape($numsondage).
"'";
359 $resql = $db->query($sql);
366 $sql =
"SELECT id_users, nom as name, id_sondage, reponses";
367 $sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs";
368 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
370 $resql = $db->query($sql);
375 $num = $db->num_rows(
$resql);
376 while ($compteur < $num) {
377 $obj = $db->fetch_object(
$resql);
380 $ensemblereponses = $obj->reponses;
383 for ($j = 0; $j < $nbcolonnes; $j++) {
384 $car = substr($ensemblereponses, $j, 1);
392 $sql2 =
'UPDATE '.MAIN_DB_PREFIX.
'opensurvey_user_studs';
393 $sql2 .=
" SET reponses = '".$db->escape($newcar).
"'";
394 $sql2 .=
" WHERE id_users = '".$db->escape($obj->id_users).
"'";
397 $resql2 = $db->query($sql2);
414 if ($object->fk_user_creat) {
415 $userstatic =
new User($db);
416 $userstatic->fetch($object->fk_user_creat);
419 $result = $object->fetch(0, $numsondage);
425 $title = $object->title.
" - ".$langs->trans(
'Card');
427 $arrayofjs = array();
428 $arrayofcss = array(
'/opensurvey/css/style.css');
429 llxHeader(
'', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss);
433 $toutsujet = explode(
",", $object->sujet);
434 $listofanswers = array();
435 foreach ($toutsujet as $value) {
436 $tmp = explode(
'@', $value);
437 $listofanswers[] = array(
'label'=>$tmp[0],
'format'=>($tmp[1] ? $tmp[1] :
'checkbox'));
439 $toutsujet = str_replace(
"@",
"<br>", $toutsujet);
440 $toutsujet = str_replace(
"°",
"'", $toutsujet);
443 print
'<form name="formulaire4" action="#" method="POST">'.
"\n";
444 print
'<input type="hidden" name="token" value="'.newToken().
'">';
446 $head = opensurvey_prepare_head($object);
452 $linkback =
'<a href="'.DOL_URL_ROOT.
'/opensurvey/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
454 dol_banner_tab($object,
'id', $linkback, 1,
'id_sondage',
'id_sondage', $morehtmlref);
457 print
'<div class="fichecenter">';
459 print
'<div class="fichehalfleft">';
460 print
'<div class="underbanner clearboth"></div>';
461 print
'<table class="border tableforfield centpercent">';
464 $type = ($object->format ==
"A") ?
'classic' :
'date';
465 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td>';
466 print
img_picto(
'',
dol_buildpath(
'/opensurvey/img/'.($type ==
'classic' ?
'chart-32.png' :
'calendar-32.png'), 1),
'width="16"', 1);
467 print
' '.$langs->trans($type ==
'classic' ?
"TypeClassic" :
"TypeDate").
'</td></tr>';
471 $adresseadmin = $object->mail_admin;
472 print $langs->trans(
"Title").
'</td><td>';
473 if ($action ==
'edit') {
474 print
'<input type="text" name="nouveautitre" size="40" value="'.dol_escape_htmltag($object->title).
'">';
481 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
482 if ($action ==
'edit') {
483 $doleditor =
new DolEditor(
'nouveauxcommentaires', $object->description,
'', 120,
'dolibarr_notes',
'In', 1, 1, 1, ROWS_7,
'90%');
484 $doleditor->Create(0,
'');
486 print (
dol_textishtml($object->description) ? $object->description :
dol_nl2br($object->description, 1,
true));
492 if (!$object->fk_user_creat) {
493 print
'<tr><td>'.$langs->trans(
"EMail").
'</td><td>';
494 if ($action ==
'edit') {
495 print
'<input type="text" name="nouvelleadresse" class="minwith200" value="'.$object->mail_admin.
'">';
505 print
'<div class="fichehalfright">';
506 print
'<div class="underbanner clearboth"></div>';
508 print
'<table class="border tableforfield centpercent">';
512 print
'<tr><td>'.$langs->trans(
'ExpireDate').
'</td><td>';
513 if ($action ==
'edit') {
514 print
$form->selectDate($expiredate ? $expiredate : $object->date_fin,
'expire', 0, 0, 0,
'', 1, 0);
525 print $langs->trans(
"Author").
'</td><td>';
526 if ($object->fk_user_creat) {
527 print $userstatic->getLoginUrl(1);
534 print
'<tr><td>'.$langs->trans(
"UrlForSurvey",
'').
'</td><td>';
537 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
538 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
541 $url = $urlwithouturlroot.dol_buildpath(
'/public/opensurvey/studs.php', 1).
'?sondage='.$object->id_sondage;
542 $urllink =
'<input type="text" class="quatrevingtpercent" '.($action ==
'edit' ?
'disabled' :
'').
' id="opensurveyurl" name="opensurveyurl" value="'.$url.
'">';
544 if ($action !=
'edit') {
554 print
'<div class="clearboth"></div>';
558 print
'</form>'.
"\n";
563 print
'<div class="tabsAction">';
565 print
'<a class="butAction" href="exportcsv.php?id='.urlencode($numsondage).
'">'.$langs->trans(
"ExportSpreadsheet").
' (.CSV)</a>';
573 if (!$user->rights->opensurvey->write) {
577 print
'<form name="formulaire" action="" method="POST">'.
"\n";
578 print
'<input type="hidden" name="token" value="'.newToken().
'">';
579 print
'<input type="hidden" name="backtopage" value="'.GETPOST(
'backtopage',
'alpha').
'">';
581 print
'<div class="center">'.
"\n";
585 if ($object->format ==
"A") {
586 print $langs->trans(
"AddNewColumn").
':<br><br>';
587 print $langs->trans(
"Title").
' <input type="text" name="nouvellecolonne" size="40"><br>';
588 $tmparray = array(
'checkbox'=>$langs->trans(
"CheckBox"),
'yesno'=>$langs->trans(
"YesNoList"),
'foragainst'=>$langs->trans(
"PourContreList"));
589 print $langs->trans(
"Type").
' '.
$form->selectarray(
"typecolonne", $tmparray,
GETPOST(
'typecolonne')).
'<br><br>';
590 print
'<input type="submit" class="button" name="ajoutercolonne" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'">';
591 print
'<input type="hidden" name="id_sondage" value="'.dol_escape_htmltag($object->id_sondage).
'">';
592 print
' ';
593 print
'<input type="submit" class="button button-cancel" name="retoursondage" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
594 print
'<br><br>'.
"\n";
596 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
600 print $langs->trans(
"AddADate").
':<br><br>'.
"\n";
601 print
'<select name="nouveaujour"> '.
"\n";
602 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
603 for ($i = 1; $i < 32; $i++) {
604 print
'<OPTION VALUE="'.$i.
'">'.$i.
'</OPTION>'.
"\n";
606 print
'</select>'.
"\n";
608 print $formother->select_month(
'',
'nouveaumois', 1);
612 print $formother->selectyear(
'',
'nouvelleannee', 1, 0, 5, 0, 1);
614 print
'<br><br>'.$langs->trans(
"AddStartHour").
': <br><br>'.
"\n";
615 print
'<select name="nouvelleheuredebut"> '.
"\n";
616 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
617 for ($i = 0; $i < 24; $i++) {
618 print
'<OPTION VALUE="'.$i.
'">'.$i.
' H</OPTION>'.
"\n";
620 print
'</select>'.
"\n";
621 print
'<select name="nouvelleminutedebut"> '.
"\n";
622 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
623 print
'<OPTION VALUE="00">00</OPTION>'.
"\n";
624 print
'<OPTION VALUE="15">15</OPTION>'.
"\n";
625 print
'<OPTION VALUE="30">30</OPTION>'.
"\n";
626 print
'<OPTION VALUE="45">45</OPTION>'.
"\n";
627 print
'</select>'.
"\n";
628 print
'<br><br>'.$langs->trans(
"AddEndHour").
': <br><br>'.
"\n";
629 print
'<select name="nouvelleheurefin"> '.
"\n";
630 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
631 for ($i = 0; $i < 24; $i++) {
632 print
'<OPTION VALUE="'.$i.
'">'.$i.
' H</OPTION>'.
"\n";
634 print
'</SELECT>'.
"\n";
635 print
'<select name="nouvelleminutefin"> '.
"\n";
636 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
637 print
'<OPTION VALUE="00">00</OPTION>'.
"\n";
638 print
'<OPTION VALUE="15">15</OPTION>'.
"\n";
639 print
'<OPTION VALUE="30">30</OPTION>'.
"\n";
640 print
'<OPTION VALUE="45">45</OPTION>'.
"\n";
641 print
'</select>'.
"\n";
644 print
' <input type="submit" class="button" name="ajoutercolonne" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'">'.
"\n";
645 print
' ';
646 print
'<input type="submit" class="button button-cancel" name="retoursondage" value="'.$langs->trans(
"Cancel").
'">';
649 print
'</form>'.
"\n";
650 print
'<br><br><br><br>'.
"\n";
656 if ($user->rights->opensurvey->write) {
657 print
'<span class="opacitymedium">';
658 $s = $langs->trans(
"PollAdminDesc",
'{s1}', $langs->trans(
"Add"));
659 print str_replace(
'{s1}',
img_picto(
'',
'delete'), $s);
663 $nbcolonnes = substr_count($object->sujet,
',') + 1;
665 print
'<form name="formulaire" action="" method="POST">'.
"\n";
666 print
'<input type="hidden" name="token" value="'.newToken().
'">';
667 print
'<input type="hidden" name="page_y" value="">';
669 print
'<div class="cadre div-table-responsive-no-min"> '.
"\n";
672 print
'<table class="resultats">'.
"\n";
675 $toutsujet = explode(
",", $object->sujet);
676 $toutsujet = str_replace(
"°",
"'", $toutsujet);
679 print
'<td></td>'.
"\n";
680 print
'<td></td>'.
"\n";
683 if ($user->rights->opensurvey->write) {
684 for ($i = 0; isset($toutsujet[$i]); $i++) {
685 print
'<td class=somme><input type="image" name="effacecolonne'.$i.
'" src="'.
img_picto(
'',
'delete.png',
'',
false, 1).
'"></td>'.
"\n";
693 if ($object->format ==
"D") {
696 print
'<td></td>'.
"\n";
697 print
'<td></td>'.
"\n";
701 $nbofsujet = count($toutsujet);
702 for ($i = 0; $i < $nbofsujet; $i++) {
703 $current = $toutsujet[$i];
705 if (strpos($toutsujet[$i],
'@') !==
false) {
706 $current = substr($toutsujet[$i], 0, strpos($toutsujet[$i],
'@'));
709 if (isset($toutsujet[$i + 1]) && strpos($toutsujet[$i + 1],
'@') !==
false) {
710 $next = substr($toutsujet[$i + 1], 0, strpos($toutsujet[$i + 1],
'@'));
711 } elseif (isset($toutsujet[$i + 1])) {
712 $next = $toutsujet[$i + 1];
717 $currenty = strftime(
"%Y", $current);
721 $nexty = strftime(
"%Y", $next);
723 if (isset($toutsujet[$i + 1]) && ($currenty == $nexty)) {
726 print
'<td colspan='.$colspan.
' class="annee">';
728 print strftime(
"%Y", $current);
735 if ($user->rights->opensurvey->write) {
736 print
'<td class="annee">';
737 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
742 print
'<td></td>'.
"\n";
743 print
'<td></td>'.
"\n";
747 for ($i = 0; $i < $nbofsujet; $i++) {
748 $cur = intval($toutsujet[$i]);
750 if (isset($toutsujet[$i + 1]) ===
false) {
753 $next = intval($toutsujet[$i + 1]);
759 print
'<td colspan='.$colspan.
' class="mois">'.
dol_print_date($cur,
"%B").
'</td>'.
"\n";
765 if ($user->rights->opensurvey->write) {
766 print
'<td class="mois"><a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
771 print
'<td></td>'.
"\n";
772 print
'<td></td>'.
"\n";
776 for ($i = 0; $i < $nbofsujet; $i++) {
777 $cur = intval($toutsujet[$i]);
778 if (isset($toutsujet[$i + 1]) ===
false) {
781 $next = intval($toutsujet[$i + 1]);
786 print
'<td colspan='.$colspan.
' class="jour">'.
dol_print_date($cur,
"%a %e").
'</td>'.
"\n";
792 if ($user->rights->opensurvey->write) {
793 print
'<td class="jour"><a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
798 if (strpos($object->sujet,
'@') !==
false) {
800 print
'<td></td>'.
"\n";
801 print
'<td></td>'.
"\n";
803 for ($i = 0; isset($toutsujet[$i]); $i++) {
804 $heures = explode(
'@', $toutsujet[$i]);
805 if (isset($heures[1])) {
806 print
'<td class="heure">'.dol_htmlentities($heures[1]).
'</td>'.
"\n";
808 print
'<td class="heure"></td>'.
"\n";
812 if ($user->rights->opensurvey->write) {
813 print
'<td class="heure"><a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
821 print
'<td></td>'.
"\n";
822 print
'<td></td>'.
"\n";
824 for ($i = 0; isset($toutsujet[$i]); $i++) {
825 $tmp = explode(
'@', $toutsujet[$i]);
826 print
'<td class="sujet">'.dol_htmlentities($tmp[0]).
'</td>'.
"\n";
829 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";
836 $sumagainst = array();
838 $sql =
"SELECT id_users, nom as name, id_sondage, reponses";
839 $sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs";
840 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
842 $resql = $db->query($sql);
847 $num = $db->num_rows(
$resql);
848 while ($compteur < $num) {
849 $obj = $db->fetch_object(
$resql);
851 $ensemblereponses = $obj->reponses;
853 print
'<tr><td>'.
"\n";
855 if ($user->rights->opensurvey->write) {
856 print
'<input type="image" class="reposition" name="effaceligne'.$compteur.
'" src="'.
img_picto(
'',
'delete.png',
'',
false, 1).
'">'.
"\n";
860 print
'</td><td class="nom">'.dol_htmlentities($obj->name).
'</td>'.
"\n";
863 if (!$testligneamodifier) {
864 for ($i = 0; $i < $nbcolonnes; $i++) {
865 $car = substr($ensemblereponses, $i, 1);
868 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
869 if (((
string) $car) ==
"1") {
870 print
'<td class="ok">OK</td>'.
"\n";
872 print
'<td class="non">KO</td>'.
"\n";
875 if (!isset($sumfor[$i])) {
878 if (((
string) $car) ==
"1") {
882 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
883 if (((
string) $car) ==
"1") {
884 print
'<td class="ok">'.$langs->trans(
"Yes").
'</td>'.
"\n";
885 } elseif (((
string) $car) ==
"0") {
886 print
'<td class="non">'.$langs->trans(
"No").
'</td>'.
"\n";
888 print
'<td class="vide"> </td>'.
"\n";
891 if (!isset($sumfor[$i])) {
894 if (!isset($sumagainst[$i])) {
897 if (((
string) $car) ==
"1") {
900 if (((
string) $car) ==
"0") {
904 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
905 if (((
string) $car) ==
"1") {
906 print
'<td class="ok">'.$langs->trans(
"For").
'</td>'.
"\n";
907 } elseif (((
string) $car) ==
"0") {
908 print
'<td class="non">'.$langs->trans(
"Against").
'</td>'.
"\n";
910 print
'<td class="vide"> </td>'.
"\n";
913 if (!isset($sumfor[$i])) {
916 if (!isset($sumagainst[$i])) {
919 if (((
string) $car) ==
"1") {
922 if (((
string) $car) ==
"0") {
929 if ($compteur == $ligneamodifier) {
930 for ($i = 0; $i < $nbcolonnes; $i++) {
931 $car = substr($ensemblereponses, $i, 1);
932 print
'<td class="vide">';
933 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
934 print
'<input type="checkbox" name="choix'.$i.
'" value="1" ';
940 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
941 $arraychoice = array(
'2'=>
' ',
'0'=>$langs->trans(
"No"),
'1'=>$langs->trans(
"Yes"));
942 print
$form->selectarray(
"choix".$i, $arraychoice, $car);
944 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
945 $arraychoice = array(
'2'=>
' ',
'0'=>$langs->trans(
"Against"),
'1'=>$langs->trans(
"For"));
946 print
$form->selectarray(
"choix".$i, $arraychoice, $car);
951 for ($i = 0; $i < $nbcolonnes; $i++) {
952 $car = substr($ensemblereponses, $i, 1);
953 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
954 if (((
string) $car) ==
"1") {
955 print
'<td class="ok">OK</td>'.
"\n";
957 print
'<td class="non">KO</td>'.
"\n";
960 if (!isset($sumfor[$i])) {
963 if (((
string) $car) ==
"1") {
967 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
968 if (((
string) $car) ==
"1") {
969 print
'<td class="ok">'.$langs->trans(
"For").
'</td>'.
"\n";
970 } elseif (((
string) $car) ==
"0") {
971 print
'<td class="non">'.$langs->trans(
"Against").
'</td>'.
"\n";
973 print
'<td class="vide"> </td>'.
"\n";
976 if (!isset($sumfor[$i])) {
979 if (!isset($sumagainst[$i])) {
982 if (((
string) $car) ==
"1") {
985 if (((
string) $car) ==
"0") {
989 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
990 if (((
string) $car) ==
"1") {
991 print
'<td class="ok">'.$langs->trans(
"For").
'</td>'.
"\n";
992 } elseif (((
string) $car) ==
"0") {
993 print
'<td class="non">'.$langs->trans(
"Against").
'</td>'.
"\n";
995 print
'<td class="vide"> </td>'.
"\n";
998 if (!isset($sumfor[$i])) {
1001 if (!isset($sumagainst[$i])) {
1002 $sumagainst[$i] = 0;
1004 if (((
string) $car) ==
"1") {
1007 if (((
string) $car) ==
"0") {
1016 if ($compteur != $ligneamodifier && ($user->rights->opensurvey->write)) {
1017 print
'<td class="casevide"><input type="submit" class="button reposition" name="modifierligne'.$compteur.
'" value="'.
dol_escape_htmltag($langs->trans(
"Edit")).
'"></td>'.
"\n";
1021 for ($i = 0; $i < $nblines; $i++) {
1023 if ($compteur == $i) {
1024 print
'<td class="casevide">';
1025 print
'<input type="hidden" name="idtomodify'.$compteur.
'" value="'.$obj->id_users.
'">';
1026 print
'<input type="submit" class="button button-save reposition" name="validermodifier'.$compteur.
'" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'">';
1037 if (empty($testligneamodifier)) {
1039 print
'<td></td>'.
"\n";
1040 print
'<td class="nom">'.
"\n";
1041 print
'<input type="text" class="maxwidthonsmartphone" placeholder="'.dol_escape_htmltag($langs->trans(
"Name")).
'" name="nom" maxlength="64">'.
"\n";
1044 for ($i = 0; $i < $nbcolonnes; $i++) {
1045 print
'<td class="vide">';
1046 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
1047 print
'<input type="checkbox" name="choix'.$i.
'" value="1"';
1053 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
1054 $arraychoice = array(
'2'=>
' ',
'0'=>$langs->trans(
"No"),
'1'=>$langs->trans(
"Yes"));
1055 print
$form->selectarray(
"choix".$i, $arraychoice);
1057 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
1058 $arraychoice = array(
'2'=>
' ',
'0'=>$langs->trans(
"Against"),
'1'=>$langs->trans(
"For"));
1059 print
$form->selectarray(
"choix".$i, $arraychoice);
1065 print
'<td><input type="image" name="boutonp" class="borderimp" value="'.$langs->trans(
"Vote").
'" src="'.
img_picto(
'',
'edit_add',
'',
false, 1).
'"></td>'.
"\n";
1071 for ($i = 0; $i < $nbcolonnes + 1; $i++) {
1072 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
1075 if (isset($sumfor[$i])) {
1077 $meilleurecolonne = $sumfor[$i];
1079 if (isset($sumfor[$i]) && $sumfor[$i] > $meilleurecolonne) {
1080 $meilleurecolonne = $sumfor[$i];
1088 print
'<td></td>'.
"\n";
1089 print
'<td class="center">'.$langs->trans(
"Total").
'</td>'.
"\n";
1090 for ($i = 0; $i < $nbcolonnes; $i++) {
1091 $showsumfor = isset($sumfor[$i]) ? $sumfor[$i] :
'';
1092 $showsumagainst = isset($sumagainst[$i]) ? $sumagainst[$i] :
'';
1093 if (empty($showsumfor)) {
1096 if (empty($showsumagainst)) {
1097 $showsumagainst = 0;
1101 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
1104 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
1105 print $langs->trans(
"Yes").
': '.$showsumfor.
'<br>'.$langs->trans(
"No").
': '.$showsumagainst;
1107 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
1108 print $langs->trans(
"For").
': '.$showsumfor.
'<br>'.$langs->trans(
"Against").
': '.$showsumagainst;
1114 if ($nbofcheckbox >= 2) {
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";
1122 print
'<td class="somme"></td>'.
"\n";
1130 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")),
null,
'errors');
1133 if (isset($erreur_prenom) && $erreur_prenom) {
1137 if (isset($erreur_ajout_date) && $erreur_ajout_date) {
1142 print
'</table>'.
"\n";
1143 print
'</div>'.
"\n";
1146 $toutsujet = explode(
",", $object->sujet);
1149 $meilleursujet =
'';
1150 for ($i = 0; $i < $nbcolonnes; $i++) {
1151 if (isset($sumfor[$i]) ===
true && isset($meilleurecolonne) ===
true && $sumfor[$i] == $meilleurecolonne) {
1152 $meilleursujet .= ($meilleursujet ?
", " :
"");
1154 if ($object->format ==
"D") {
1155 $meilleursujetexport = $toutsujet[$i];
1157 if (strpos($toutsujet[$i],
'@') !==
false) {
1158 $toutsujetdate = explode(
"@", $toutsujet[$i]);
1159 $meilleursujet .=
dol_print_date($toutsujetdate[0],
'daytext').($toutsujetdate[0] ?
' ('.dol_print_date($toutsujetdate[0],
'%A').
')' :
'').
' - '.$toutsujetdate[1];
1161 $meilleursujet .=
dol_print_date((empty($toutsujet[$i]) ? 0 : $toutsujet[$i]),
'daytext').
' ('.
dol_print_date((empty($toutsujet[$i]) ? 0 : $toutsujet[$i]),
'%A').
')';
1164 $tmps = explode(
'@', $toutsujet[$i]);
1171 $meilleursujet = substr($meilleursujet, 1);
1172 $meilleursujet = str_replace(
"°",
"'", $meilleursujet);
1175 if ($nbofcheckbox >= 2) {
1176 $vote_str = $langs->trans(
'votes');
1177 print
'<p class="affichageresultats">'.
"\n";
1179 if (isset($meilleurecolonne) && $compteursujet ==
"1") {
1180 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";
1181 } elseif (isset($meilleurecolonne)) {
1182 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";
1184 print
'<br></p><br>'.
"\n";
1187 print
'</form>'.
"\n";
1189 print
'<a name="bas"></a>'.
"\n";