added saisie votes et candidats
This commit is contained in:
parent
461cd822c3
commit
c699108e65
46
gestion/saisieCandidats.php
Normal file
46
gestion/saisieCandidats.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
|
||||||
|
<?php
|
||||||
|
require_once '../session_init.php';
|
||||||
|
require_once 'config.inc.php';
|
||||||
|
require_once 'db.class.php';
|
||||||
|
require_once 'fonctions.inc.php';
|
||||||
|
|
||||||
|
$path = $_SERVER["PHP_SELF"];
|
||||||
|
$db = new db();
|
||||||
|
|
||||||
|
$idVotation = getpost("idVotation");
|
||||||
|
$idVote = getpost("idVote");
|
||||||
|
$candidat = getpost("candidat");
|
||||||
|
|
||||||
|
if (!empty($idCandidat))
|
||||||
|
{
|
||||||
|
$query = "INSERT INTO liste_candidats VALUES (0, " . $idVotation . ", " . $idVote . ",'" . $candidat . "')";
|
||||||
|
$db->query($query);
|
||||||
|
header("Location: " . $$base_url . "/" . $path , TRUE, 301);
|
||||||
|
return;
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
require_once 'entete.php';
|
||||||
|
print('<br><br>
|
||||||
|
<!-- lalis Grid Section -->
|
||||||
|
<section id="content">
|
||||||
|
<div class="container">') . EOL;
|
||||||
|
print(' <div class="row">
|
||||||
|
<div class="col-lg-12 text-center">');
|
||||||
|
|
||||||
|
if (empty($idVotation))
|
||||||
|
{
|
||||||
|
choixVotation($path, 0, false);
|
||||||
|
}elseif (empty($idVote))
|
||||||
|
{
|
||||||
|
choixVote($path, $idVotation);
|
||||||
|
}
|
||||||
|
print(' </div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>');
|
||||||
|
require_once("footer.html");
|
||||||
|
}
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
?>;
|
@ -7,8 +7,6 @@ require_once 'fonctions.inc.php';
|
|||||||
$path = $_SERVER["PHP_SELF"];
|
$path = $_SERVER["PHP_SELF"];
|
||||||
$db = new db();
|
$db = new db();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$idVotation = getpost("id");
|
$idVotation = getpost("id");
|
||||||
$method = getpost("method");
|
$method = getpost("method");
|
||||||
$libelle = getpost("libelle");
|
$libelle = getpost("libelle");
|
||||||
|
@ -113,20 +113,44 @@ class dbcore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function queryVotationName($db, $idVotation) :string
|
function queryVoteName($idVote)
|
||||||
|
{
|
||||||
|
$query = "SELECT libelle FROM liste_votes where id='" . $idVote . "'";
|
||||||
|
$this->query($query);
|
||||||
|
$voteLine = $this->result->fetch_assoc();
|
||||||
|
return $voteLine["libelle"];
|
||||||
|
}
|
||||||
|
|
||||||
|
function queryVotationName($idVotation) :string
|
||||||
{
|
{
|
||||||
$query = "SELECT libelle FROM liste_votations WHERE id='" . $idVotation . "'";
|
$query = "SELECT libelle FROM liste_votations WHERE id='" . $idVotation . "'";
|
||||||
$db->query($query);
|
$this->query($query);
|
||||||
$votationLine = $db->result->fetch_assoc();
|
$votationLine = $this->result->fetch_assoc();
|
||||||
return $votationLine["libelle"];
|
return $votationLine["libelle"];
|
||||||
}
|
}
|
||||||
|
|
||||||
function queryVotes($db, $idVotation)
|
function queryVotes($idVotation)
|
||||||
{
|
{
|
||||||
$query = "SELECT * FROM liste_votes LEFT JOIN methods ON liste_votes.methode=methods.id WHERE idVotation='" . $idVotation . "'";
|
$query = "SELECT * FROM liste_votes LEFT JOIN methods ON liste_votes.methode=methods.id WHERE idVotation='" . $idVotation . "'";
|
||||||
$db->query($query);
|
$this->query($query);
|
||||||
$votes = $db->result->fetch_all();
|
$votes = $this->result->fetch_all();
|
||||||
return $votes;
|
return $votes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function queryCandidatsList($idVotation, $idVote)
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM liste_candidats WHERE idVotation='" . $idVotation . "' AND idVote='" . $idVote . "'";
|
||||||
|
$this->query($query);
|
||||||
|
$candidats = $this->result->fetch_all();
|
||||||
|
return $candidats;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function queryCandidatName($idCandidat)
|
||||||
|
{
|
||||||
|
$query = "SELECT libelle FROM liste_candidats where id='" . $idCandidat . "'";
|
||||||
|
$this->query($query);
|
||||||
|
$line = $this->result->fetch_assoc();
|
||||||
|
return $line["candidat"];
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -44,6 +44,32 @@ function mb_ucfirst($str)
|
|||||||
return $char . $str;
|
return $char . $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function choixVote($path, $idVotation, $confirm=false)
|
||||||
|
{
|
||||||
|
global $base_url, $action;
|
||||||
|
|
||||||
|
$db = new db();
|
||||||
|
$query = "SELECT * FROM liste_votes WHERE idVotation=" . $idVotation;
|
||||||
|
$result = $db->query($query);
|
||||||
|
$votes = $db->result->fetch_all(MYSQLI_ASSOC);
|
||||||
|
print ('<form method="get" action="' . $path . '">');
|
||||||
|
print "<pre>";
|
||||||
|
print '<input type="hidden" name="idVotation" value="' . $idVotation . '"/>';
|
||||||
|
foreach($votes as $key => $value )
|
||||||
|
{
|
||||||
|
print '<input type="radio" name="idVote" value="' . $value["id"] . '"/> ' . $value["candidat"] . '<br>';
|
||||||
|
}
|
||||||
|
// TODO confirmation du choix par javascript si $confirm = true
|
||||||
|
|
||||||
|
print '</pre><br>
|
||||||
|
<div>
|
||||||
|
<input type="submit" value="Envoyer"/>
|
||||||
|
<input type="submit" formaction="index.php" value="' . _("Annuler") . '"/>
|
||||||
|
</div>
|
||||||
|
</form>';
|
||||||
|
$db->close();
|
||||||
|
}
|
||||||
|
|
||||||
function choixVotation($path, $methode = 2, $confirm = true) //2 = toutes les votations 0 = votations en cours 1 = votations cloturées
|
function choixVotation($path, $methode = 2, $confirm = true) //2 = toutes les votations 0 = votations en cours 1 = votations cloturées
|
||||||
{
|
{
|
||||||
global $base_url, $action;
|
global $base_url, $action;
|
||||||
@ -57,18 +83,6 @@ function choixVotation($path, $methode = 2, $confirm = true) //2 = toutes les v
|
|||||||
$result = $db->query($query);
|
$result = $db->query($query);
|
||||||
$votations = $db->result->fetch_all(MYSQLI_ASSOC);
|
$votations = $db->result->fetch_all(MYSQLI_ASSOC);
|
||||||
|
|
||||||
/*if ($db->result->num_rows == 1)
|
|
||||||
{
|
|
||||||
$redirect = '<META HTTP-EQUIV=Refresh CONTENT="0; URL=' . $base_url . $path . '?id=' . $votations["0"]["id"];
|
|
||||||
if( !empty($action))
|
|
||||||
{
|
|
||||||
$redirect .= '&action=' . $action;
|
|
||||||
}
|
|
||||||
$redirect .= '">';
|
|
||||||
|
|
||||||
//echo $redirect;
|
|
||||||
header( 'Location: ' . $base_url . '/gestionsite/modifVotation.php?id=' . $votations["0"]["id"]) . $redirect;
|
|
||||||
}*/
|
|
||||||
print ('<form method="get" action="' . $path . '">');
|
print ('<form method="get" action="' . $path . '">');
|
||||||
print "<pre>";
|
print "<pre>";
|
||||||
print '<input type="hidden" name="action" value="' . $action . '"/>';
|
print '<input type="hidden" name="action" value="' . $action . '"/>';
|
||||||
|
Reference in New Issue
Block a user