2022-09-21 14:47:18 +02:00
|
|
|
<?php
|
|
|
|
require_once '../session_init.php';
|
|
|
|
require_once 'config.inc.php';
|
|
|
|
require_once 'db.class.php';
|
|
|
|
require_once 'entete.php';
|
|
|
|
require_once 'fonctions.inc.php';
|
|
|
|
|
|
|
|
$path = $_SERVER["PHP_SELF"];
|
|
|
|
$db = new db();
|
|
|
|
|
|
|
|
function queryVotationName($db, $idVotation) :string
|
|
|
|
{
|
|
|
|
$query = "SELECT libelle FROM liste_votations WHERE id='" . $idVotation . "'";
|
|
|
|
$db->query($query);
|
|
|
|
$votationLine = $db->result->fetch_assoc();
|
|
|
|
return $votationLine["libelle"];
|
|
|
|
}
|
|
|
|
|
2022-09-21 21:12:49 +02:00
|
|
|
function queryVotes($db, $idVotation)
|
2022-09-21 21:05:44 +02:00
|
|
|
{
|
2022-09-25 15:24:43 +02:00
|
|
|
$query = "SELECT * FROM liste_votes LEFT JOIN methods ON liste_votes.methode=methods.id WHERE idVotation='" . $idVotation . "'";
|
2022-09-21 21:05:44 +02:00
|
|
|
$db->query($query);
|
2022-09-25 14:44:23 +02:00
|
|
|
$votes = $db->result->fetch_all();
|
2022-09-21 21:05:44 +02:00
|
|
|
return $votes;
|
|
|
|
}
|
|
|
|
|
2022-09-21 14:47:18 +02:00
|
|
|
$idVotation = getpost("id");
|
|
|
|
if (!empty($idVotation))
|
|
|
|
{
|
|
|
|
$_SESSION["idVotation"] = $idVotation;
|
|
|
|
$votationName = queryVotationName($db, $idVotation);
|
|
|
|
}elseif (array_key_exists("idVotation", $_SESSION))
|
|
|
|
{
|
|
|
|
if (!empty($_SESSION["idVotation"]))
|
|
|
|
{
|
|
|
|
$idVotation = $_SESSION["idVotation"];
|
|
|
|
$votationName = queryVotationName($db, $idVotation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print('<br><br>
|
|
|
|
<!-- lalis Grid Section -->
|
|
|
|
<section id="content">
|
|
|
|
<div class="container">') . EOL;
|
|
|
|
print(' <div class="row">
|
2022-09-21 21:05:44 +02:00
|
|
|
<div class="col-lg-12 text-center">');
|
|
|
|
$votes = queryVotes($db, $idVotation);
|
2022-09-21 21:12:49 +02:00
|
|
|
if (!empty($votes))
|
2022-09-21 21:05:44 +02:00
|
|
|
{
|
2022-09-21 21:12:49 +02:00
|
|
|
foreach ($votes as $value)
|
|
|
|
{
|
2022-09-25 15:16:08 +02:00
|
|
|
print ($value[1] . " " . $value[5] . EOLH);
|
2022-09-21 21:12:49 +02:00
|
|
|
}
|
2022-09-21 21:05:44 +02:00
|
|
|
echo EOLH . EOLH;
|
2022-09-21 21:12:49 +02:00
|
|
|
}
|
2022-09-21 21:05:44 +02:00
|
|
|
|
|
|
|
print(' <h3>Nouveau vote pour la votation');
|
2022-09-21 14:47:18 +02:00
|
|
|
|
|
|
|
if (empty($idVotation))
|
|
|
|
{
|
|
|
|
choixVotation($path, 0, false);
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
print(": " . $votationName . '</h3>' . EOL);
|
|
|
|
$method = getpost("method");
|
|
|
|
$libelle = getpost("libelle");
|
|
|
|
if (empty($method) or empty($libelle))
|
|
|
|
{
|
|
|
|
votesForm($path);
|
|
|
|
}else
|
|
|
|
{
|
2022-09-21 21:44:00 +02:00
|
|
|
$query = "INSERT INTO liste_votes VALUES (0, '" . $libelle . "', " . $method . "," . $idVotation . ")";
|
2022-09-21 21:05:44 +02:00
|
|
|
print($query);
|
|
|
|
$db->query($query);
|
2022-09-21 14:47:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$db->close();
|
|
|
|
|
|
|
|
print(' </div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>');
|
|
|
|
require_once("footer.html");
|
|
|
|
|
|
|
|
?>
|