25if (!defined(
'NOLOGIN')) {
 
   28if (!defined(
'NOCSRFCHECK')) {
 
   29  define(
"NOCSRFCHECK", 1); 
 
   31if (!defined(
'NOBROWSERNOTIF')) {
 
   32  define(
'NOBROWSERNOTIF', 
'1');
 
   34if (!defined(
'NOIPCHECK')) {
 
   35  define(
'NOIPCHECK', 
'1'); 
 
   39require 
'../../main.inc.php';
 
   40require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
 
   41require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
 
   42require_once DOL_DOCUMENT_ROOT.
"/opensurvey/class/opensurveysondage.class.php";
 
   43require_once DOL_DOCUMENT_ROOT.
"/opensurvey/lib/opensurvey.lib.php";
 
   44require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
 
   48$action = 
GETPOST(
'action', 
'aZ09');
 
   51  $numsondage = 
GETPOST(
'sondage', 
'alpha');
 
   55$result = $object->fetch(0, $numsondage);
 
   57$nblines = $object->fetch_lines();
 
   63if (empty($conf->opensurvey->enabled)) {
 
   72$nbcolonnes = substr_count($object->sujet, 
',') + 1;
 
   74$listofvoters = explode(
',', $_SESSION[
"savevoter"]);
 
   77if (
GETPOST(
'ajoutcomment', 
'alpha')) {
 
   78  if (!$canbemodified) {
 
   84  $comment = 
GETPOST(
"comment", 
'alphanohtml');
 
   85  $comment_user = 
GETPOST(
'commentuser', 
'alphanohtml');
 
   89    setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Comment")), 
null, 
'errors');
 
   93    setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")), 
null, 
'errors');
 
   96  if (!in_array($comment_user, $listofvoters)) {
 
   97    setEventMessages($langs->trans(
"UserMustBeSameThanUserUsedToVote"), 
null, 
'errors');
 
  102  $nb_post_max = 
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
 
  107  if ($nb_post_max > 0) { 
 
  108    $sql = 
"SELECT COUNT(id_comment) as nb_comments";
 
  109    $sql .= 
" FROM ".MAIN_DB_PREFIX.
"opensurvey_comments";
 
  110    $sql .= 
" WHERE ip = '".$db->escape($user_ip).
"'";
 
  111    $sql .= 
" AND date_creation > '".$db->idate($minmonthpost).
"'";
 
  112    $resql = $db->query($sql);
 
  114      $num = $db->num_rows($resql);
 
  118        $obj = $db->fetch_object($resql);
 
  119        $nb_post_ip = $obj->nb_comments;
 
  124  if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
 
  125    setEventMessages($langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"), 
null, 
'errors');
 
  130    $resql = $object->addComment($comment, $comment_user, $user_ip);
 
  140  if (!$canbemodified) {
 
  145  if (
GETPOST(
'nom', 
'alphanohtml')) {
 
  147    for ($i = 0; $i < $nbcolonnes; $i++) {
 
  148      if (GETPOSTISSET(
"choix".$i) && 
GETPOST(
"choix".$i) == 
'1') {
 
  149        $nouveauchoix .= 
"1";
 
  150      } elseif (GETPOSTISSET(
"choix".$i) && 
GETPOST(
"choix".$i) == 
'2') {
 
  151        $nouveauchoix .= 
"2";
 
  153        $nouveauchoix .= 
"0";
 
  158    $nb_post_max = 
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
 
  163    if ($nb_post_max > 0) { 
 
  164      $sql = 
"SELECT COUNT(id_users) as nb_records";
 
  165      $sql .= 
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs";
 
  166      $sql .= 
" WHERE ip = '".$db->escape($user_ip).
"'";
 
  167      $sql .= 
" AND date_creation > '".$db->idate($minmonthpost).
"'";
 
  168      $resql = $db->query($sql);
 
  170        $num = $db->num_rows($resql);
 
  174          $obj = $db->fetch_object($resql);
 
  175          $nb_post_ip = $obj->nb_records;
 
  181    $nom = substr(
GETPOST(
"nom", 
'alphanohtml'), 0, 64);
 
  184    $sql = 
'SELECT id_users, nom as name';
 
  185    $sql .= 
' FROM '.MAIN_DB_PREFIX.
'opensurvey_user_studs';
 
  186    $sql .= 
" WHERE id_sondage='".$db->escape($numsondage).
"' AND nom = '".$db->escape($nom).
"' ORDER BY id_users";
 
  187    $resql = $db->query($sql);
 
  192    $num_rows = $db->num_rows($resql);
 
  197    } elseif ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
 
  198      setEventMessages($langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"), 
null, 
'errors');
 
  202      $sql = 
'INSERT INTO '.MAIN_DB_PREFIX.
'opensurvey_user_studs (nom, id_sondage, reponses, ip, date_creation)';
 
  203      $sql .= 
" VALUES ('".$db->escape($nom).
"', '".$db->escape($numsondage).
"','".$db->escape($nouveauchoix).
"', '".$db->escape($user_ip).
"', '".$db->idate($now).
"')";
 
  204      $resql = $db->query($sql);
 
  208        $_SESSION[
"savevoter"] = $nom.
','.(empty($_SESSION[
"savevoter"]) ? 
'' : $_SESSION[
"savevoter"]); 
 
  209        $listofvoters = explode(
',', $_SESSION[
"savevoter"]);
 
  211        if ($object->mailsonde) {
 
  212          if ($object->fk_user_creat) {
 
  213            $userstatic = 
new User($db);
 
  214            $userstatic->fetch($object->fk_user_creat);
 
  216            $email = $userstatic->email;
 
  218            $email = $object->mail_admin;
 
  223            include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
 
  225            $application = ($conf->global->MAIN_APPLICATION_TITLE ? $conf->global->MAIN_APPLICATION_TITLE : 
'Dolibarr ERP/CRM');
 
  227            $link = getUrlSondage($numsondage, 
true);
 
  228            $link = 
'<a href="'.$link.
'">'.$link.
'</a>';
 
  229            $body = str_replace(
'\n', 
'<br>', $langs->transnoentities(
'EmailSomeoneVoted', $nom, $link));
 
  232            $cmailfile = 
new CMailFile(
"[".$application.
"] ".$langs->trans(
"Poll").
': '.$object->title, $email, $conf->global->MAIN_MAIL_EMAIL_FROM, $body, 
null, 
null, 
null, 
'', 
'', 0, -1);
 
  233            $result = $cmailfile->sendfile();
 
  241    setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")), 
null, 
'errors');
 
  247$testmodifier = 
false;
 
  248$testligneamodifier = 
false;
 
  250for ($i = 0; $i < $nblines; $i++) {
 
  251  if (GETPOSTISSET(
'modifierligne'.$i)) {
 
  252    $ligneamodifier = $i;
 
  253    $testligneamodifier = 
true;
 
  257  if (GETPOSTISSET(
'validermodifier'.$i)) {
 
  259    $testmodifier = 
true;
 
  265  for ($i = 0; $i < $nbcolonnes; $i++) {
 
  266    if (GETPOSTISSET(
"choix".$i) && 
GETPOST(
"choix".$i) == 
'1') {
 
  267      $nouveauchoix .= 
"1";
 
  268    } elseif (GETPOSTISSET(
"choix".$i) && 
GETPOST(
"choix".$i) == 
'2') {
 
  269      $nouveauchoix .= 
"2";
 
  271      $nouveauchoix .= 
"0";
 
  275  if (!$canbemodified) {
 
  279  $idtomodify = 
GETPOST(
"idtomodify".$modifier);
 
  280  $sql = 
'UPDATE '.MAIN_DB_PREFIX.
"opensurvey_user_studs";
 
  281  $sql .= 
" SET reponses = '".$db->escape($nouveauchoix).
"'";
 
  282  $sql .= 
" WHERE id_users = '".$db->escape($idtomodify).
"'";
 
  284  $resql = $db->query($sql);
 
  291$idcomment = 
GETPOST(
'deletecomment', 
'int');
 
  293  if (!$canbemodified) {
 
  297  $resql = $object->deleteComment($idcomment);
 
  306$form = 
new Form($db);
 
  309$arrayofcss = array(
'/opensurvey/css/style.css');
 
  311llxHeaderSurvey($object->title, 
"", 0, 0, $arrayofjs, $arrayofcss, $numsondage);
 
  313if (empty($object->ref)) {     
 
  314  $langs->load(
"errors");
 
  315  print $langs->trans(
"ErrorRecordNotFound");
 
  324$toutsujet = explode(
",", $object->sujet);
 
  325$listofanswers = array();
 
  326foreach ($toutsujet as $value) {
 
  327  $tmp = explode(
'@', $value);
 
  328  $listofanswers[] = array(
'label'=>$tmp[0], 
'format'=>(!empty($tmp[1]) ? $tmp[1] : 
'checkbox'));
 
  330$toutsujet = str_replace(
"°", 
"'", $toutsujet);
 
  334print 
'<div class="survey_invitation">'.$langs->trans(
"YouAreInivitedToVote").
'</div>';
 
  335print 
'<span class="opacitymedium">'.$langs->trans(
"OpenSurveyHowTo").
'</span><br>';
 
  336if (empty($object->allow_spy)) {
 
  337  print 
'<span class="opacitymedium">'.$langs->trans(
"YourVoteIsPrivate").
'</span><br>';
 
  339  print $form->textwithpicto(
'<span class="opacitymedium">'.$langs->trans(
"YourVoteIsPublic").
'</span>', $langs->trans(
"CanSeeOthersVote")).
'<br>';
 
  343if (empty($object->description)) {
 
  344  print 
'<div class="corps"> '.
"\n";
 
  348$titre = str_replace(
"\\", 
"", $object->title);
 
  349print 
'<strong>'.dol_htmlentities($titre).
'</strong><br>';
 
  351if (!empty($object->description)) {
 
  352  print 
'<br><div class="corps"> '.
"\n";
 
  356if ($object->description) {
 
  363if (!$canbemodified) {
 
  364  print 
'<br><center><div class="quatrevingtpercent center warning">'.$langs->trans(
'SurveyExpiredInfo').
'</div></center>';
 
  371print 
'<div class="cadre"> '.
"\n";
 
  372print 
'<br><br>'.
"\n";
 
  375print 
'<table class="resultats">'.
"\n";
 
  378if ($object->format == 
"D") {
 
  381  print 
'<td></td>'.
"\n";
 
  385  $nbofsujet = count($toutsujet);
 
  386  for ($i = 0; $i < $nbofsujet; $i++) {
 
  387    if (isset($toutsujet[$i + 1]) && date(
'Y', intval($toutsujet[$i])) == date(
'Y', intval($toutsujet[$i + 1]))) {
 
  390      print 
'<td colspan='.$colspan.
' class="annee">'.date(
'Y', intval($toutsujet[$i])).
'</td>'.
"\n";
 
  397  print 
'<td></td>'.
"\n";
 
  401  for ($i = 0; $i < $nbofsujet; $i++) {
 
  402    $cur = intval($toutsujet[$i]); 
 
  404    if (isset($toutsujet[$i + 1]) === 
false) {
 
  407      $next = intval($toutsujet[$i + 1]);
 
  413      print 
'<td colspan='.$colspan.
' class="mois">'.
dol_print_date($cur, 
"%B").
'</td>'.
"\n";
 
  420  print 
'<td></td>'.
"\n";
 
  424  for ($i = 0; $i < $nbofsujet; $i++) {
 
  425    $cur = intval($toutsujet[$i]);
 
  426    if (isset($toutsujet[$i + 1]) === 
false) {
 
  429      $next = intval($toutsujet[$i + 1]);
 
  434      print 
'<td colspan="'.$colspan.
'" class="jour">'.
dol_print_date($cur, 
"%a %d").
'</td>'.
"\n";
 
  442  if (strpos($object->sujet, 
'@') !== 
false) {
 
  444    print 
'<td></td>'.
"\n";
 
  446    for ($i = 0; isset($toutsujet[$i]); $i++) {
 
  447      $heures = explode(
'@', $toutsujet[$i]);
 
  448      if (isset($heures[1])) {
 
  449        print 
'<td class="heure">'.dol_htmlentities($heures[1]).
'</td>'.
"\n";
 
  451        print 
'<td class="heure"></td>'.
"\n";
 
  460  print 
'<td></td>'.
"\n";
 
  462  for ($i = 0; isset($toutsujet[$i]); $i++) {
 
  463    $tmp = explode(
'@', $toutsujet[$i]);
 
  464    print 
'<td class="sujet">'.dol_escape_htmltag($tmp[0]).
'</td>'.
"\n";
 
  472$currentusername = 
'';
 
  474$sumagainst = array();
 
  476$sql = 
"SELECT id_users, nom as name, id_sondage, reponses";
 
  477$sql .= 
" FROM ".MAIN_DB_PREFIX.
"opensurvey_user_studs";
 
  478$sql .= 
" WHERE id_sondage = '".$db->escape($numsondage).
"'";
 
  479$resql = $db->query($sql);
 
  484$num = $db->num_rows($resql);
 
  485while ($compteur < $num) {
 
  486  $obj = $db->fetch_object($resql);
 
  488  $ensemblereponses = $obj->reponses;
 
  491  $mod_ok = (in_array($obj->name, $listofvoters));
 
  493  if (!$mod_ok && !$object->allow_spy) {
 
  501  print 
'<td class="nom">'.dol_htmlentities($obj->name).
'</td>'.
"\n";
 
  504  if (!$testligneamodifier) {
 
  505    for ($i = 0; $i < $nbcolonnes; $i++) {
 
  506      $car = substr($ensemblereponses, $i, 1);
 
  509      if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno', 
'foragainst'))) {
 
  510        if (((
string) $car) == 
"1") {
 
  511          print 
'<td class="ok">OK</td>'.
"\n";
 
  513          print 
'<td class="non">KO</td>'.
"\n";
 
  516        if (!isset($sumfor[$i])) {
 
  519        if (((
string) $car) == 
"1") {
 
  523      if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] == 
'yesno') {
 
  524        if (((
string) $car) == 
"1") {
 
  525          print 
'<td class="ok">'.$langs->trans(
"Yes").
'</td>'.
"\n";
 
  526        } elseif (((
string) $car) == 
"0") {
 
  527          print 
'<td class="non">'.$langs->trans(
"No").
'</td>'.
"\n";
 
  529          print 
'<td class="vide"> </td>'.
"\n";
 
  532        if (!isset($sumfor[$i])) {
 
  535        if (!isset($sumagainst[$i])) {
 
  538        if (((
string) $car) == 
"1") {
 
  541        if (((
string) $car) == 
"0") {
 
  545      if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] == 
'foragainst') {
 
  546        if (((
string) $car) == 
"1") {
 
  547          print 
'<td class="ok">'.$langs->trans(
"For").
'</td>'.
"\n";
 
  548        } elseif (((
string) $car) == 
"0") {
 
  549          print 
'<td class="non">'.$langs->trans(
"Against").
'</td>'.
"\n";
 
  551          print 
'<td class="vide"> </td>'.
"\n";
 
  554        if (!isset($sumfor[$i])) {
 
  557        if (!isset($sumagainst[$i])) {
 
  560        if (((
string) $car) == 
"1") {
 
  563        if (((
string) $car) == 
"0") {
 
  570    if ($compteur == $ligneamodifier) {
 
  571      for ($i = 0; $i < $nbcolonnes; $i++) {
 
  572        $car = substr($ensemblereponses, $i, 1);
 
  573        print 
'<td class="vide">';
 
  574        if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno', 
'foragainst'))) {
 
  575          print 
'<input type="checkbox" name="choix'.$i.
'" value="1" ';
 
  581        if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] == 
'yesno') {
 
  582          $arraychoice = array(
'2'=>
' ', 
'0'=>$langs->trans(
"No"), 
'1'=>$langs->trans(
"Yes"));
 
  583          print $form->selectarray(
"choix".$i, $arraychoice, $car);
 
  585        if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] == 
'foragainst') {
 
  586          $arraychoice = array(
'2'=>
' ', 
'0'=>$langs->trans(
"Against"), 
'1'=>$langs->trans(
"For"));
 
  587          print $form->selectarray(
"choix".$i, $arraychoice, $car);
 
  592      for ($i = 0; $i < $nbcolonnes; $i++) {
 
  593        $car = substr($ensemblereponses, $i, 1);
 
  594        if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno', 
'foragainst'))) {
 
  595          if (((
string) $car) == 
"1") {
 
  596            print 
'<td class="ok">OK</td>'.
"\n";
 
  598            print 
'<td class="non">KO</td>'.
"\n";
 
  601          if (!isset($sumfor[$i])) {
 
  604          if (((
string) $car) == 
"1") {
 
  608        if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] == 
'yesno') {
 
  609          if (((
string) $car) == 
"1") {
 
  610            print 
'<td class="ok">'.$langs->trans(
"For").
'</td>'.
"\n";
 
  611          } elseif (((
string) $car) == 
"0") {
 
  612            print 
'<td class="non">'.$langs->trans(
"Against").
'</td>'.
"\n";
 
  614            print 
'<td class="vide"> </td>'.
"\n";
 
  617          if (!isset($sumfor[$i])) {
 
  620          if (!isset($sumagainst[$i])) {
 
  623          if (((
string) $car) == 
"1") {
 
  626          if (((
string) $car) == 
"0") {
 
  630        if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] == 
'foragainst') {
 
  631          if (((
string) $car) == 
"1") {
 
  632            print 
'<td class="ok">'.$langs->trans(
"For").
'</td>'.
"\n";
 
  633          } elseif (((
string) $car) == 
"0") {
 
  634            print 
'<td class="non">'.$langs->trans(
"Against").
'</td>'.
"\n";
 
  636            print 
'<td class="vide"> </td>'.
"\n";
 
  639          if (!isset($sumfor[$i])) {
 
  642          if (!isset($sumagainst[$i])) {
 
  645          if (((
string) $car) == 
"1") {
 
  648          if (((
string) $car) == 
"0") {
 
  657  if ($compteur != $ligneamodifier && $mod_ok) {
 
  658    $currentusername = $obj->name;
 
  659    print 
'<td class="casevide"><input type="submit" class="button small" name="modifierligne'.$compteur.
'" value="'.
dol_escape_htmltag($langs->trans(
"Edit")).
'"></td>'.
"\n";
 
  663  for ($i = 0; $i < $nblines; $i++) {
 
  664    if (GETPOSTISSET(
"modifierligne".$i)) {
 
  665      if ($compteur == $i) {
 
  666        print 
'<td class="casevide">';
 
  667        print 
'<input type="hidden" name="idtomodify'.$compteur.
'" value="'.$obj->id_users.
'">';
 
  668        print 
'<input type="submit" class="button button-save small" name="validermodifier'.$compteur.
'" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'">';
 
  679if ($ligneamodifier < 0 && (!isset($_SESSION[
'nom']))) {
 
  681  print 
'<td class="nom">'.
"\n";
 
  682  if (isset($_SESSION[
'nom'])) {
 
  683    print 
'<input type=hidden name="nom" value="'.$_SESSION[
'nom'].
'">'.$_SESSION[
'nom'].
"\n";
 
  685    print 
'<input type="text" name="nom" placeholder="'.dol_escape_htmltag($langs->trans(
"Name")).
'" maxlength="64" class=" minwidth175" value="">'.
"\n";
 
  690  for ($i = 0; $i < $nbcolonnes; $i++) {
 
  691    print 
'<td class="vide">';
 
  692    if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno', 
'foragainst'))) {
 
  693      print 
'<input type="checkbox" name="choix'.$i.
'" value="1"';
 
  694      if (GETPOSTISSET(
'choix'.$i) && 
GETPOST(
'choix'.$i) == 
'1') {
 
  699    if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] == 
'yesno') {
 
  700      $arraychoice = array(
'2'=>
' ', 
'0'=>$langs->trans(
"No"), 
'1'=>$langs->trans(
"Yes"));
 
  701      print $form->selectarray(
"choix".$i, $arraychoice, 
GETPOST(
'choix'.$i));
 
  703    if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] == 
'foragainst') {
 
  704      $arraychoice = array(
'2'=>
' ', 
'0'=>$langs->trans(
"Against"), 
'1'=>$langs->trans(
"For"));
 
  705      print $form->selectarray(
"choix".$i, $arraychoice, 
GETPOST(
'choix'.$i));
 
  711  print 
'<td><input type="image" class="borderimp" name="boutonp" value="'.$langs->trans(
"Vote").
'" src="'.
img_picto(
'', 
'edit_add', 
'', 
false, 1).
'"></td>'.
"\n";
 
  717for ($i = 0; $i < $nbcolonnes; $i++) {
 
  718  if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno', 
'foragainst'))) {
 
  721  if (isset($sumfor[$i])) {
 
  723      $meilleurecolonne = $sumfor[$i];
 
  725    if (!isset($meilleurecolonne) || $sumfor[$i] > $meilleurecolonne) {
 
  726      $meilleurecolonne = $sumfor[$i];
 
  731if ($object->allow_spy) {
 
  734  print 
'<td class="center">'.$langs->trans(
"Total").
'</td>'.
"\n";
 
  735  for ($i = 0; $i < $nbcolonnes; $i++) {
 
  736    $showsumfor = isset($sumfor[$i]) ? $sumfor[$i] : 
'';
 
  737    $showsumagainst = isset($sumagainst[$i]) ? $sumagainst[$i] : 
'';
 
  738    if (empty($showsumfor)) {
 
  741    if (empty($showsumagainst)) {
 
  746    if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno', 
'foragainst'))) {
 
  749    if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] == 
'yesno') {
 
  750      print $langs->trans(
"Yes").
': '.$showsumfor.
'<br>'.$langs->trans(
"No").
': '.$showsumagainst;
 
  752    if (!empty($listofanswers[$i][
'format']) && $listofanswers[$i][
'format'] == 
'foragainst') {
 
  753      print $langs->trans(
"For").
': '.$showsumfor.
'<br>'.$langs->trans(
"Against").
': '.$showsumagainst;
 
  759  if ($nbofcheckbox >= 2) {
 
  761    print 
'<td class="somme"></td>'.
"\n";
 
  762    for ($i = 0; $i < $nbcolonnes; $i++) {
 
  764      if (empty($listofanswers[$i][
'format']) || !in_array($listofanswers[$i][
'format'], array(
'yesno', 
'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) {
 
  765        print 
'<td class="somme"><img src="'.dol_buildpath(
'/opensurvey/img/medaille.png', 1).
'"></td>'.
"\n";
 
  767        print 
'<td class="somme"></td>'.
"\n";
 
  773print 
'</table>'.
"\n";
 
  776if ($object->allow_spy) {
 
  777  $toutsujet = explode(
",", $object->sujet);
 
  778  $toutsujet = str_replace(
"°", 
"'", $toutsujet);
 
  783  for ($i = 0; $i < $nbcolonnes; $i++) {
 
  784    if (isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) {
 
  785      $meilleursujet .= ($meilleursujet ? 
", " : 
"");
 
  786      if ($object->format == 
"D") {
 
  787        $meilleursujetexport = $toutsujet[$i];
 
  788        if (strpos($toutsujet[$i], 
'@') !== 
false) {
 
  789          $toutsujetdate = explode(
"@", $toutsujet[$i]);
 
  792          $meilleursujet .= 
dol_print_date((empty($toutsujet[$i]) ? 0 : $toutsujet[$i]), 
'daytext').
' ('.
dol_print_date((empty($toutsujet[$i]) ? 0 : $toutsujet[$i]), 
'%A').
')';
 
  795        $tmps = explode(
'@', $toutsujet[$i]);
 
  803  $meilleursujet = substr(
"$meilleursujet", 1);
 
  804  $meilleursujet = str_replace(
"°", 
"'", $meilleursujet);
 
  807  if ($nbofcheckbox >= 2) {
 
  808    $vote_str = $langs->trans(
'votes');
 
  809    print 
'<p class="affichageresultats">'.
"\n";
 
  811    if (isset($meilleurecolonne) && $compteursujet == 
"1") {
 
  812      print 
'<img src="'.dol_buildpath(
'/opensurvey/img/medaille.png', 1).
'"> '.$langs->trans(
'TheBestChoice').
": <b>".$meilleursujet.
"</b> ".$langs->trans(
'with').
" <b>".$meilleurecolonne.
"</b>".$vote_str.
".\n";
 
  813    } elseif (isset($meilleurecolonne)) {
 
  814      print 
'<img src="'.dol_buildpath(
'/opensurvey/img/medaille.png', 1).
'"> '.$langs->trans(
'TheBestChoices').
": <b>".$meilleursujet.
"</b> ".$langs->trans(
'with').
" <b>".$meilleurecolonne.
"</b>".$vote_str.
".\n";
 
  817    print 
'</p><br>'.
"\n";
 
  825$comments = $object->getComments();
 
  828  print 
'<br><u><span class="bold opacitymedium">'.$langs->trans(
"CommentsOfVoters").
':</span></u><br>'.
"\n";
 
  830  foreach ($comments as $obj) {
 
  834    print 
'<div class="comment"><span class="usercomment">';
 
  835    if (in_array($obj->usercomment, $listofvoters)) {
 
  836      print 
'<a href="'.$_SERVER[
"PHP_SELF"].
'?deletecomment='.$obj->id_comment.
'&sondage='.$numsondage.
'"> '.
img_picto(
'', 
'delete.png', 
'', 
false, 0, 0, 
'', 
'nomarginleft').
'</a> ';
 
  844if ($object->allow_comments && $currentusername) {
 
  845  print 
'<br><div class="addcomment"><span class="opacitymedium">'.$langs->trans(
"AddACommentForPoll").
"</span><br>\n";
 
  847  print 
'<textarea name="comment" rows="'.ROWS_2.
'" class="quatrevingtpercent">'.
dol_escape_htmltag(
GETPOST(
'comment', 
'alphanohtml'), 0, 1).
'</textarea><br>'.
"\n";
 
  848  print $langs->trans(
"Name").
': ';
 
  849  print 
'<input type="text" name="commentuser" maxlength="64" value="'.dol_escape_htmltag(GETPOSTISSET(
'commentuser') ? 
GETPOST(
'commentuser', 
'alphanohtml') : (empty($_SESSION[
'nom']) ? $currentusername : $_SESSION[
'nom'])).
'">   '.
"\n";
 
  850  print 
'<input type="submit" class="button smallpaddingimp" name="ajoutcomment" value="'.dol_escape_htmltag($langs->trans(
"AddComment")).
'"><br>'.
"\n";
 
  851  print 
'</form>'.
"\n";
 
  858print 
'<a name="bas"></a>'.
"\n";
 
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
 
Put here description of your class.
 
const STATUS_CLOSED
Closed.
 
Class to manage Dolibarr users.
 
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
 
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
 
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
 
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
 
dol_now($mode='auto')
Return date for now.
 
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
 
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_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
 
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
 
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
 
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
 
getUserRemoteIP()
Return the IP of remote user.
 
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...
 
httponly_accessforbidden($message=1, $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.