<!doctype html>
<html lang=fr>
	<?php	
		session_start();
		if (!isset($_SESSION['Autorisation']) or ($_SESSION['Autorisation'] != 0))
		{
		header("Location: index.php");
		exit();
		} 
	?>
	<head>
		<title>liste 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'].'&nbsp;-&nbsp; '.$_SESSION['NomEtab'].'</h3>';
				include('includes/menu_etudiant.inc');
			?>
		</header>
		
		<article><!-- Start of the  page content. -->
			<h2>Situations Professionnelles</h2>
			<p style="font-style: italic; text-align: center; ">Les SP validées par votre professeur ne peuvent plus être modifiées ou détruites</p>
			<?php 
				// This script retrieves records from the users table.
				require ('connect/mysqli_connect.php'); // Connect to the db.
				$Id=$_SESSION['NumAct'];
				$q = "SELECT * FROM situationpro WHERE NumEt='$Id' ORDER BY IdentificationSP ;";	
				$result = mysqli_query ($dbcon, $q); 
				$ligne = mysqli_num_rows($result);
				
				if ($result) 
				{		   // If it ran, display the records.
					// Table header.
					echo '<table>
					<tr height="40">
					<th style="width:8%">PDF E42</th>
					<th style="width:8%">PDF E5</th>
					<th style="width:8%">Modif.</th>
					<th style="width:8%">Supprim.</th>
					<th><b>Identification</b></th>
					<th><b>Nom</b></th>
					<th><b>Période</b></th>
					<th><b>Validé</b></th>
					</tr>
					';
	
					
					// Fetch and display the records:
					while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
					{
						echo'	<tr <tr height="40">
							<td><a class="bouton" href="sp_e42_pdf.php?id='. $row['NumSP'] . '">&nbsp;&nbsp;<span class="iconic">d</span>&nbsp;&nbsp;</a></td>
							<td><a class="bouton" href="sp_e5_pdf.php?id='. $row['NumSP'] . '">&nbsp;&nbsp;<span class="iconic">d</span>&nbsp;&nbsp;</a></td>
							';

						if($row['ValideSP']=="Oui")
						{	
							echo'<td></td><td></td>';
						}
						else // l'étudiant peut la modifier ou la supprimer
						{
						echo'	
							<td><a class="bouton" href="sp_modif.php?id='. $row['NumSP'] . '">&nbsp;&nbsp;<span class="iconic">p</span>&nbsp;&nbsp;</a></td>	
							<td><a class="bouton" href="sp_suppr.php?id='. $row['NumSP'] . '">&nbsp;&nbsp;<span class="iconic">x</span>&nbsp;&nbsp;</a></td>';
						}
						echo'
						<td>' . $row['IdentificationSP'] . '</td>
						<td>' . $row['IntituleSP'] . '</td>
						<td>' . $row['PeriodeSP'] . '</td>
						<td>' . $row['ValideSP'] . '</td>
						</tr>';
					}
					echo '</table>'; // Close the table.
					/*
					echo '<br/>';
					echo '<table style="width:400px">';
					echo' <tr><td>nombre de SP : ' . $ligne;
					echo '</td></tr></table>';
					*/
					
					mysqli_free_result ($result); // 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>';
				} // End of if ($result).
				

				mysqli_close($dbcon); // Close the database connection.
			?>
			<br/>
			<h3><a href="sp_ajout.php" class="bouton10" >Ajouter une situation Pro</a></h3>
			
			<br/>&nbsp;
		</article>
		<footer>
			<?php include ('includes/footer.inc'); ?>
		</footer>
	</body>
</html>