<!doctype html>
<html lang=fr>
	<?php											
		session_start();
		if (!isset($_SESSION['Autorisation']) or ($_SESSION['Autorisation'] != 1))
		{
		header("Location: index.php");
		exit();
		} 
	?>
	<head>
		<title>Situation pro</title>
		<meta charset=utf-8>
		<meta name=viewport content="width=device-width, initial-scale=1">
		<link rel="stylesheet" href="nogstyle.css">

	</head>
	<body>
		<header>
			<?php 
				include('includes/header_simple.inc'); 
				echo'<h3>'.$_SESSION['PrenomAct'].' '.$_SESSION['NomAct'].' '.$_SESSION['NomEtab'].'</h3>';
				include('includes/menu_prof.inc'); 
				$_SESSION['page']=$_SERVER['PHP_SELF']; // on récupèrele nom de la page pour le DELETE
				$_SESSION['table']="evaluation";
				$_SESSION['cleprimaire']="Numeval";
			?>
		</header>
		<article>
		
		
		<!-- Start of the  page content. -->
		
		
			<h2>Evaluation au fil de l'eau des Situations Professionnelles</h2>
			
			<form class="centre80" action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post">
				<label class="label1" for="Nom">Session </label>
					<select name="session" >
						<option value="-1"> Toutes
				 		<?php
				 			$annee=intval(date('Y'));
					  		for ($i = $annee ; $i<= $annee+2 ; $i++)
							{
								echo '<option value="' . $i . '"';
								echo ">" . $i . "</option>";
							}
				 		?>
					</select>	
						

					<input id="submit" type="submit" name="submit" value="Selection">
			</form>
			<br/>
			
			<?php 
				if ($_SERVER['REQUEST_METHOD'] == 'POST')
				{
					$sessionex = $_POST['session'];
					
					if($sessionex==-1)
					{
						$restriction='';
					}
					else
					{
						$restriction= 'WHERE sessionEval='.$sessionex.' ';
					}
					/////////////////////////////////////////////////-->
					// This script retrieves records from the users table.
					require ('connect/mysqli_connect.php'); // Connect to the db.
					
					//REQUETE de toutes les SP évaluées
					
					$q1 = "SELECT NumEval,nomEval,epreuveEval, sessionEval ,codeEtab,dateEval
					       FROM eval_liste
					       $restriction 
					       ORDER BY dateEval;";
					       
					$result1 = mysqli_query ($dbcon, $q1)or die(mysqli_error($dbcon));
					$nb_lignes = mysqli_num_rows($result1); //compte le nombre de lignes
										
					// tableau des SP
					echo '<table>';
					// On génére le tableau SP	 eval
					if ($result1)
					{		
					   // If it ran, display the records.
						// Table header.
						echo '<table>
						<tr>
						<th><b>Num Eval</b></th>
						<th><b>Nom Eval</b></th>
						<th><b>Epreuve</b></th>
						<th><b>Session</b></th>
						<th><b>Date</b></th>
						<th><b>Code Etab</b></th>
						<th><b>Modif.</b></th>
						<th><b>Suppr.</b></th>
						</tr>';
						
						// Fetch and display the records:
						while ($row = mysqli_fetch_array($result1, MYSQLI_ASSOC))
						{
							echo '<tr>
							<td>' . $row['NumEval'] . '</td>
							<td><b><a href="prof_eval_note.php?id='.$row['NumEval'].'">'.$row['nomEval'].'<b></td>
							<td>' . $row['epreuveEval'] . '</td>
							<td>' . $row['sessionEval'] . '</td>
							<td>' . $row['dateEval'] . '</td>
							<td>' . $row['codeEtab'] . '</td>
							<td><a class="bouton" href="prof_eval_cms.php?cms=M&id='. $row['NumEval'] . '"><span class="iconic">p</span></a></td>	
							<td><a class="bouton" href="prof_eval_cms.php?cms=S&id='. $row['NumEval'].'" ><span class="iconic">x</a></td>									
							</tr>';
							
						}
						echo '</table>'; // Close the table.
						echo '<p class="centre40"><b>'.$nb_lignes .' SP évaluées </b></p>';
						mysqli_free_result ($result1); // Free up the resources.
					}
					 else 
					 { // If it did not run OK.// Public message:
					
						echo '<p class="error">The current users could not be retrieved. We apologize for any inconvenience.</p>';
						// Debugging message:
						echo '<p>' . mysqli_error($dbcon) . '<br><br>Query: ' . $q . '</p>';
					}
					mysqli_close($dbcon); // Close the database connection.
				}
			?>	
			<p style="text-align: center">
				<br/>
				<a class="bouton10" href="prof_eval_cms.php?cms=C">Ajouter une évaluation </a>
				<br/>
			</p>		
		</article>	
		<footer>
			<?php include ('includes/footer.inc'); ?>
		</footer>
	</body>
</html>