diff --git a/gestion/saisieCandidats.php b/gestion/saisieCandidats.php new file mode 100644 index 0000000..f2d7a74 --- /dev/null +++ b/gestion/saisieCandidats.php @@ -0,0 +1,46 @@ + +query($query); + header("Location: " . $$base_url . "/" . $path , TRUE, 301); + return; +}else +{ + require_once 'entete.php'; + print('

+ +
+
') . EOL; + print('
+
'); + + if (empty($idVotation)) + { + choixVotation($path, 0, false); + }elseif (empty($idVote)) + { + choixVote($path, $idVotation); + } + print('
+
+
+
'); + require_once("footer.html"); +} +$db->close(); + +?>; diff --git a/gestion/saisieVotes.php b/gestion/saisieVotes.php index b2282c4..cdb0105 100644 --- a/gestion/saisieVotes.php +++ b/gestion/saisieVotes.php @@ -7,8 +7,6 @@ require_once 'fonctions.inc.php'; $path = $_SERVER["PHP_SELF"]; $db = new db(); - - $idVotation = getpost("id"); $method = getpost("method"); $libelle = getpost("libelle"); diff --git a/include/db.class.php b/include/db.class.php index 41ab75e..bb95c20 100644 --- a/include/db.class.php +++ b/include/db.class.php @@ -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 . "'"; - $db->query($query); - $votationLine = $db->result->fetch_assoc(); + $this->query($query); + $votationLine = $this->result->fetch_assoc(); 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 . "'"; - $db->query($query); - $votes = $db->result->fetch_all(); + $this->query($query); + $votes = $this->result->fetch_all(); 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"]; + } ?> diff --git a/include/fonctions.inc.php b/include/fonctions.inc.php index 15ab3bc..ed669a4 100644 --- a/include/fonctions.inc.php +++ b/include/fonctions.inc.php @@ -44,6 +44,32 @@ function mb_ucfirst($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 ('
'); + print "
";
+	print '';
+	foreach($votes as $key => $value )
+	{
+		print ' ' . $value["candidat"] . '
'; + } + // TODO confirmation du choix par javascript si $confirm = true + + print '

+
+ + +
+
'; + $db->close(); +} + function choixVotation($path, $methode = 2, $confirm = true) //2 = toutes les votations 0 = votations en cours 1 = votations cloturées { global $base_url, $action; @@ -57,18 +83,6 @@ function choixVotation($path, $methode = 2, $confirm = true) //2 = toutes les v $result = $db->query($query); $votations = $db->result->fetch_all(MYSQLI_ASSOC); - /*if ($db->result->num_rows == 1) - { - $redirect = ''); print "
";
 	print '';