27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
29require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
30require_once DOL_DOCUMENT_ROOT.
"/opensurvey/class/opensurveysondage.class.php";
31require_once DOL_DOCUMENT_ROOT.
"/opensurvey/lib/opensurvey.lib.php";
34if (!$user->hasRight(
'opensurvey',
'read')) {
39$action =
GETPOST(
'action',
'aZ09');
40$numsondage =
GETPOST(
"id",
'alphanohtml');
43$result =
$object->fetch(0, $numsondage);
48$nblines =
$object->fetch_lines();
57 header(
'Location: results.php?id='.(GETPOSTISSET(
'id_sondage') ?
GETPOST(
'id_sondage',
'aZ09') :
GETPOST(
'id',
'alphanohtml')));
61$nbcolonnes = substr_count(
$object->sujet,
',') + 1;
66 $erreur_prenom =
false;
69 for ($i = 0; $i < $nbcolonnes; $i++) {
70 if (GETPOSTISSET(
"choix$i") &&
GETPOST(
"choix$i") ==
'1') {
72 } elseif (GETPOSTISSET(
"choix$i") &&
GETPOST(
"choix$i") ==
'2') {
79 $nom = substr(
GETPOST(
"nom",
'alphanohtml'), 0, 64);
82 $sql =
'SELECT id_users, nom as name';
83 $sql .=
' FROM '.MAIN_DB_PREFIX.
'opensurvey_user_studs';
84 $sql .=
" WHERE id_sondage='".$db->escape($numsondage).
"' AND nom = '".$db->escape($nom).
"'";
85 $sql .=
' ORDER BY id_users';
86 $resql = $db->query($sql);
87 $num_rows = $db->num_rows($resql);
92 $sql =
'INSERT INTO '.MAIN_DB_PREFIX.
'opensurvey_user_studs (nom, id_sondage, reponses, date_creation)';
93 $sql .=
" VALUES ('".$db->escape($nom).
"', '".$db->escape($numsondage).
"', '".$db->escape($nouveauchoix).
"', '".$db->idate(
dol_now()).
"')";
94 $resql = $db->query($sql);
103$testmodifier =
false;
104$testligneamodifier =
false;
106for ($i = 0; $i < $nblines; $i++) {
107 if (GETPOSTISSET(
'modifierligne'.$i)) {
108 $ligneamodifier = $i;
109 $testligneamodifier =
true;
113 if (GETPOSTISSET(
'validermodifier'.$i)) {
115 $testmodifier =
true;
120 if (!$user->hasRight(
'opensurvey',
'write')) {
125 for ($i = 0; $i < $nbcolonnes; $i++) {
126 if (GETPOSTISSET(
"choix$i") &&
GETPOST(
"choix$i") ==
'1') {
127 $nouveauchoix .=
"1";
128 } elseif (GETPOSTISSET(
"choix$i") &&
GETPOST(
"choix$i") ==
'2') {
129 $nouveauchoix .=
"2";
131 $nouveauchoix .=
"0";
135 $idtomodify =
GETPOST(
"idtomodify".$modifier);
136 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_user_studs";
137 $sql .=
" SET reponses = '".$db->escape($nouveauchoix).
"'";
138 $sql .=
" WHERE id_users = '".$db->escape($idtomodify).
"'";
140 $resql = $db->query($sql);
149 if (!$user->hasRight(
'opensurvey',
'write')) {
153 $nouveauxsujets =
$object->sujet;
156 $nouveauxsujets .=
',';
157 $nouveauxsujets .= str_replace(array(
",",
"@"),
" ",
GETPOST(
"nouvellecolonne")).(!
GETPOST(
"typecolonne") ?
'' :
'@'.GETPOST(
"typecolonne"));
160 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_sondage";
161 $sql .=
" SET sujet = '".$db->escape($nouveauxsujets).
"'";
162 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
163 $resql = $db->query($sql);
167 header(
'Location: results.php?id='.
$object->id_sondage);
173if (GETPOSTISSET(
"ajoutercolonne") &&
$object->format ==
"D") {
175 if (!$user->hasRight(
'opensurvey',
'write')) {
179 $nouveauxsujets =
$object->sujet;
181 if (GETPOSTISSET(
"nouveaujour") &&
GETPOST(
"nouveaujour") !=
"vide" &&
182 GETPOSTISSET(
"nouveaumois") &&
GETPOST(
"nouveaumois") !=
"vide" &&
183 GETPOSTISSET(
"nouvelleannee") &&
GETPOST(
"nouvelleannee") !=
"vide") {
186 if (GETPOSTISSET(
"nouvelleheuredebut") &&
GETPOST(
"nouvelleheuredebut") !=
"vide") {
187 $nouvelledate .=
"@";
188 $nouvelledate .=
GETPOST(
"nouvelleheuredebut");
189 $nouvelledate .=
"h";
191 if (
GETPOST(
"nouvelleminutedebut") !=
"vide") {
192 $nouvelledate .=
GETPOST(
"nouvelleminutedebut");
196 if (GETPOSTISSET(
"nouvelleheurefin") &&
GETPOST(
"nouvelleheurefin") !=
"vide") {
197 $nouvelledate .=
"-";
198 $nouvelledate .=
GETPOST(
"nouvelleheurefin");
199 $nouvelledate .=
"h";
201 if (
GETPOST(
"nouvelleminutefin") !=
"vide") {
202 $nouvelledate .=
GETPOST(
"nouvelleminutefin");
206 if (
GETPOST(
"nouvelleheuredebut") ==
"vide" || (GETPOSTISSET(
"nouvelleheuredebut") && GETPOSTISSET(
"nouvelleheurefin")
208 && (
GETPOST(
"nouvelleminutedebut") <
GETPOST(
"nouvelleminutefin")))))) {
209 $erreur_ajout_date =
false;
211 $erreur_ajout_date =
"yes";
215 $datesbase = explode(
",",
$object->sujet);
216 $taillebase = count($datesbase);
219 if ($nouvelledate < $datesbase[0]) {
221 } elseif ($nouvelledate > $datesbase[$taillebase - 1]) {
222 $cleinsertion = count($datesbase);
224 $nbdatesbase = count($datesbase);
225 for ($i = 0; $i < $nbdatesbase; $i++) {
227 if ($nouvelledate > $datesbase[$i] && $nouvelledate < $datesbase[$j]) {
233 array_splice($datesbase, $cleinsertion, 0, $nouvelledate);
234 $cle = array_search($nouvelledate, $datesbase);
236 $nbofdates = count($datesbase);
237 for ($i = 0; $i < $nbofdates; $i++) {
238 $dateinsertion .=
",";
239 $dateinsertion .= $datesbase[$i];
242 $dateinsertion = substr(
"$dateinsertion", 1);
245 if (isset($erreur_ajout_date) && empty($erreur_ajout_date)) {
246 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_sondage";
247 $sql .=
" SET sujet = '".$db->escape($dateinsertion).
"'";
248 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
249 $resql = $db->query($sql);
253 header(
'Location: results.php?id='.
$object->id_sondage);
256 if ($cleinsertion >= 0) {
257 $sql =
'SELECT s.reponses';
258 $sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs as s";
259 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
260 $resql = $db->query($sql);
264 $num = $db->num_rows($resql);
266 while ($compteur < $num) {
267 $obj = $db->fetch_object($resql);
268 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_user_studs";
269 if ($cleinsertion == 0) {
270 $sql .=
" SET reponses = '0".$db->escape($obj->reponses).
"'";
272 $reponsesadd = str_split($obj->reponses);
273 $lengthresponses = count($reponsesadd);
274 for ($cpt = $lengthresponses; $cpt > $cleinsertion; $cpt--) {
275 $reponsesadd[$cpt] = $reponsesadd[$cpt-1];
277 $reponsesadd[$cleinsertion] =
'0';
278 $reponsesadd = implode($reponsesadd);
279 $sql .=
" SET reponses = '".$db->escape($reponsesadd).
"'";
281 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
282 $resql = $db->query($sql);
290 $adresseadmin =
$object->mail_admin;
292 $erreur_ajout_date =
"yes";
297for ($i = 0; $i < $nblines; $i++) {
300 if (!$user->hasRight(
'opensurvey',
'write')) {
308 $sql =
"SELECT id_users, nom as name, id_sondage, reponses";
309 $sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs";
310 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
311 $resql = $db->query($sql);
315 $num = $db->num_rows($resql);
316 while ($compteur < $num) {
317 $obj = $db->fetch_object($resql);
319 if ($compteur == $i) {
320 $sql2 =
'DELETE FROM '.MAIN_DB_PREFIX.
'opensurvey_user_studs';
321 $sql2 .=
" WHERE id_users = ".((int) $obj->id_users);
322 $resql2 = $db->query($sql2);
331for ($i = 0; $i < $nbcolonnes; $i++) {
332 if ((
GETPOST(
"effacecolonne".$i) ||
GETPOST(
"effacecolonne".$i.
"_x") ||
GETPOST(
"effacecolonne".$i.
".x"))
333 && $nbcolonnes > 1) {
335 if (!$user->hasRight(
'opensurvey',
'write')) {
341 $toutsujet = explode(
",",
$object->sujet);
343 $nouveauxsujets =
'';
346 while (isset($toutsujet[$j])) {
349 if (!empty($nouveauxsujets)) {
350 $nouveauxsujets .=
',';
352 $nouveauxsujets .= $toutsujet[$j];
359 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_sondage";
360 $sql .=
" SET sujet = '".$db->escape($nouveauxsujets).
"' WHERE id_sondage = '".$db->escape($numsondage).
"'";
361 $resql = $db->query($sql);
368 $sql =
"SELECT id_users, nom as name, id_sondage, reponses";
369 $sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs";
370 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
372 $resql = $db->query($sql);
377 $num = $db->num_rows($resql);
378 while ($compteur < $num) {
379 $obj = $db->fetch_object($resql);
382 $ensemblereponses = $obj->reponses;
385 for ($j = 0; $j < $nbcolonnes; $j++) {
386 $car = substr($ensemblereponses, $j, 1);
394 $sql2 =
'UPDATE '.MAIN_DB_PREFIX.
'opensurvey_user_studs';
395 $sql2 .=
" SET reponses = '".$db->escape($newcar).
"'";
396 $sql2 .=
" WHERE id_users = '".$db->escape($obj->id_users).
"'";
399 $resql2 = $db->query($sql2);
414$form =
new Form($db);
417 $userstatic =
new User($db);
418 $userstatic->fetch(
$object->fk_user_creat);
421$result =
$object->fetch(0, $numsondage);
427$title =
$object->title.
" - ".$langs->trans(
'Card');
430$arrayofcss = array(
'/opensurvey/css/style.css');
432llxHeader(
'', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss);
436$toutsujet = explode(
",",
$object->sujet);
437$listofanswers = array();
438foreach ($toutsujet as $value) {
439 $tmp = explode(
'@', $value);
440 $listofanswers[] = array(
'label'=>$tmp[0],
'format'=>(!empty($tmp[1]) ? $tmp[1] :
'checkbox'));
442$toutsujet = str_replace(
"@",
"<br>", $toutsujet);
443$toutsujet = str_replace(
"°",
"'", $toutsujet);
446print
'<form name="formulaire4" action="#" method="POST">'.
"\n";
447print
'<input type="hidden" name="token" value="'.newToken().
'">';
448print
'<input type="hidden" name="id" value="'.GETPOST(
'id').
'">';
456$linkback =
'<a href="'.DOL_URL_ROOT.
'/opensurvey/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
458dol_banner_tab($object,
'id', $linkback, 1,
'id_sondage',
'id_sondage', $morehtmlref);
461print
'<div class="fichecenter">';
463print
'<div class="fichehalfleft">';
464print
'<div class="underbanner clearboth"></div>';
465print
'<table class="border tableforfield centpercent">';
468$type = (
$object->format ==
"A") ?
'classic' :
'date';
469print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td>';
470print
img_picto(
'',
dol_buildpath(
'/opensurvey/img/'.($type ==
'classic' ?
'chart-32.png' :
'calendar-32.png'), 1),
'width="16"', 1);
471print
' '.$langs->trans($type ==
'classic' ?
"TypeClassic" :
"TypeDate").
'</td></tr>';
475$adresseadmin =
$object->mail_admin;
476print $langs->trans(
"Title").
'</td><td>';
477if ($action ==
'edit') {
478 print
'<input type="text" name="nouveautitre" size="40" value="'.dol_escape_htmltag(
$object->title).
'">';
485print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak">';
486if ($action ==
'edit') {
487 $doleditor =
new DolEditor(
'nouveauxcommentaires',
$object->description,
'', 120,
'dolibarr_notes',
'In', 1, 1, 1, ROWS_7,
'90%');
488 $doleditor->Create(0,
'');
497 print
'<tr><td>'.$langs->trans(
"EMail").
'</td><td>';
498 if ($action ==
'edit') {
499 print
'<input type="text" name="nouvelleadresse" class="minwith200" value="'.$object->mail_admin.
'">';
509print
'<div class="fichehalfright">';
510print
'<div class="underbanner clearboth"></div>';
512print
'<table class="border tableforfield centpercent">';
515print
'<tr><td>'.$langs->trans(
'ExpireDate').
'</td><td>';
516if ($action ==
'edit') {
517 print $form->selectDate($expiredate ? $expiredate :
$object->date_fin,
'expire', 0, 0, 0,
'', 1, 0);
528print $langs->trans(
"Author").
'</td><td>';
530 print $userstatic->getLoginUrl(-1);
537print
'<tr><td>'.$langs->trans(
"UrlForSurvey",
'').
'</td><td>';
540$urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
541$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
544$url = $urlwithouturlroot.dol_buildpath(
'/public/opensurvey/studs.php', 1).
'?sondage='.
$object->id_sondage;
545$urllink =
'<input type="text" class="quatrevingtpercent" '.($action ==
'edit' ?
'disabled' :
'').
' id="opensurveyurl" name="opensurveyurl" value="'.$url.
'">';
547if ($action !=
'edit') {
557print
'<div class="clearboth"></div>';
566print
'<div class="tabsAction">';
568print
'<a class="butAction" href="exportcsv.php?id='.urlencode($numsondage).
'">'.$langs->trans(
"ExportSpreadsheet").
' (.CSV)</a>';
576 if (!$user->hasRight(
'opensurvey',
'write')) {
580 print
'<form name="formulaire" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
581 print
'<input type="hidden" name="token" value="'.newToken().
'">';
582 print
'<input type="hidden" name="backtopage" value="'.GETPOST(
'backtopage',
'alpha').
'">';
583 print
'<input type="hidden" name="id" value="'.GETPOST(
'id',
'alpha').
'">';
584 print
'<input type="hidden" name="ajoutsujet" value="1">';
586 print
'<div class="center">'.
"\n";
591 print $langs->trans(
"AddNewColumn").
':<br><br>';
592 print $langs->trans(
"Title").
' <input type="text" name="nouvellecolonne" size="40"><br>';
593 $tmparray = array(
'checkbox'=>$langs->trans(
"CheckBox"),
'yesno'=>$langs->trans(
"YesNoList"),
'foragainst'=>$langs->trans(
"PourContreList"));
594 print $langs->trans(
"Type").
' '.$form->selectarray(
"typecolonne", $tmparray,
GETPOST(
'typecolonne')).
'<br><br>';
595 print
'<input type="submit" class="button" name="ajoutercolonne" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'">';
596 print
'<input type="hidden" name="id_sondage" value="'.dol_escape_htmltag(
$object->id_sondage).
'">';
597 print
' ';
598 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
599 print
'<br><br>'.
"\n";
601 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
605 print $langs->trans(
"AddADate").
':<br><br>'.
"\n";
606 print
'<select name="nouveaujour"> '.
"\n";
607 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
608 for ($i = 1; $i < 32; $i++) {
609 print
'<OPTION VALUE="'.$i.
'">'.$i.
'</OPTION>'.
"\n";
611 print
'</select>'.
"\n";
613 print $formother->select_month(
'',
'nouveaumois', 1);
617 print $formother->selectyear(
'',
'nouvelleannee', 1, 0, 5, 0, 1);
619 print
'<br><br>'.$langs->trans(
"AddStartHour").
': <br><br>'.
"\n";
620 print
'<select name="nouvelleheuredebut"> '.
"\n";
621 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
622 for ($i = 0; $i < 24; $i++) {
623 print
'<OPTION VALUE="'.$i.
'">'.$i.
' H</OPTION>'.
"\n";
625 print
'</select>'.
"\n";
626 print
'<select name="nouvelleminutedebut"> '.
"\n";
627 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
628 print
'<OPTION VALUE="00">00</OPTION>'.
"\n";
629 print
'<OPTION VALUE="15">15</OPTION>'.
"\n";
630 print
'<OPTION VALUE="30">30</OPTION>'.
"\n";
631 print
'<OPTION VALUE="45">45</OPTION>'.
"\n";
632 print
'</select>'.
"\n";
633 print
'<br><br>'.$langs->trans(
"AddEndHour").
': <br><br>'.
"\n";
634 print
'<select name="nouvelleheurefin"> '.
"\n";
635 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
636 for ($i = 0; $i < 24; $i++) {
637 print
'<OPTION VALUE="'.$i.
'">'.$i.
' H</OPTION>'.
"\n";
639 print
'</SELECT>'.
"\n";
640 print
'<select name="nouvelleminutefin"> '.
"\n";
641 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
642 print
'<OPTION VALUE="00">00</OPTION>'.
"\n";
643 print
'<OPTION VALUE="15">15</OPTION>'.
"\n";
644 print
'<OPTION VALUE="30">30</OPTION>'.
"\n";
645 print
'<OPTION VALUE="45">45</OPTION>'.
"\n";
646 print
'</select>'.
"\n";
649 print
' <input type="submit" class="button" name="ajoutercolonne" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'">'.
"\n";
650 print
' ';
651 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
654 print
'</form>'.
"\n";
655 print
'<br><br><br><br>'.
"\n";
661if ($user->hasRight(
'opensurvey',
'write')) {
662 print
'<span class="opacitymedium">';
663 $s = $langs->trans(
"PollAdminDesc",
'{s1}', $langs->trans(
"Add"));
664 print str_replace(
'{s1}',
img_picto(
'',
'delete'), $s);
668$nbcolonnes = substr_count(
$object->sujet,
',') + 1;
670print
'<form name="formulaire" action="" method="POST">'.
"\n";
671print
'<input type="hidden" name="token" value="'.newToken().
'">';
672print
'<input type="hidden" name="page_y" value="">';
674print
'<div class="cadre div-table-responsive-no-min"> '.
"\n";
677print
'<table class="resultats margintoponly">'.
"\n";
680$toutsujet = explode(
",",
$object->sujet);
681$toutsujet = str_replace(
"°",
"'", $toutsujet);
684print
'<td></td>'.
"\n";
685print
'<td></td>'.
"\n";
688if ($user->hasRight(
'opensurvey',
'write')) {
689 for ($i = 0; isset($toutsujet[$i]); $i++) {
690 print
'<td class=somme><input type="image" class="buttonwebsite" name="effacecolonne'.$i.
'" src="'.
img_picto(
'',
'delete.png',
'',
false, 1).
'"></td>'.
"\n";
701 print
'<td></td>'.
"\n";
702 print
'<td></td>'.
"\n";
706 $nbofsujet = count($toutsujet);
707 for ($i = 0; $i < $nbofsujet; $i++) {
708 if (isset($toutsujet[$i + 1]) && date(
'Y', intval($toutsujet[$i])) == date(
'Y', intval($toutsujet[$i + 1]))) {
711 print
'<td colspan='.$colspan.
' class="annee">'.date(
'Y', intval($toutsujet[$i])).
'</td>'.
"\n";
716 if ($user->hasRight(
'opensurvey',
'write')) {
717 print
'<td class="annee">';
718 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.
$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
723 print
'<td></td>'.
"\n";
724 print
'<td></td>'.
"\n";
728 for ($i = 0; $i < $nbofsujet; $i++) {
729 $cur = intval($toutsujet[$i]);
731 if (isset($toutsujet[$i + 1]) ===
false) {
734 $next = intval($toutsujet[$i + 1]);
740 print
'<td colspan='.$colspan.
' class="mois">'.
dol_print_date($cur,
"%B").
'</td>'.
"\n";
746 if ($user->hasRight(
'opensurvey',
'write')) {
747 print
'<td class="mois"><a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.
$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
752 print
'<td></td>'.
"\n";
753 print
'<td></td>'.
"\n";
757 for ($i = 0; $i < $nbofsujet; $i++) {
758 $cur = intval($toutsujet[$i]);
759 if (isset($toutsujet[$i + 1]) ===
false) {
762 $next = intval($toutsujet[$i + 1]);
767 print
'<td colspan='.$colspan.
' class="jour">'.
dol_print_date($cur,
"%a %d").
'</td>'.
"\n";
773 if ($user->hasRight(
'opensurvey',
'write')) {
774 print
'<td class="jour"><a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.
$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
779 if (strpos(
$object->sujet,
'@') !==
false) {
781 print
'<td></td>'.
"\n";
782 print
'<td></td>'.
"\n";
784 for ($i = 0; isset($toutsujet[$i]); $i++) {
785 $heures = explode(
'@', $toutsujet[$i]);
786 if (isset($heures[1])) {
787 print
'<td class="heure">'.dol_htmlentities($heures[1]).
'</td>'.
"\n";
789 print
'<td class="heure"></td>'.
"\n";
793 if ($user->hasRight(
'opensurvey',
'write')) {
794 print
'<td class="heure"><a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.
$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
802 print
'<td></td>'.
"\n";
803 print
'<td></td>'.
"\n";
805 for ($i = 0; isset($toutsujet[$i]); $i++) {
806 $tmp = explode(
'@', $toutsujet[$i]);
807 print
'<td class="sujet">'.dol_htmlentities($tmp[0]).
'</td>'.
"\n";
810 print
'<td class="sujet"><a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$numsondage.
'&ajoutsujet=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'"><span class="fa fa-plus-circle valignmiddle btnTitle-icon"></span></a></td>'.
"\n";
817$sumagainst = array();
819$sql =
"SELECT id_users, nom as name, id_sondage, reponses";
820$sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs";
821$sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
823$resql = $db->query($sql);
828$num = $db->num_rows($resql);
829while ($compteur < $num) {
830 $obj = $db->fetch_object($resql);
832 $ensemblereponses = $obj->reponses;
834 print
'<tr><td>'.
"\n";
836 if ($user->hasRight(
'opensurvey',
'write')) {
837 print
'<input type="image" class="reposition" name="effaceligne'.$compteur.
'" src="'.
img_picto(
'',
'delete.png',
'',
false, 1).
'">'.
"\n";
841 print
'</td><td class="nom">'.dol_htmlentities($obj->name).
'</td>'.
"\n";
844 if (!$testligneamodifier) {
845 for ($i = 0; $i < $nbcolonnes; $i++) {
846 $car = substr($ensemblereponses, $i, 1);
849 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
850 if (((
string) $car) ==
"1") {
851 print
'<td class="ok">OK</td>'.
"\n";
853 print
'<td class="non">KO</td>'.
"\n";
856 if (!isset($sumfor[$i])) {
859 if (((
string) $car) ==
"1") {
863 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
864 if (((
string) $car) ==
"1") {
865 print
'<td class="ok">'.$langs->trans(
"Yes").
'</td>'.
"\n";
866 } elseif (((
string) $car) ==
"0") {
867 print
'<td class="non">'.$langs->trans(
"No").
'</td>'.
"\n";
869 print
'<td class="vide"> </td>'.
"\n";
872 if (!isset($sumfor[$i])) {
875 if (!isset($sumagainst[$i])) {
878 if (((
string) $car) ==
"1") {
881 if (((
string) $car) ==
"0") {
885 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
886 if (((
string) $car) ==
"1") {
887 print
'<td class="ok">'.$langs->trans(
"For").
'</td>'.
"\n";
888 } elseif (((
string) $car) ==
"0") {
889 print
'<td class="non">'.$langs->trans(
"Against").
'</td>'.
"\n";
891 print
'<td class="vide"> </td>'.
"\n";
894 if (!isset($sumfor[$i])) {
897 if (!isset($sumagainst[$i])) {
900 if (((
string) $car) ==
"1") {
903 if (((
string) $car) ==
"0") {
910 if ($compteur == $ligneamodifier) {
911 for ($i = 0; $i < $nbcolonnes; $i++) {
912 $car = substr($ensemblereponses, $i, 1);
913 print
'<td class="vide">';
914 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
915 print
'<input type="checkbox" name="choix'.$i.
'" value="1" ';
921 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
922 $arraychoice = array(
'2'=>
' ',
'0'=>$langs->trans(
"No"),
'1'=>$langs->trans(
"Yes"));
923 print $form->selectarray(
"choix".$i, $arraychoice, $car);
925 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
926 $arraychoice = array(
'2'=>
' ',
'0'=>$langs->trans(
"Against"),
'1'=>$langs->trans(
"For"));
927 print $form->selectarray(
"choix".$i, $arraychoice, $car);
932 for ($i = 0; $i < $nbcolonnes; $i++) {
933 $car = substr($ensemblereponses, $i, 1);
934 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
935 if (((
string) $car) ==
"1") {
936 print
'<td class="ok">OK</td>'.
"\n";
938 print
'<td class="non">KO</td>'.
"\n";
941 if (!isset($sumfor[$i])) {
944 if (((
string) $car) ==
"1") {
948 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
949 if (((
string) $car) ==
"1") {
950 print
'<td class="ok">'.$langs->trans(
"For").
'</td>'.
"\n";
951 } elseif (((
string) $car) ==
"0") {
952 print
'<td class="non">'.$langs->trans(
"Against").
'</td>'.
"\n";
954 print
'<td class="vide"> </td>'.
"\n";
957 if (!isset($sumfor[$i])) {
960 if (!isset($sumagainst[$i])) {
963 if (((
string) $car) ==
"1") {
966 if (((
string) $car) ==
"0") {
970 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
971 if (((
string) $car) ==
"1") {
972 print
'<td class="ok">'.$langs->trans(
"For").
'</td>'.
"\n";
973 } elseif (((
string) $car) ==
"0") {
974 print
'<td class="non">'.$langs->trans(
"Against").
'</td>'.
"\n";
976 print
'<td class="vide"> </td>'.
"\n";
979 if (!isset($sumfor[$i])) {
982 if (!isset($sumagainst[$i])) {
985 if (((
string) $car) ==
"1") {
988 if (((
string) $car) ==
"0") {
997 if ($compteur != $ligneamodifier && ($user->hasRight(
'opensurvey',
'write'))) {
998 print
'<td class="casevide"><input type="submit" class="button reposition" name="modifierligne'.$compteur.
'" value="'.
dol_escape_htmltag($langs->trans(
"Edit")).
'"></td>'.
"\n";
1002 for ($i = 0; $i < $nblines; $i++) {
1003 if (GETPOSTISSET(
"modifierligne".$i)) {
1004 if ($compteur == $i) {
1005 print
'<td class="casevide">';
1006 print
'<input type="hidden" name="idtomodify'.$compteur.
'" value="'.$obj->id_users.
'">';
1007 print
'<input type="submit" class="button button-save reposition" name="validermodifier'.$compteur.
'" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'">';
1018if (empty($testligneamodifier)) {
1020 print
'<td></td>'.
"\n";
1021 print
'<td class="nom">'.
"\n";
1022 print
'<input type="text" class="maxwidthonsmartphone" placeholder="'.dol_escape_htmltag($langs->trans(
"Name")).
'" name="nom" maxlength="64">'.
"\n";
1025 for ($i = 0; $i < $nbcolonnes; $i++) {
1026 print
'<td class="vide">';
1027 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
1028 print
'<input type="checkbox" name="choix'.$i.
'" value="1"';
1029 if (GETPOSTISSET(
'choix'.$i) &&
GETPOST(
'choix'.$i) ==
'1') {
1034 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
1035 $arraychoice = array(
'2'=>
' ',
'0'=>$langs->trans(
"No"),
'1'=>$langs->trans(
"Yes"));
1036 print $form->selectarray(
"choix".$i, $arraychoice);
1038 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
1039 $arraychoice = array(
'2'=>
' ',
'0'=>$langs->trans(
"Against"),
'1'=>$langs->trans(
"For"));
1040 print $form->selectarray(
"choix".$i, $arraychoice);
1046 print
'<td><input type="image" name="boutonp" class="borderimp" value="'.$langs->trans(
"Vote").
'" src="'.
img_picto(
'',
'edit_add',
'',
false, 1).
'"></td>'.
"\n";
1052for ($i = 0; $i < $nbcolonnes + 1; $i++) {
1053 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
1056 if (isset($sumfor[$i])) {
1058 $meilleurecolonne = $sumfor[$i];
1060 if (isset($sumfor[$i]) && $sumfor[$i] > $meilleurecolonne) {
1061 $meilleurecolonne = $sumfor[$i];
1069print
'<td></td>'.
"\n";
1070print
'<td class="center">'.$langs->trans(
"Total").
'</td>'.
"\n";
1071for ($i = 0; $i < $nbcolonnes; $i++) {
1072 $showsumfor = isset($sumfor[$i]) ? $sumfor[$i] :
'';
1073 $showsumagainst = isset($sumagainst[$i]) ? $sumagainst[$i] :
'';
1074 if (empty($showsumfor)) {
1077 if (empty($showsumagainst)) {
1078 $showsumagainst = 0;
1082 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
1085 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
1086 print $langs->trans(
"Yes").
': '.$showsumfor.
'<br>'.$langs->trans(
"No").
': '.$showsumagainst;
1088 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
1089 print $langs->trans(
"For").
': '.$showsumfor.
'<br>'.$langs->trans(
"Against").
': '.$showsumagainst;
1095if ($nbofcheckbox >= 2) {
1097 print
'<td></td>'.
"\n";
1098 print
'<td></td>'.
"\n";
1099 for ($i = 0; $i < $nbcolonnes; $i++) {
1100 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) {
1101 print
'<td class="somme"><img src="'.dol_buildpath(
'/opensurvey/img/medaille.png', 1).
'"></td>'.
"\n";
1103 print
'<td class="somme"></td>'.
"\n";
1110if (GETPOSTISSET(
"boutonp") &&
GETPOST(
"nom") ==
"") {
1111 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")),
null,
'errors');
1114if (isset($erreur_prenom) && $erreur_prenom) {
1118if (isset($erreur_ajout_date) && $erreur_ajout_date) {
1123print
'</table>'.
"\n";
1127$toutsujet = explode(
",",
$object->sujet);
1131for ($i = 0; $i < $nbcolonnes; $i++) {
1132 if (isset($sumfor[$i]) ===
true && isset($meilleurecolonne) ===
true && $sumfor[$i] == $meilleurecolonne) {
1133 $meilleursujet .= ($meilleursujet ?
", " :
"");
1137 if (strpos($toutsujet[$i],
'@') !==
false) {
1138 $toutsujetdate = explode(
"@", $toutsujet[$i]);
1139 $meilleursujet .=
dol_print_date($toutsujetdate[0],
'daytext').($toutsujetdate[0] ?
' ('.dol_print_date($toutsujetdate[0],
'%A').
')' :
'').
' - '.$toutsujetdate[1];
1141 $meilleursujet .=
dol_print_date((empty($toutsujet[$i]) ? 0 : $toutsujet[$i]),
'daytext').
' ('.
dol_print_date((empty($toutsujet[$i]) ? 0 : $toutsujet[$i]),
'%A').
')';
1144 $tmps = explode(
'@', $toutsujet[$i]);
1152$meilleursujet = str_replace(
"°",
"'", $meilleursujet);
1155if ($nbofcheckbox >= 2) {
1156 $vote_str = $langs->trans(
'votes');
1157 print
'<p class="affichageresultats">'.
"\n";
1159 if (isset($meilleurecolonne) && $compteursujet ==
"1") {
1160 print
'<img src="'.DOL_URL_ROOT.
'/opensurvey/img/medaille.png"> '.$langs->trans(
'TheBestChoice').
": <b>".$meilleursujet.
"</b> - <b>".$meilleurecolonne.
"</b> ".$vote_str.
".\n";
1161 } elseif (isset($meilleurecolonne)) {
1162 print
'<img src="'.DOL_URL_ROOT.
'/opensurvey/img/medaille.png"> '.$langs->trans(
'TheBestChoices').
": <b>".$meilleursujet.
"</b> - <b>".$meilleurecolonne.
"</b> ".$vote_str.
".\n";
1164 print
'<br></p><br>'.
"\n";
1167print
'</form>'.
"\n";
1169print
'<a name="bas"></a>'.
"\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage a WYSIWYG editor.
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...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
dol_now($mode='auto')
Return date for now.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.