<?php
include('include/entete.php');
include('include/entete_adm.php');
include('config/config.inc.php');
include('config/lib.inc.php');

$maCleDeCryptage = getCleDeCryptage();	

?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>FAFIH - DECIDAY</title>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/fonctions.js"></script>
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="css/style.css" rel="stylesheet" type="text/css"><script>
jQuery(document).ready(function(){
	<?php
	if(isset($_SESSION['msg']) && !empty($_SESSION['msg'])){
		?>
	alert('<?php print addslashes($_SESSION['msg']);?>');
	<?php
		$_SESSION['msg']="";
	}
	?>
	$("#export").click(function(e){
		e.preventDefault;
		window.location.href='export-suivi-cap-adm.php';
	})
});
	
</script>
</head>

<body>
	
	<?php include('include/header.php');?>
	
	<div class="container contentPage">
	
		<?php include('include/admin-header.php');?>
		
		<div class="col-lg-2 col-md-2 col-sm-1 hidden-xs bgTitrePage"></div>
		<div class="col-lg-8 col-md-8 col-sm-10 col-xs-12 titreContenuPage">Suivi des Capitaines</div>
		<div class="col-lg-2 col-md-2 col-sm-1 hidden-xs bgTitrePage"></div>
		<div class="clearfix"></div>
		<br/><br/>
		<button type="button" class="btn btn-default btn-lg" id="export" title="Télécharger le fichier Excel">
  			<span class="glyphicon glyphicon-save-file" aria-hidden="true"></span> Export Excel
		</button>
	<?php
	$query="SELECT * FROM `capitaines`
			INNER JOIN eta ON  num_eta = id_eta";
	$db = connect_base();
	$queryRequest = $db->prepare( $query );
	$queryRequest->execute();
	if($queryRequest->rowCount()>0){
		
		
				
		
		$data=$queryRequest->fetchAll();
		echo '<table cellpadding="0" cellspacing="0" class="table tabAdm">';
			echo "<tr><th>Nom</th><th>Prénom</th><th>Email</th><th>&Eacute;tablissement</th><th>Code Postal</th><th>Ville</th></tr>";
			foreach($data as $val){
				$count=0;
				echo "<tr><td>".decrypter($maCleDeCryptage,$val['nom_cap'])."</td>";
				echo "<td>".decrypter($maCleDeCryptage,$val['prenom_cap'])."</td>";				
				echo "<td>".decrypter($maCleDeCryptage,$val['email_cap'])."</td>";
				echo "<td>".decrypter($maCleDeCryptage,$val['nom_eta'])."</td>";
				echo "<td>".decrypter($maCleDeCryptage,$val['cp'])."</td>";
				echo "<td>".decrypter($maCleDeCryptage,$val['ville'])."</td>";
				echo "</tr>";
			}
		echo '</table>';
	}
	?>
		<br /><div class="btnDeci"><a href="index-adm.php">Retour</a></div>		
	</div>
	
	<?php include('include/footer.php');?>

</body>
</html>