26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
28 require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
29 require_once DOL_DOCUMENT_ROOT.
"/opensurvey/class/opensurveysondage.class.php";
30 require_once DOL_DOCUMENT_ROOT.
"/opensurvey/fonctions.php";
38 $action =
GETPOST(
'action',
'aZ09');
42 $result = $object->fetch(0, $numsondage);
43 if ($result <= 0)
dol_print_error(
'',
'Failed to get survey id '.$numsondage);
45 $nblines = $object->fetch_lines();
54 header(
'Location: results.php?id='.$_GET[
'id']);
58 $nbcolonnes = substr_count($object->sujet,
',') + 1;
65 $erreur_prenom =
false;
68 for ($i = 0; $i < $nbcolonnes; $i++)
70 if (isset($_POST[
"choix$i"]) && $_POST[
"choix$i"] ==
'1')
73 } elseif (isset($_POST[
"choix$i"]) && $_POST[
"choix$i"] ==
'2')
81 $nom = substr(
GETPOST(
"nom",
'nohtml'), 0, 64);
84 $sql =
'SELECT id_users, nom as name';
85 $sql .=
' FROM '.MAIN_DB_PREFIX.
'opensurvey_user_studs';
86 $sql .=
" WHERE id_sondage='".$db->escape($numsondage).
"' AND nom = '".$db->escape($nom).
"'";
87 $sql .=
' ORDER BY id_users';
89 $num_rows = $db->num_rows(
$resql);
95 $sql =
'INSERT INTO '.MAIN_DB_PREFIX.
'opensurvey_user_studs (nom, id_sondage, reponses)';
96 $sql .=
" VALUES ('".$db->escape($nom).
"', '".$db->escape($numsondage).
"','".$db->escape($nouveauchoix).
"')";
104 $testmodifier =
false;
105 $testligneamodifier =
false;
106 $ligneamodifier = -1;
107 for ($i = 0; $i < $nblines; $i++)
109 if (isset($_POST[
'modifierligne'.$i]))
111 $ligneamodifier = $i;
112 $testligneamodifier =
true;
116 if (isset($_POST[
'validermodifier'.$i]))
119 $testmodifier =
true;
128 for ($i = 0; $i < $nbcolonnes; $i++)
131 if (isset($_POST[
"choix$i"]) && $_POST[
"choix$i"] ==
'1')
133 $nouveauchoix .=
"1";
134 } elseif (isset($_POST[
"choix$i"]) && $_POST[
"choix$i"] ==
'2')
136 $nouveauchoix .=
"2";
138 $nouveauchoix .=
"0";
142 $idtomodify = $_POST[
"idtomodify".$modifier];
143 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_user_studs";
144 $sql .=
" SET reponses = '".$db->escape($nouveauchoix).
"'";
145 $sql .=
" WHERE id_users = '".$db->escape($idtomodify).
"'";
147 $resql = $db->query($sql);
152 if (
GETPOST(
"ajoutercolonne") &&
GETPOST(
'nouvellecolonne') && $object->format ==
"A")
157 $nouveauxsujets = $object->sujet;
160 $nouveauxsujets .=
',';
161 $nouveauxsujets .= str_replace(array(
",",
"@"),
" ",
GETPOST(
"nouvellecolonne")).(empty($_POST[
"typecolonne"]) ?
'' :
'@'.GETPOST(
"typecolonne"));
164 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_sondage";
165 $sql .=
" SET sujet = '".$db->escape($nouveauxsujets).
"'";
166 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
167 $resql = $db->query($sql);
170 header(
'Location: results.php?id='.$object->id_sondage);
175 if (isset($_POST[
"ajoutercolonne"]) && $object->format ==
"D")
180 $nouveauxsujets = $object->sujet;
182 if (isset($_POST[
"nouveaujour"]) && $_POST[
"nouveaujour"] !=
"vide" &&
183 isset($_POST[
"nouveaumois"]) && $_POST[
"nouveaumois"] !=
"vide" &&
184 isset($_POST[
"nouvelleannee"]) && $_POST[
"nouvelleannee"] !=
"vide") {
185 $nouvelledate =
dol_mktime(0, 0, 0, $_POST[
"nouveaumois"], $_POST[
"nouveaujour"], $_POST[
"nouvelleannee"]);
187 if (isset($_POST[
"nouvelleheuredebut"]) && $_POST[
"nouvelleheuredebut"] !=
"vide") {
188 $nouvelledate .=
"@";
189 $nouvelledate .=
GETPOST(
"nouvelleheuredebut");
190 $nouvelledate .=
"h";
192 if ($_POST[
"nouvelleminutedebut"] !=
"vide") {
193 $nouvelledate .=
GETPOST(
"nouvelleminutedebut");
197 if (isset($_POST[
"nouvelleheurefin"]) && $_POST[
"nouvelleheurefin"] !=
"vide") {
198 $nouvelledate .=
"-";
199 $nouvelledate .=
GETPOST(
"nouvelleheurefin");
200 $nouvelledate .=
"h";
202 if ($_POST[
"nouvelleminutefin"] !=
"vide") {
203 $nouvelledate .=
GETPOST(
"nouvelleminutefin");
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++)
229 if ($nouvelledate > $datesbase[$i] && $nouvelledate < $datesbase[$j]) {
235 array_splice($datesbase, $cleinsertion, 0, $nouvelledate);
236 $cle = array_search($nouvelledate, $datesbase);
238 $nbofdates = count($datesbase);
239 for ($i = 0; $i < $nbofdates; $i++) {
240 $dateinsertion .=
",";
241 $dateinsertion .= $datesbase[$i];
244 $dateinsertion = substr(
"$dateinsertion", 1);
247 if (isset($erreur_ajout_date) && empty($erreur_ajout_date))
249 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_sondage";
250 $sql .=
" SET sujet = '".$db->escape($dateinsertion).
"'";
251 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
252 $resql = $db->query($sql);
255 header(
'Location: results.php?id='.$object->id_sondage);
259 $adresseadmin = $object->mail_admin;
261 $erreur_ajout_date =
"yes";
266 for ($i = 0; $i < $nblines; $i++)
277 $sql =
"SELECT id_users, nom as name, id_sondage, reponses";
278 $sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs";
279 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
280 $resql = $db->query($sql);
282 $num = $db->num_rows(
$resql);
283 while ($compteur < $num)
285 $obj = $db->fetch_object(
$resql);
289 $sql2 =
'DELETE FROM '.MAIN_DB_PREFIX.
'opensurvey_user_studs';
290 $sql2 .=
' WHERE id_users = '.$db->escape($obj->id_users);
291 $resql2 = $db->query($sql2);
300 for ($i = 0; $i < $nbcolonnes; $i++)
302 if ((
GETPOST(
"effacecolonne".$i) ||
GETPOST(
"effacecolonne".$i.
"_x") ||
GETPOST(
"effacecolonne".$i.
".x"))
310 $toutsujet = explode(
",", $object->sujet);
312 $nouveauxsujets =
'';
315 while (isset($toutsujet[$j]))
320 if (!empty($nouveauxsujets)) $nouveauxsujets .=
',';
321 $nouveauxsujets .= $toutsujet[$j];
328 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_sondage";
329 $sql .=
" SET sujet = '".$db->escape($nouveauxsujets).
"' WHERE id_sondage = '".$db->escape($numsondage).
"'";
330 $resql = $db->query($sql);
335 $sql =
"SELECT id_users, nom as name, id_sondage, reponses";
336 $sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs";
337 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
339 $resql = $db->query($sql);
345 $num = $db->num_rows(
$resql);
346 while ($compteur < $num)
348 $obj = $db->fetch_object(
$resql);
351 $ensemblereponses = $obj->reponses;
354 for ($j = 0; $j < $nbcolonnes; $j++)
356 $car = substr($ensemblereponses, $j, 1);
364 $sql2 =
'UPDATE '.MAIN_DB_PREFIX.
'opensurvey_user_studs';
365 $sql2 .=
" SET reponses = '".$db->escape($newcar).
"'";
366 $sql2 .=
" WHERE id_users = '".$db->escape($obj->id_users).
"'";
369 $resql2 = $db->query($sql2);
384 $form =
new Form($db);
386 if ($object->fk_user_creat) {
387 $userstatic =
new User($db);
388 $userstatic->fetch($object->fk_user_creat);
391 $result = $object->fetch(0, $numsondage);
398 $title = $object->title.
" - ".$langs->trans(
'Card');
400 $arrayofjs = array();
401 $arrayofcss = array(
'/opensurvey/css/style.css');
402 llxHeader(
'', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss);
406 $toutsujet = explode(
",", $object->sujet);
407 $listofanswers = array();
408 foreach ($toutsujet as $value)
410 $tmp = explode(
'@', $value);
411 $listofanswers[] = array(
'label'=>$tmp[0],
'format'=>($tmp[1] ? $tmp[1] :
'checkbox'));
413 $toutsujet = str_replace(
"@",
"<br>", $toutsujet);
414 $toutsujet = str_replace(
"°",
"'", $toutsujet);
417 print '<form name="formulaire4" action="#" method="POST">'.
"\n";
418 print '<input type="hidden" name="token" value="'.newToken().
'">';
426 $linkback =
'<a href="'.DOL_URL_ROOT.
'/opensurvey/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
428 dol_banner_tab($object,
'id', $linkback, 1,
'id_sondage',
'id_sondage', $morehtmlref);
431 print '<div class="fichecenter">';
432 print '<div class="underbanner clearboth"></div>';
434 print '<table class="border tableforfield centpercent">';
437 $type = ($object->format ==
"A") ?
'classic' :
'date';
438 print '<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td colspan="2">';
439 print img_picto(
'',
dol_buildpath(
'/opensurvey/img/'.($type ==
'classic' ?
'chart-32.png' :
'calendar-32.png'), 1),
'width="16"', 1);
440 print ' '.$langs->trans($type ==
'classic' ?
"TypeClassic" :
"TypeDate").
'</td></tr>';
444 $adresseadmin = $object->mail_admin;
445 print $langs->trans(
"Title").
'</td><td colspan="2">';
446 if ($action ==
'edit') {
447 print '<input type="text" name="nouveautitre" size="40" value="'.dol_escape_htmltag(
dol_htmlentities($object->title)).
'">';
454 print '<tr><td>'.$langs->trans(
'ExpireDate').
'</td><td colspan="2">';
455 if ($action ==
'edit')
print $form->selectDate($expiredate ? $expiredate : $object->date_fin,
'expire', 0, 0, 0,
'', 1, 0);
464 print $langs->trans(
"Author").
'</td><td colspan="2">';
465 if ($object->fk_user_creat) {
466 print $userstatic->getLoginUrl(1);
473 print '<tr><td>'.img_picto(
'',
'globe').
' '.$langs->trans(
"UrlForSurvey",
'').
'</td><td colspan="2">';
476 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
477 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
480 $url = $urlwithouturlroot.dol_buildpath(
'/public/opensurvey/studs.php', 1).
'?sondage='.$object->id_sondage;
481 $urllink =
'<input type="text" style="width: 60%" '.($action ==
'edit' ?
'disabled' :
'').
' id="opensurveyurl" name="opensurveyurl" value="'.$url.
'">';
483 if ($action !=
'edit')
485 print '<script type="text/javascript">
486 jQuery(document).ready(function () {
487 jQuery("#opensurveyurl").click(function() { jQuery(this).select(); } );
490 print ' <a href="'.$url.
'" target="_blank">'.$langs->trans(
"Link").
'</a>';
501 print '</form>'.
"\n";
506 print '<div class="tabsAction">';
508 print '<a class="butAction" href="exportcsv.php?id='.urlencode($numsondage).
'">'.$langs->trans(
"ExportSpreadsheet").
' (.CSV)</a>';
519 print '<form name="formulaire" action="" method="POST">'.
"\n";
520 print '<input type="hidden" name="token" value="'.newToken().
'">';
521 print '<input type="hidden" name="backtopage" value="'.GETPOST(
'backtopage',
'alpha').
'">';
523 print '<div class="center">'.
"\n";
527 if ($object->format ==
"A")
529 print $langs->trans(
"AddNewColumn").
':<br><br>';
530 print $langs->trans(
"Title").
' <input type="text" name="nouvellecolonne" size="40"><br>';
531 $tmparray = array(
'checkbox'=>$langs->trans(
"CheckBox"),
'yesno'=>$langs->trans(
"YesNoList"),
'foragainst'=>$langs->trans(
"PourContreList"));
532 print $langs->trans(
"Type").
' '.$form->selectarray(
"typecolonne", $tmparray,
GETPOST(
'typecolonne')).
'<br><br>';
533 print '<input type="submit" class="button" name="ajoutercolonne" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'">';
534 print ' ';
535 print '<input type="submit" class="button button-cancel" name="retoursondage" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
536 print '<br><br>'.
"\n";
538 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
542 print $langs->trans(
"AddADate").
':<br><br>'.
"\n";
543 print '<select name="nouveaujour"> '.
"\n";
544 print '<OPTION VALUE="vide"> </OPTION>'.
"\n";
545 for ($i = 1; $i < 32; $i++) {
546 print '<OPTION VALUE="'.$i.
'">'.$i.
'</OPTION>'.
"\n";
548 print '</select>'.
"\n";
550 print $formother->select_month(
'',
'nouveaumois', 1);
554 print $formother->select_year(
'',
'nouvelleannee', 1, 0, 5, 0, 1);
556 print '<br><br>'.$langs->trans(
"AddStartHour").
': <br><br>'.
"\n";
557 print '<select name="nouvelleheuredebut"> '.
"\n";
558 print '<OPTION VALUE="vide"> </OPTION>'.
"\n";
559 for ($i = 0; $i < 24; $i++) {
560 print '<OPTION VALUE="'.$i.
'">'.$i.
' H</OPTION>'.
"\n";
562 print '</select>'.
"\n";
563 print '<select name="nouvelleminutedebut"> '.
"\n";
564 print '<OPTION VALUE="vide"> </OPTION>'.
"\n";
565 print '<OPTION VALUE="00">00</OPTION>'.
"\n";
566 print '<OPTION VALUE="15">15</OPTION>'.
"\n";
567 print '<OPTION VALUE="30">30</OPTION>'.
"\n";
568 print '<OPTION VALUE="45">45</OPTION>'.
"\n";
569 print '</select>'.
"\n";
570 print '<br><br>'.$langs->trans(
"AddEndHour").
': <br><br>'.
"\n";
571 print '<select name="nouvelleheurefin"> '.
"\n";
572 print '<OPTION VALUE="vide"> </OPTION>'.
"\n";
573 for ($i = 0; $i < 24; $i++) {
574 print '<OPTION VALUE="'.$i.
'">'.$i.
' H</OPTION>'.
"\n";
576 print '</SELECT>'.
"\n";
577 print '<select name="nouvelleminutefin"> '.
"\n";
578 print '<OPTION VALUE="vide"> </OPTION>'.
"\n";
579 print '<OPTION VALUE="00">00</OPTION>'.
"\n";
580 print '<OPTION VALUE="15">15</OPTION>'.
"\n";
581 print '<OPTION VALUE="30">30</OPTION>'.
"\n";
582 print '<OPTION VALUE="45">45</OPTION>'.
"\n";
583 print '</select>'.
"\n";
586 print' <input type="submit" class="button" name="ajoutercolonne" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'">'.
"\n";
587 print ' ';
588 print '<input type="submit" class="button button-cancel" name="retoursondage" value="'.$langs->trans(
"Cancel").
'">';
591 print '</form>'.
"\n";
592 print '<br><br><br><br>'.
"\n";
598 if ($user->rights->opensurvey->write) {
599 print '<span class="opacitymedium">'.$langs->trans(
"PollAdminDesc",
img_picto(
'',
'delete'), $langs->trans(
"Add")).
'</span><br>';
602 $nbcolonnes = substr_count($object->sujet,
',') + 1;
604 print '<form name="formulaire" action="" method="POST">'.
"\n";
605 print '<input type="hidden" name="token" value="'.newToken().
'">';
607 print '<div class="cadre"> '.
"\n";
610 print '<table class="resultats">'.
"\n";
613 $toutsujet = explode(
",", $object->sujet);
614 $toutsujet = str_replace(
"°",
"'", $toutsujet);
617 print '<td></td>'.
"\n";
618 print '<td></td>'.
"\n";
621 if ($user->rights->opensurvey->write) {
622 for ($i = 0; isset($toutsujet[$i]); $i++) {
623 print '<td class=somme><input type="image" name="effacecolonne'.$i.
'" src="'.
img_picto(
'',
'delete.png',
'',
false, 1).
'"></td>'.
"\n";
631 if ($object->format ==
"D")
635 print '<td></td>'.
"\n";
636 print '<td></td>'.
"\n";
640 $nbofsujet = count($toutsujet);
641 for ($i = 0; $i < $nbofsujet; $i++)
643 $current = $toutsujet[$i];
645 if (strpos($toutsujet[$i],
'@') !==
false) {
646 $current = substr($toutsujet[$i], 0, strpos($toutsujet[$i],
'@'));
649 if (isset($toutsujet[$i + 1]) && strpos($toutsujet[$i + 1],
'@') !==
false) {
650 $next = substr($toutsujet[$i + 1], 0, strpos($toutsujet[$i + 1],
'@'));
651 } elseif (isset($toutsujet[$i + 1])) {
652 $next = $toutsujet[$i + 1];
656 if ($current) $currenty = strftime(
"%Y", $current);
658 if ($next) $nexty = strftime(
"%Y", $next);
659 if (isset($toutsujet[$i + 1]) && ($currenty == $nexty))
663 print '<td colspan='.$colspan.
' class="annee">';
664 if ($current)
print strftime(
"%Y", $current);
670 if ($user->rights->opensurvey->write) {
671 print '<td class="annee">';
672 print '<a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
677 print '<td></td>'.
"\n";
678 print '<td></td>'.
"\n";
682 for ($i = 0; $i < $nbofsujet; $i++) {
683 $cur = intval($toutsujet[$i]);
685 if (isset($toutsujet[$i + 1]) ===
false) {
688 $next = intval($toutsujet[$i + 1]);
700 if ($user->rights->opensurvey->write) {
701 print '<td class="mois"><a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
706 print '<td></td>'.
"\n";
707 print '<td></td>'.
"\n";
711 for ($i = 0; $i < $nbofsujet; $i++) {
712 $cur = intval($toutsujet[$i]);
713 if (isset($toutsujet[$i + 1]) ===
false) {
716 $next = intval($toutsujet[$i + 1]);
727 if ($user->rights->opensurvey->write) {
728 print '<td class="jour"><a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
733 if (strpos($object->sujet,
'@') !==
false) {
735 print '<td></td>'.
"\n";
736 print '<td></td>'.
"\n";
738 for ($i = 0; isset($toutsujet[$i]); $i++) {
739 $heures = explode(
'@', $toutsujet[$i]);
740 if (isset($heures[1])) {
741 print '<td class="heure">'.dol_htmlentities($heures[1]).
'</td>'.
"\n";
743 print '<td class="heure"></td>'.
"\n";
747 if ($user->rights->opensurvey->write) {
748 print '<td class="heure"><a href="'.$_SERVER[
"PHP_SELF"].
'?ajoutsujet=1&id='.$object->id_sondage.
'">'.$langs->trans(
"Add").
'</a></td>'.
"\n";
756 print '<td></td>'.
"\n";
757 print '<td></td>'.
"\n";
759 for ($i = 0; isset($toutsujet[$i]); $i++)
761 $tmp = explode(
'@', $toutsujet[$i]);
762 print '<td class="sujet">'.dol_htmlentities($tmp[0]).
'</td>'.
"\n";
765 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";
772 $sumagainst = array();
774 $sql =
"SELECT id_users, nom as name, id_sondage, reponses";
775 $sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs";
776 $sql .=
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
778 $resql = $db->query($sql);
784 $num = $db->num_rows(
$resql);
785 while ($compteur < $num)
787 $obj = $db->fetch_object(
$resql);
789 $ensemblereponses = $obj->reponses;
791 print '<tr><td>'.
"\n";
793 if ($user->rights->opensurvey->write) {
794 print '<input type="image" name="effaceligne'.$compteur.
'" src="'.
img_picto(
'',
'delete.png',
'',
false, 1).
'">'.
"\n";
798 print '</td><td class="nom">'.dol_htmlentities($obj->name).
'</td>'.
"\n";
801 if (!$testligneamodifier)
803 for ($i = 0; $i < $nbcolonnes; $i++)
805 $car = substr($ensemblereponses, $i, 1);
808 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst')))
810 if (((
string) $car) ==
"1")
print '<td class="ok">OK</td>'.
"\n";
811 else print '<td class="non">KO</td>'.
"\n";
813 if (!isset($sumfor[$i])) $sumfor[$i] = 0;
814 if (((
string) $car) ==
"1") $sumfor[$i]++;
816 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno')
818 if (((
string) $car) ==
"1")
print '<td class="ok">'.$langs->trans(
"Yes").
'</td>'.
"\n";
819 elseif (((
string) $car) ==
"0")
print '<td class="non">'.$langs->trans("No").'</td>'."\
n";
820 else print '<td class="vide"> </td>'."\n";
822 if (!isset($sumfor[$i])) $sumfor[$i] = 0;
823 if (!isset($sumagainst[$i])) $sumagainst[$i] = 0;
824 if (((
string) $car) == "1") $sumfor[$i]++;
825 if (((
string) $car) == "0") $sumagainst[$i]++;
827 if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
829 if (((
string) $car) ==
"1")
print '<td class="ok">'.$langs->trans(
"For").
'</td>'.
"\n";
830 elseif (((
string) $car) ==
"0")
print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
831 else print '<td class="vide"> </td>'."\n";
833 if (!isset($sumfor[$i])) $sumfor[$i] = 0;
834 if (!isset($sumagainst[$i])) $sumagainst[$i] = 0;
835 if (((
string) $car) == "1") $sumfor[$i]++;
836 if (((
string) $car) == "0") $sumagainst[$i]++;
841 if ($compteur == $ligneamodifier)
843 for ($i = 0; $i < $nbcolonnes; $i++)
845 $car = substr($ensemblereponses, $i, 1);
846 print '<td class="vide">';
847 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst')))
849 print '<input type="checkbox" name="choix'.$i.
'" value="1" ';
850 if ($car ==
'1')
print 'checked';
853 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno')
855 $arraychoice = array(
'2'=>
' ',
'0'=>$langs->trans(
"No"),
'1'=>$langs->trans(
"Yes"));
856 print $form->selectarray(
"choix".$i, $arraychoice, $car);
858 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst')
860 $arraychoice = array(
'2'=>
' ',
'0'=>$langs->trans(
"Against"),
'1'=>$langs->trans(
"For"));
861 print $form->selectarray(
"choix".$i, $arraychoice, $car);
866 for ($i = 0; $i < $nbcolonnes; $i++)
868 $car = substr($ensemblereponses, $i, 1);
869 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst')))
871 if (((
string) $car) ==
"1")
print '<td class="ok">OK</td>'.
"\n";
872 else print '<td class="non">KO</td>'.
"\n";
874 if (!isset($sumfor[$i])) $sumfor[$i] = 0;
875 if (((
string) $car) ==
"1") $sumfor[$i]++;
877 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno')
879 if (((
string) $car) ==
"1")
print '<td class="ok">'.$langs->trans(
"For").
'</td>'.
"\n";
880 elseif (((
string) $car) ==
"0")
print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
881 else print '<td class="vide"> </td>'."\n";
883 if (!isset($sumfor[$i])) $sumfor[$i] = 0;
884 if (!isset($sumagainst[$i])) $sumagainst[$i] = 0;
885 if (((
string) $car) == "1") $sumfor[$i]++;
886 if (((
string) $car) == "0") $sumagainst[$i]++;
888 if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
890 if (((
string) $car) ==
"1")
print '<td class="ok">'.$langs->trans(
"For").
'</td>'.
"\n";
891 elseif (((
string) $car) ==
"0")
print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
892 else print '<td class="vide"> </td>'."\n";
894 if (!isset($sumfor[$i])) $sumfor[$i] = 0;
895 if (!isset($sumagainst[$i])) $sumagainst[$i] = 0;
896 if (((
string) $car) == "1") $sumfor[$i]++;
897 if (((
string) $car) == "0") $sumagainst[$i]++;
904 if ($compteur != $ligneamodifier && ($user->rights->opensurvey->write))
906 print '<td class="casevide"><input type="submit" class="button" name="modifierligne'.$compteur.
'" value="'.
dol_escape_htmltag($langs->trans(
"Edit")).
'"></td>'.
"\n";
910 for ($i = 0; $i < $nblines; $i++)
916 print '<td class="casevide">';
917 print '<input type="hidden" name="idtomodify'.$compteur.
'" value="'.$obj->id_users.
'">';
918 print '<input type="submit" class="button button-save" name="validermodifier'.$compteur.
'" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'">';
929 if (empty($testligneamodifier))
932 print '<td></td>'.
"\n";
933 print '<td class="nom">'.
"\n";
934 print '<input type="text" placeholder="'.dol_escape_htmltag($langs->trans(
"Name")).
'" name="nom" maxlength="64" size="24">'.
"\n";
937 for ($i = 0; $i < $nbcolonnes; $i++)
939 print '<td class="vide">';
940 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst')))
942 print '<input type="checkbox" name="choix'.$i.
'" value="1"';
949 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno')
951 $arraychoice = array(
'2'=>
' ',
'0'=>$langs->trans(
"No"),
'1'=>$langs->trans(
"Yes"));
952 print $form->selectarray(
"choix".$i, $arraychoice);
954 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst')
956 $arraychoice = array(
'2'=>
' ',
'0'=>$langs->trans(
"Against"),
'1'=>$langs->trans(
"For"));
957 print $form->selectarray(
"choix".$i, $arraychoice);
963 print '<td><input type="image" name="boutonp" class="borderimp" value="'.$langs->trans(
"Vote").
'" src="'.
img_picto(
'',
'edit_add',
'',
false, 1).
'"></td>'.
"\n";
969 for ($i = 0; $i < $nbcolonnes + 1; $i++)
971 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst')))
973 if (isset($sumfor[$i]))
977 $meilleurecolonne = $sumfor[$i];
979 if (isset($sumfor[$i]) && $sumfor[$i] > $meilleurecolonne)
981 $meilleurecolonne = $sumfor[$i];
989 print '<td></td>'.
"\n";
990 print '<td class="center">'.$langs->trans(
"Total").
'</td>'.
"\n";
991 for ($i = 0; $i < $nbcolonnes; $i++)
993 $showsumfor = isset($sumfor[$i]) ? $sumfor[$i] :
'';
994 $showsumagainst = isset($sumagainst[$i]) ? $sumagainst[$i] :
'';
995 if (empty($showsumfor)) $showsumfor = 0;
996 if (empty($showsumagainst)) $showsumagainst = 0;
999 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst')))
print $showsumfor;
1000 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'yesno')
print $langs->trans(
"Yes").
': '.$showsumfor.
'<br>'.$langs->trans(
"No").
': '.$showsumagainst;
1001 if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] ==
'foragainst')
print $langs->trans(
"For").
': '.$showsumfor.
'<br>'.$langs->trans(
"Against").
': '.$showsumagainst;
1006 if ($nbofcheckbox >= 2)
1009 print '<td></td>'.
"\n";
1010 print '<td></td>'.
"\n";
1011 for ($i = 0; $i < $nbcolonnes; $i++) {
1012 if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno',
'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne)
1014 print '<td class="somme"><img src="'.dol_buildpath(
'/opensurvey/img/medaille.png', 1).
'"></td>'.
"\n";
1016 print '<td class="somme"></td>'.
"\n";
1024 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")), null,
'errors');
1027 if (isset($erreur_prenom) && $erreur_prenom) {
1031 if (isset($erreur_ajout_date) && $erreur_ajout_date) {
1036 print '</table>'.
"\n";
1037 print '</div>'.
"\n";
1040 $toutsujet = explode(
",", $object->sujet);
1043 $meilleursujet =
'';
1044 for ($i = 0; $i < $nbcolonnes; $i++)
1046 if (isset($sumfor[$i]) ===
true && isset($meilleurecolonne) ===
true && $sumfor[$i] == $meilleurecolonne)
1048 $meilleursujet .=
", ";
1050 if ($object->format ==
"D") {
1051 $meilleursujetexport = $toutsujet[$i];
1053 if (strpos($toutsujet[$i],
'@') !==
false) {
1054 $toutsujetdate = explode(
"@", $toutsujet[$i]);
1055 $meilleursujet .=
dol_print_date($toutsujetdate[0],
'daytext').($toutsujetdate[0] ?
' ('.dol_print_date($toutsujetdate[0],
'%A').
')' :
'').
' - '.$toutsujetdate[1];
1057 $meilleursujet .=
dol_print_date($toutsujet[$i],
'daytext').($toutsujet[$i] ?
' ('.dol_print_date($toutsujet[$i],
'%A').
')' :
'');
1060 $tmps = explode(
'@', $toutsujet[$i]);
1067 $meilleursujet = substr($meilleursujet, 1);
1068 $meilleursujet = str_replace(
"°",
"'", $meilleursujet);
1071 if ($nbofcheckbox >= 2)
1073 $vote_str = $langs->trans(
'votes');
1074 print '<p class="affichageresultats">'.
"\n";
1076 if (isset($meilleurecolonne) && $compteursujet ==
"1") {
1077 print "<img src=\"".DOL_URL_ROOT.
'/opensurvey/img/medaille.png'.
"\"> ".$langs->trans(
'TheBestChoice').
": <b>".$meilleursujet.
" </b>".$langs->trans(
"with").
" <b>".$meilleurecolonne.
"</b> ".$vote_str.
".\n";
1078 } elseif (isset($meilleurecolonne)) {
1079 print "<img src=\"".DOL_URL_ROOT.
'/opensurvey/img/medaille.png'.
"\"> ".$langs->trans(
'TheBestChoices').
": <b>".$meilleursujet.
" </b>".$langs->trans(
"with").
" <b>".$meilleurecolonne.
"</b> ".$vote_str.
".\n";
1081 print '<br></p><br>'.
"\n";
1084 print '</form>'.
"\n";
1086 print '<a name="bas"></a>'.
"\n";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
dol_htmlentities($string, $flags=null, $encoding= 'UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
const STATUS_VALIDATED
Validated/Opened status.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Put here description of your class.
print $_SERVER["PHP_SELF"]
Edit parameters.
opensurvey_prepare_head(Opensurveysondage $object)
Returns an array with the tabs for the "Opensurvey poll" section It loads tabs from modules looking f...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
print $_SERVER["PHP_SELF"] n
Edit parameters.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...