Removed all old code. All orignal code has been rewritten now.
This commit is contained in:
parent
473fbf2c33
commit
e24fb9f48a
@ -39,7 +39,9 @@ $numsondageadmin=GETPOST("sondage");
|
|||||||
$numsondage=substr($numsondageadmin, 0, 16);
|
$numsondage=substr($numsondageadmin, 0, 16);
|
||||||
|
|
||||||
$object=new Opensurveysondage($db);
|
$object=new Opensurveysondage($db);
|
||||||
$object->fetch(0,$numsondageadmin);
|
$result=$object->fetch(0,$numsondage);
|
||||||
|
if ($result <= 0) dol_print_error('','Failed to get survey id '.$numsondage);
|
||||||
|
|
||||||
$nblignes=count($object->fetch_lines());
|
$nblignes=count($object->fetch_lines());
|
||||||
|
|
||||||
|
|
||||||
@ -587,7 +589,7 @@ print '<input type="hidden" name="sondage" value="'.$numsondageadmin.'">';
|
|||||||
print '<div class="cadre"> '."\n";
|
print '<div class="cadre"> '."\n";
|
||||||
print '<br>'."\n";
|
print '<br>'."\n";
|
||||||
|
|
||||||
//debut de l'affichage de résultats
|
// Start to show survey result
|
||||||
print '<table class="resultats">'."\n";
|
print '<table class="resultats">'."\n";
|
||||||
|
|
||||||
//reformatage des données des sujets du sondage
|
//reformatage des données des sujets du sondage
|
||||||
@ -863,14 +865,14 @@ while ($compteur < $num)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//a la fin de chaque ligne se trouve les boutons modifier
|
// Button edit at end of line
|
||||||
if ($compteur != $ligneamodifier)
|
if ($compteur != $ligneamodifier)
|
||||||
{
|
{
|
||||||
print '<td class="casevide"><input type="submit" class="button" name="modifierligne'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Edit")).'"></td>'."\n";
|
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
|
//demande de confirmation pour modification de ligne
|
||||||
for ($i = 0; $i < $nblignes; $i++)
|
for ($i=0; $i<$nblignes; $i++)
|
||||||
{
|
{
|
||||||
if (isset($_POST["modifierligne".$i]))
|
if (isset($_POST["modifierligne".$i]))
|
||||||
{
|
{
|
||||||
@ -935,10 +937,12 @@ for ($i=0; $i < $nbcolonnes + 1; $i++)
|
|||||||
$nbofcheckbox++;
|
$nbofcheckbox++;
|
||||||
if (isset($sumfor[$i]))
|
if (isset($sumfor[$i]))
|
||||||
{
|
{
|
||||||
if ($i == 0) {
|
if ($i == 0)
|
||||||
|
{
|
||||||
$meilleurecolonne = $sumfor[$i];
|
$meilleurecolonne = $sumfor[$i];
|
||||||
}
|
}
|
||||||
if (isset($sumfor[$i]) && $sumfor[$i] > $meilleurecolonne){
|
if (isset($sumfor[$i]) && $sumfor[$i] > $meilleurecolonne)
|
||||||
|
{
|
||||||
$meilleurecolonne = $sumfor[$i];
|
$meilleurecolonne = $sumfor[$i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1015,7 +1019,7 @@ $toutsujet = explode(",", $object->sujet);
|
|||||||
$compteursujet = 0;
|
$compteursujet = 0;
|
||||||
$meilleursujet = '';
|
$meilleursujet = '';
|
||||||
for ($i = 0; $i < $nbcolonnes; $i++) {
|
for ($i = 0; $i < $nbcolonnes; $i++) {
|
||||||
if (isset($sumfor[$i]) === true && isset($meilleurecolonne) === true && $sumfor[$i] == $meilleurecolonne){
|
if (isset($sumfor[$i]) === true && isset($meilleurecolonne) === true && $sumfor[$i] == $meilleurecolonne) {
|
||||||
$meilleursujet.=", ";
|
$meilleursujet.=", ";
|
||||||
|
|
||||||
if ($object->format == "D" || $object->format == "D+") {
|
if ($object->format == "D" || $object->format == "D+") {
|
||||||
@ -1038,7 +1042,6 @@ for ($i = 0; $i < $nbcolonnes; $i++) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//adaptation pour affichage des valeurs
|
|
||||||
$meilleursujet = substr("$meilleursujet", 1);
|
$meilleursujet = substr("$meilleursujet", 1);
|
||||||
$meilleursujet = str_replace("°", "'", $meilleursujet);
|
$meilleursujet = str_replace("°", "'", $meilleursujet);
|
||||||
|
|
||||||
@ -1046,18 +1049,20 @@ $meilleursujet = str_replace("°", "'", $meilleursujet);
|
|||||||
if ($nbofcheckbox >= 2)
|
if ($nbofcheckbox >= 2)
|
||||||
{
|
{
|
||||||
$vote_str = $langs->trans('votes');
|
$vote_str = $langs->trans('votes');
|
||||||
print '<p class=affichageresultats>'."\n";
|
print '<p class="affichageresultats">'."\n";
|
||||||
|
|
||||||
if (isset($meilleurecolonne) && $compteursujet == "1") {
|
if (isset($meilleurecolonne) && $compteursujet == "1") {
|
||||||
print "<img src=\"".dol_buildpath('/opensurvey/img/medaille.png',1)."\"> " . $langs->trans('TheBestChoice') . " : <b>$meilleursujet </b>" . $langs->trans("with") . " <b>$meilleurecolonne </b>" . $vote_str . ".<br>\n";
|
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";
|
||||||
} elseif (isset($meilleurecolonne)) {
|
} elseif (isset($meilleurecolonne)) {
|
||||||
print "<img src=\"".dol_buildpath('/opensurvey/img/medaille.png',1)."\"> " . $langs->trans('TheBestChoices') . " : <b>$meilleursujet </b>" . $langs->trans("with") . " <b>$meilleurecolonne </b>" . $vote_str . ".<br>\n";
|
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";
|
||||||
}
|
}
|
||||||
print '</p><br>'."\n";
|
print '<br></p><br>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</form>'."\n";
|
print '</form>'."\n";
|
||||||
|
|
||||||
|
print '<a name="bas"></a>'."\n";
|
||||||
|
|
||||||
llxFooterSurvey();
|
llxFooterSurvey();
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|||||||
@ -51,15 +51,15 @@ $object=new Opensurveysondage($db);
|
|||||||
$result=$object->fetch(0,$numsondage);
|
$result=$object->fetch(0,$numsondage);
|
||||||
if ($result <= 0) dol_print_error('','Failed to get survey id '.$numsondage);
|
if ($result <= 0) dol_print_error('','Failed to get survey id '.$numsondage);
|
||||||
|
|
||||||
|
$nblignes=count($object->fetch_lines());
|
||||||
$nbcolonnes = substr_count($object->sujet, ',') + 1;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$nbcolonnes = substr_count($object->sujet, ',') + 1;
|
||||||
|
|
||||||
$listofvoters=explode(',',$_SESSION["savevoter"]);
|
$listofvoters=explode(',',$_SESSION["savevoter"]);
|
||||||
|
|
||||||
// Add comment
|
// Add comment
|
||||||
@ -162,22 +162,22 @@ if (isset($_POST["boutonp"]) || isset($_POST["boutonp_x"]))
|
|||||||
|
|
||||||
|
|
||||||
// Update vote
|
// Update vote
|
||||||
$sql = 'SELECT * FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs WHERE id_sondage='.$connect->Param('numsondage').' ORDER BY id_users';
|
|
||||||
$sql = $connect->Prepare($sql);
|
|
||||||
$user_studs = $connect->Execute($sql, array($numsondage));
|
|
||||||
$nblignes = $user_studs->RecordCount();
|
|
||||||
$testmodifier = false;
|
$testmodifier = false;
|
||||||
|
$testligneamodifier = false;
|
||||||
$ligneamodifier = -1;
|
$ligneamodifier = -1;
|
||||||
for ($i=0; $i<$nblignes; $i++)
|
for ($i=0; $i<$nblignes; $i++)
|
||||||
{
|
{
|
||||||
if (isset($_POST['modifierligne'.$i])) {
|
if (isset($_POST['modifierligne'.$i]))
|
||||||
$ligneamodifier = $i;
|
{
|
||||||
|
$ligneamodifier=$i;
|
||||||
|
$testligneamodifier=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//test pour voir si une ligne est a modifier
|
//test pour voir si une ligne est a modifier
|
||||||
if (isset($_POST['validermodifier'.$i])) {
|
if (isset($_POST['validermodifier'.$i]))
|
||||||
$modifier = $i;
|
{
|
||||||
$testmodifier = true;
|
$modifier=$i;
|
||||||
|
$testmodifier=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,33 +200,16 @@ if ($testmodifier)
|
|||||||
$nouveauchoix.="0";
|
$nouveauchoix.="0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$idtomodify=$_POST["idtomodify".$modifier];
|
||||||
|
$sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_user_studs";
|
||||||
|
$sql.= " SET reponses = '".$db->escape($nouveauchoix)."'";
|
||||||
|
$sql.= " WHERE id_users = '".$db->escape($idtomodify)."'";
|
||||||
|
|
||||||
$compteur=0;
|
dol_syslog("sql=".$sql);
|
||||||
while ($data = $user_studs->FetchNextObject(false) )
|
$resql = $db->query($sql);
|
||||||
{
|
if (! $resql) dol_print_error($db);
|
||||||
if ($compteur == $modifier)
|
}
|
||||||
{
|
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_user_studs";
|
|
||||||
$sql.= " SET reponses = '".$db->escape($nouveauchoix)."'";
|
|
||||||
$sql.= " WHERE nom = '".$db->escape($data->nom)."' AND id_users = '".$db->escape($data->id_users)."'";
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
if ($resql <= 0)
|
|
||||||
{
|
|
||||||
dol_print_error($db);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($object->mailsonde=="yes")
|
|
||||||
{
|
|
||||||
// TODO Use CMailFile
|
|
||||||
//$headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit";
|
|
||||||
//mail ("$object->mail_admin", "[".NOMAPPLICATION."] " . _("Poll's participation") . " : $object->titre", "\"$data->nom\""."" . _("has filled a line.\nYou can find your poll at the link") . " :\n\n".getUrlSondage($numsondage)." \n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,$headers);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$compteur++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete comment
|
// Delete comment
|
||||||
$idcomment=GETPOST('deletecomment','int');
|
$idcomment=GETPOST('deletecomment','int');
|
||||||
@ -245,30 +228,30 @@ if ($idcomment)
|
|||||||
$form=new Form($db);
|
$form=new Form($db);
|
||||||
$object=new OpenSurveySondage($db);
|
$object=new OpenSurveySondage($db);
|
||||||
|
|
||||||
|
$result=$object->fetch(0,$numsondage);
|
||||||
|
if ($result <= 0)
|
||||||
|
{
|
||||||
|
print $langs->trans("ErrorRecordNotFound");
|
||||||
|
llxFooterSurvey();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
$arrayofjs=array();
|
$arrayofjs=array();
|
||||||
$arrayofcss=array('/opensurvey/css/style.css');
|
$arrayofcss=array('/opensurvey/css/style.css');
|
||||||
llxHeaderSurvey($object->titre, "", 0, 0, $arrayofjs, $arrayofcss);
|
llxHeaderSurvey($object->titre, "", 0, 0, $arrayofjs, $arrayofcss);
|
||||||
|
|
||||||
$res=$object->fetch(0,$numsondage);
|
|
||||||
|
|
||||||
if ($res <= 0)
|
|
||||||
{
|
|
||||||
print $langs->trans("ErrorPollDoesNotExists",$numsondage);
|
|
||||||
llxFooterSurvey();
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define format of choices
|
// Define format of choices
|
||||||
$toutsujet=explode(",",$object->sujet);
|
$toutsujet=explode(",",$object->sujet);
|
||||||
|
$listofanswers=array();
|
||||||
|
foreach ($toutsujet as $value)
|
||||||
|
{
|
||||||
|
$tmp=explode('@',$value);
|
||||||
|
$listofanswers[]=array('label'=>$tmp[0],'format'=>($tmp[1]?$tmp[1]:'checkbox'));
|
||||||
|
}
|
||||||
|
$toutsujet=str_replace("@","<br>",$toutsujet);
|
||||||
$toutsujet=str_replace("°","'",$toutsujet);
|
$toutsujet=str_replace("°","'",$toutsujet);
|
||||||
|
|
||||||
$listofanswers=array();
|
|
||||||
foreach ($toutsujet as $value)
|
|
||||||
{
|
|
||||||
$tmp=explode('@',$value);
|
|
||||||
$listofanswers[]=array('label'=>$tmp[0],'format'=>($tmp[1]?$tmp[1]:'checkbox'));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
print '<div class="survey_invitation">'.$langs->trans("YouAreInivitedToVote").'</div>';
|
print '<div class="survey_invitation">'.$langs->trans("YouAreInivitedToVote").'</div>';
|
||||||
print $langs->trans("OpenSurveyHowTo").'<br><br>';
|
print $langs->trans("OpenSurveyHowTo").'<br><br>';
|
||||||
@ -283,7 +266,8 @@ print '<strong>'.$titre.'</strong><br>'."\n";
|
|||||||
print $langs->trans("InitiatorOfPoll") .' : '.$object->nom_admin.'<br>'."\n";
|
print $langs->trans("InitiatorOfPoll") .' : '.$object->nom_admin.'<br>'."\n";
|
||||||
|
|
||||||
//affichage des commentaires du sondage
|
//affichage des commentaires du sondage
|
||||||
if ($object->commentaires) {
|
if ($object->commentaires)
|
||||||
|
{
|
||||||
print '<br>'.$langs->trans("Description") .' :<br>'."\n";
|
print '<br>'.$langs->trans("Description") .' :<br>'."\n";
|
||||||
$commentaires=dol_nl2br($object->commentaires);
|
$commentaires=dol_nl2br($object->commentaires);
|
||||||
print $commentaires;
|
print $commentaires;
|
||||||
@ -294,19 +278,14 @@ print '</div>'."\n";
|
|||||||
|
|
||||||
print '<form name="formulaire" action="studs.php?sondage='.$numsondage.'"'.'#bas" method="POST" onkeypress="javascript:process_keypress(event)">'."\n";
|
print '<form name="formulaire" action="studs.php?sondage='.$numsondage.'"'.'#bas" method="POST" onkeypress="javascript:process_keypress(event)">'."\n";
|
||||||
print '<input type="hidden" name="sondage" value="' . $numsondage . '"/>';
|
print '<input type="hidden" name="sondage" value="' . $numsondage . '"/>';
|
||||||
// Todo : add CSRF protection
|
|
||||||
print '<div class="cadre"> '."\n";
|
print '<div class="cadre"> '."\n";
|
||||||
print '<br><br>'."\n";
|
print '<br><br>'."\n";
|
||||||
|
|
||||||
// Debut de l'affichage des resultats du sondage
|
// Start to show survey result
|
||||||
print '<table class="resultats">'."\n";
|
print '<table class="resultats">'."\n";
|
||||||
|
|
||||||
//recuperation des utilisateurs du sondage
|
// Show choice titles
|
||||||
$sql = 'SELECT * FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs WHERE id_sondage='.$connect->Param('numsondage').' ORDER BY id_users';
|
|
||||||
$sql = $connect->Prepare($sql);
|
|
||||||
$user_studs = $connect->Execute($sql, array($numsondage));
|
|
||||||
|
|
||||||
//si le sondage est un sondage de date
|
|
||||||
if ($object->format=="D"||$object->format=="D+")
|
if ($object->format=="D"||$object->format=="D+")
|
||||||
{
|
{
|
||||||
//affichage des sujets du sondage
|
//affichage des sujets du sondage
|
||||||
@ -410,15 +389,22 @@ else
|
|||||||
$sumfor = array();
|
$sumfor = array();
|
||||||
$sumagainst = array();
|
$sumagainst = array();
|
||||||
$compteur = 0;
|
$compteur = 0;
|
||||||
|
$sql ="SELECT id_users, nom, id_sondage, reponses";
|
||||||
$sql = 'SELECT * FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs WHERE id_sondage='.$connect->Param('numsondage').' ORDER BY id_users';
|
$sql.=" FROM ".MAIN_DB_PREFIX."opensurvey_user_studs";
|
||||||
$sql = $connect->Prepare($sql);
|
$sql.=" WHERE id_sondage = '".$db->escape($numsondage)."'";
|
||||||
$user_studs = $connect->Execute($sql, array($numsondage));
|
dol_syslog('sql='.$sql);
|
||||||
|
$resql=$db->query($sql);
|
||||||
while ($data = $user_studs->FetchNextObject(false))
|
if (! $resql)
|
||||||
{
|
{
|
||||||
$ensemblereponses = $data->reponses;
|
dol_print_error($db);
|
||||||
$nombase=str_replace("°","'",$data->nom);
|
exit;
|
||||||
|
}
|
||||||
|
$num=$db->num_rows($resql);
|
||||||
|
while ($compteur < $num)
|
||||||
|
{
|
||||||
|
$obj=$db->fetch_object($resql);
|
||||||
|
|
||||||
|
$ensemblereponses = $obj->reponses;
|
||||||
|
|
||||||
print '<tr>'."\n";
|
print '<tr>'."\n";
|
||||||
|
|
||||||
@ -426,41 +412,23 @@ while ($data = $user_studs->FetchNextObject(false))
|
|||||||
$mod_ok = ($object->canedit || (! empty($nombase) && in_array($nombase, $listofvoters)));
|
$mod_ok = ($object->canedit || (! empty($nombase) && in_array($nombase, $listofvoters)));
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
|
$nombase=str_replace("°","'",$obj->nom);
|
||||||
print '<td class="nom">'.$nombase.'</td>'."\n";
|
print '<td class="nom">'.$nombase.'</td>'."\n";
|
||||||
|
|
||||||
// pour chaque colonne
|
// si la ligne n'est pas a changer, on affiche les données
|
||||||
for ($i=0; $i < $nbcolonnes; $i++)
|
if (! $testligneamodifier)
|
||||||
{
|
{
|
||||||
$car = substr($ensemblereponses, $i, 1);
|
for ($i = 0; $i < $nbcolonnes; $i++)
|
||||||
if ($compteur == $ligneamodifier)
|
|
||||||
{
|
|
||||||
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 (((string) $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
|
|
||||||
{
|
{
|
||||||
|
$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";
|
||||||
else print '<td class="non">KO</td>'."\n";
|
else print '<td class="non">KO</td>'."\n";
|
||||||
// Total
|
// Total
|
||||||
if (isset($sumfor[$i]) === false) $sumfor[$i] = 0;
|
if (! isset($sumfor[$i])) $sumfor[$i] = 0;
|
||||||
if (((string) $car) == "1") $sumfor[$i]++;
|
if (((string) $car) == "1") $sumfor[$i]++;
|
||||||
}
|
}
|
||||||
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
|
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
|
||||||
@ -476,9 +444,9 @@ while ($data = $user_studs->FetchNextObject(false))
|
|||||||
}
|
}
|
||||||
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
|
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
|
||||||
{
|
{
|
||||||
if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
|
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 if (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</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;
|
||||||
if (! isset($sumagainst[$i])) $sumagainst[$i] = 0;
|
if (! isset($sumagainst[$i])) $sumagainst[$i] = 0;
|
||||||
@ -487,18 +455,90 @@ while ($data = $user_studs->FetchNextObject(false))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//sinon on remplace les choix de l'utilisateur par une ligne de checkbox pour recuperer de nouvelles valeurs
|
||||||
|
if ($compteur == $ligneamodifier)
|
||||||
|
{
|
||||||
|
for ($i = 0; $i < $nbcolonnes; $i++)
|
||||||
|
{
|
||||||
|
$car = substr($ensemblereponses, $i, 1);
|
||||||
|
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]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Button edit at end of line
|
// Button edit at end of line
|
||||||
if ($compteur != $ligneamodifier && $mod_ok)
|
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";
|
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
|
//demande de confirmation pour modification de ligne
|
||||||
for ($i=0;$i<$nblignes;$i++) {
|
for ($i=0; $i<$nblignes; $i++)
|
||||||
if (isset($_POST["modifierligne$i"])) {
|
{
|
||||||
if ($compteur == $i) {
|
if (isset($_POST["modifierligne".$i]))
|
||||||
print '<td class="casevide"><input type="submit" class="button" name="validermodifier'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Save")).'"></td>'."\n";
|
{
|
||||||
|
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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -547,7 +587,7 @@ if ($ligneamodifier < 0 && (! isset($_SESSION['nom'])))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Affichage du bouton de formulaire pour inscrire un nouvel utilisateur dans la base
|
// Affichage du bouton de formulaire pour inscrire un nouvel utilisateur dans la base
|
||||||
print '<td><input type="image" name="boutonp" value="' . $langs->trans('Vote') . '" src="'.dol_buildpath('/opensurvey/img/add-24.png',1).'"></td>'."\n";
|
print '<td><input type="image" name="boutonp" value="'.$langs->trans("Vote").'" src="'.dol_buildpath('/opensurvey/img/add-24.png',1).'"></td>'."\n";
|
||||||
print '</tr>'."\n";
|
print '</tr>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,7 +595,7 @@ if ($ligneamodifier < 0 && (! isset($_SESSION['nom'])))
|
|||||||
$nbofcheckbox=0;
|
$nbofcheckbox=0;
|
||||||
for ($i=0; $i < $nbcolonnes; $i++)
|
for ($i=0; $i < $nbcolonnes; $i++)
|
||||||
{
|
{
|
||||||
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] != 'checkbox') continue;
|
if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst')))
|
||||||
$nbofcheckbox++;
|
$nbofcheckbox++;
|
||||||
if (isset($sumfor[$i]))
|
if (isset($sumfor[$i]))
|
||||||
{
|
{
|
||||||
@ -571,7 +611,7 @@ for ($i=0; $i < $nbcolonnes; $i++)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show line total
|
// Show line total
|
||||||
print '<tr '.$bc[false].'>'."\n";
|
print '<tr>'."\n";
|
||||||
print '<td align="center">'. $langs->trans("Total") .'</td>'."\n";
|
print '<td align="center">'. $langs->trans("Total") .'</td>'."\n";
|
||||||
for ($i = 0; $i < $nbcolonnes; $i++)
|
for ($i = 0; $i < $nbcolonnes; $i++)
|
||||||
{
|
{
|
||||||
@ -587,7 +627,7 @@ for ($i = 0; $i < $nbcolonnes; $i++)
|
|||||||
print '</td>'."\n";
|
print '</td>'."\n";
|
||||||
}
|
}
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
// Show picto winnner
|
// Show picto winner
|
||||||
if ($nbofcheckbox >= 2)
|
if ($nbofcheckbox >= 2)
|
||||||
{
|
{
|
||||||
print '<tr>'."\n";
|
print '<tr>'."\n";
|
||||||
@ -595,7 +635,7 @@ if ($nbofcheckbox >= 2)
|
|||||||
for ($i=0; $i < $nbcolonnes; $i++)
|
for ($i=0; $i < $nbcolonnes; $i++)
|
||||||
{
|
{
|
||||||
//print 'xx'.(! empty($listofanswers[$i]['format'])).'-'.$sumfor[$i].'-'.$meilleurecolonne;
|
//print 'xx'.(! empty($listofanswers[$i]['format'])).'-'.$sumfor[$i].'-'.$meilleurecolonne;
|
||||||
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'checkbox' && isset($sumfor[$i]) && isset($meilleurecolonne) && $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";
|
print '<td class="somme"><img src="'.dol_buildpath('/opensurvey/img/medaille.png',1).'"></td>'."\n";
|
||||||
} else {
|
} else {
|
||||||
@ -625,7 +665,9 @@ for ($i = 0; $i < $nbcolonnes; $i++) {
|
|||||||
} else {
|
} else {
|
||||||
$meilleursujet .= dol_print_date($toutsujet[$i],'daytext'). ' ('.dol_print_date($toutsujet[$i],'%A').')';
|
$meilleursujet .= dol_print_date($toutsujet[$i],'daytext'). ' ('.dol_print_date($toutsujet[$i],'%A').')';
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$tmps=explode('@',$toutsujet[$i]);
|
$tmps=explode('@',$toutsujet[$i]);
|
||||||
$meilleursujet .= $tmps[0];
|
$meilleursujet .= $tmps[0];
|
||||||
}
|
}
|
||||||
@ -644,13 +686,13 @@ if ($nbofcheckbox >= 2)
|
|||||||
$vote_str = $langs->trans('votes');
|
$vote_str = $langs->trans('votes');
|
||||||
print '<p class="affichageresultats">'."\n";
|
print '<p class="affichageresultats">'."\n";
|
||||||
|
|
||||||
if ($compteursujet == "1" && isset($meilleurecolonne)) {
|
if (isset($meilleurecolonne) && $compteursujet == "1") {
|
||||||
print '<img src="images/medaille.png" alt="Meilleur choix"> ' . $langs->trans('TheBestChoice') . ": <b>$meilleursujet</b> " . $langs->trans('with') . " <b>$meilleurecolonne </b>" . $vote_str . ".\n";
|
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";
|
||||||
} elseif (isset($meilleurecolonne)) {
|
} elseif (isset($meilleurecolonne)) {
|
||||||
print '<img src="images/medaille.png" alt="Meilleur choix"> ' . $langs->trans('TheBestChoices') . ": <b>$meilleursujet</b> " . $langs->trans('with') . " <b>$meilleurecolonne </b>" . $vote_str . ".\n";
|
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";
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</p><br>';
|
print '</p><br>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
@ -685,8 +727,8 @@ print $langs->trans("Name") .' : ';
|
|||||||
print '<input type="text" name="commentuser" maxlength="64" /> '."\n";
|
print '<input type="text" name="commentuser" maxlength="64" /> '."\n";
|
||||||
print '<input type="submit" class="button" name="ajoutcomment" value="'.dol_escape_htmltag($langs->trans("AddComment")).'"><br>'."\n";
|
print '<input type="submit" class="button" name="ajoutcomment" value="'.dol_escape_htmltag($langs->trans("AddComment")).'"><br>'."\n";
|
||||||
print '</form>'."\n";
|
print '</form>'."\n";
|
||||||
// Focus javascript sur la case de texte du formulaire
|
|
||||||
print '</div>'."\n";
|
print '</div>'."\n"; // div add comment
|
||||||
|
|
||||||
print '<br><br>';
|
print '<br><br>';
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user