Added a new feature to disable spying other users’ vote
This commit is contained in:
parent
2b01981213
commit
13d4ea4c38
@ -18,7 +18,8 @@
|
|||||||
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
|
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
|
||||||
|
|
||||||
ALTER TABLE llx_bookmark ADD COLUMN entity integer DEFAULT 1 NOT NULL;
|
ALTER TABLE llx_bookmark ADD COLUMN entity integer DEFAULT 1 NOT NULL;
|
||||||
ALTER TABLE `llx_opensurvey_sondage` ADD `allow_comments` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT 1 AFTER `canedit` ;
|
ALTER TABLE `llx_opensurvey_sondage` ADD COLUMN `allow_comments` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT 1 AFTER `canedit` ;
|
||||||
ALTER TABLE `llx_opensurvey_sondage` DROP `survey_link_visible` ;
|
ALTER TABLE `llx_opensurvey_sondage` DROP COLUMN `survey_link_visible` ;
|
||||||
ALTER TABLE `llx_opensurvey_sondage` DROP INDEX `idx_id_sondage_admin` ;
|
ALTER TABLE `llx_opensurvey_sondage` DROP INDEX `idx_id_sondage_admin` ;
|
||||||
ALTER TABLE `llx_opensurvey_sondage` DROP `id_sondage_admin` ;
|
ALTER TABLE `llx_opensurvey_sondage` DROP COLUMN `id_sondage_admin` ;
|
||||||
|
ALTER TABLE `llx_opensurvey_sondage` ADD COLUMN `allow_spy` TINYINT( 1 ) UNSIGNED NOT NULL AFTER `allow_comments` ;
|
||||||
@ -26,6 +26,7 @@ CREATE TABLE llx_opensurvey_sondage (
|
|||||||
mailsonde varchar(2) DEFAULT '0',
|
mailsonde varchar(2) DEFAULT '0',
|
||||||
canedit integer DEFAULT 0,
|
canedit integer DEFAULT 0,
|
||||||
allow_comments TINYINT(1) unsigned NOT NULL DEFAULT 1,
|
allow_comments TINYINT(1) unsigned NOT NULL DEFAULT 1,
|
||||||
|
allow_spy TINYINT(1) unsigned NOT NULL DEFAULT 1,
|
||||||
origin VARCHAR(64),
|
origin VARCHAR(64),
|
||||||
tms TIMESTAMP,
|
tms TIMESTAMP,
|
||||||
sujet TEXT
|
sujet TEXT
|
||||||
|
|||||||
@ -27,7 +27,7 @@ SelectedDays=Selected days
|
|||||||
TheBestChoice=The best choice currently is
|
TheBestChoice=The best choice currently is
|
||||||
TheBestChoices=The best choices currently are
|
TheBestChoices=The best choices currently are
|
||||||
with=with
|
with=with
|
||||||
OpenSurveyHowTo=If you agree to vote in this poll, you have to give your name, choose the values that fit best for you (without paying attention to the choices of the other voters) and validate with the plus button at the end of the line.
|
OpenSurveyHowTo=If you agree to vote in this poll, you have to give your name, choose the values that fit best for you and validate with the plus button at the end of the line.
|
||||||
InitiatorOfPoll=Initiator of the poll
|
InitiatorOfPoll=Initiator of the poll
|
||||||
CommentsOfVoters=Comments of voters
|
CommentsOfVoters=Comments of voters
|
||||||
ConfirmRemovalOfPoll=Are you sure you want to remove this poll (and all votes)
|
ConfirmRemovalOfPoll=Are you sure you want to remove this poll (and all votes)
|
||||||
@ -66,7 +66,8 @@ AddEndHour=Add end hour
|
|||||||
votes=vote(s)
|
votes=vote(s)
|
||||||
NoCommentYet=No comments have been posted for this poll yet
|
NoCommentYet=No comments have been posted for this poll yet
|
||||||
CanEditVotes=Can change vote of others
|
CanEditVotes=Can change vote of others
|
||||||
CanComment=Users can comment in the poll
|
CanComment=Voters can comment in the poll
|
||||||
|
CanSeeOthersVote=Voters can see other people's vote
|
||||||
SelectDayDesc=For each selected day, you can choose, or not, meeting hours in the following format :<br>- empty,<br>- "8h", "8H" or "8:00" to give a meeting's start hour,<br>- "8-11", "8h-11h", "8H-11H" or "8:00-11:00" to give a meeting's start and end hour,<br>- "8h15-11h15", "8H15-11H15" or "8:15-11:15" for the same thing but with minutes.
|
SelectDayDesc=For each selected day, you can choose, or not, meeting hours in the following format :<br>- empty,<br>- "8h", "8H" or "8:00" to give a meeting's start hour,<br>- "8-11", "8h-11h", "8H-11H" or "8:00-11:00" to give a meeting's start and end hour,<br>- "8h15-11h15", "8H15-11H15" or "8:15-11:15" for the same thing but with minutes.
|
||||||
BackToCurrentMonth=Back to current month
|
BackToCurrentMonth=Back to current month
|
||||||
PublicLinkToCreateSurvey=Public link to allow everybody to create a survey
|
PublicLinkToCreateSurvey=Public link to allow everybody to create a survey
|
||||||
|
|||||||
@ -88,6 +88,7 @@ if ($action == 'update')
|
|||||||
$object->date_fin = $expiredate;
|
$object->date_fin = $expiredate;
|
||||||
$object->canedit = GETPOST('canedit')=='on'?1:0;
|
$object->canedit = GETPOST('canedit')=='on'?1:0;
|
||||||
$object->allow_comments = GETPOST('cancomment') == 'on' ? true : false;
|
$object->allow_comments = GETPOST('cancomment') == 'on' ? true : false;
|
||||||
|
$object->allow_spy = GETPOST('canseeothersvote') == 'on' ? true : false;
|
||||||
|
|
||||||
$res=$object->update($user);
|
$res=$object->update($user);
|
||||||
if ($res < 0)
|
if ($res < 0)
|
||||||
@ -176,7 +177,7 @@ $linkback = '<a href="'.dol_buildpath('/opensurvey/list.php',1).'">'.$langs->tra
|
|||||||
// Ref
|
// Ref
|
||||||
print '<tr><td width="18%">'.$langs->trans('Ref').'</td>';
|
print '<tr><td width="18%">'.$langs->trans('Ref').'</td>';
|
||||||
print '<td colspan="3">';
|
print '<td colspan="3">';
|
||||||
print $form->showrefnav($object, 'sondage', $linkback, 1, 'id_sondage', 'id_sondage');
|
print $form->showrefnav($object, 'id', $linkback, 1, 'id_sondage', 'id_sondage');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
@ -239,6 +240,15 @@ if ($action == 'edit')
|
|||||||
else print yn($object->allow_comments);
|
else print yn($object->allow_comments);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Users can see others vote
|
||||||
|
print '<tr><td>'.$langs->trans('CanSeeOthersVote').'</td><td colspan="2">';
|
||||||
|
if ($action == 'edit')
|
||||||
|
{
|
||||||
|
print '<input type="checkbox" name="canseeothersvote" size="40"'.($object->allow_spy?' checked="true"':'').'">';
|
||||||
|
}
|
||||||
|
else print yn($object->allow_spy);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
// Expire date
|
// Expire date
|
||||||
print '<tr><td>'.$langs->trans('ExpireDate').'</td><td colspan="2">';
|
print '<tr><td>'.$langs->trans('ExpireDate').'</td><td colspan="2">';
|
||||||
if ($action == 'edit') print $form->select_date($expiredate?$expiredate:$object->date_fin,'expire');
|
if ($action == 'edit') print $form->select_date($expiredate?$expiredate:$object->date_fin,'expire');
|
||||||
|
|||||||
@ -57,6 +57,12 @@ class Opensurveysondage extends CommonObject
|
|||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public $allow_comments;
|
public $allow_comments;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow users see others vote
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $allow_spy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -121,7 +127,7 @@ class Opensurveysondage extends CommonObject
|
|||||||
$sql.= " ".(! isset($this->format)?'NULL':"'".$this->db->escape($this->format)."'").",";
|
$sql.= " ".(! isset($this->format)?'NULL':"'".$this->db->escape($this->format)."'").",";
|
||||||
$sql.= " ".(! isset($this->mailsonde)?'NULL':"'".$this->db->escape($this->mailsonde)."'").",";
|
$sql.= " ".(! isset($this->mailsonde)?'NULL':"'".$this->db->escape($this->mailsonde)."'").",";
|
||||||
$sql.= " ".(! isset($this->canedit)?'NULL':"'".$this->db->escape($this->canedit)."'")."";
|
$sql.= " ".(! isset($this->canedit)?'NULL':"'".$this->db->escape($this->canedit)."'")."";
|
||||||
|
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
@ -189,6 +195,7 @@ class Opensurveysondage extends CommonObject
|
|||||||
$sql.= " t.mailsonde,";
|
$sql.= " t.mailsonde,";
|
||||||
$sql.= " t.canedit,";
|
$sql.= " t.canedit,";
|
||||||
$sql.= " t.allow_comments,";
|
$sql.= " t.allow_comments,";
|
||||||
|
$sql.= " t.allow_spy,";
|
||||||
$sql.= " t.sujet,";
|
$sql.= " t.sujet,";
|
||||||
$sql.= " t.tms";
|
$sql.= " t.tms";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as t";
|
$sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as t";
|
||||||
@ -212,6 +219,7 @@ class Opensurveysondage extends CommonObject
|
|||||||
$this->mailsonde = $obj->mailsonde;
|
$this->mailsonde = $obj->mailsonde;
|
||||||
$this->canedit = $obj->canedit;
|
$this->canedit = $obj->canedit;
|
||||||
$this->allow_comments = $obj->allow_comments;
|
$this->allow_comments = $obj->allow_comments;
|
||||||
|
$this->allow_spy = $obj->allow_spy;
|
||||||
$this->sujet = $obj->sujet;
|
$this->sujet = $obj->sujet;
|
||||||
|
|
||||||
$this->date_m = $this->db->jdate($obj->tls);
|
$this->date_m = $this->db->jdate($obj->tls);
|
||||||
@ -261,6 +269,7 @@ class Opensurveysondage extends CommonObject
|
|||||||
if (isset($this->mailsonde)) $this->mailsonde=trim($this->mailsonde);
|
if (isset($this->mailsonde)) $this->mailsonde=trim($this->mailsonde);
|
||||||
$this->canedit = $this->canedit ? 1 : 0;
|
$this->canedit = $this->canedit ? 1 : 0;
|
||||||
$this->allow_comments = $this->allow_comments ? 1 : 0;
|
$this->allow_comments = $this->allow_comments ? 1 : 0;
|
||||||
|
$this->allow_spy = $this->allow_spy ? 1 : 0;
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
// Put here code to add a control on parameters values
|
// Put here code to add a control on parameters values
|
||||||
@ -277,7 +286,8 @@ class Opensurveysondage extends CommonObject
|
|||||||
$sql.= " format=".(isset($this->format)?"'".$this->db->escape($this->format)."'":"null").",";
|
$sql.= " format=".(isset($this->format)?"'".$this->db->escape($this->format)."'":"null").",";
|
||||||
$sql.= " mailsonde=".(isset($this->mailsonde)?$this->db->escape($this->mailsonde):"null").",";
|
$sql.= " mailsonde=".(isset($this->mailsonde)?$this->db->escape($this->mailsonde):"null").",";
|
||||||
$sql.= " canedit=".$this->db->escape($this->canedit).",";
|
$sql.= " canedit=".$this->db->escape($this->canedit).",";
|
||||||
$sql.= " allow_comments=".$this->db->escape($this->allow_comments);
|
$sql.= " allow_comments=".$this->db->escape($this->allow_comments).",";
|
||||||
|
$sql.= " allow_spy=".$this->db->escape($this->allow_spy);
|
||||||
|
|
||||||
$sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'";
|
$sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'";
|
||||||
|
|
||||||
|
|||||||
@ -229,7 +229,7 @@ function dol_survey_random($car)
|
|||||||
*/
|
*/
|
||||||
function ajouter_sondage($origin)
|
function ajouter_sondage($origin)
|
||||||
{
|
{
|
||||||
global $conf, $db;
|
global $db;
|
||||||
|
|
||||||
$sondage=dol_survey_random(16);
|
$sondage=dol_survey_random(16);
|
||||||
|
|
||||||
@ -255,13 +255,14 @@ function ajouter_sondage($origin)
|
|||||||
}
|
}
|
||||||
$canedit=empty($_SESSION['formatcanedit'])?'0':'1';
|
$canedit=empty($_SESSION['formatcanedit'])?'0':'1';
|
||||||
$allow_comments = empty($_SESSION['allow_comments']) ? 0 : 1;
|
$allow_comments = empty($_SESSION['allow_comments']) ? 0 : 1;
|
||||||
|
$allow_spy = empty($_SESSION['allow_spy']) ? 0 : 1;
|
||||||
|
|
||||||
// Insert survey
|
// Insert survey
|
||||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_sondage';
|
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_sondage';
|
||||||
$sql.= '(id_sondage, commentaires, mail_admin, nom_admin, titre, date_fin, format, mailsonde, canedit, allow_comments, origin, sujet)';
|
$sql.= '(id_sondage, commentaires, mail_admin, nom_admin, titre, date_fin, format, mailsonde, canedit, allow_comments, allow_spy, origin, sujet)';
|
||||||
$sql.= " VALUES ('".$db->escape($sondage)."', '".$db->escape($_SESSION['commentaires'])."', '".$db->escape($_SESSION['adresse'])."', '".$db->escape($_SESSION['nom'])."',";
|
$sql.= " VALUES ('".$db->escape($sondage)."', '".$db->escape($_SESSION['commentaires'])."', '".$db->escape($_SESSION['adresse'])."', '".$db->escape($_SESSION['nom'])."',";
|
||||||
$sql.= " '".$db->escape($_SESSION['titre'])."', '".$db->idate($date_fin)."', '".$_SESSION['formatsondage']."', '".$db->escape($_SESSION['mailsonde'])."',";
|
$sql.= " '".$db->escape($_SESSION['titre'])."', '".$db->idate($date_fin)."', '".$_SESSION['formatsondage']."', '".$db->escape($_SESSION['mailsonde'])."',";
|
||||||
$sql.= " '".$canedit."', '".$allow_comments."', '".$db->escape($origin)."',";
|
$sql.= " '".$canedit."', '".$allow_comments."', '".$allow_spy."', '".$db->escape($origin)."',";
|
||||||
$sql.= " '".$db->escape($_SESSION['toutchoix'])."'";
|
$sql.= " '".$db->escape($_SESSION['toutchoix'])."'";
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
dol_syslog($sql);
|
dol_syslog($sql);
|
||||||
@ -289,6 +290,7 @@ function ajouter_sondage($origin)
|
|||||||
unset($_SESSION["canedit"]);
|
unset($_SESSION["canedit"]);
|
||||||
unset($_SESSION["mailsonde"]);
|
unset($_SESSION["mailsonde"]);
|
||||||
unset($_SESSION['allow_comments']);
|
unset($_SESSION['allow_comments']);
|
||||||
|
unset($_SESSION['allow_spy']);
|
||||||
|
|
||||||
header("Location: ".$urlback);
|
header("Location: ".$urlback);
|
||||||
exit();
|
exit();
|
||||||
|
|||||||
@ -80,6 +80,12 @@ if (GETPOST("creation_sondage_date") || GETPOST("creation_sondage_autre") || GET
|
|||||||
} else {
|
} else {
|
||||||
$_SESSION['allow_comments'] = false;
|
$_SESSION['allow_comments'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GETPOST('allow_spy') == 'on') {
|
||||||
|
$_SESSION['allow_spy'] = true;
|
||||||
|
} else {
|
||||||
|
$_SESSION['allow_spy'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (! isValidEmail($adresse)) $erreur_adresse = true;
|
if (! isValidEmail($adresse)) $erreur_adresse = true;
|
||||||
|
|
||||||
@ -182,6 +188,10 @@ if ($_SESSION['allow_comments']) $allow_comments = "checked";
|
|||||||
|
|
||||||
print '<input type="checkbox" name="allow_comments" '.$allow_comments.'> '.$langs->trans('CanComment').'<br />'."\n";
|
print '<input type="checkbox" name="allow_comments" '.$allow_comments.'> '.$langs->trans('CanComment').'<br />'."\n";
|
||||||
|
|
||||||
|
if ($_SESSION['allow_spy']) $allow_spy = "checked";
|
||||||
|
|
||||||
|
print '<input type="checkbox" name="allow_spy" '.$allow_spy.'> '.$langs->trans('CanSeeOthersVote').'<br />'."\n";
|
||||||
|
|
||||||
if (GETPOST('choix_sondage'))
|
if (GETPOST('choix_sondage'))
|
||||||
{
|
{
|
||||||
if (GETPOST('choix_sondage') == 'date') print '<input type="hidden" name="creation_sondage_date" value="date">';
|
if (GETPOST('choix_sondage') == 'date') print '<input type="hidden" name="creation_sondage_date" value="date">';
|
||||||
|
|||||||
@ -365,108 +365,44 @@ else
|
|||||||
|
|
||||||
|
|
||||||
// Loop on each answer
|
// Loop on each answer
|
||||||
$sumfor = array();
|
if ($object->allow_spy) {
|
||||||
$sumagainst = array();
|
$sumfor = array();
|
||||||
$compteur = 0;
|
$sumagainst = array();
|
||||||
$sql ="SELECT id_users, nom, id_sondage, reponses";
|
$compteur = 0;
|
||||||
$sql.=" FROM ".MAIN_DB_PREFIX."opensurvey_user_studs";
|
$sql ="SELECT id_users, nom, id_sondage, reponses";
|
||||||
$sql.=" WHERE id_sondage = '".$db->escape($numsondage)."'";
|
$sql.=" FROM ".MAIN_DB_PREFIX."opensurvey_user_studs";
|
||||||
dol_syslog('sql='.$sql);
|
$sql.=" WHERE id_sondage = '".$db->escape($numsondage)."'";
|
||||||
$resql=$db->query($sql);
|
dol_syslog('sql='.$sql);
|
||||||
if (! $resql)
|
$resql=$db->query($sql);
|
||||||
{
|
if (! $resql)
|
||||||
dol_print_error($db);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$num=$db->num_rows($resql);
|
|
||||||
while ($compteur < $num)
|
|
||||||
{
|
|
||||||
$obj=$db->fetch_object($resql);
|
|
||||||
|
|
||||||
$ensemblereponses = $obj->reponses;
|
|
||||||
|
|
||||||
print '<tr>'."\n";
|
|
||||||
|
|
||||||
// ligne d'un usager pré-authentifié
|
|
||||||
$mod_ok = ($object->canedit || (! empty($nombase) && in_array($nombase, $listofvoters)));
|
|
||||||
|
|
||||||
// Name
|
|
||||||
$nombase=str_replace("°","'",$obj->nom);
|
|
||||||
print '<td class="nom">'.$nombase.'</td>'."\n";
|
|
||||||
|
|
||||||
// si la ligne n'est pas a changer, on affiche les données
|
|
||||||
if (! $testligneamodifier)
|
|
||||||
{
|
{
|
||||||
for ($i = 0; $i < $nbcolonnes; $i++)
|
dol_print_error($db);
|
||||||
{
|
exit;
|
||||||
$car = substr($ensemblereponses, $i, 1);
|
|
||||||
//print 'xx'.$i."-".$car.'-'.$listofanswers[$i]['format'].'zz';
|
|
||||||
|
|
||||||
if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst')))
|
|
||||||
{
|
|
||||||
if (((string) $car) == "1") print '<td class="ok">OK</td>'."\n";
|
|
||||||
else print '<td class="non">KO</td>'."\n";
|
|
||||||
// Total
|
|
||||||
if (! isset($sumfor[$i])) $sumfor[$i] = 0;
|
|
||||||
if (((string) $car) == "1") $sumfor[$i]++;
|
|
||||||
}
|
|
||||||
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
|
|
||||||
{
|
|
||||||
if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("Yes").'</td>'."\n";
|
|
||||||
else if (((string) $car) == "0") print '<td class="non">'.$langs->trans("No").'</td>'."\n";
|
|
||||||
else print '<td class="vide"> </td>'."\n";
|
|
||||||
// Total
|
|
||||||
if (! isset($sumfor[$i])) $sumfor[$i] = 0;
|
|
||||||
if (! isset($sumagainst[$i])) $sumagainst[$i] = 0;
|
|
||||||
if (((string) $car) == "1") $sumfor[$i]++;
|
|
||||||
if (((string) $car) == "0") $sumagainst[$i]++;
|
|
||||||
}
|
|
||||||
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
|
|
||||||
{
|
|
||||||
if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
|
|
||||||
else if (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
|
|
||||||
else print '<td class="vide"> </td>'."\n";
|
|
||||||
// Total
|
|
||||||
if (! isset($sumfor[$i])) $sumfor[$i] = 0;
|
|
||||||
if (! isset($sumagainst[$i])) $sumagainst[$i] = 0;
|
|
||||||
if (((string) $car) == "1") $sumfor[$i]++;
|
|
||||||
if (((string) $car) == "0") $sumagainst[$i]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
$num=$db->num_rows($resql);
|
||||||
|
while ($compteur < $num)
|
||||||
{
|
{
|
||||||
//sinon on remplace les choix de l'utilisateur par une ligne de checkbox pour recuperer de nouvelles valeurs
|
$obj=$db->fetch_object($resql);
|
||||||
if ($compteur == $ligneamodifier)
|
|
||||||
{
|
$ensemblereponses = $obj->reponses;
|
||||||
for ($i = 0; $i < $nbcolonnes; $i++)
|
|
||||||
{
|
print '<tr>'."\n";
|
||||||
$car = substr($ensemblereponses, $i, 1);
|
|
||||||
print '<td class="vide">';
|
// ligne d'un usager pré-authentifié
|
||||||
if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst')))
|
$mod_ok = ($object->canedit || (! empty($nombase) && in_array($nombase, $listofvoters)));
|
||||||
{
|
|
||||||
print '<input type="checkbox" name="choix'.$i.'" value="1" ';
|
// Name
|
||||||
if ($car == '1') print 'checked="checked"';
|
$nombase=str_replace("°","'",$obj->nom);
|
||||||
print '>';
|
print '<td class="nom">'.$nombase.'</td>'."\n";
|
||||||
}
|
|
||||||
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
|
// si la ligne n'est pas a changer, on affiche les données
|
||||||
{
|
if (! $testligneamodifier)
|
||||||
$arraychoice=array('2'=>' ','0'=>$langs->trans("No"),'1'=>$langs->trans("Yes"));
|
|
||||||
print $form->selectarray("choix".$i, $arraychoice, $car);
|
|
||||||
}
|
|
||||||
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
|
|
||||||
{
|
|
||||||
$arraychoice=array('2'=>' ','0'=>$langs->trans("Against"),'1'=>$langs->trans("For"));
|
|
||||||
print $form->selectarray("choix".$i, $arraychoice, $car);
|
|
||||||
}
|
|
||||||
print '</td>'."\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
for ($i = 0; $i < $nbcolonnes; $i++)
|
for ($i = 0; $i < $nbcolonnes; $i++)
|
||||||
{
|
{
|
||||||
$car = substr($ensemblereponses, $i, 1);
|
$car = substr($ensemblereponses, $i, 1);
|
||||||
|
//print 'xx'.$i."-".$car.'-'.$listofanswers[$i]['format'].'zz';
|
||||||
|
|
||||||
if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst')))
|
if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst')))
|
||||||
{
|
{
|
||||||
if (((string) $car) == "1") print '<td class="ok">OK</td>'."\n";
|
if (((string) $car) == "1") print '<td class="ok">OK</td>'."\n";
|
||||||
@ -477,8 +413,8 @@ while ($compteur < $num)
|
|||||||
}
|
}
|
||||||
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
|
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
|
||||||
{
|
{
|
||||||
if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
|
if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("Yes").'</td>'."\n";
|
||||||
else if (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
|
else if (((string) $car) == "0") print '<td class="non">'.$langs->trans("No").'</td>'."\n";
|
||||||
else print '<td class="vide"> </td>'."\n";
|
else print '<td class="vide"> </td>'."\n";
|
||||||
// Total
|
// Total
|
||||||
if (! isset($sumfor[$i])) $sumfor[$i] = 0;
|
if (! isset($sumfor[$i])) $sumfor[$i] = 0;
|
||||||
@ -499,31 +435,97 @@ while ($compteur < $num)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
// Button edit at end of line
|
|
||||||
if ($compteur != $ligneamodifier && $mod_ok)
|
|
||||||
{
|
|
||||||
print '<td class="casevide"><input type="submit" class="button" name="modifierligne'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Edit")).'"></td>'."\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
//demande de confirmation pour modification de ligne
|
|
||||||
for ($i=0; $i<$nblignes; $i++)
|
|
||||||
{
|
|
||||||
if (isset($_POST["modifierligne".$i]))
|
|
||||||
{
|
{
|
||||||
if ($compteur == $i)
|
//sinon on remplace les choix de l'utilisateur par une ligne de checkbox pour recuperer de nouvelles valeurs
|
||||||
|
if ($compteur == $ligneamodifier)
|
||||||
{
|
{
|
||||||
print '<td class="casevide">';
|
for ($i = 0; $i < $nbcolonnes; $i++)
|
||||||
print '<input type="hidden" name="idtomodify'.$compteur.'" value="'.$obj->id_users.'">';
|
{
|
||||||
print '<input type="submit" class="button" name="validermodifier'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
|
$car = substr($ensemblereponses, $i, 1);
|
||||||
print '</td>'."\n";
|
print '<td class="vide">';
|
||||||
|
if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst')))
|
||||||
|
{
|
||||||
|
print '<input type="checkbox" name="choix'.$i.'" value="1" ';
|
||||||
|
if ($car == '1') print 'checked="checked"';
|
||||||
|
print '>';
|
||||||
|
}
|
||||||
|
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
|
||||||
|
{
|
||||||
|
$arraychoice=array('2'=>' ','0'=>$langs->trans("No"),'1'=>$langs->trans("Yes"));
|
||||||
|
print $form->selectarray("choix".$i, $arraychoice, $car);
|
||||||
|
}
|
||||||
|
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
|
||||||
|
{
|
||||||
|
$arraychoice=array('2'=>' ','0'=>$langs->trans("Against"),'1'=>$langs->trans("For"));
|
||||||
|
print $form->selectarray("choix".$i, $arraychoice, $car);
|
||||||
|
}
|
||||||
|
print '</td>'."\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for ($i = 0; $i < $nbcolonnes; $i++)
|
||||||
|
{
|
||||||
|
$car = substr($ensemblereponses, $i, 1);
|
||||||
|
if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst')))
|
||||||
|
{
|
||||||
|
if (((string) $car) == "1") print '<td class="ok">OK</td>'."\n";
|
||||||
|
else print '<td class="non">KO</td>'."\n";
|
||||||
|
// Total
|
||||||
|
if (! isset($sumfor[$i])) $sumfor[$i] = 0;
|
||||||
|
if (((string) $car) == "1") $sumfor[$i]++;
|
||||||
|
}
|
||||||
|
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
|
||||||
|
{
|
||||||
|
if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
|
||||||
|
else if (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
|
||||||
|
else print '<td class="vide"> </td>'."\n";
|
||||||
|
// Total
|
||||||
|
if (! isset($sumfor[$i])) $sumfor[$i] = 0;
|
||||||
|
if (! isset($sumagainst[$i])) $sumagainst[$i] = 0;
|
||||||
|
if (((string) $car) == "1") $sumfor[$i]++;
|
||||||
|
if (((string) $car) == "0") $sumagainst[$i]++;
|
||||||
|
}
|
||||||
|
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
|
||||||
|
{
|
||||||
|
if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
|
||||||
|
else if (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
|
||||||
|
else print '<td class="vide"> </td>'."\n";
|
||||||
|
// Total
|
||||||
|
if (! isset($sumfor[$i])) $sumfor[$i] = 0;
|
||||||
|
if (! isset($sumagainst[$i])) $sumagainst[$i] = 0;
|
||||||
|
if (((string) $car) == "1") $sumfor[$i]++;
|
||||||
|
if (((string) $car) == "0") $sumagainst[$i]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$compteur++;
|
// Button edit at end of line
|
||||||
print '</tr>'."\n";
|
if ($compteur != $ligneamodifier && $mod_ok)
|
||||||
|
{
|
||||||
|
print '<td class="casevide"><input type="submit" class="button" name="modifierligne'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Edit")).'"></td>'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
//demande de confirmation pour modification de ligne
|
||||||
|
for ($i=0; $i<$nblignes; $i++)
|
||||||
|
{
|
||||||
|
if (isset($_POST["modifierligne".$i]))
|
||||||
|
{
|
||||||
|
if ($compteur == $i)
|
||||||
|
{
|
||||||
|
print '<td class="casevide">';
|
||||||
|
print '<input type="hidden" name="idtomodify'.$compteur.'" value="'.$obj->id_users.'">';
|
||||||
|
print '<input type="submit" class="button" name="validermodifier'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
|
||||||
|
print '</td>'."\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$compteur++;
|
||||||
|
print '</tr>'."\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add line to add new record
|
// Add line to add new record
|
||||||
@ -589,39 +591,41 @@ for ($i=0; $i < $nbcolonnes; $i++)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show line total
|
if ($object->allow_spy) {
|
||||||
print '<tr>'."\n";
|
// Show line total
|
||||||
print '<td align="center">'. $langs->trans("Total") .'</td>'."\n";
|
|
||||||
for ($i = 0; $i < $nbcolonnes; $i++)
|
|
||||||
{
|
|
||||||
$showsumfor = isset($sumfor[$i])?$sumfor[$i]:'';
|
|
||||||
$showsumagainst = isset($sumagainst[$i])?$sumagainst[$i]:'';
|
|
||||||
if (empty($showsumfor)) $showsumfor = 0;
|
|
||||||
if (empty($showsumagainst)) $showsumagainst = 0;
|
|
||||||
|
|
||||||
print '<td>';
|
|
||||||
if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst'))) print $showsumfor;
|
|
||||||
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') print $langs->trans("Yes").': '.$showsumfor.'<br>'.$langs->trans("No").': '.$showsumagainst;
|
|
||||||
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') print $langs->trans("For").': '.$showsumfor.'<br>'.$langs->trans("Against").': '.$showsumagainst;
|
|
||||||
print '</td>'."\n";
|
|
||||||
}
|
|
||||||
print '</tr>';
|
|
||||||
// Show picto winner
|
|
||||||
if ($nbofcheckbox >= 2)
|
|
||||||
{
|
|
||||||
print '<tr>'."\n";
|
print '<tr>'."\n";
|
||||||
print '<td class="somme"></td>'."\n";
|
print '<td align="center">'. $langs->trans("Total") .'</td>'."\n";
|
||||||
for ($i=0; $i < $nbcolonnes; $i++)
|
for ($i = 0; $i < $nbcolonnes; $i++)
|
||||||
{
|
{
|
||||||
//print 'xx'.(! empty($listofanswers[$i]['format'])).'-'.$sumfor[$i].'-'.$meilleurecolonne;
|
$showsumfor = isset($sumfor[$i])?$sumfor[$i]:'';
|
||||||
if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne)
|
$showsumagainst = isset($sumagainst[$i])?$sumagainst[$i]:'';
|
||||||
{
|
if (empty($showsumfor)) $showsumfor = 0;
|
||||||
print '<td class="somme"><img src="'.dol_buildpath('/opensurvey/img/medaille.png',1).'"></td>'."\n";
|
if (empty($showsumagainst)) $showsumagainst = 0;
|
||||||
} else {
|
|
||||||
print '<td class="somme"></td>'."\n";
|
print '<td>';
|
||||||
}
|
if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst'))) print $showsumfor;
|
||||||
|
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') print $langs->trans("Yes").': '.$showsumfor.'<br>'.$langs->trans("No").': '.$showsumagainst;
|
||||||
|
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') print $langs->trans("For").': '.$showsumfor.'<br>'.$langs->trans("Against").': '.$showsumagainst;
|
||||||
|
print '</td>'."\n";
|
||||||
|
}
|
||||||
|
print '</tr>';
|
||||||
|
// Show picto winner
|
||||||
|
if ($nbofcheckbox >= 2)
|
||||||
|
{
|
||||||
|
print '<tr>'."\n";
|
||||||
|
print '<td class="somme"></td>'."\n";
|
||||||
|
for ($i=0; $i < $nbcolonnes; $i++)
|
||||||
|
{
|
||||||
|
//print 'xx'.(! empty($listofanswers[$i]['format'])).'-'.$sumfor[$i].'-'.$meilleurecolonne;
|
||||||
|
if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne)
|
||||||
|
{
|
||||||
|
print '<td class="somme"><img src="'.dol_buildpath('/opensurvey/img/medaille.png',1).'"></td>'."\n";
|
||||||
|
} else {
|
||||||
|
print '<td class="somme"></td>'."\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print '</tr>'."\n";
|
||||||
}
|
}
|
||||||
print '</tr>'."\n";
|
|
||||||
}
|
}
|
||||||
print '</table>'."\n";
|
print '</table>'."\n";
|
||||||
print '</div>'."\n";
|
print '</div>'."\n";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user