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";
35if (!$user->hasRight(
'opensurvey',
'read')) {
40$action =
GETPOST(
'action',
'aZ09');
41$numsondage =
GETPOST(
"id",
'alphanohtml');
44$result =
$object->fetch(0, $numsondage);
49$nblines =
$object->fetch_lines();
58 header(
'Location: results.php?id='.(GETPOSTISSET(
'id_sondage') ?
GETPOST(
'id_sondage',
'aZ09') :
GETPOST(
'id',
'alphanohtml')));
62$nbcolonnes = substr_count(
$object->sujet,
',') + 1;
67 $erreur_prenom =
false;
70 for ($i = 0; $i < $nbcolonnes; $i++) {
71 if (GETPOSTISSET(
"choix$i") &&
GETPOST(
"choix$i") ==
'1') {
73 } elseif (GETPOSTISSET(
"choix$i") &&
GETPOST(
"choix$i") ==
'2') {
80 $nom = substr(
GETPOST(
"nom",
'alphanohtml'), 0, 64);
83 $sql =
'SELECT id_users, nom as name';
84 $sql .=
' FROM '.MAIN_DB_PREFIX.
'opensurvey_user_studs';
85 $sql .=
" WHERE id_sondage='".$db->escape($numsondage).
"' AND nom = '".$db->escape($nom).
"'";
86 $sql .=
' ORDER BY id_users';
87 $resql = $db->query($sql);
88 $num_rows = $db->num_rows($resql);
93 $sql =
'INSERT INTO '.MAIN_DB_PREFIX.
'opensurvey_user_studs (nom, id_sondage, reponses, date_creation)';
94 $sql .=
" VALUES ('".$db->escape($nom).
"', '".$db->escape($numsondage).
"', '".$db->escape($nouveauchoix).
"', '".$db->idate(
dol_now()).
"')";
95 $resql = $db->query($sql);
104$testmodifier =
false;
105$testligneamodifier =
false;
107for ($i = 0; $i < $nblines; $i++) {
108 if (GETPOSTISSET(
'modifierligne'.$i)) {
109 $ligneamodifier = $i;
110 $testligneamodifier =
true;
114 if (GETPOSTISSET(
'validermodifier'.$i)) {
116 $testmodifier =
true;
121 if (!$user->hasRight(
'opensurvey',
'write')) {
126 for ($i = 0; $i < $nbcolonnes; $i++) {
127 if (GETPOSTISSET(
"choix$i") &&
GETPOST(
"choix$i") ==
'1') {
128 $nouveauchoix .=
"1";
129 } elseif (GETPOSTISSET(
"choix$i") &&
GETPOST(
"choix$i") ==
'2') {
130 $nouveauchoix .=
"2";
132 $nouveauchoix .=
"0";
136 $idtomodify =
GETPOST(
"idtomodify".$modifier);
137 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_user_studs";
138 $sql .=
" SET reponses = '".$db->escape($nouveauchoix).
"'";
139 $sql .=
" WHERE id_users = '".$db->escape($idtomodify).
"'";
141 $resql = $db->query($sql);
150 if (!$user->hasRight(
'opensurvey',
'write')) {
154 $nouveauxsujets =
$object->sujet;
157 $nouveauxsujets .=
',';
158 $nouveauxsujets .= str_replace(array(
",",
"@"),
" ",
GETPOST(
"nouvellecolonne")).(!
GETPOST(
"typecolonne") ?
'' :
'@'.GETPOST(
"typecolonne"));
161 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_sondage";
162 $sql .=
" SET sujet = '".$db->escape($nouveauxsujets).
"'";
163 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
164 $resql = $db->query($sql);
168 header(
'Location: results.php?id='.
$object->id_sondage);
174if (GETPOSTISSET(
"ajoutercolonne") &&
$object->format ==
"D") {
176 if (!$user->hasRight(
'opensurvey',
'write')) {
180 $nouveauxsujets =
$object->sujet;
182 if (GETPOSTISSET(
"nouveaujour") &&
GETPOST(
"nouveaujour") !=
"vide" &&
183 GETPOSTISSET(
"nouveaumois") &&
GETPOST(
"nouveaumois") !=
"vide" &&
184 GETPOSTISSET(
"nouvelleannee") &&
GETPOST(
"nouvelleannee") !=
"vide") {
187 if (GETPOSTISSET(
"nouvelleheuredebut") &&
GETPOST(
"nouvelleheuredebut") !=
"vide") {
188 $nouvelledate .=
"@";
189 $nouvelledate .=
GETPOST(
"nouvelleheuredebut");
190 $nouvelledate .=
"h";
192 if (
GETPOST(
"nouvelleminutedebut") !=
"vide") {
193 $nouvelledate .=
GETPOST(
"nouvelleminutedebut");
197 if (GETPOSTISSET(
"nouvelleheurefin") &&
GETPOST(
"nouvelleheurefin") !=
"vide") {
198 $nouvelledate .=
"-";
199 $nouvelledate .=
GETPOST(
"nouvelleheurefin");
200 $nouvelledate .=
"h";
202 if (
GETPOST(
"nouvelleminutefin") !=
"vide") {
203 $nouvelledate .=
GETPOST(
"nouvelleminutefin");
207 if (
GETPOST(
"nouvelleheuredebut") ==
"vide" || (GETPOSTISSET(
"nouvelleheuredebut") && GETPOSTISSET(
"nouvelleheurefin")
209 && (
GETPOST(
"nouvelleminutedebut") <
GETPOST(
"nouvelleminutefin")))))) {
210 $erreur_ajout_date =
false;
212 $erreur_ajout_date =
"yes";
216 $datesbase = explode(
",",
$object->sujet);
217 $taillebase = count($datesbase);
220 if ($nouvelledate < $datesbase[0]) {
222 } elseif ($nouvelledate > $datesbase[$taillebase - 1]) {
223 $cleinsertion = count($datesbase);
225 $nbdatesbase = count($datesbase);
226 for ($i = 0; $i < $nbdatesbase; $i++) {
228 if ($nouvelledate > $datesbase[$i] && $nouvelledate < $datesbase[$j]) {
234 array_splice($datesbase, $cleinsertion, 0, $nouvelledate);
235 $cle = array_search($nouvelledate, $datesbase);
237 $nbofdates = count($datesbase);
238 for ($i = 0; $i < $nbofdates; $i++) {
239 $dateinsertion .=
",";
240 $dateinsertion .= $datesbase[$i];
243 $dateinsertion = substr(
"$dateinsertion", 1);
246 if (isset($erreur_ajout_date) && empty($erreur_ajout_date)) {
247 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_sondage";
248 $sql .=
" SET sujet = '".$db->escape($dateinsertion).
"'";
249 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
250 $resql = $db->query($sql);
254 header(
'Location: results.php?id='.
$object->id_sondage);
257 if ($cleinsertion >= 0) {
258 $sql =
'SELECT s.reponses';
259 $sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs as s";
260 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
261 $resql = $db->query($sql);
265 $num = $db->num_rows($resql);
267 while ($compteur < $num) {
268 $obj = $db->fetch_object($resql);
269 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_user_studs";
270 if ($cleinsertion == 0) {
271 $sql .=
" SET reponses = '0".$db->escape($obj->reponses).
"'";
273 $reponsesadd = str_split($obj->reponses);
274 $lengthresponses = count($reponsesadd);
275 for ($cpt = $lengthresponses; $cpt > $cleinsertion; $cpt--) {
276 $reponsesadd[$cpt] = $reponsesadd[$cpt - 1];
278 $reponsesadd[$cleinsertion] =
'0';
279 $reponsesadd = implode($reponsesadd);
280 $sql .=
" SET reponses = '".$db->escape($reponsesadd).
"'";
282 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
283 $resql = $db->query($sql);
291 $adresseadmin =
$object->mail_admin;
293 $erreur_ajout_date =
"yes";
298for ($i = 0; $i < $nblines; $i++) {
301 if (!$user->hasRight(
'opensurvey',
'write')) {
309 $sql =
"SELECT id_users, nom as name, id_sondage, reponses";
310 $sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs";
311 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
312 $resql = $db->query($sql);
316 $num = $db->num_rows($resql);
317 while ($compteur < $num) {
318 $obj = $db->fetch_object($resql);
320 if ($compteur == $i) {
321 $sql2 =
'DELETE FROM '.MAIN_DB_PREFIX.
'opensurvey_user_studs';
322 $sql2 .=
" WHERE id_users = ".((int) $obj->id_users);
323 $resql2 = $db->query($sql2);
332for ($i = 0; $i < $nbcolonnes; $i++) {
333 if ((
GETPOST(
"effacecolonne".$i) ||
GETPOST(
"effacecolonne".$i.
"_x") ||
GETPOST(
"effacecolonne".$i.
".x"))
334 && $nbcolonnes > 1) {
336 if (!$user->hasRight(
'opensurvey',
'write')) {
342 $toutsujet = explode(
",",
$object->sujet);
344 $nouveauxsujets =
'';
347 while (isset($toutsujet[$j])) {
350 if (!empty($nouveauxsujets)) {
351 $nouveauxsujets .=
',';
353 $nouveauxsujets .= $toutsujet[$j];
360 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_sondage";
361 $sql .=
" SET sujet = '".$db->escape($nouveauxsujets).
"' WHERE id_sondage = '".$db->escape($numsondage).
"'";
362 $resql = $db->query($sql);
369 $sql =
"SELECT id_users, nom as name, id_sondage, reponses";
370 $sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs";
371 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
373 $resql = $db->query($sql);
378 $num = $db->num_rows($resql);
379 while ($compteur < $num) {
380 $obj = $db->fetch_object($resql);
383 $ensemblereponses = $obj->reponses;
386 for ($j = 0; $j < $nbcolonnes; $j++) {
387 $car = substr($ensemblereponses, $j, 1);
395 $sql2 =
'UPDATE '.MAIN_DB_PREFIX.
'opensurvey_user_studs';
396 $sql2 .=
" SET reponses = '".$db->escape($newcar).
"'";
397 $sql2 .=
" WHERE id_users = '".$db->escape($obj->id_users).
"'";
400 $resql2 = $db->query($sql2);
415$form =
new Form($db);
418 $userstatic =
new User($db);
419 $userstatic->fetch(
$object->fk_user_creat);
422$result =
$object->fetch(0, $numsondage);
428$title =
$object->title.
" - ".$langs->trans(
'Card');
431$arrayofcss = array(
'/opensurvey/css/style.css');
433llxHeader(
'', $title, $helpurl,
'', 0, 0, $arrayofjs, $arrayofcss);
437$toutsujet = explode(
",",
$object->sujet);
438$listofanswers = array();
439foreach ($toutsujet as $value) {
440 $tmp = explode(
'@', $value);
441 $listofanswers[] = array(
'label' => $tmp[0],
'format' => (!empty($tmp[1]) ? $tmp[1] :
'checkbox'));
443$toutsujet = str_replace(
"@",
"<br>", $toutsujet);
444$toutsujet = str_replace(
"°",
"'", $toutsujet);
447print
'<form name="formulaire4" action="#" method="POST">'.
"\n";
448print
'<input type="hidden" name="token" value="'.newToken().
'">';
449print
'<input type="hidden" name="id" value="'.GETPOST(
'id').
'">';
457$linkback =
'<a href="'.DOL_URL_ROOT.
'/opensurvey/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
459dol_banner_tab($object,
'id', $linkback, 1,
'id_sondage',
'id_sondage', $morehtmlref);
462print
'<div class="fichecenter">';
464print
'<div class="fichehalfleft">';
465print
'<div class="underbanner clearboth"></div>';
466print
'<table class="border tableforfield centpercent">';
469$type = (
$object->format ==
"A") ?
'classic' :
'date';
470print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td>';
471print
img_picto(
'',
dol_buildpath(
'/opensurvey/img/'.($type ==
'classic' ?
'chart-32.png' :
'calendar-32.png'), 1),
'width="16"', 1);
472print
' '.$langs->trans($type ==
'classic' ?
"TypeClassic" :
"TypeDate").
'</td></tr>';
476$adresseadmin =
$object->mail_admin;
477print $langs->trans(
"Title").
'</td><td>';
478if ($action ==
'edit') {
479 print
'<input type="text" name="nouveautitre" size="40" value="'.dol_escape_htmltag(
$object->title).
'">';
486print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak">';
487if ($action ==
'edit') {
488 $doleditor =
new DolEditor(
'nouveauxcommentaires',
$object->description,
'', 120,
'dolibarr_notes',
'In',
true, 1, 1, ROWS_7,
'90%');
489 $doleditor->Create(0,
'');
498 print
'<tr><td>'.$langs->trans(
"EMail").
'</td><td>';
499 if ($action ==
'edit') {
500 print
'<input type="text" name="nouvelleadresse" class="minwidth200" value="'.$object->mail_admin.
'">';
510print
'<div class="fichehalfright">';
511print
'<div class="underbanner clearboth"></div>';
513print
'<table class="border tableforfield centpercent">';
516print
'<tr><td>'.$langs->trans(
'ExpireDate').
'</td><td>';
517if ($action ==
'edit') {
518 print $form->selectDate($expiredate ? $expiredate :
$object->date_fin,
'expire', 0, 0, 0,
'', 1, 0);
529print $langs->trans(
"Author").
'</td><td>';
531 print $userstatic->getLoginUrl(-1);
538print
'<tr><td>'.$langs->trans(
"UrlForSurvey",
'').
'</td><td>';
541$urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
542$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
545$url = $urlwithouturlroot.dol_buildpath(
'/public/opensurvey/studs.php', 1).
'?sondage='.
$object->id_sondage;
546$urllink =
'<input type="text" class="quatrevingtpercent" '.($action ==
'edit' ?
'disabled' :
'').
' id="opensurveyurl" name="opensurveyurl" value="'.$url.
'">';
548if ($action !=
'edit') {
558print
'<div class="clearboth"></div>';
567print
'<div class="tabsAction">';
569print
'<a class="butAction" href="exportcsv.php?id='.urlencode($numsondage).
'">'.$langs->trans(
"ExportSpreadsheet").
' (.CSV)</a>';
577 if (!$user->hasRight(
'opensurvey',
'write')) {
581 print
'<form name="formulaire" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
582 print
'<input type="hidden" name="token" value="'.newToken().
'">';
583 print
'<input type="hidden" name="backtopage" value="'.GETPOST(
'backtopage',
'alpha').
'">';
584 print
'<input type="hidden" name="id" value="'.GETPOST(
'id',
'alpha').
'">';
585 print
'<input type="hidden" name="ajoutsujet" value="1">';
587 print
'<div class="center">'.
"\n";
592 print $langs->trans(
"AddNewColumn").
':<br><br>';
593 print $langs->trans(
"Title").
' <input type="text" name="nouvellecolonne" size="40"><br>';
594 $tmparray = array(
'checkbox' => $langs->trans(
"CheckBox"),
'yesno' => $langs->trans(
"YesNoList"),
'foragainst' => $langs->trans(
"PourContreList"));
595 print $langs->trans(
"Type").
' '.$form->selectarray(
"typecolonne", $tmparray,
GETPOST(
'typecolonne')).
'<br><br>';
596 print
'<input type="submit" class="button" name="ajoutercolonne" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'">';
597 print
'<input type="hidden" name="id_sondage" value="'.dol_escape_htmltag(
$object->id_sondage).
'">';
598 print
' ';
599 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
600 print
'<br><br>'.
"\n";
602 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
606 print $langs->trans(
"AddADate").
':<br><br>'.
"\n";
607 print
'<select name="nouveaujour"> '.
"\n";
608 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
609 for ($i = 1; $i < 32; $i++) {
610 print
'<OPTION VALUE="'.$i.
'">'.$i.
'</OPTION>'.
"\n";
612 print
'</select>'.
"\n";
614 print $formother->select_month(
'',
'nouveaumois', 1);
618 print $formother->selectyear(
'',
'nouvelleannee', 1, 0, 5, 0, 1);
620 print
'<br><br>'.$langs->trans(
"AddStartHour").
': <br><br>'.
"\n";
621 print
'<select name="nouvelleheuredebut"> '.
"\n";
622 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
623 for ($i = 0; $i < 24; $i++) {
624 print
'<OPTION VALUE="'.$i.
'">'.$i.
' H</OPTION>'.
"\n";
626 print
'</select>'.
"\n";
627 print
'<select name="nouvelleminutedebut"> '.
"\n";
628 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
629 print
'<OPTION VALUE="00">00</OPTION>'.
"\n";
630 print
'<OPTION VALUE="15">15</OPTION>'.
"\n";
631 print
'<OPTION VALUE="30">30</OPTION>'.
"\n";
632 print
'<OPTION VALUE="45">45</OPTION>'.
"\n";
633 print
'</select>'.
"\n";
634 print
'<br><br>'.$langs->trans(
"AddEndHour").
': <br><br>'.
"\n";
635 print
'<select name="nouvelleheurefin"> '.
"\n";
636 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
637 for ($i = 0; $i < 24; $i++) {
638 print
'<OPTION VALUE="'.$i.
'">'.$i.
' H</OPTION>'.
"\n";
640 print
'</SELECT>'.
"\n";
641 print
'<select name="nouvelleminutefin"> '.
"\n";
642 print
'<OPTION VALUE="vide"> </OPTION>'.
"\n";
643 print
'<OPTION VALUE="00">00</OPTION>'.
"\n";
644 print
'<OPTION VALUE="15">15</OPTION>'.
"\n";
645 print
'<OPTION VALUE="30">30</OPTION>'.
"\n";
646 print
'<OPTION VALUE="45">45</OPTION>'.
"\n";
647 print
'</select>'.
"\n";
650 print
' <input type="submit" class="button" name="ajoutercolonne" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'">'.
"\n";
651 print
' ';
652 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
655 print
'</form>'.
"\n";
656 print
'<br><br><br><br>'.
"\n";
662if ($user->hasRight(
'opensurvey',
'write')) {
663 print
'<span class="opacitymedium">';
664 $s = $langs->trans(
"PollAdminDesc",
'{s1}', $langs->trans(
"Add"));
665 print str_replace(
'{s1}',
img_picto(
'',
'delete'), $s);
669$nbcolonnes = substr_count(
$object->sujet,
',') + 1;
671print
'<form name="formulaire" action="" method="POST">'.
"\n";
672print
'<input type="hidden" name="token" value="'.newToken().
'">';
673print
'<input type="hidden" name="page_y" value="">';
675print
'<div class="cadre div-table-responsive-no-min"> '.
"\n";
678print
'<table class="resultats margintoponly">'.
"\n";
681$toutsujet = explode(
",",
$object->sujet);
682$toutsujet = str_replace(
"°",
"'", $toutsujet);
685print
'<td></td>'.
"\n";
686print
'<td></td>'.
"\n";
689if ($user->hasRight(
'opensurvey',
'write')) {
690 for ($i = 0; isset($toutsujet[$i]); $i++) {
691 print
'<td class=somme><input type="image" class="buttonwebsite" name="effacecolonne'.$i.
'" src="'.
img_picto(
'',
'delete.png',
'', 0, 1).
'"></td>'.
"\n";
702 print
'<td></td>'.
"\n";
703 print
'<td></td>'.
"\n";
707 $nbofsujet = count($toutsujet);
708 for ($i = 0; $i < $nbofsujet; $i++) {
709 if (isset($toutsujet[$i + 1]) && date(
'Y', intval($toutsujet[$i])) == date(
'Y', intval($toutsujet[$i + 1]))) {
712 print
'<td colspan='.$colspan.
' class="annee">'.date(
'Y', intval($toutsujet[$i])).
'</td>'.
"\n";
717 if ($user->hasRight(
'opensurvey',
'write')) {
718 print
'<td class="annee">';
719 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.
$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
724 print
'<td></td>'.
"\n";
725 print
'<td></td>'.
"\n";
729 for ($i = 0; $i < $nbofsujet; $i++) {
730 $cur = intval($toutsujet[$i]);
732 if (!isset($toutsujet[$i + 1])) {
735 $next = intval($toutsujet[$i + 1]);
741 print
'<td colspan='.$colspan.
' class="mois">'.
dol_print_date($cur,
"%B").
'</td>'.
"\n";
747 if ($user->hasRight(
'opensurvey',
'write')) {
748 print
'<td class="mois"><a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.
$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
753 print
'<td></td>'.
"\n";
754 print
'<td></td>'.
"\n";
758 for ($i = 0; $i < $nbofsujet; $i++) {
759 $cur = intval($toutsujet[$i]);
760 if (!isset($toutsujet[$i + 1])) {
763 $next = intval($toutsujet[$i + 1]);
768 print
'<td colspan='.$colspan.
' class="jour">'.
dol_print_date($cur,
"%a %d").
'</td>'.
"\n";
774 if ($user->hasRight(
'opensurvey',
'write')) {
775 print
'<td class="jour"><a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.
$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
780 if (strpos(
$object->sujet,
'@') !==
false) {
782 print
'<td></td>'.
"\n";
783 print
'<td></td>'.
"\n";
785 for ($i = 0; isset($toutsujet[$i]); $i++) {
786 $heures = explode(
'@', $toutsujet[$i]);
787 if (isset($heures[1])) {
788 print
'<td class="heure">'.dol_htmlentities($heures[1]).
'</td>'.
"\n";
790 print
'<td class="heure"></td>'.
"\n";
794 if ($user->hasRight(
'opensurvey',
'write')) {
795 print
'<td class="heure"><a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.
$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
803 print
'<td></td>'.
"\n";
804 print
'<td></td>'.
"\n";
806 for ($i = 0; isset($toutsujet[$i]); $i++) {
807 $tmp = explode(
'@', $toutsujet[$i]);
808 print
'<td class="sujet">'.dol_htmlentities($tmp[0]).
'</td>'.
"\n";
811 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";
818$sumagainst = array();
820$sql =
"SELECT id_users, nom as name, id_sondage, reponses";
821$sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs";
822$sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
824$resql = $db->query($sql);
829$num = $db->num_rows($resql);
830while ($compteur < $num) {
831 $obj = $db->fetch_object($resql);
833 $ensemblereponses = $obj->reponses;
835 print
'<tr><td>'.
"\n";
837 if ($user->hasRight(
'opensurvey',
'write')) {
838 print
'<input type="image" class="reposition" name="effaceligne'.$compteur.
'" src="'.
img_picto(
'',
'delete.png',
'', 0, 1).
'">'.
"\n";
842 print
'</td><td class="nom">'.dol_htmlentities($obj->name).
'</td>'.
"\n";
845 if (!$testligneamodifier) {
846 for ($i = 0; $i < $nbcolonnes; $i++) {
847 $car = substr($ensemblereponses, $i, 1);
850 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
851 if (((
string) $car) ==
"1") {
852 print
'<td class="ok">OK</td>'.
"\n";
854 print
'<td class="non">KO</td>'.
"\n";
857 if (!isset($sumfor[$i])) {
860 if (((
string) $car) ==
"1") {
864 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
865 if (((
string) $car) ==
"1") {
866 print
'<td class="ok">'.$langs->trans(
"Yes").
'</td>'.
"\n";
867 } elseif (((
string) $car) ==
"0") {
868 print
'<td class="non">'.$langs->trans(
"No").
'</td>'.
"\n";
870 print
'<td class="vide"> </td>'.
"\n";
873 if (!isset($sumfor[$i])) {
876 if (!isset($sumagainst[$i])) {
879 if (((
string) $car) ==
"1") {
882 if (((
string) $car) ==
"0") {
886 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
887 if (((
string) $car) ==
"1") {
888 print
'<td class="ok">'.$langs->trans(
"For").
'</td>'.
"\n";
889 } elseif (((
string) $car) ==
"0") {
890 print
'<td class="non">'.$langs->trans(
"Against").
'</td>'.
"\n";
892 print
'<td class="vide"> </td>'.
"\n";
895 if (!isset($sumfor[$i])) {
898 if (!isset($sumagainst[$i])) {
901 if (((
string) $car) ==
"1") {
904 if (((
string) $car) ==
"0") {
911 if ($compteur == $ligneamodifier) {
912 for ($i = 0; $i < $nbcolonnes; $i++) {
913 $car = substr($ensemblereponses, $i, 1);
914 print
'<td class="vide">';
915 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
916 print
'<input type="checkbox" name="choix'.$i.
'" value="1" ';
922 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
923 $arraychoice = array(
'2' =>
' ',
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
924 print $form->selectarray(
"choix".$i, $arraychoice, $car);
926 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
927 $arraychoice = array(
'2' =>
' ',
'0' => $langs->trans(
"Against"),
'1' => $langs->trans(
"For"));
928 print $form->selectarray(
"choix".$i, $arraychoice, $car);
933 for ($i = 0; $i < $nbcolonnes; $i++) {
934 $car = substr($ensemblereponses, $i, 1);
935 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
936 if (((
string) $car) ==
"1") {
937 print
'<td class="ok">OK</td>'.
"\n";
939 print
'<td class="non">KO</td>'.
"\n";
942 if (!isset($sumfor[$i])) {
945 if (((
string) $car) ==
"1") {
949 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
950 if (((
string) $car) ==
"1") {
951 print
'<td class="ok">'.$langs->trans(
"For").
'</td>'.
"\n";
952 } elseif (((
string) $car) ==
"0") {
953 print
'<td class="non">'.$langs->trans(
"Against").
'</td>'.
"\n";
955 print
'<td class="vide"> </td>'.
"\n";
958 if (!isset($sumfor[$i])) {
961 if (!isset($sumagainst[$i])) {
964 if (((
string) $car) ==
"1") {
967 if (((
string) $car) ==
"0") {
971 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
972 if (((
string) $car) ==
"1") {
973 print
'<td class="ok">'.$langs->trans(
"For").
'</td>'.
"\n";
974 } elseif (((
string) $car) ==
"0") {
975 print
'<td class="non">'.$langs->trans(
"Against").
'</td>'.
"\n";
977 print
'<td class="vide"> </td>'.
"\n";
980 if (!isset($sumfor[$i])) {
983 if (!isset($sumagainst[$i])) {
986 if (((
string) $car) ==
"1") {
989 if (((
string) $car) ==
"0") {
998 if ($compteur != $ligneamodifier && ($user->hasRight(
'opensurvey',
'write'))) {
999 print
'<td class="casevide"><input type="submit" class="button reposition" name="modifierligne'.$compteur.
'" value="'.
dol_escape_htmltag($langs->trans(
"Edit")).
'"></td>'.
"\n";
1003 for ($i = 0; $i < $nblines; $i++) {
1004 if (GETPOSTISSET(
"modifierligne".$i)) {
1005 if ($compteur == $i) {
1006 print
'<td class="casevide">';
1007 print
'<input type="hidden" name="idtomodify'.$compteur.
'" value="'.$obj->id_users.
'">';
1008 print
'<input type="submit" class="button button-save reposition" name="validermodifier'.$compteur.
'" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'">';
1019if (empty($testligneamodifier)) {
1021 print
'<td></td>'.
"\n";
1022 print
'<td class="nom">'.
"\n";
1023 print
'<input type="text" class="maxwidthonsmartphone" placeholder="'.dol_escape_htmltag($langs->trans(
"Name")).
'" name="nom" maxlength="64">'.
"\n";
1026 for ($i = 0; $i < $nbcolonnes; $i++) {
1027 print
'<td class="vide">';
1028 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
1029 print
'<input type="checkbox" name="choix'.$i.
'" value="1"';
1030 if (GETPOSTISSET(
'choix'.$i) &&
GETPOST(
'choix'.$i) ==
'1') {
1035 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
1036 $arraychoice = array(
'2' =>
' ',
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
1037 print $form->selectarray(
"choix".$i, $arraychoice);
1039 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
1040 $arraychoice = array(
'2' =>
' ',
'0' => $langs->trans(
"Against"),
'1' => $langs->trans(
"For"));
1041 print $form->selectarray(
"choix".$i, $arraychoice);
1047 print
'<td><input type="image" name="boutonp" class="borderimp" value="'.$langs->trans(
"Vote").
'" src="'.
img_picto(
'',
'edit_add',
'', 0, 1).
'"></td>'.
"\n";
1053for ($i = 0; $i < $nbcolonnes + 1; $i++) {
1054 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
1057 if (isset($sumfor[$i])) {
1059 $meilleurecolonne = $sumfor[$i];
1061 if (isset($sumfor[$i]) && $sumfor[$i] > $meilleurecolonne) {
1062 $meilleurecolonne = $sumfor[$i];
1070print
'<td></td>'.
"\n";
1071print
'<td class="center">'.$langs->trans(
"Total").
'</td>'.
"\n";
1072for ($i = 0; $i < $nbcolonnes; $i++) {
1073 $showsumfor = isset($sumfor[$i]) ? $sumfor[$i] :
'';
1074 $showsumagainst = isset($sumagainst[$i]) ? $sumagainst[$i] :
'';
1075 if (empty($showsumfor)) {
1078 if (empty($showsumagainst)) {
1079 $showsumagainst = 0;
1083 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst'))) {
1086 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno') {
1087 print $langs->trans(
"Yes").
': '.$showsumfor.
'<br>'.$langs->trans(
"No").
': '.$showsumagainst;
1089 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst') {
1090 print $langs->trans(
"For").
': '.$showsumfor.
'<br>'.$langs->trans(
"Against").
': '.$showsumagainst;
1096if ($nbofcheckbox >= 2) {
1098 print
'<td></td>'.
"\n";
1099 print
'<td></td>'.
"\n";
1100 for ($i = 0; $i < $nbcolonnes; $i++) {
1101 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) {
1102 print
'<td class="somme"><img src="'.dol_buildpath(
'/opensurvey/img/medaille.png', 1).
'"></td>'.
"\n";
1104 print
'<td class="somme"></td>'.
"\n";
1111if (GETPOSTISSET(
"boutonp") &&
GETPOST(
"nom") ==
"") {
1112 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")),
null,
'errors');
1115if (isset($erreur_prenom) && $erreur_prenom) {
1119if (isset($erreur_ajout_date) && $erreur_ajout_date) {
1124print
'</table>'.
"\n";
1128$toutsujet = explode(
",",
$object->sujet);
1132for ($i = 0; $i < $nbcolonnes; $i++) {
1133 if (isset($sumfor[$i]) && isset($meilleurecolonne) && ($sumfor[$i] == $meilleurecolonne)) {
1134 $meilleursujet .= ($meilleursujet ?
", " :
"");
1138 if (strpos($toutsujet[$i],
'@') !==
false) {
1139 $toutsujetdate = explode(
"@", $toutsujet[$i]);
1140 $meilleursujet .=
dol_print_date($toutsujetdate[0],
'daytext').($toutsujetdate[0] ?
' ('.dol_print_date($toutsujetdate[0],
'%A').
')' :
'').
' - '.$toutsujetdate[1];
1142 $meilleursujet .=
dol_print_date((empty($toutsujet[$i]) ? 0 : $toutsujet[$i]),
'daytext').
' ('.
dol_print_date((empty($toutsujet[$i]) ? 0 : $toutsujet[$i]),
'%A').
')';
1145 $tmps = explode(
'@', $toutsujet[$i]);
1153$meilleursujet = str_replace(
"°",
"'", $meilleursujet);
1156if ($nbofcheckbox >= 2) {
1157 $vote_str = $langs->trans(
'votes');
1158 print
'<p class="affichageresultats">'.
"\n";
1160 if (isset($meilleurecolonne) && $compteursujet ==
"1") {
1161 print
'<img src="'.DOL_URL_ROOT.
'/opensurvey/img/medaille.png"> '.$langs->trans(
'TheBestChoice').
": <b>".$meilleursujet.
"</b> - <b>".$meilleurecolonne.
"</b> ".$vote_str.
".\n";
1162 } elseif (isset($meilleurecolonne)) {
1163 print
'<img src="'.DOL_URL_ROOT.
'/opensurvey/img/medaille.png"> '.$langs->trans(
'TheBestChoices').
": <b>".$meilleursujet.
"</b> - <b>".$meilleurecolonne.
"</b> ".$vote_str.
".\n";
1165 print
'<br></p><br>'.
"\n";
1168print
'</form>'.
"\n";
1170print
'<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($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)
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.