1
0

ajout saisie de la liste des votes

This commit is contained in:
Daniel Tartavel 2022-09-15 18:34:18 +02:00
parent 0cefd8f9a0
commit b3790d3425
3 changed files with 93 additions and 6 deletions

View File

@ -17,12 +17,19 @@ print(' <div class="row">
<h3>Nouvelle votation</h3>
<h4>');
if (array_key_exists("titre", $_GET))
$titre = getpost("titre");
$libelle = getpost("libelle");
$dateDebut = getpost("dateDebut");
$dateFin = getpost("dateFin");
if ($titre !== null and $libelle!== null and $dateDebut!== null and $dateFin !== null)
{
var_dump($_get);
$db = new db();
$query = "INSERT INTO liste_votations ('titre', 'libelle', 'status', 'dateDebut', 'dateFin') VALUES('" . $titre . "', '" . $libelle . "', '0', '" . $dateDebut . "', '" . $dateFin . "')"; // clotûre
$db->query($query);
}else
{
votationForm($path);
votationForm($path, $titre, $libelle, $dateDebut, $dateFin);
}
print(' </div>

View File

@ -0,0 +1,40 @@
<?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';
$idVotation = getpost("id");
$path = $_SERVER["PHP_SELF"];
print('<br><br>
<!-- lalis Grid Section -->
<section id="content">
<div class="container">');
print(' <div class="row">
<div class="col-lg-12 text-center">
<h3>Nouveau vote</h3>
<h4>');
if (empty($idVotation))
{
if (array_key_exists("idVotation", $GLOBALS))
{
$idVotation == $GLOBALS["idVotation"];
}else
{
choixVotation($path);
}
}
votesForm($path);
print(' </div>
</div>
</form>
</div>
</section>');
require_once("footer.html");
?>

View File

@ -30,7 +30,7 @@ function getpost( $var )
return $_POST[$var];
}else
{
return false;
return null;
}
}
@ -44,9 +44,10 @@ function mb_ucfirst($str)
return $char . $str;
}
function choixVotation($path, $methode=2) //2 = toutes les votations 1 = votations en cours 0 = votations cloturées
function choixVotation($path, $methode = 2, $confirm = true) //2 = toutes les votations 1 = votations en cours 0 = votations cloturées
{
global $db, $base_url, $action;
$query = "SELECT * FROM liste_votations";
if ($methode != 2)
{
@ -64,7 +65,7 @@ function choixVotation($path, $methode=2) //2 = toutes les votations 1 = votat
}
$redirect .= '">';
echo $redirect;
//echo $redirect;
header( 'Location: ' . $base_url . '/gestionsite/modifVotation.php?id=' . $votations["0"]["id"]) . $redirect;
}
print ('<form method="get" action="' . $path . '">');
@ -74,6 +75,8 @@ function choixVotation($path, $methode=2) //2 = toutes les votations 1 = votat
{
print '<input type="radio" name="id" value="' . $value["id"] . '"> ' . $value["titre"] . '&nbsp;:' . $value["libelle"] . '<br>';
}
// TODO confirmation du choix par javascript si $confirm = true
print '</pre><br>
<div>
<input type="submit" value="Envoyer">
@ -93,6 +96,43 @@ function votationForm($path, $titre="", $libelle="", $dateDebut="", $DateFin="",
print('<input type="submit" value="' . _("Envoyer") . '">') . EOLH;
}
function votesForm($path, $libelle = "", $method = 0)
{
$db = new db();
$query = "SELECT *m FROM methods"; // clotûre
$db->query($query);
$methods = $db->result::fetch_all(MYSQLI_ASSOC);
if (!(array_key_exists($method, $methods)))
{
print(_("L'ID de la méthode demandée n'est pas bonne " . __file__ . __LINE__));
log_error(_("L'ID de la méthode demandée n'est pas bonne " . __file__ . __LINE__), true, true);
}
//TODO vérification du formulaire en javascript
print('<form method="get" action="' . $path . '">');
print('<label for="libelle">' . _("Libellé du vote") .'</label><br><input type="text" id="libelle" name="libelle" value="'. $libelle . '">') . EOLH;
print('<label for="method">' . _("Méthode de vote") . '</label><br>
<input type="select" id="method" name="method" value="'. $method . '">') . EOLH;
if ($method == 0)
{
print('<option value ="">' . _("Choisissez une option") . '<option>');
}
foreach ($methods as $id => $value)
{
if ($id == $value)
{
print('<option value ="' . $id . '" selected>' . $value . '<option>');
}else
{
print('<option value ="' . $id . '">' . $value . '<option>');
}
}
print('<input type="submit" formaction="index.php" value="' . _("Annuler") . '">') . EOLH;
print('<input type="submit" value="' . _("Envoyer") . '">') . EOLH;
}
function envoiMail($destinataire, $sujet, $text, $html=false, $cc='', $bcc='')
{