28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
30require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
31require_once DOL_DOCUMENT_ROOT.
"/opensurvey/class/opensurveysondage.class.php";
32require_once DOL_DOCUMENT_ROOT.
"/opensurvey/lib/opensurvey.lib.php";
45if (!$user->hasRight(
'opensurvey',
'read')) {
50$action =
GETPOST(
'action',
'aZ09');
51$numsondage =
GETPOST(
"id",
'alphanohtml');
54$result =
$object->fetch(0, $numsondage);
59$nblines =
$object->fetch_lines();
69 header(
'Location: results.php?id='.(GETPOSTISSET(
'id_sondage') ?
GETPOST(
'id_sondage',
'aZ09') :
GETPOST(
'id',
'alphanohtml')));
73$nbcolonnes = substr_count(
$object->sujet,
',') + 1;
78 $erreur_prenom =
false;
81 for ($i = 0; $i < $nbcolonnes; $i++) {
82 if (GETPOSTISSET(
"choix$i") &&
GETPOST(
"choix$i") ==
'1') {
84 } elseif (GETPOSTISSET(
"choix$i") &&
GETPOST(
"choix$i") ==
'2') {
91 $nom = substr(
GETPOST(
"nom",
'alphanohtml'), 0, 64);
94 $sql =
'SELECT id_users, nom as name';
95 $sql .=
' FROM '.MAIN_DB_PREFIX.
'opensurvey_user_studs';
96 $sql .=
" WHERE id_sondage='".$db->escape($numsondage).
"' AND nom = '".$db->escape($nom).
"'";
97 $sql .=
' ORDER BY id_users';
98 $resql = $db->query($sql);
99 $num_rows = $db->num_rows($resql);
104 $sql =
'INSERT INTO '.MAIN_DB_PREFIX.
'opensurvey_user_studs (nom, id_sondage, reponses, date_creation)';
105 $sql .=
" VALUES ('".$db->escape($nom).
"', '".$db->escape($numsondage).
"', '".$db->escape($nouveauchoix).
"', '".$db->idate(
dol_now()).
"')";
106 $resql = $db->query($sql);
115$testmodifier =
false;
116$testligneamodifier =
false;
118for ($i = 0; $i < $nblines; $i++) {
119 if (GETPOSTISSET(
'modifierligne'.$i)) {
120 $ligneamodifier = $i;
121 $testligneamodifier =
true;
125 if (GETPOSTISSET(
'validermodifier'.$i)) {
127 $testmodifier =
true;
132 if (!$user->hasRight(
'opensurvey',
'write')) {
137 for ($i = 0; $i < $nbcolonnes; $i++) {
138 if (GETPOSTISSET(
"choix$i") &&
GETPOST(
"choix$i") ==
'1') {
139 $nouveauchoix .=
"1";
140 } elseif (GETPOSTISSET(
"choix$i") &&
GETPOST(
"choix$i") ==
'2') {
141 $nouveauchoix .=
"2";
143 $nouveauchoix .=
"0";
147 $idtomodify =
GETPOST(
"idtomodify".$modifier);
148 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_user_studs";
149 $sql .=
" SET reponses = '".$db->escape($nouveauchoix).
"'";
150 $sql .=
" WHERE id_users = '".$db->escape($idtomodify).
"'";
152 $resql = $db->query($sql);
161 if (!$user->hasRight(
'opensurvey',
'write')) {
165 $nouveauxsujets =
$object->sujet;
168 $nouveauxsujets .=
',';
169 $nouveauxsujets .= str_replace(array(
",",
"@"),
" ",
GETPOST(
"nouvellecolonne")).(!
GETPOST(
"typecolonne") ?
'' :
'@'.GETPOST(
"typecolonne"));
172 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_sondage";
173 $sql .=
" SET sujet = '".$db->escape($nouveauxsujets).
"'";
174 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
175 $resql = $db->query($sql);
179 header(
'Location: results.php?id='.
$object->id_sondage);
185if (GETPOSTISSET(
"ajoutercolonne") &&
$object->format ==
"D") {
187 if (!$user->hasRight(
'opensurvey',
'write')) {
191 $nouveauxsujets =
$object->sujet;
193 if (GETPOSTISSET(
"nouveaujour") &&
GETPOST(
"nouveaujour") !=
"vide" &&
194 GETPOSTISSET(
"nouveaumois") &&
GETPOST(
"nouveaumois") !=
"vide" &&
195 GETPOSTISSET(
"nouvelleannee") &&
GETPOST(
"nouvelleannee") !=
"vide") {
198 if (GETPOSTISSET(
"nouvelleheuredebut") &&
GETPOST(
"nouvelleheuredebut") !=
"vide") {
199 $nouvelledate .=
"@";
200 $nouvelledate .=
GETPOST(
"nouvelleheuredebut");
201 $nouvelledate .=
"h";
203 if (
GETPOST(
"nouvelleminutedebut") !=
"vide") {
204 $nouvelledate .=
GETPOST(
"nouvelleminutedebut");
208 if (GETPOSTISSET(
"nouvelleheurefin") &&
GETPOST(
"nouvelleheurefin") !=
"vide") {
209 $nouvelledate .=
"-";
210 $nouvelledate .=
GETPOST(
"nouvelleheurefin");
211 $nouvelledate .=
"h";
213 if (
GETPOST(
"nouvelleminutefin") !=
"vide") {
214 $nouvelledate .=
GETPOST(
"nouvelleminutefin");
218 if (
GETPOST(
"nouvelleheuredebut") ==
"vide" || (GETPOSTISSET(
"nouvelleheuredebut") && GETPOSTISSET(
"nouvelleheurefin")
220 && (
GETPOST(
"nouvelleminutedebut") <
GETPOST(
"nouvelleminutefin")))))) {
221 $erreur_ajout_date =
false;
223 $erreur_ajout_date =
"yes";
227 $datesbase = explode(
",",
$object->sujet);
228 $taillebase = count($datesbase);
231 if ($nouvelledate < $datesbase[0]) {
233 } elseif ($nouvelledate > $datesbase[$taillebase - 1]) {
234 $cleinsertion = count($datesbase);
236 $nbdatesbase = count($datesbase);
237 for ($i = 0; $i < $nbdatesbase; $i++) {
239 if ($nouvelledate > $datesbase[$i] && $nouvelledate < $datesbase[$j]) {
245 array_splice($datesbase, $cleinsertion, 0, $nouvelledate);
246 $cle = array_search($nouvelledate, $datesbase);
248 $nbofdates = count($datesbase);
249 for ($i = 0; $i < $nbofdates; $i++) {
250 $dateinsertion .=
",";
251 $dateinsertion .= $datesbase[$i];
254 $dateinsertion = substr(
"$dateinsertion", 1);
257 if (isset($erreur_ajout_date) && empty($erreur_ajout_date)) {
258 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_sondage";
259 $sql .=
" SET sujet = '".$db->escape($dateinsertion).
"'";
260 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
261 $resql = $db->query($sql);
265 header(
'Location: results.php?id='.
$object->id_sondage);
268 if ($cleinsertion >= 0) {
269 $sql =
'SELECT s.reponses';
270 $sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs as s";
271 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
272 $resql = $db->query($sql);
276 $num = $db->num_rows($resql);
278 while ($compteur < $num) {
279 $obj = $db->fetch_object($resql);
280 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_user_studs";
281 if ($cleinsertion == 0) {
282 $sql .=
" SET reponses = '0".$db->escape($obj->reponses).
"'";
284 $reponsesadd = str_split($obj->reponses);
285 $lengthresponses = count($reponsesadd);
286 for ($cpt = $lengthresponses; $cpt > $cleinsertion; $cpt--) {
287 $reponsesadd[$cpt] = $reponsesadd[$cpt - 1];
289 $reponsesadd[$cleinsertion] =
'0';
290 $reponsesadd = implode($reponsesadd);
291 $sql .=
" SET reponses = '".$db->escape($reponsesadd).
"'";
293 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
294 $resql = $db->query($sql);
302 $adresseadmin =
$object->mail_admin;
304 $erreur_ajout_date =
"yes";
309for ($i = 0; $i < $nblines; $i++) {
312 if (!$user->hasRight(
'opensurvey',
'write')) {
320 $sql =
"SELECT id_users, nom as name, id_sondage, reponses";
321 $sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs";
322 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
323 $resql = $db->query($sql);
327 $num = $db->num_rows($resql);
328 while ($compteur < $num) {
329 $obj = $db->fetch_object($resql);
331 if ($compteur == $i) {
332 $sql2 =
'DELETE FROM '.MAIN_DB_PREFIX.
'opensurvey_user_studs';
333 $sql2 .=
" WHERE id_users = ".((int) $obj->id_users);
334 $resql2 = $db->query($sql2);
343for ($i = 0; $i < $nbcolonnes; $i++) {
344 if ((
GETPOST(
"effacecolonne".$i) ||
GETPOST(
"effacecolonne".$i.
"_x") ||
GETPOST(
"effacecolonne".$i.
".x"))
345 && $nbcolonnes > 1) {
347 if (!$user->hasRight(
'opensurvey',
'write')) {
353 $toutsujet = explode(
",",
$object->sujet);
355 $nouveauxsujets =
'';
358 while (isset($toutsujet[$j])) {
361 if (!empty($nouveauxsujets)) {
362 $nouveauxsujets .=
',';
364 $nouveauxsujets .= $toutsujet[$j];
371 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_sondage";
372 $sql .=
" SET sujet = '".$db->escape($nouveauxsujets).
"' WHERE id_sondage = '".$db->escape($numsondage).
"'";
373 $resql = $db->query($sql);
380 $sql =
"SELECT id_users, nom as name, id_sondage, reponses";
381 $sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs";
382 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
384 $resql = $db->query($sql);
389 $num = $db->num_rows($resql);
390 while ($compteur < $num) {
391 $obj = $db->fetch_object($resql);
394 $ensemblereponses = $obj->reponses;
397 for ($j = 0; $j < $nbcolonnes; $j++) {
398 $car = substr($ensemblereponses, $j, 1);
406 $sql2 =
'UPDATE '.MAIN_DB_PREFIX.
'opensurvey_user_studs';
407 $sql2 .=
" SET reponses = '".$db->escape($newcar).
"'";
408 $sql2 .=
" WHERE id_users = '".$db->escape($obj->id_users).
"'";
411 $resql2 = $db->query($sql2);
426$form =
new Form($db);
429 $userstatic =
new User($db);
430 $userstatic->fetch(
$object->fk_user_creat);
433$result =
$object->fetch(0, $numsondage);
439$title =
$object->title.
" - ".$langs->trans(
'Card');
442$arrayofcss = array(
'/opensurvey/css/style.css');
444llxHeader(
'', $title, $helpurl,
'', 0, 0, $arrayofjs, $arrayofcss);
448$toutsujet = explode(
",",
$object->sujet);
449$listofanswers = array();
450foreach ($toutsujet as $value) {
451 $tmp = explode(
'@', $value);
452 $listofanswers[] = array(
'label' => $tmp[0],
'format' => (!empty($tmp[1]) ? $tmp[1] :
'checkbox'));
454$toutsujet = str_replace(
"@",
"<br>", $toutsujet);
455$toutsujet = str_replace(
"°",
"'", $toutsujet);
458print
'<form name="formulaire4" action="#" method="POST">'.
"\n";
459print
'<input type="hidden" name="token" value="'.newToken().
'">';
460print
'<input type="hidden" name="id" value="'.GETPOST(
'id').
'">';
468$linkback =
'<a href="'.DOL_URL_ROOT.
'/opensurvey/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
470dol_banner_tab($object,
'id', $linkback, 1,
'id_sondage',
'id_sondage', $morehtmlref);
473print
'<div class="fichecenter">';
475print
'<div class="fichehalfleft">';
476print
'<div class="underbanner clearboth"></div>';
477print
'<table class="border tableforfield centpercent">';
480$type = (
$object->format ==
"A") ?
'classic' :
'date';
481print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td>';
482print
img_picto(
'',
dol_buildpath(
'/opensurvey/img/'.($type ==
'classic' ?
'chart-32.png' :
'calendar-32.png'), 1),
'width="16"', 1);
483print
' '.$langs->trans($type ==
'classic' ?
"TypeClassic" :
"TypeDate").
'</td></tr>';
487$adresseadmin =
$object->mail_admin;
488print $langs->trans(
"Title").
'</td><td>';
489if ($action ==
'edit') {
490 print
'<input type="text" name="nouveautitre" size="40" value="'.dol_escape_htmltag(
$object->title).
'">';
497print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak">';
498if ($action ==
'edit') {
499 $doleditor =
new DolEditor(
'nouveauxcommentaires',
$object->description,
'', 120,
'dolibarr_notes',
'In',
true, 1, 1, ROWS_7,
'90%');
500 $doleditor->Create(0,
'');
509 print
'<tr><td>'.$langs->trans(
"EMail").
'</td><td>';
510 if ($action ==
'edit') {
511 print
'<input type="text" name="nouvelleadresse" class="minwidth200" value="'.$object->mail_admin.
'">';
521print
'<div class="fichehalfright">';
522print
'<div class="underbanner clearboth"></div>';
524print
'<table class="border tableforfield centpercent">';
527print
'<tr><td>'.$langs->trans(
'ExpireDate').
'</td><td>';
528if ($action ==
'edit') {
529 print $form->selectDate($expiredate ? $expiredate :
$object->date_fin,
'expire', 0, 0, 0,
'', 1, 0);
540print $langs->trans(
"Author").
'</td><td>';
542 print $userstatic->getLoginUrl(-1);
549print
'<tr><td>'.$langs->trans(
"UrlForSurvey",
'').
'</td><td>';
552$urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
553$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
556$url = $urlwithouturlroot.dol_buildpath(
'/public/opensurvey/studs.php', 1).
'?sondage='.
$object->id_sondage;
557$urllink =
'<input type="text" class="quatrevingtpercent" '.($action ==
'edit' ?
'disabled' :
'').
' id="opensurveyurl" name="opensurveyurl" value="'.$url.
'">';
559if ($action !=
'edit') {
569print
'<div class="clearboth"></div>';
578print
'<div class="tabsAction">';
580print
'<a class="butAction" href="exportcsv.php?id='.urlencode($numsondage).
'">'.$langs->trans(
"ExportSpreadsheet").
' (.CSV)</a>';
588 if (!$user->hasRight(
'opensurvey',
'write')) {
592 print
'<form name="formulaire" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
593 print
'<input type="hidden" name="token" value="'.newToken().
'">';
594 print
'<input type="hidden" name="backtopage" value="'.GETPOST(
'backtopage',
'alpha').
'">';
595 print
'<input type="hidden" name="id" value="'.GETPOST(
'id',
'alpha').
'">';
596 print
'<input type="hidden" name="ajoutsujet" value="1">';
598 print
'<div class="center">'.
"\n";
603 print $langs->trans(
"AddNewColumn").
':<br><br>';
604 print $langs->trans(
"Title").
' <input type="text" name="nouvellecolonne" size="40"><br>';
605 $tmparray = array(
'checkbox' => $langs->trans(
"CheckBox"),
'yesno' => $langs->trans(
"YesNoList"),
'foragainst' => $langs->trans(
"PourContreList"));
606 print $langs->trans(
"Type").
' '.$form->selectarray(
"typecolonne", $tmparray,
GETPOST(
'typecolonne')).
'<br><br>';
607 print
'<input type="submit" class="button" name="ajoutercolonne" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'">';
608 print
'<input type="hidden" name="id_sondage" value="'.dol_escape_htmltag(
$object->id_sondage).
'">';
609 print
' ';
610 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
611 print
'<br><br>'.
"\n";
613 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
617 print $langs->trans(
"AddADate").
':<br><br>'.
"\n";
618 print
'<select name="nouveaujour"> '.
"\n";
619 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
620 for ($i = 1; $i < 32; $i++) {
621 print
'<OPTION VALUE="'.$i.
'">'.$i.
'</OPTION>'.
"\n";
623 print
'</select>'.
"\n";
625 print $formother->select_month(
'',
'nouveaumois', 1);
629 print $formother->selectyear(
'',
'nouvelleannee', 1, 0, 5, 0, 1);
631 print
'<br><br>'.$langs->trans(
"AddStartHour").
': <br><br>'.
"\n";
632 print
'<select name="nouvelleheuredebut"> '.
"\n";
633 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
634 for ($i = 0; $i < 24; $i++) {
635 print
'<OPTION VALUE="'.$i.
'">'.$i.
' H</OPTION>'.
"\n";
637 print
'</select>'.
"\n";
638 print
'<select name="nouvelleminutedebut"> '.
"\n";
639 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
640 print
'<OPTION VALUE="00">00</OPTION>'.
"\n";
641 print
'<OPTION VALUE="15">15</OPTION>'.
"\n";
642 print
'<OPTION VALUE="30">30</OPTION>'.
"\n";
643 print
'<OPTION VALUE="45">45</OPTION>'.
"\n";
644 print
'</select>'.
"\n";
645 print
'<br><br>'.$langs->trans(
"AddEndHour").
': <br><br>'.
"\n";
646 print
'<select name="nouvelleheurefin"> '.
"\n";
647 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
648 for ($i = 0; $i < 24; $i++) {
649 print
'<OPTION VALUE="'.$i.
'">'.$i.
' H</OPTION>'.
"\n";
651 print
'</SELECT>'.
"\n";
652 print
'<select name="nouvelleminutefin"> '.
"\n";
653 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
654 print
'<OPTION VALUE="00">00</OPTION>'.
"\n";
655 print
'<OPTION VALUE="15">15</OPTION>'.
"\n";
656 print
'<OPTION VALUE="30">30</OPTION>'.
"\n";
657 print
'<OPTION VALUE="45">45</OPTION>'.
"\n";
658 print
'</select>'.
"\n";
661 print
' <input type="submit" class="button" name="ajoutercolonne" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'">'.
"\n";
662 print
' ';
663 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
666 print
'</form>'.
"\n";
667 print
'<br><br><br><br>'.
"\n";
673if ($user->hasRight(
'opensurvey',
'write')) {
674 print
'<span class="opacitymedium">';
675 $s = $langs->trans(
"PollAdminDesc",
'{s1}', $langs->trans(
"Add"));
676 print str_replace(
'{s1}',
img_picto(
'',
'delete'), $s);
680$nbcolonnes = substr_count(
$object->sujet,
',') + 1;
682print
'<form name="formulaire" action="" method="POST">'.
"\n";
683print
'<input type="hidden" name="token" value="'.newToken().
'">';
684print
'<input type="hidden" name="page_y" value="">';
686print
'<div class="cadre div-table-responsive-no-min"> '.
"\n";
689print
'<table class="resultats margintoponly">'.
"\n";
692$toutsujet = explode(
",",
$object->sujet);
693$toutsujet = str_replace(
"°",
"'", $toutsujet);
696print
'<td></td>'.
"\n";
697print
'<td></td>'.
"\n";
700if ($user->hasRight(
'opensurvey',
'write')) {
701 for ($i = 0; isset($toutsujet[$i]); $i++) {
702 print
'<td class=somme><input type="image" class="buttonwebsite" name="effacecolonne'.$i.
'" src="'.
img_picto(
'',
'delete.png',
'', 0, 1).
'"></td>'.
"\n";
713 print
'<td></td>'.
"\n";
714 print
'<td></td>'.
"\n";
718 $nbofsujet = count($toutsujet);
719 for ($i = 0; $i < $nbofsujet; $i++) {
720 if (isset($toutsujet[$i + 1]) && date(
'Y', intval($toutsujet[$i])) == date(
'Y', intval($toutsujet[$i + 1]))) {
723 print
'<td colspan='.$colspan.
' class="annee">'.date(
'Y', intval($toutsujet[$i])).
'</td>'.
"\n";
728 if ($user->hasRight(
'opensurvey',
'write')) {
729 print
'<td class="annee">';
730 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.
$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
735 print
'<td></td>'.
"\n";
736 print
'<td></td>'.
"\n";
740 for ($i = 0; $i < $nbofsujet; $i++) {
741 $cur = intval($toutsujet[$i]);
743 if (!isset($toutsujet[$i + 1])) {
746 $next = intval($toutsujet[$i + 1]);
752 print
'<td colspan='.$colspan.
' class="mois">'.
dol_print_date($cur,
"%B").
'</td>'.
"\n";
758 if ($user->hasRight(
'opensurvey',
'write')) {
759 print
'<td class="mois"><a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.
$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
764 print
'<td></td>'.
"\n";
765 print
'<td></td>'.
"\n";
769 for ($i = 0; $i < $nbofsujet; $i++) {
770 $cur = intval($toutsujet[$i]);
771 if (!isset($toutsujet[$i + 1])) {
774 $next = intval($toutsujet[$i + 1]);
779 print
'<td colspan='.$colspan.
' class="jour">'.
dol_print_date($cur,
"%a %d").
'</td>'.
"\n";
785 if ($user->hasRight(
'opensurvey',
'write')) {
786 print
'<td class="jour"><a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.
$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
791 if (strpos(
$object->sujet,
'@') !==
false) {
793 print
'<td></td>'.
"\n";
794 print
'<td></td>'.
"\n";
796 for ($i = 0; isset($toutsujet[$i]); $i++) {
797 $heures = explode(
'@', $toutsujet[$i]);
798 if (isset($heures[1])) {
799 print
'<td class="heure">'.dol_htmlentities($heures[1]).
'</td>'.
"\n";
801 print
'<td class="heure"></td>'.
"\n";
805 if ($user->hasRight(
'opensurvey',
'write')) {
806 print
'<td class="heure"><a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.
$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
814 print
'<td></td>'.
"\n";
815 print
'<td></td>'.
"\n";
817 for ($i = 0; isset($toutsujet[$i]); $i++) {
818 $tmp = explode(
'@', $toutsujet[$i]);
819 print
'<td class="sujet">'.dol_htmlentities($tmp[0]).
'</td>'.
"\n";
822 print
'<td class="sujet"><a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$numsondage.
'&ajoutsujet=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'"><span class="fa fa-plus-circle valignmiddle btnTitle-icon"></span></a></td>'.
"\n";
829$sumagainst = array();
831$sql =
"SELECT id_users, nom as name, id_sondage, reponses";
832$sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs";
833$sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
835$resql = $db->query($sql);
840$num = $db->num_rows($resql);
841while ($compteur < $num) {
842 $obj = $db->fetch_object($resql);
844 $ensemblereponses = $obj->reponses;
846 print
'<tr><td>'.
"\n";
848 if ($user->hasRight(
'opensurvey',
'write')) {
849 print
'<input type="image" class="reposition" name="effaceligne'.$compteur.
'" src="'.
img_picto(
'',
'delete.png',
'', 0, 1).
'">'.
"\n";
853 print
'</td><td class="nom">'.dol_htmlentities($obj->name).
'</td>'.
"\n";
856 if (!$testligneamodifier) {
857 for ($i = 0; $i < $nbcolonnes; $i++) {
858 $car = substr($ensemblereponses, $i, 1);
861 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
862 if (((
string) $car) ==
"1") {
863 print
'<td class="ok">OK</td>'.
"\n";
865 print
'<td class="non">KO</td>'.
"\n";
868 if (!isset($sumfor[$i])) {
871 if (((
string) $car) ==
"1") {
875 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
876 if (((
string) $car) ==
"1") {
877 print
'<td class="ok">'.$langs->trans(
"Yes").
'</td>'.
"\n";
878 } elseif (((
string) $car) ==
"0") {
879 print
'<td class="non">'.$langs->trans(
"No").
'</td>'.
"\n";
881 print
'<td class="vide"> </td>'.
"\n";
884 if (!isset($sumfor[$i])) {
887 if (!isset($sumagainst[$i])) {
890 if (((
string) $car) ==
"1") {
893 if (((
string) $car) ==
"0") {
897 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
898 if (((
string) $car) ==
"1") {
899 print
'<td class="ok">'.$langs->trans(
"For").
'</td>'.
"\n";
900 } elseif (((
string) $car) ==
"0") {
901 print
'<td class="non">'.$langs->trans(
"Against").
'</td>'.
"\n";
903 print
'<td class="vide"> </td>'.
"\n";
906 if (!isset($sumfor[$i])) {
909 if (!isset($sumagainst[$i])) {
912 if (((
string) $car) ==
"1") {
915 if (((
string) $car) ==
"0") {
922 if ($compteur == $ligneamodifier) {
923 for ($i = 0; $i < $nbcolonnes; $i++) {
924 $car = substr($ensemblereponses, $i, 1);
925 print
'<td class="vide">';
926 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
927 print
'<input type="checkbox" name="choix'.$i.
'" value="1" ';
933 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
934 $arraychoice = array(
'2' =>
' ',
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
935 print $form->selectarray(
"choix".$i, $arraychoice, $car);
937 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
938 $arraychoice = array(
'2' =>
' ',
'0' => $langs->trans(
"Against"),
'1' => $langs->trans(
"For"));
939 print $form->selectarray(
"choix".$i, $arraychoice, $car);
944 for ($i = 0; $i < $nbcolonnes; $i++) {
945 $car = substr($ensemblereponses, $i, 1);
946 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
947 if (((
string) $car) ==
"1") {
948 print
'<td class="ok">OK</td>'.
"\n";
950 print
'<td class="non">KO</td>'.
"\n";
953 if (!isset($sumfor[$i])) {
956 if (((
string) $car) ==
"1") {
960 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
961 if (((
string) $car) ==
"1") {
962 print
'<td class="ok">'.$langs->trans(
"For").
'</td>'.
"\n";
963 } elseif (((
string) $car) ==
"0") {
964 print
'<td class="non">'.$langs->trans(
"Against").
'</td>'.
"\n";
966 print
'<td class="vide"> </td>'.
"\n";
969 if (!isset($sumfor[$i])) {
972 if (!isset($sumagainst[$i])) {
975 if (((
string) $car) ==
"1") {
978 if (((
string) $car) ==
"0") {
982 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
983 if (((
string) $car) ==
"1") {
984 print
'<td class="ok">'.$langs->trans(
"For").
'</td>'.
"\n";
985 } elseif (((
string) $car) ==
"0") {
986 print
'<td class="non">'.$langs->trans(
"Against").
'</td>'.
"\n";
988 print
'<td class="vide"> </td>'.
"\n";
991 if (!isset($sumfor[$i])) {
994 if (!isset($sumagainst[$i])) {
997 if (((
string) $car) ==
"1") {
1000 if (((
string) $car) ==
"0") {
1009 if ($compteur != $ligneamodifier && ($user->hasRight(
'opensurvey',
'write'))) {
1010 print
'<td class="casevide"><input type="submit" class="button reposition" name="modifierligne'.$compteur.
'" value="'.
dol_escape_htmltag($langs->trans(
"Edit")).
'"></td>'.
"\n";
1014 for ($i = 0; $i < $nblines; $i++) {
1015 if (GETPOSTISSET(
"modifierligne".$i)) {
1016 if ($compteur == $i) {
1017 print
'<td class="casevide">';
1018 print
'<input type="hidden" name="idtomodify'.$compteur.
'" value="'.$obj->id_users.
'">';
1019 print
'<input type="submit" class="button button-save reposition" name="validermodifier'.$compteur.
'" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'">';
1030if (empty($testligneamodifier)) {
1032 print
'<td></td>'.
"\n";
1033 print
'<td class="nom">'.
"\n";
1034 print
'<input type="text" class="maxwidthonsmartphone" placeholder="'.dol_escape_htmltag($langs->trans(
"Name")).
'" name="nom" maxlength="64">'.
"\n";
1037 for ($i = 0; $i < $nbcolonnes; $i++) {
1038 print
'<td class="vide">';
1039 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
1040 print
'<input type="checkbox" name="choix'.$i.
'" value="1"';
1041 if (GETPOSTISSET(
'choix'.$i) &&
GETPOST(
'choix'.$i) ==
'1') {
1046 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
1047 $arraychoice = array(
'2' =>
' ',
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
1048 print $form->selectarray(
"choix".$i, $arraychoice);
1050 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
1051 $arraychoice = array(
'2' =>
' ',
'0' => $langs->trans(
"Against"),
'1' => $langs->trans(
"For"));
1052 print $form->selectarray(
"choix".$i, $arraychoice);
1058 print
'<td><input type="image" name="boutonp" class="borderimp classfortooltip" title="'.dolPrintHTML($langs->trans(
"AddTheVote")).
'" value="'.$langs->trans(
"Vote").
'" src="'.
img_picto(
'',
'edit_add',
'', 0, 1).
'"></td>'.
"\n";
1064for ($i = 0; $i < $nbcolonnes + 1; $i++) {
1065 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
1068 if (isset($sumfor[$i])) {
1070 $meilleurecolonne = $sumfor[$i];
1072 if (isset($sumfor[$i]) && $sumfor[$i] > $meilleurecolonne) {
1073 $meilleurecolonne = $sumfor[$i];
1081print
'<td></td>'.
"\n";
1082print
'<td class="center">'.$langs->trans(
"Total").
'</td>'.
"\n";
1083for ($i = 0; $i < $nbcolonnes; $i++) {
1084 $showsumfor = isset($sumfor[$i]) ? $sumfor[$i] :
'';
1085 $showsumagainst = isset($sumagainst[$i]) ? $sumagainst[$i] :
'';
1086 if (empty($showsumfor)) {
1089 if (empty($showsumagainst)) {
1090 $showsumagainst = 0;
1094 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
1097 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
1098 print $langs->trans(
"Yes").
': '.$showsumfor.
'<br>'.$langs->trans(
"No").
': '.$showsumagainst;
1100 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
1101 print $langs->trans(
"For").
': '.$showsumfor.
'<br>'.$langs->trans(
"Against").
': '.$showsumagainst;
1107if ($nbofcheckbox >= 2) {
1109 print
'<td></td>'.
"\n";
1110 print
'<td></td>'.
"\n";
1111 for ($i = 0; $i < $nbcolonnes; $i++) {
1112 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) {
1113 print
'<td class="somme"><img src="'.dol_buildpath(
'/opensurvey/img/medaille.png', 1).
'"></td>'.
"\n";
1115 print
'<td class="somme"></td>'.
"\n";
1122if (GETPOSTISSET(
"boutonp") &&
GETPOST(
"nom") ==
"") {
1123 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")),
null,
'errors');
1126if (isset($erreur_prenom) && $erreur_prenom) {
1130if (isset($erreur_ajout_date) && $erreur_ajout_date) {
1135print
'</table>'.
"\n";
1139$toutsujet = explode(
",",
$object->sujet);
1143for ($i = 0; $i < $nbcolonnes; $i++) {
1144 if (isset($sumfor[$i]) && isset($meilleurecolonne) && ($sumfor[$i] == $meilleurecolonne)) {
1145 $meilleursujet .= ($meilleursujet ?
", " :
"");
1149 if (strpos($toutsujet[$i],
'@') !==
false) {
1150 $toutsujetdate = explode(
"@", $toutsujet[$i]);
1151 $meilleursujet .=
dol_print_date($toutsujetdate[0],
'daytext').($toutsujetdate[0] ?
' ('.dol_print_date($toutsujetdate[0],
'%A').
')' :
'').
' - '.$toutsujetdate[1];
1153 $meilleursujet .=
dol_print_date((empty($toutsujet[$i]) ? 0 : $toutsujet[$i]),
'daytext').
' ('.
dol_print_date((empty($toutsujet[$i]) ? 0 : $toutsujet[$i]),
'%A').
')';
1156 $tmps = explode(
'@', $toutsujet[$i]);
1164$meilleursujet = str_replace(
"°",
"'", $meilleursujet);
1167if ($nbofcheckbox >= 2) {
1168 $vote_str = $langs->trans(
'votes');
1169 print
'<p class="affichageresultats">'.
"\n";
1171 if (isset($meilleurecolonne) && $compteursujet ==
"1") {
1172 print
'<img src="'.DOL_URL_ROOT.
'/opensurvey/img/medaille.png"> '.$langs->trans(
'TheBestChoice').
": <b>".$meilleursujet.
"</b> - <b>".$meilleurecolonne.
"</b> ".$vote_str.
".\n";
1173 } elseif (isset($meilleurecolonne)) {
1174 print
'<img src="'.DOL_URL_ROOT.
'/opensurvey/img/medaille.png"> '.$langs->trans(
'TheBestChoices').
": <b>".$meilleursujet.
"</b> - <b>".$meilleurecolonne.
"</b> ".$vote_str.
".\n";
1176 print
'<br></p><br>'.
"\n";
1179print
'</form>'.
"\n";
1181print
'<a name="bas"></a>'.
"\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_now($mode='auto')
Return date for now.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
opensurvey_prepare_head(Opensurveysondage $object)
Returns an array with the tabs for the "Opensurvey poll" section It loads tabs from modules looking f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.