<html>
<!--    cibl&eacute; par:  liste-contrat.php

		cible: toute les pages ajout...php
 -->

<!-- param&egrave;tre &eacute;mis:        -session_id         le num&eacute;ro de la session
						

	 param&egrave;tre re&ccedil;evable :  -session_id         le num&eacute;ro de la session
	 						-code_contrat
							-code_client
 -->
 <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Registre des s&eacute;jours non compl&eacute;t&eacute;</title>
<body>

<?php 

//Fichiers contenant les fonctions utilis&eacute;es dans le script.
require("../outils/gui.php");
require("../outils/session.php");
require("../outils/mise_en_page.php");



//V&eacute;rifier si la session est valide.
$Bsession_id = $_GET["Bsession_id"];
verifierSession($Bsession_id);

//V&eacute;rifier les droits de l'utilisateur.
$privilege_base = lirePrivilege($Bsession_id);
if (($privilege_base != 2) and ($privilege_base != 1))
	die("Vous n'avez pas les droits!");

	
$sql = "SELECT base_contrat.code_contrat, base_contrat.date_emission, base_contrat.date_debut,
			   base_contrat.date_fin, base_clients.organisme, base_clients.nom, base_clients.prenom, base_contrat.etat,
			   base_clients.code_client
          FROM base_clients,base_contrat LEFT JOIN base_information
		    ON base_contrat.code_contrat = base_information.code_contrat
	     WHERE base_contrat.num_client = base_clients.code_client
		   AND base_information.code_contrat is NULL;";
$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die ("Ne peut lire dans la table des contrats, clients, informations".$sql);
$num = mysqli_num_rows($result);


if ($num)
	{
		print("<center>Liste des contrats n'ayant pas compl&eacute;t&eacute; le registre de s&eacute;jour.<br><br><br>");
		
		//No contrat		
		print ("<table width=100%>\n");
		print("<tr><td>");
		print("<b>No contrat<br><br>"); 
		print("</td>");
		
		//date d'emission
		print("<td>");
		print("<b>&Eacute;tat<br><br>");
		print("</td>");
		
		//date d'emission
		print("<td>");
		print("<b>date &eacute;mission<br><br>");
		print("</td>");
		
		//debut
		print("<td>");
		print("<b>D&eacute;but<br><br>");
		print("</td>");
		
		//Fin
		print("<td>");
		print("<b>Fin<br><br>");
		print("</td>");
		
		//organisme
		print("<td>");
		print("<b>Organisme<br><br>");
		print("</td>");
		
		//nom
		print("<td>");
		print("<b>Nom<br><br>");
		print("</td>");

		//pr&eacute;nom
		print("<td>");
		print("<b>Pr&eacute;nom<br><br>");
		print("</td>");
		print("</tr>");

		// Affiche les r&eacute;sultats de la requ&ecirc;te
		while ($row = mysqli_fetch_row($result))
		{
		
			$code_contrat = $row[0];
			$date_emission = $row[1];		
			$date_debut = $row[2];
			$date_fin = $row[3];
			$organisme = $row[4]; 
			$nom = $row[5];
			$prenom = $row[6];
			$etat = $row[7];
			$code_client = $row[8];			
			
			print ("<tr>\n");
			$i = 0;
			
			// affiche le code du contrat
			print("<td>");
			print("<a href=\"../contract/gestion-contract.php?Bsession_id=$Bsession_id&code_contrat=$code_contrat&code_client=$code_client\">");			
			print($code_contrat);
			print("</a>");
			print("</td>");

			// affiche l'&eacute;tat
			print("<td>");
			print($etat);
			print("</td>");
			
			// affiche la date d'&eacute;mission
			print("<td>");
			print($date_emission);
			print("</td>");
			
			// affiche la date de d&eacute;but
			print("<td>");
			print($date_debut);
			print("</td>");
			
			// affiche la date fin
			print("<td>");
			print($date_fin);
			print("</td>");
			
			// affiche l'organisme
			print("<td>");
			print("<a href=\"../client/gestion-client.php?Bsession_id=$Bsession_id&code_client=$code_client\">");
			print($organisme);
			print("</td>");
			
			// affiche le nom
			print("<td>");
			print($nom);
			print("</td>");
		
			// affiche le pr&eacute;nom
			print("<td>");
			print($prenom);
			print("</td>");
						
			
		}
		print ("</table>\n");
		
		// lib&eacute;rer la m&eacute;moire		
		((mysqli_free_result($result) || (is_object($result) && (get_class($result) == "mysqli_result"))) ? true : false);
	} 
	else
	{		
		print ("<br>Pas de r&eacute;sultats<br>");
	}		
		





//BAS DE PAGE**********************************************************************
	
print("<hr><table width=100%><tr><td width=50%><center>");
	//Afficher le bouton de retour au menu principal.
	
	print("<a href='rapport.php?Bsession_id=".$Bsession_id."'><img src=bouton2.gif border=0></a>");
	
	print("<a href='../menu-base.php?Bsession_id=".$_GET['Bsession_id']."'><img src=bouton1.gif border=0></a>");

print("</td><tr></table>");	
	//Fin du formulaire.

	
	





	
?>

</body>
</html>	
	
	
	
	
