first commit
This commit is contained in:
		
							
								
								
									
										96
									
								
								vote.form.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								vote.form.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,96 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
require_once 'session_init.php';
 | 
			
		||||
require_once 'config.inc.php';
 | 
			
		||||
require_once 'db.class.php';
 | 
			
		||||
require_once "log.php";
 | 
			
		||||
require_once 'entete.html';
 | 
			
		||||
 | 
			
		||||
$idVotant = trim(base64_decode(urldecode($_GET["id"])), " \n\r");
 | 
			
		||||
$idVotation = $_GET["v"];
 | 
			
		||||
 | 
			
		||||
$dolibarr = new dbDolibarr();
 | 
			
		||||
 | 
			
		||||
$query = "SELECT * FROM llx_adherent WHERE login='" . $dolibarr->protect($idVotant) . "'";
 | 
			
		||||
 | 
			
		||||
$result = $dolibarr->query($query);
 | 
			
		||||
$votant = $dolibarr->result->fetch_array();
 | 
			
		||||
print('<br><br>
 | 
			
		||||
	<!-- lalis Grid Section -->
 | 
			
		||||
 | 
			
		||||
	<section id="content">
 | 
			
		||||
		<div class="container">
 | 
			
		||||
			<form method="get" action="vote.php">
 | 
			
		||||
			<input type="hidden" name="id" value="' . $idVotant . '">
 | 
			
		||||
			<input type="hidden" name="v" value="' . $idVotation . '">');
 | 
			
		||||
print('			<div class="row">
 | 
			
		||||
					<div class="col-lg-12 text-center">
 | 
			
		||||
						<h3>VOTE</h3>
 | 
			
		||||
						<h4>');
 | 
			
		||||
if ($dolibarr->result->num_rows == 0)
 | 
			
		||||
{
 | 
			
		||||
	print "Identifiant non autorisé.<br>Si vous pensez qu'il s'agit d'une erreur, adressez vous à un responsable de l'association</h4>.<br><br><br><br>";
 | 
			
		||||
}else
 | 
			
		||||
{
 | 
			
		||||
	$dolibarr->close();
 | 
			
		||||
	$db = new db();
 | 
			
		||||
	$query = 'SELECT *, UNIX_TIMESTAMP(dateDebut) as td, UNIX_TIMESTAMP(dateFin) as tf  FROM liste_votations WHERE id=' . $db->protect($idVotation);
 | 
			
		||||
	$resultVotation = $db->query($query);
 | 
			
		||||
	$votation = $db->result->fetch_array();
 | 
			
		||||
	$now = date('Y-m-d');
 | 
			
		||||
	if ( time() >= $votation['td'] AND time() <= $votation['tf'] )
 | 
			
		||||
	{
 | 
			
		||||
		$query = "SELECT * FROM votes WHERE idVotant='" . $db->protect($idVotant) ."'";
 | 
			
		||||
		$db->query($query);
 | 
			
		||||
		if ($db->result->num_rows == 0)
 | 
			
		||||
		{
 | 
			
		||||
			if ($resultVotation === FALSE)
 | 
			
		||||
			{
 | 
			
		||||
				print "Votation non trouvée</h4>" . EOLH;
 | 
			
		||||
			}else
 | 
			
		||||
			{
 | 
			
		||||
				echo $votation["libelle"] . "</h4>";
 | 
			
		||||
				print ('				<hr class="star-primary">
 | 
			
		||||
									</div>
 | 
			
		||||
								</div>
 | 
			
		||||
								<div class="row"><h5>Bonjour ' . $votant['firstname'] . " " . $votant['lastname'] . "</h5>" . EOLH . EOLH . "Attention: les votes blancs sont comptés comme vote exprimés." . EOLH . "Les abstentions ou l'absence de choix, comme non exprimés." . EOLH . "
 | 
			
		||||
								Vérifiez bien votre vote avant de l'envoyer, il est impossible de le modifier après.");
 | 
			
		||||
 | 
			
		||||
				$query='SELECT * FROM liste_votes WHERE idVotation="' . $db->protect($idVotation) .'"';
 | 
			
		||||
				$result = $db->query($query);
 | 
			
		||||
				$votes = $db->result->fetch_all(MYSQLI_ASSOC);
 | 
			
		||||
				foreach ($votes as $vote)
 | 
			
		||||
				{
 | 
			
		||||
					echo "<div><h5>" . $vote["libelle"] . "</h5><br>";
 | 
			
		||||
					$query='SELECT * FROM liste_candidats WHERE idVotation=' . $db->protect($idVotation) . ' AND idVote=' . $vote["id"];
 | 
			
		||||
					$result = $db->query($query);
 | 
			
		||||
					$candidats = $db->result->fetch_all(MYSQLI_ASSOC);
 | 
			
		||||
					echo "<pre>";
 | 
			
		||||
					foreach($candidats as $candidat)
 | 
			
		||||
					{
 | 
			
		||||
						echo '<input type="radio" name="vote[' . $vote["id"] . ']" value="' . $candidat["id"] . '"> ' . $candidat["candidat"] . ' <br>';
 | 
			
		||||
					}
 | 
			
		||||
					print "</pre>
 | 
			
		||||
						</div><br>";
 | 
			
		||||
				}
 | 
			
		||||
				print ('				<div class="text-center">
 | 
			
		||||
										<h4><input type="submit" value="Voter"></h4>');
 | 
			
		||||
			}
 | 
			
		||||
		}else
 | 
			
		||||
		{
 | 
			
		||||
			print "		Bonjour " . $votant['firstname'] . " " . $votant['lastname'] . ',' . EOLH  . EOLH  . "vous avez déjà voté, vous ne pouvez pas revoter ou modifier votre vote." . EOLH . "Si vous pensez que c'est une erreur, veuillez prendre contact avec les responsables de l'association.</h4>";
 | 
			
		||||
		}
 | 
			
		||||
	}else
 | 
			
		||||
	{
 | 
			
		||||
		print "		Bonjour " . $votant['firstname'] . " " . $votant['lastname'] . ',</h4>' . EOLH  . EOLH  . "Le vote ne sera ouvert qu'à partir du " . formattedate('fr', $votation['td'] , "Europe/Paris") . " et jusqu'au " . formattedate('fr', $votation['tf'] , "Europe/Paris") . '.' . EOLH .  "Si vous pensez que ceci est une erreur, veuillez prendre contact avec les responsables de l'association.</h4>";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
print('					</div>
 | 
			
		||||
					</div>
 | 
			
		||||
				</form>
 | 
			
		||||
			</div>
 | 
			
		||||
		</section>');
 | 
			
		||||
require_once("footer.html");
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
		Reference in New Issue
	
	Block a user