<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>
<!--**************************SCRIPT POUR LE CALCUL AUTOMATIQUE DANS LES CELLULES*********************** --> 
<script type="text/javascript">
<!--
function majligne()
{
	var result;
	result = ((document.mod_cafeteria.nb_pers_cafe.value) * (document.mod_cafeteria.nb_repas_cafe.value) * (document.mod_cafeteria.prix_repas_cafe.value)) + ((document.mod_cafeteria.lunchpm.value) * (document.mod_cafeteria.prix_lunchpm.value));
	document.mod_cafeteria.plein_prix_cafe.value = Math.round(result*100)/100;
}
//-->
</script> 


<script type="text/javascript">
<!--
function majlignechalet(no)
{
	var result;
	var prix_par_jour =(document.mod_chalet.prix_par_jour.value/1);
	var nuite =(document.mod_chalet.nuite.value/1);
	var frais_terrain = (document.mod_chalet.frais_terrain.value/1);
	if (prix_par_jour == ""){ prix_par_jour=0; }
	if (nuite == ""){ nuite=1; }
	if (frais_terrain == ""){ frais_terrain=0; }
	result = (prix_par_jour * nuite+frais_terrain);
	document.mod_chalet.plein_prix.value = Math.round(result*100)/100;
}
//-->
</script> 
<!--**************************************************************************************************** -->

 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Gestion contrat</title>
 </head>
<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");
require("gestion-poste.php");
require("../historique.php");

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

$code_contrat = $_GET["$code_contrat"];
$code_client = $_GET["$code_client"];
$etat = $_GET["$etat"];
$date_emission = $_GET["$date_emission"];
$date_debut = $_GET["$date_debut"];
$date_fin = $_GET["$date_fin"];
$heure_debut = $_GET["$heure_debut"];
$heure_fin = $_GET["$heure_fin"];
$cal_debut = $_GET["$cal_debut"];
$cal_fin = $_GET["$cal_fin"];
$mod_date = $_GET["$mod_date"];
$nuite = $_GET["$nuite"];
$numero_contrat = $_GET["$numero_contrat"];
$depot_50 = $_GET["$depot_50"];
$type = $_GET["$type"];
$type_precedent = $_GET["$type_precedent"];
$privilege_base = $_GET["$privilege_base"];
$mois_du_contrat = $_GET["$mois_du_contrat"];
$prec_etat = $_GET["prec_etat"];
$num_chalet = $_GET["num_chalet"];
$ancien_prix = $_GET["ancien_prix"];
$type_client = $_GET["type_client"];
$prix_par_jour = $_GET["prix_par_jour"];
$frais_terrain = $_GET["frais_terrain"];
$plein_prix = $_GET["plein_prix"];
$prix_reel = $_GET["prix_reel"];
$mod_clientele = $_GET["mod_clientele"];
$nb_jeune = $_GET["nb_jeune"];
$nb_adulte = $_GET["nb_adulte"];
$nb_pers_cafe = $_GET["nb_pers_cafe"];
$nb_repas_cafe = $_GET["nb_repas_cafe"];
$prix_repas_cafe = $_GET["prix_repas_cafe"];
$lunchpm = $_GET["lunchpm"];
$prix_lunchpm = $_GET["prix_lunchpm"];
$plein_prix_cafe = $_GET["plein_prix_cafe"];
$prix_reel_cafe = $_GET["prix_reel_cafe"];
$commentaire_cafe = addslashes($_GET["commentaire_cafe"]);
$num_activite = $_GET["num_activite"];
$ancien_prix = $_GET["ancien_prix"];
$activite = $_GET["activite"];
$inclu = $_GET["inclu"];
$num_materiel = $_GET["num_materiel"];
$materiel = $_GET["materiel"];
$quantite = $_GET["quantite"];
$inclu = $_GET["inclu"];
$achat = $_GET["achat"];
$code_rabais = $_GET["code_rabais"];
$commentaire_rabais = $_GET["commentaire_rabais"];
$prix_rabais = $_GET["prix_rabais"];
$poste = $_GET["poste"];
$wich_base = $_GET["wich_base"];
$depot_reel = $_GET["depot_reel"];
$mod_expedie = $_GET["mod_expedie"];
$expedie = $_GET["expedie"];
$recu = $_GET["recu"];
$supp_depot = $_GET["supp_depot"];
$commentaire = $_GET["commentaire"];



//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!");

$code_contrat = $_GET["code_contrat"];
$code_client = $_GET["code_client"];
	

//*****************************************************************************************************
// remplir les variables ***************************************************************************************	
//********************************************************************************************
//RECHERCHE DANS LA TABLE BASE_CONTRAT
$sql = "SELECT etat, date_emission, date_debut, date_fin, heure_debut, heure_fin, nuite, numero_contrat 
        FROM base_contrat
	    WHERE code_contrat ='$code_contrat';";
		
// Ex&eacute;cute la requ&eacute;te et mettre les r&eacute;sultats dans $result
$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql)
	or die ("Ne peut lire dans la table des membres".$sql);
// obtenir le nombre d'enregistrement. 0 si invalide, 1 si valide.
$num = mysqli_num_rows($result);

// met la valeur dans les variables
if ($num)
{
	$i = 0;
	$row = mysqli_fetch_row($result);
	$etat = ($row[$i++]);
	$date_emission = ($row[$i++]);
	$date_debut = ($row[$i++]);
	$date_fin = ($row[$i++]);
	$heure_debut = ($row[$i++]);
	$heure_fin = ($row[$i++]);		
	$nuite = ($row[$i++]);
	$numero_contrat = ($row[$i++]);
}
else
{
	die ("Il y a un probl&egrave;me dans la base de donn&eacute;es !".$sql);
}
// fait le m&eacute;nage des r&eacute;sultat en m&eacute;moire
((mysqli_free_result($result) || (is_object($result) && (get_class($result) == "mysqli_result"))) ? true : false);


//RECHERCHE LE TYPE DE CLIENT
	$sql = "SELECT type   
        	FROM base_clients
		    WHERE base_clients.code_client = '$code_client';";
	$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die ("Ne peut lire dans la table des clients".$sql);
	$row = mysqli_fetch_row($result);
	$type = $row[0];


//*****************************************************************************************************
// afficher les r&eacute;sultats *****************************************************************************
//*****************************************************************************************************	
print("<center><font size=5><u><b>Gestion de contrat</b></u></center><br>");
print("<table width=100% border=0><tr><td valign=top>");			
historique("../historique.txt","MENU GESTION CONTRAT #".$code_contrat."",$Bsession_id);

$sql_client = "SELECT num_client, depot_50
        	  FROM base_contrat
		     WHERE base_contrat.code_contrat = '$code_contrat';";
	$result_client = mysqli_query($GLOBALS["___mysqli_ston"], $sql_client) or die ("Ne peut lire le client".$sql_client);
	$row_client = mysqli_fetch_row($result_client);
	$code_client = ($row_client[0]);
	$depot_50 = ($row_client[1]);

displayClient();
displayContract();
displayClientele();
displayCafeteria();
displayChalet();
displayActivite();
displayLocation();
displayAchat();
displayRabais();
displayTotal();



//BAS DE PAGE**********************************************************************
	
print("<hr><table width=100%><tr><td width=50%><center>");
	//Afficher le bouton de retour au menu principal.
	print("<a href='contract.php?Bsession_id=".$Bsession_id."'><img src=bouton3.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>");	
	
	
/*************************************************************************
 * displayContract
 *
 * T&acirc;che: Afficher les champs de donn&eacute;es du client ainsi que le lien pour le modifier
 *
 ************************************************************************/	
function displayContract()
{	
	//Variables globales.
		global $Bsession_id, $code_client, $code_contrat, $etat, $date_emission, $date_debut, $date_fin, $heure_debut, $heure_fin, $nuite, $type, $numero_contrat,$privilege_base;


	$sql = "SELECT cal_debut, cal_fin, mois_du_contrat
        	  FROM base_contrat
		     WHERE base_contrat.code_contrat = '$code_contrat';";
	$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die ("Ne peut lire cal_debut, cal_fin".$sql);
	$row = mysqli_fetch_row($result);
	$cal_debut = ($row[0]);
	$cal_fin = ($row[1]);	
	$mois_du_contrat = ($row[2]);


		
	//Tableau de mise en page.
	print("<center><table cellspacing=0 cellpadding=0 width=750px border=0>");
	print("<tr><td bgcolor=white width=27px><img src=coin-haut-gauche.gif></td>");
	print("<td bgcolor=#636300><font face=Arial,Helvetica size=3 color=white><b>2 : Information sur le contrat</b></td>");
	print("<td bgcolor=white width=27px><img src=coin-haut-droit.gif></td>");
	print("</td></tr></table>");	
	
	
	
	print("<table width=750px cellspacing=0 cellpadding=0 border=0>");

	print("<form action=\"confirmation-contract.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\" name=\"mod_numero_contrat\">");
	print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
	print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
	print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");
	print("<tr><td bgcolor=#C8DB8D colspan=2><font face=Arial,Helvetica size=2>");
	print("<b>Num&eacute;ro du contrat: </b>");
	print("<input type=\"text\" name=\"numero_contrat\" value=".$numero_contrat." align=\"top\" maxlength=\"10\" size=\"9\">");
	if ($privilege_base == 2)//protection pour les droits de modification
		print("<input type=\"image\" alt=\"btn_numero_contrat\" src=\"bouton0.gif\" border=0 width=15 height=24>");
	print("</form></td></tr>");

	//&eacute;TAT
	print("<tr><td bgcolor=#E7EFCE colspan=2><font face=Arial,Helvetica size=2>");
	print("<form action=\"confirmation-contract.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\" name=\"mod_etat\">");
	print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
	print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
	print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");
	print("<input type=\"hidden\" name=\"type_precedent\" value=".$etat.">");		
	print("<b>&eacute;tat : </b>");
	print("<select name=\"type\">");
			print("<option selected value=\"".$etat."\">".$etat."</option>");
			print("<option value=\"soumission\">soumission</option>");
			print("<option value=\"actif\">actif</option>");
	if ($etat <> "soumission")
	{
			print("<option value=\"pass&eacute;\">pass&eacute;</option>"); 
	}		
			print("<option value=\"annul&eacute;\">annul&eacute;</option>	");		
		print("</select>");
	if ($privilege_base == 2)//protection pour les droits de modification
		print("<input type=\"image\" alt=\"btn_etat\" src=\"bouton0.gif\" border=0 width=15 height=24>");
	print("</form>");		
	
		
	//DATE D'&eacute;MISSION
	print("</div></td></tr><tr><td bgcolor=#C8DB8D colspan=2><font face=Arial,Helvetica size=2>");
	print("<form action=\"confirmation-contract.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\" name=\"mod_date_emission\">");
	print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
	print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
	print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");		
	print("<b>Date d'&eacute;mission : </b>");
	print("<input type=\"text\" name=\"date_emission\" value=\"".$date_emission."\"  align=\"top\" maxlength=\"15\" size=\"25\">");
	if ($privilege_base == 2)//protection pour les droits de modification
		print("<input type=\"image\" alt=\"btn_date_emission\" src=\"bouton0.gif\" border=0 width=15 height=24>(AAAA-MM-JJ)");
	print("</form></td></tr>");
		
	//MOIS DU CONTRAT
	print("<tr><td bgcolor=#C8DB8D colspan=2><font face=Arial,Helvetica size=2>");
	print("<form action=\"confirmation-contract.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\" name=\"mod_mois_contrat\">");
	print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
	print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
	print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");		
	print("<b>Mois du contrat : </b>");
	print("<select name=\"mois_du_contrat\">");
	
	if (empty($mois_du_contrat))
	{
		//Decoupe les dates
		$debut_aryDateMaintenant = explode("-",$date_debut);
		$mois_debut = $debut_aryDateMaintenant[1];
		print("<option selected value=\"".$mois_debut."\">".$mois_debut."</option>");
	}
	else	
	{
		print("<option selected value=\"".$mois_du_contrat."\">".$mois_du_contrat."</option>");
	}
			
		print("<option value=\"1\">01-Janvier</option>
			<option value=\"2\">02-Fevrier</option>
			<option value=\"3\">03-Mars</option>
			<option value=\"4\">04-Avril</option>
			<option value=\"5\">05-Mai</option>
			<option value=\"6\">06-Juin</option>
			<option value=\"7\">07-Juillet</option>
			<option value=\"8\">08-Aout</option>
			<option value=\"9\">09-Septembre</option>
			<option value=\"10\">10-Octobre</option>
			<option value=\"11\">11-Novembre</option>
			<option value=\"12\">12-Decembre</option>			
		</select>");
	if ($privilege_base == 2)//protection pour les droits de modification	
		print("<input type=\"image\" alt=\"btn_mois_du_contrat\" src=\"bouton0.gif\" border=0 width=15 height=24>");
	print("</form></td></tr>");	

	//DATE DU CONTRACT
	//debut
	if (($etat == 'actif') or ($etat == 'soumission'))//Si le contrat est actif on permet de faire des modification aux dates
	{
		print("</td></tr><tr><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");	
		print("<form action=\"confirmation-contract.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\" name=\"mod_date_debut\">");
		print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
		print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
		print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");
		print("<input type=\"hidden\" name=\"type_precedent\" value=".$etat.">");		
		print("<input type=\"hidden\" name=\"e\" value=1>");		
		print("<b>Date d&eacute;but : </b>");
		print("<input type=\"text\" name=\"date_debut\" value=\"".$date_debut."\" align=\"top\" maxlength=\"10\" size=\"10\">(AAAA-MM-JJ)<br>");
	
		print("<b>Heure d&eacute;but: </b>");
		print("<input type=\"text\" name=\"heure_debut\" value=\"".$heure_debut."\" align=\"top\" maxlength=\"10\" size=\"9\">(HHMM)<br>");
		
		print("<b>Calendrier d&eacute;but: </b>");
		print("<select name=\"cal_debut\">
			<option selected value=\"".$cal_debut."\">".$cal_debut."</option>
			<option value=\"1\">1</option>
			<option value=\"2\">2</option>
			<option value=\"3\">3</option>
			<option value=\"4\">4</option>			
		</select>");
		
		print("</td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	
	
		//fin	
		print("<br><b>Date fin : </b>");
		print("<input type=\"text\" name=\"date_fin\" value=\"".$date_fin."\" align=\"top\" maxlength=\"10\" size=\"10\">(AAAA-MM-JJ)<br>");	

		print("<b>Heure fin: </b>");
		print("<input type=\"text\" name=\"heure_fin\" value=\"".$heure_fin."\" align=\"top\" maxlength=\"10\" size=\"9\"><br>");
		
		print("<b>Calendrier fin: </b>");
		print("<select name=\"cal_fin\">
			<option selected value=\"".$cal_fin."\">".$cal_fin."</option>
			<option value=\"1\">1</option>
			<option value=\"2\">2</option>
			<option value=\"3\">3</option>
			<option value=\"4\">4</option>			
		</select>");
		if ($privilege_base == 2)//protection pour les droits de modification	
			print("<input type=\"image\" alt=\"btn_heure_fin\" src=\"bouton0.gif\" border=0 width=15 height=24>");
		print("</form>");		
	}
	else//si le contrat n'est pas actif on ne permet pas de faire de changement aux dates
	{
		print("</td></tr><tr><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");	
		print("<b>Date d&eacute;but : </b>");
		print($date_debut."(AAAA-MM-JJ)<br>");
		print("<b>Heure d&eacute;but: </b>");
		print($heure_debut."(HHMM)<br>");
		print("<b>Calendrier d&eacute;but: </b>".$cal_debut);
		
		print("</td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");

		//fin	
		print("<br><b>Date fin : </b>");
		print($date_fin."(AAAA-MM-JJ)<br>");	
		print("<b>Heure fin: </b>");
		print($heure_fin."<br>");		
		print("<b>Calendrier fin: </b>".$cal_fin);
	}
	
	
	print("</td></tr><tr><td bgcolor=#C8DB8D colspan=2><font face=Arial,Helvetica size=2>");

	//nuit&eacute;
	print("<b>Nombre de nuit&eacute;es : </b>");
	print($nuite);
	
	print("</td></tr>");
	
	print("</td></tr></table>");
	
	
print("<center><table cellspacing=0 cellpadding=0 width=750px border=0>");
print("<tr><td bgcolor=white width=27px><img src=coin-bas-gauche.gif></td>");
print("<td bgcolor=#636300 width=746px></td>");
print("<td bgcolor=white width=27px><img src=coin-bas-droit.gif></td>");
print("</tr></table><BR><BR>");			
	
	
}	
	
	
	
/*************************************************************************
 * displayClient
 *
 * T&acirc;che: Afficher les champs de donn&eacute;es du client ainsi que le lien pour le modifier
 *
 ************************************************************************/
function displayClient()
{

	//Variables globales.
		global $Bsession_id, $code_client, $type, $privilege_base;
 	
/*******************************************************************************************
 Requ&ecirc;te pour afficher le client
/*******************************************************************************************/
	$sql = "SELECT organisme, type, org_tel, org_ad_civile, org_rue, org_ville,
    	           org_province, org_pays, org_code_postal, commentaire   
        	FROM base_clients
		    WHERE base_clients.code_client = '$code_client';";
		
	// Ex&eacute;cute la requ&ecirc;te et mettre les r&eacute;sultats dans $result
	$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die ("Ne peut lire dans la table des clients".$sql);
	// obtenir le nombre d'enregistrement. 0 si invalide, 1 si valide.
	$num = mysqli_num_rows($result);

	// met la valeur dans les variables
	if ($num)
	{
		$i = 0;
		$row = mysqli_fetch_row($result);
		$organisme = ($row[$i++]);
		$type = ($row[$i++]);
		$org_tel = ($row[$i++]);
		$org_ad_civile = ($row[$i++]);
		$org_rue = ($row[$i++]);
		$org_ville = ($row[$i++]);
		$org_province = ($row[$i++]);
		$org_pays = ($row[$i++]);
		$org_code_postal = ($row[$i++]);
		$commentaire = ($row[$i++]);
	}
	else
	{
		die ("Il y a un probl&egrave;me dans la base de donn&eacute;es !".$sql);
	}

	// fait le m&eacute;nage des r&eacute;sultat en m&eacute;moire
	((mysqli_free_result($result) || (is_object($result) && (get_class($result) == "mysqli_result"))) ? true : false);
	
//*****************************************************************************************************
// afficher les r&eacute;sultats du client********************************************************************
//*****************************************************************************************************

	print("<center><table cellspacing=0 cellpadding=0 width=750px border=0>");
	print("<tr><td bgcolor=white width=27px><img src=coin-haut-gauche.gif></td>");
	print("<td bgcolor=#636300><font face=Arial,Helvetica size=3 color=white><b>1 : Information sur le client</b></td>");
	print("<td bgcolor=white width=27px><img src=coin-haut-droit.gif></td>");
	print("</td></tr></table>");	

	print("<table width=750px cellspacing=0 cellpadding=0 border=0>");
	
	print("<tr><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Organisme:</b> ".$organisme."</td><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");
	print("<b>Type:</b> ".$type."</td></tr><tr><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>T&eacute;l&eacute;phone:</b> ".$org_tel."</td><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");
	print("<b>Commentaire:<br></b>".$commentaire."</td></tr><tr><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Adresse:<br></b> ".$org_ad_civile." ".$org_rue.",<br>");
	print($org_ville.", ".$org_province.",<br>");
	print($org_pays."<br>".$org_code_postal."</td><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");
	

	print("<a href=\"../client/gestion-client.php?Bsession_id=$Bsession_id&code_client=$code_client\">Modifier le client</a>");
	
	print("</tr></td></table>");
	
print("<center><table cellspacing=0 cellpadding=0 width=750px border=0>");
print("<tr><td bgcolor=white width=27px><img src=coin-bas-gauche.gif></td>");
print("<td bgcolor=#636300 width=746px></td>");
print("<td bgcolor=white width=27px><img src=coin-bas-droit.gif></td>");
print("</tr></table><BR><BR>");		

}		


/*************************************************************************
 * displayChalet
 *
 * T&acirc;che: Afficher les champs de donn&eacute;es du client ainsi que le lien pour le modifier
 *
 ************************************************************************/	
function displayChalet()
{
	//Variables globales.
		global $Bsession_id, $code_client, $code_contrat, $type, $etat, $nuite, $privilege_base, $date_debut, $wich_base;
		
		$wich_base = 0;

	//RECHERCHE DANS LA TABLE BASE_CHALETS
	$sql = "SELECT base_ref1chalets.nom, base_chalets.prix_plein, base_chalets.prix_rabais,
	               base_chalets.date_modif, base_chalets.actif, base_chalets.num_chalet, base_chalets.prix_par_jour, base_chalets.frais_terrain, base_ref1chalets.base
	   		  FROM base_ref1chalets, base_chalets
			 WHERE base_chalets.code_contrat = '$code_contrat'
			   AND base_chalets.reservation = 'N'
               AND base_ref1chalets.num_chalet = base_chalets.num_chalet;";

	// Ex&eacute;cute la requ&egrave;te et mettre les r&eacute;sultats dans $result
	$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die ("Ne peut lire dans la table base_ref1chalets<br><br>".$sql);
	// obtenir le nombre d'enregistrement. 0 si invalide, 1 si valide.
	$num = mysqli_num_rows($result);
	

	//Va chercher letat du contrat
	$sql2 = "SELECT base_contrat.etat
			   FROM base_contrat
			  WHERE base_contrat.code_contrat = '$code_contrat';";
	$result2 = mysqli_query($GLOBALS["___mysqli_ston"], $sql2) or die ("Ne peut lire dans la table base_contrat<br><br>".$sql2);
	$row2 = mysqli_fetch_row($result2);
	$etat_contrat = $row2[0];

//Tableau de mise en page.

	print("<table cellspacing=0 cellpadding=0 width=100% border=0>");
	print("<tr><td bgcolor=white width=27px><img src=coin-haut-gauche.gif></td>");
	print("<td bgcolor=#636300><font face=Arial,Helvetica size=3 color=white><b>");
	print("4 : Information sur le(s) chalet(s)</b></td>");
	print("<td bgcolor=white width=27px><img src=coin-haut-droit.gif></td>");
	print("</td></tr></table>");	

	print("<table width=100% cellspacing=0 cellpadding=0 border=0>");
	print("<tr><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2><b>");
	print("<b>Liste des chalets :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Prix par jour :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");	
	print("<b>Frais terrain :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");	
	print("<b>Prix total :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Prix avec escompte :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Date :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Actif :</b></td></tr>");		
	
	// boucle et requete pour l'affichage des chalets choisis
		while ($row = mysqli_fetch_row($result))
		{	
		
			if ($row[8] == 'V')
				$wich_base = 1;
			
			$chalet_compteur=1;
			
			print("<form action=\"confirmation-contract.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\" name=\"mod_chalet\">");
			print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
			print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
			print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");
			print("<input type=\"hidden\" name=\"type\" value=".$etat_contrat.">");
			print("<input type=\"hidden\" name=\"type_precedent\" value=".$etat_contrat.">");
			print("<input type=\"hidden\" name=\"prec_etat\" value=".$row[4].">");
			print("<input type=\"hidden\" name=\"num_chalet\" value=".$row[5].">");
			//pour la gestion des postes budgetaire 
			print("<input type=\"hidden\" name=\"ancien_prix\" value=".$row[2].">");
			print("<input type=\"hidden\" name=\"type_client\" value=".$type.">");
			if ($nuite == 0)
				$nuite = 1;
			print("<input type=\"hidden\" name=\"nuite\" value=\"".$nuite."\">");	
	
					
			print("<tr><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");
			
			$aryDateMaintenant = explode("-",$date_debut);
			if(empty($aaaa)) $aaaa = $aryDateMaintenant[0];
			if(empty($mm)) $mm = $aryDateMaintenant[1];
			if(empty($jj)) $jj = $aryDateMaintenant[2]; 
			
			print("<a href=\"../calendrier/calendrier.php?Bsession_id=".$Bsession_id."&chalet=".$row[5]."&date=".$jj."-".$mm."-".$aaaa."\" target=blank><img src=images/bouton_calendrier.jpg border=0></a> ");
			print($row[0]);
			print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");
			if ($row[4] == 'O')
				print("<input type=text name=prix_par_jour value=\"".$row[6]."\" align=top maxlength=10 size=15 onChange=majlignechalet(".$row[5].");>");
			else
			{
				print($row[6]);
				print("<input type=hidden name=prix_par_jour value=\"".$row[6]."\">");
			}
			print("</td><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");
			if ($row[4] == 'O')
				print("<input type=text name=frais_terrain value=\"".$row[7]."\" align=top maxlength=10 size=15 onChange=majlignechalet(".$row[5].");>");
			else
			{
				print($row[7]);
				print("<input type=\"hidden\" name=\"frais_terrain\" value=\"".$row[7]."\">");
			}
			print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");
			
			if ($row[4] == 'O')
				print("<input type=text name=plein_prix value=\"".$row[1]."\" align=top maxlength=10 size=15 DISABLED onfocus='this.blur();'>");
			else
			{
				print($row[1]);
				print("<input type=\"hidden\" name=\"plein_prix\" value=\"".$row[1]."\">");
			}		
			print("</td><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");
			if ($row[4] == 'O')			
				print("<input type=text name=prix_reel value=\"".$row[2]."\" align=top maxlength=10 size=15>");
			else
			{
				print($row[2]);
				print("<input type=\"hidden\" name=\"prix_reel\" value=\"".$row[2]."\">");
			}		
			print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");
			print($row[3]);
			print("</td><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");
			print("<select name=\"etat\">
				<option selected value=\"".$row[4]."\">".$row[4]."</option>
				<option value=\"O\">O</option>
				<option value=\"N\">N</option>
			</select>");
	
			if (($etat != "annul&eacute;") and ($etat != "pass&eacute;") and ($privilege_base == 2))
			{
				print("<input type=\"image\" alt=\"btn_chalet\" src=\"bouton0.gif\" border=0 width=15 height=24></form>");
			}	
			print("</td></tr>");
			
			$chalet_compteur++;
			
		}
	
		//BOUTON AJOUTER
		print("<tr><td bgcolor=#E7EFCE colspan= 7><font face=Arial,Helvetica size=2><div align=right>");
		if (($etat != "annul&eacute;") and ($etat != "pass&eacute;") and ($privilege_base == 2))
		{
			print("Pour ajouter un nouveau chalet : <a href='ajout-chalet.php?Bsession_id=".$Bsession_id."&code_contrat=".$code_contrat."&code_client=".$code_client."&etat_contrat=".$etat_contrat."&type=".$etat_contrat."&type_precedent=".$etat_contrat."&type_client=".$type."&nuite=".$nuite."' target=blank><img src=bouton2.gif border=0></a>");
		}	
		print("</td></tr>");
		print("</table>");
		
print("<center><table cellspacing=0 cellpadding=0 width=100% border=0>");
print("<tr><td bgcolor=white width=27px><img src=coin-bas-gauche.gif></td>");
print("<td bgcolor=#636300 width=100%></td>");
print("<td bgcolor=white width=27px><img src=coin-bas-droit.gif></td>");
print("</tr></table><BR><BR>");			


}




/*************************************************************************
 * displayclientele
 *
 * T&acirc;che: Afficher les champs de donn&eacute;es du nombre de jeune et d'adulte
 *
 ************************************************************************/
function displayClientele()
{
	//Variables globales.
		global $Bsession_id, $code_contrat, $code_client, $nb_jeune, $nb_adulte, $type, $etat, $nuite, $privilege_base;

	
	//RECHERCHE DANS LA TABLE BASE_NB_CLIENT
	$sql = "SELECT nb_jeune, nb_adulte, mis_a_jour, actif  
    	    FROM base_nb_clients
	       WHERE code_contrat ='$code_contrat'";
		
	// Ex&eacute;cute la requ&egrave;te et mettre les r&eacute;sultats dans $result
	$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die ("Ne peut lire dans la table des base_nb_clients".$sql);
	// obtenir le nombre d'enregistrement. 0 si invalide, 1 si valide.
	$num = mysqli_num_rows($result);


	
	//Tableau de mise en page.
	print("<table width=100% border=0>");
	print("<tr><td colspan=3 bgcolor=black><font size=4 color=white><b><center>Client&egrave;le</b></center></font></td></tr>");
	
		
	while ($row = mysqli_fetch_row($result))//boucle pour l'affichage de toute les donn&eacute;es
	{
	
		//JEUNE
		print("<tr><td><font face=Arial,Helvetica size=2>");
		print("<form action=\"confirmation-contract.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\" name=\"mod_jeune\">");
		print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
		print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
		print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");
		print("<input type=\"hidden\" name=\"mod_clientele\" value=1>");		
		
		//JEUNE				
		print("<b>Jeune : </b>");
		if ($row[3] == 'O')
			print("<input type=\"text\" name=\"nb_jeune\" value=\"".$row[0]."\" align=\"top\" maxlength=\"15\" size=\"5\">");
		else
		{
			print($row[0]);	
			print("<input type=\"hidden\" name=\"nb_jeune\" value=".$row[0].">");
		}				
		print("</td>");
	

		//ADULTE
		print("<td><font face=Arial,Helvetica size=2>");
		print("<b>Adulte : </b>");
		if ($row[3] == 'O')
			print("<input type=\"text\" name=\"nb_adulte\" value=\"".$row[1]."\" align=\"top\" maxlength=\"15\" size=\"5\">");
		else	
		{
			print($row[1]);
			print("<input type=\"hidden\" name=\"nb_adulte\" value=".$row[1].">");
		}				

		
		
		
		if (($row[3] == 'O') and ($etat != "annul&eacute;") and ($etat != "pass&eacute;") and ($privilege_base == 2))
		{
			print("<input type=\"image\" alt=\"btn_nb_clients\" src=\"bouton0.gif\" border=0 width=15 height=24>");
		}	
		print("</form></td></tr>");
	}
	print("</center></td></tr></table>");

}




/*************************************************************************
 * displayCafeteria
 *
 * T&acirc;che: Afficher les champs de donn&eacute;es du nombre de jeune et d'adulte
 *
 ************************************************************************/
function displayCafeteria()
{	

//Variables globales.
		global $Bsession_id, $code_contrat, $code_client, $type, $etat, $nuite, $privilege_base;

//RECHERCHE DANS LA TABLE BASE_CAFETERIA
	$sql = "SELECT nb_pers, prix_plein, prix_rabais, date_modif, actif, nb_repas, prix_par_repas, lunchpm, prix_lunchpm, commentaire
    	    FROM base_cafeteria
	       WHERE code_contrat ='$code_contrat'
		   AND actif ='O';";
		
	// Ex&eacute;cute la requ&egrave;te et mettre les r&eacute;sultats dans $result
	$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die ("Ne peut lire dans la table des base_nb_clients".$sql);
	// obtenir le nombre d'enregistrement. 0 si invalide, 1 si valide.
	$num = mysqli_num_rows($result);			
		
	//Tableau de mise en page.
	print("<table cellspacing=0 cellpadding=0 width=100% border=0>");
	print("<tr><td bgcolor=white width=27px><img src=coin-haut-gauche.gif></td>");
	print("<td bgcolor=#636300><font face=Arial,Helvetica size=3 color=white><b>3 : Information sur la caf&eacute;t&eacute;ria</b></td>");
	print("<td bgcolor=white width=27px><img src=coin-haut-droit.gif></td>");	
	print("</td></tr></table>");
	
	
	print("<table width=100% cellspacing=0 cellpadding=0 border=0>");
	print("<tr><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2><b>");
	print("<b>Nombre de personne</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Nombre de repas</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Prix / repas</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	
	print("<b>Nb lunchpm</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Prix / lunchpm</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");		
	print("<b>Prix total</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Prix avec escompte</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Date</b></td><td bgcolor=#E7EFCE></tr>");
	
	
	while ($row = mysqli_fetch_row($result))//boucle pour l'affichage de toute les donn&eacute;es
	{

		print("<form action=\"confirmation-contract.php?Bsession_id=".$_GET['Bsession_id']."\" method=get name=mod_cafeteria>");
		print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
		print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
		print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");
		print("<input type=\"hidden\" name=\"mod_cafe\" value=1>");
		//pour la gestion des postes budgetaire
		print("<input type=\"hidden\" name=\"ancien_prix\" value=".$row[2].">");
		print("<input type=\"hidden\" name=\"type\" value=".$type.">");
	
	
		print("<tr><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");
		if ($row[4] == 'O')
			print("<input type=\"text\" name=\"nb_pers_cafe\" value=\"".$row[0]."\" align=\"top\" maxlength=\"15\" size=\"10\">");
		else
			print($row[0]);	
		print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");
		
		if ($row[4] == 'O')
			print("<input name=nb_repas_cafe value=".$row[5]." align=top maxlength=15 size=10 onChange='majligne();'>");
		else
			print($row[5]);	
		print("</td><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");
		
		if ($row[4] == 'O')
			print("<input name=prix_repas_cafe value=".$row[6]." align=top maxlength=15 size=10 onChange='majligne();'>");
		else
			print($row[6]);	
		print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");
		
		
		
		if ($row[4] == 'O')
			print("<input name=lunchpm value=".$row[7]." align=top maxlength=15 size=10 onChange='majligne();'>");
		else
			print($row[7]);	
		print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");	
		
		if ($row[4] == 'O')
			print("<input name=prix_lunchpm value=".$row[8]." align=top maxlength=15 size=10 onChange='majligne();'>");
		else
			print($row[8]);	
		print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");	
				
		
		if ($row[4] == 'O')
			print("<input name=plein_prix_cafe value=".$row[1]."  align=top maxlength=15 size=10 DISABLED onfocus='this.blur();'>");
		else
			print($row[1]);
		print("</td><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");

		if ($row[4] == 'O')
			print("<input type=\"text\" name=\"prix_reel_cafe\" value=\"".$row[2]."\" align=\"top\" maxlength=\"15\" size=\"10\">");
		else
			print($row[2]);
		print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");
		print($row[3]);				

		
		print("</td></tr><tr><td colspan=7 bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");
		if ($row[4] == 'O')
			print("<textarea name=commentaire_cafe rows=3 cols=96 wrap=PHYSICAL>".$row[9]."</textarea>");
		else
			print($row[9]);	
		print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");
		
		
		//bouton pour modifier
		if (($row[4] == 'O') and ($etat != "annul&eacute;") and ($etat != "pass&eacute;") and ($privilege_base == 2))
		{	
			print("<input type=\"image\" alt=\"btn_cafe\" src=\"bouton0.gif\" border=0 width=15 height=24>");
		}
		print("</form>");
		print("</td></tr>");

	}
	
	if (empty ($num))
	{
		//BOUTON AJOUTER
		print("<tr><td bgcolor=#E7EFCE colspan= 8><div align=right>");
		
		if (($etat != "annul&eacute;") and ($etat != "pass&eacute;") and ($privilege_base == 2))
		{
			print("<font face=Arial,Helvetica size=2>Pour ajouter une caf&eacute;t&eacute;ria : <a href='ajout-cafeteria.php?Bsession_id=".$Bsession_id."&code_contrat=".$code_contrat."&code_client=".$code_client."&type=".$type."' target=blank><img src=bouton2.gif border=0></a>");
		}		
		print("</td></tr>");
	}	
	print("</table>");	
	
print("<center><table cellspacing=0 cellpadding=0 width=100% border=0>");
print("<tr><td bgcolor=white width=27px><img src=coin-bas-gauche.gif></td>");
print("<td bgcolor=#636300 width=100%></td>");
print("<td bgcolor=white width=27px><img src=coin-bas-droit.gif></td>");
print("</tr></table><BR><BR>");	
	
}	




/*************************************************************************
 * displayActivite
 *
 * T&acirc;che: Afficher les champs de donn&eacute;es des activit&eacute;s
 *
 ************************************************************************/	
function displayActivite()
{	
	//Variables globales.
		global $Bsession_id, $code_client, $code_contrat, $type, $etat, $nuite, $privilege_base;

	//RECHERCHE DANS LA TABLE BASE_ACTIVITES
	$sql = "SELECT base_ref1activites.nom, base_activites.prix_plein, base_activites.prix_rabais,
	               base_activites.date_modif, base_activites.actif, base_activites.num_activite, base_activites.inclu
	   		  FROM base_ref1activites, base_activites
			 WHERE base_activites.code_contrat = '$code_contrat'	   
               AND base_ref1activites.num_activite = base_activites.num_activite;";
			   
		
	// Ex&eacute;cute la requ&ecirc;te et mettre les r&eacute;sultats dans $result
	$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die ("Ne peut lire dans la table base_activites<br><br>".$sql);
	// obtenir le nombre d'enregistrement. 0 si invalide, 1 si valide.
	$num = mysqli_num_rows($result);		
		
		
//Tableau de mise en page.
	print("<table cellspacing=0 cellpadding=0 width=100% border=0>");
	print("<tr><td bgcolor=white width=27px><img src=coin-haut-gauche.gif></td>");
	print("<td bgcolor=#636300><font face=Arial,Helvetica size=3 color=white><b>5 : Information sur les activit&eacute;s</b></td>");
	print("<td bgcolor=white width=27px><img src=coin-haut-droit.gif></td>");	
	print("</td></tr></table>");	


	print("<table cellspacing=0 cellpadding=0 width=100% border=0>");
	print("<tr><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2><b>");
	print("<b>Liste des activit&eacute;s :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Prix total :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Prix avec escompte :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Inclu :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Date :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Actif :</b></td></tr>");		
	
	
	// boucle et requete pour l'affichage des chalets choisis
		while ($row = mysqli_fetch_row($result))
		{
			print("<form action=\"confirmation-contract.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\" name=\"mod_activite\">");
			print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
			print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
			print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");	
			print("<input type=\"hidden\" name=\"num_activite\" value=".$row[5].">");
			//pour la gestion des postes budgetaire 
			print("<input type=\"hidden\" name=\"ancien_prix\" value=".$row[2].">");
			print("<input type=\"hidden\" name=\"type_client\" value=".$type.">");
			print("<input type=\"hidden\" name=\"prec_etat\" value=".$row[4].">");
			print("<input type=\"hidden\" name=\"type\" value=".$etat.">");
			$inclu = $row[6];						

			
			print("<tr><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");
			print($row[0]);
			print("<input type=\"hidden\" name=\"activite\" value=".$row[0].">");
			print("</td><td bgcolor=#D6E4AC>");
			
				
			if ($row[4] == 'O')
				print("<input type=\"text\" name=\"plein_prix\" value=".$row[1]." align=\"top\" maxlength=\"10\" size=\"15\">");
			else
			{
				print($row[1]);
				print("<input type=\"hidden\" name=\"plein_prix\" value=".$row[1].">");
			}
			
			
			
			print("</td><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");
				
			if ($row[4] == 'O')	
				print("<input type=\"text\" name=\"prix_reel\" value=".$row[2]." align=\"top\" maxlength=\"10\" size=\"15\">");
			else
			{
				print($row[2]);
				print("<input type=\"hidden\" name=\"prix_reel\" value=".$row[2].">");
			}	
			print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");
			
			
			
			if ($row[4] == 'O')
			{
				print("<select name=\"inclu\">
					<option selected value=\"".$row[6]."\">".$row[6]."</option>
					<option value=\"O\">O</option>
					<option value=\"N\">N</option>
				</select>");
			}
			else
			{
				print($row[6]);
				print("<input type=\"hidden\" name=\"inclu\" value=".$row[6].">");
			}	

			print("</td><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");			
			
			
			
				
			print($row[3]);
			print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");	
			print("<select name=\"etat\">
				<option selected value=\"".$row[4]."\">".$row[4]."</option>
				<option value=\"O\">O</option>
				<option value=\"N\">N</option>
			</select>");
	
			if (($etat != "annul&eacute;") and ($etat != "pass&eacute;") and ($privilege_base == 2))
			{
				print("<input type=\"image\" alt=\"btn_activite\" src=\"bouton0.gif\" border=0 width=15 height=24></form>");
			}
			print("</td></tr>");	
		}	

		//BOUTON AJOUTER
		print("<tr><td bgcolor=#E7EFCE colspan= 6><font face=Arial,Helvetica size=2><div align=right>");
		
		if (($etat != "annul&eacute;") and ($etat != "pass&eacute;") and ($privilege_base == 2))
		{
			print("<font face=Arial,Helvetica size=2>Pour ajouter une nouvelle activit&eacute; : <a href='ajout-activite.php?Bsession_id=".$Bsession_id."&code_contrat=".$code_contrat."&code_client=".$code_client."&type=".$type."' target=blank><img src=bouton2.gif border=0></a>");
		}		
		print("</td></tr>");
	print("</table>");
	
print("<center><table cellspacing=0 cellpadding=0 width=100% border=0>");
print("<tr><td bgcolor=white width=27px><img src=coin-bas-gauche.gif></td>");
print("<td bgcolor=#636300 width=100%></td>");
print("<td bgcolor=white width=27px><img src=coin-bas-droit.gif></td>");
print("</tr></table><BR><BR>");		
	

	
}	


/*************************************************************************
 * displayLocation
 *
 * T&acirc;che: Afficher les champs de donn&eacute;es des location de mat&eacute;riel
 *
 ************************************************************************/	
function displayLocation()
{	
	//Variables globales.
		global $Bsession_id, $code_client, $code_contrat, $type, $etat, $nuite, $privilege_base;

	//RECHERCHE DANS LA TABLE BASE_LOC_MATERIELS
	$sql = "SELECT base_ref1materiels.nom, base_loc_materiels.quantite, base_loc_materiels.prix_plein, base_loc_materiels.prix_rabais,
	               base_loc_materiels.date_modif, base_loc_materiels.actif, base_loc_materiels.num_materiel, base_loc_materiels.inclu
	   		  FROM base_ref1materiels, base_loc_materiels
			 WHERE base_loc_materiels.code_contrat = '$code_contrat'	   
               AND base_ref1materiels.num_materiel = base_loc_materiels.num_materiel;";
			   
		
	// Ex&eacute;cute la requ&ecirc;te et mettre les r&eacute;sultats dans $result
	$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die ("Ne peut lire dans la table base_loc_materiels<br><br>".$sql);
	// obtenir le nombre d'enregistrement. 0 si invalide, 1 si valide.
	$num = mysqli_num_rows($result);		
		
		
//Tableau de mise en page.
	print("<table cellspacing=0 cellpadding=0 width=100% border=0>");
	print("<tr><td bgcolor=white width=27px><img src=coin-haut-gauche.gif></td>");
	print("<td bgcolor=#636300><font face=Arial,Helvetica size=3 color=white><b>6 : Information sur le mat&eacute;riel de location</b></td>");
	print("<td bgcolor=white width=27px><img src=coin-haut-droit.gif></td>");	
	print("</td></tr></table>");	


	print("<table width=100% cellspacing=0 cellpadding=0 border=0>");
	print("<tr><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2><b>");
	print("<b>Liste des locations :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Quantit&eacute; :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");	
	print("<b>Prix total :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Prix avec escompte :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Inclu :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Date :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Actif :</b></td></tr>");		
	
	
	// boucle et requete pour l'affichage des chalets choisis
		while ($row = mysqli_fetch_row($result))
		{
			print("<form action=\"confirmation-contract.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\" name=\"mod_location\">");
			print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
			print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
			print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");	
			print("<input type=\"hidden\" name=\"num_materiel\" value=".$row[6].">");
			print("<input type=\"hidden\" name=\"nuite\" value=".$nuite.">");
			//pour la gestion des postes budgetaire 
			print("<input type=\"hidden\" name=\"ancien_prix\" value=".$row[3].">");
			print("<input type=\"hidden\" name=\"type_client\" value=".$type.">");
			print("<input type=\"hidden\" name=\"prec_etat\" value=".$row[5].">");						
				
			print("<tr><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");
			print($row[0]);
			print("<input type=\"hidden\" name=\"materiel\" value=".$row[0].">");			
			print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");	
			
			if ($row[5] =='O')
				print("<input type=text name=\"quantite\" value=".$row[1]." align=top maxlength=40 size=15>");
			else
			{
				print($row[1]);
				print("<input type=\"hidden\" name=\"quantite\" value=".$row[1].">");				
			}
				
			print("</td><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");			
			if ($row[5] =='O')
				print("<input type=\"text\" name=\"plein_prix\" value=".$row[2]." align=\"top\" maxlength=\"10\" size=\"15\">");
			else
			{
				print($row[2]);
				print("<input type=\"hidden\" name=\"plein_prix\" value=".$row[2].">");
			}
			print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");
			
			if ($row[5] =='O')
				print("<input type=\"text\" name=\"prix_reel\" value=".$row[3]." align=\"top\" maxlength=\"10\" size=\"15\">");
			else
			{
				print($row[3]);
				print("<input type=\"hidden\" name=\"prix_reel\" value=".$row[3].">");
			}				
			print("</td><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");	
			
			//inclu
			if ($row[5] == 'O')
			{
				print("<select name=\"inclu\">
					<option selected value=\"".$row[7]."\">".$row[7]."</option>
					<option value=\"O\">O</option>
					<option value=\"N\">N</option>
				</select>");
			}
			else
			{
				print($row[7]);
				print("<input type=\"hidden\" name=\"inclu\" value=".$row[7].">");
			}	

			print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");
			
			
			
			print($row[4]);
			print("</td><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");	
			print("<select name=\"etat\">
				<option selected value=\"".$row[5]."\">".$row[5]."</option>
				<option value=\"O\">O</option>
				<option value=\"N\">N</option>
			</select>");
	
			if (($etat != "annul&eacute;") and ($etat != "pass&eacute;") and ($privilege_base == 2))
			{
				print("<input type=\"image\" alt=\"btn_location\" src=\"bouton0.gif\" border=0 width=15 height=24></form>");
			}	
			print("</td></tr>");	
		}	
		
		//BOUTON AJOUTER
		print("<tr><td bgcolor=#E7EFCE colspan= 7><font face=Arial,Helvetica size=2><div align=right>");
		if (($etat != "annul&eacute;") and ($etat != "pass&eacute;") and ($privilege_base == 2))
		{
			print("Pour ajouter une location : <a href='ajout-location.php?Bsession_id=".$Bsession_id."&code_contrat=".$code_contrat."&code_client=".$code_client."&type=O' target=blank><img src=bouton2.gif border=0></a>");
		}			
		print("</td></tr>");
	print("</table>");
	
print("<center><table cellspacing=0 cellpadding=0 width=100% border=0>");
print("<tr><td bgcolor=white width=27px><img src=coin-bas-gauche.gif></td>");
print("<td bgcolor=#636300 width=100%></td>");
print("<td bgcolor=white width=27px><img src=coin-bas-droit.gif></td>");
print("</tr></table><BR><BR>");		
	
	
}
	


/*************************************************************************
 * displayAchat
 *
 * T&acirc;che: Afficher les champs de donn&eacute;es des achats de mat&eacute;riel
 *
 ************************************************************************/	
function displayAchat()
{	
		//Variables globales.
		global $Bsession_id, $code_client, $code_contrat, $type, $etat, $nuite, $privilege_base;

	//RECHERCHE DANS LA TABLE BASE_VENTE_MATERIELS
	$sql = "SELECT base_ref1materiels.nom, base_vente_materiels.quantite, base_vente_materiels.prix_plein, base_vente_materiels.prix_rabais,
	               base_vente_materiels.date_modif, base_vente_materiels.actif, base_vente_materiels.num_materiel, base_vente_materiels.inclu
	   		  FROM base_ref1materiels, base_vente_materiels
			 WHERE base_vente_materiels.code_contrat = '$code_contrat'	   
               AND base_ref1materiels.num_materiel = base_vente_materiels.num_materiel;";
			   
		
	// Ex&eacute;cute la requ&ecirc;te et mettre les r&eacute;sultats dans $result
	$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die ("Ne peut lire dans la table base_loc_materiels<br><br>".$sql);
	// obtenir le nombre d'enregistrement. 0 si invalide, 1 si valide.
	$num = mysqli_num_rows($result);		
		
		
//Tableau de mise en page.
	print("<table cellspacing=0 cellpadding=0 width=100% border=0>");
	print("<tr><td bgcolor=white width=27px><img src=coin-haut-gauche.gif></td>");
	print("<td bgcolor=#636300><font face=Arial,Helvetica size=3 color=white><b>7 : Information sur les achats</b></td>");
	print("<td bgcolor=white width=27px><img src=coin-haut-droit.gif></td>");	
	print("</td></tr></table>");	


	print("<table width=100% cellspacing=0 cellpadding=0 border=0>");
	print("<tr><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2><b>");
	print("<b>Liste des Achats :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Quantit&eacute; :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");	
	print("<b>Prix total :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Prix avec escompte :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Inclu :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Date :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Actif :</b></td></tr>");		
	
	
	// boucle et requete pour l'affichage des chalets choisis
		while ($row = mysqli_fetch_row($result))
		{
			print("<form action=\"confirmation-contract.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\" name=\"mod_achat\">");
			print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
			print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
			print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");	
			print("<input type=\"hidden\" name=\"num_materiel\" value=".$row[6].">");
			//pour la gestion des postes budgetaire 
			print("<input type=\"hidden\" name=\"ancien_prix\" value=".$row[3].">");
			print("<input type=\"hidden\" name=\"type_client\" value=".$type.">");
			print("<input type=\"hidden\" name=\"prec_etat\" value=".$row[5].">");						
						
				
			print("<tr><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");
			print($row[0]);
			print("<input type=\"hidden\" name=\"achat\" value=".$row[0].">");
			print("</td><td bgcolor=#D6E4AC>");
			
			if ($row[5] == 'O')
				print("<input type=text name=\"quantite\" value=".$row[1]." align=top maxlength=40 size=15>");
			else
			{
				print($row[1]);	
				print("<input type=\"hidden\" name=\"quantite\" value=".$row[1].">");
			}
			
							
			print("</td><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");
			if ($row[5] == 'O')
				print("<input type=\"text\" name=\"plein_prix\" value=".$row[2]." align=\"top\" maxlength=\"10\" size=\"15\">");
			else
			{
				print($row[2]);	
				print("<input type=\"hidden\" name=\"plein_prix\" value=".$row[2].">");
			}	
			
			print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");
			if ($row[5] == 'O')
				print("<input type=\"text\" name=\"prix_reel\" value=".$row[3]." align=\"top\" maxlength=\"10\" size=\"15\">");
			else
			{
				print($row[3]);	
				print("<input type=\"hidden\" name=\"prix_reel\" value=".$row[3].">");
			}
			print("</td><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");	
			
			//inclu
			if ($row[5] == 'O')
			{
				print("<select name=\"inclu\">
					<option selected value=\"".$row[7]."\">".$row[7]."</option>
					<option value=\"O\">O</option>
					<option value=\"N\">N</option>
				</select>");
			}
			else
			{
				print($row[7]);
				print("<input type=\"hidden\" name=\"inclu\" value=".$row[7].">");
			}	
			
			
			
			
			
				
			print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");
			print($row[4]);
			print("</td><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");
			print("<select name=\"etat\">
				<option selected value=\"".$row[5]."\">".$row[5]."</option>
				<option value=\"O\">O</option>
				<option value=\"N\">N</option>
			</select>");
	
			if (($etat != "annul&eacute;") and ($etat != "pass&eacute;") and ($privilege_base == 2))
			{
				print("<input type=\"image\" alt=\"btn_achat\" src=\"bouton0.gif\" border=0 width=15 height=24></form>");
			}	
			print("</td></tr>");	
		}	
		
		//BOUTON AJOUTER
		print("<tr><td bgcolor=#E7EFCE colspan= 7><font face=Arial,Helvetica size=2><div align=right>");
		if (($etat != "annul&eacute;") and ($etat != "pass&eacute;") and ($privilege_base == 2))
		{
			print("Pour ajouter un achat : <a href='ajout-achat.php?Bsession_id=".$Bsession_id."&code_contrat=".$code_contrat."&code_client=".$code_client."&type=O' target=blank><img src=bouton2.gif border=0></a>");
		}		
		print("</td></tr>");
	print("</table>");
print("<center><table cellspacing=0 cellpadding=0 width=100% border=0>");
print("<tr><td bgcolor=white width=27px><img src=coin-bas-gauche.gif></td>");
print("<td bgcolor=#636300 width=100%></td>");
print("<td bgcolor=white width=27px><img src=coin-bas-droit.gif></td>");
print("</tr></table><BR><BR>");	
	
	
	
}




/*************************************************************************
 * displayRabais
 *
 * T&acirc;che: Afficher les champs de donn&eacute;es des rabais
 *
 ************************************************************************/	
function displayRabais()
{	
	//Variables globales.
		global $Bsession_id, $code_client, $code_contrat, $type, $etat, $nuite, $privilege_base;

	//RECHERCHE DANS LA TABLE BASE_RABAIS
	$sql = "SELECT base_rabais.code_rabais, base_rabais.code_contrat, base_rabais.prix_rabais, base_rabais.poste_budget, 
	               base_rabais.commentaire, base_rabais.actif, base_rabais.mis_a_jour
	   		  FROM base_rabais
			 WHERE base_rabais.code_contrat = '$code_contrat';";
			   
		
	// Ex&eacute;cute la requ&ecirc;te et mettre les r&eacute;sultats dans $result
	$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die ("Ne peut lire dans la table base_rabais<br><br>".$sql);
	// obtenir le nombre d'enregistrement. 0 si invalide, 1 si valide.
	$num = mysqli_num_rows($result);		
		
		
//Tableau de mise en page.
	print("<table cellspacing=0 cellpadding=0 width=100% border=0>");
	print("<tr><td bgcolor=white width=27px><img src=coin-haut-gauche.gif></td>");
	print("<td bgcolor=#636300><font face=Arial,Helvetica size=3 color=white><b>8 : Information sur les rabais</b></td>");
	print("<td bgcolor=white width=27px><img src=coin-haut-droit.gif></td>");	
	print("</td></tr></table>");	


	print("<table cellspacing=0 cellpadding=0 width=100% border=0>");
	print("<tr><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2><b>");
	print("<b>Commentaire :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Prix du rabais :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Poste :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Date :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<b>Actif :</b></td></tr>");		
	
	
	// boucle et requete pour l'affichage des rabais
		while ($row = mysqli_fetch_row($result))
		{
			print("<form action=\"confirmation-contract.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\" name=\"mod_rabais\">");
			print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
			print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
			print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");	
			print("<input type=\"hidden\" name=\"code_rabais\" value=".$row[0].">");
			//pour la gestion des postes budgetaire 
			print("<input type=\"hidden\" name=\"ancien_prix\" value=".$row[2].">");
			print("<input type=\"hidden\" name=\"type_client\" value=".$type.">");
			print("<input type=\"hidden\" name=\"prec_etat\" value=".$row[5].">");				

			
			print("<tr><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");
			
			if ($row[5] == 'O')
				print("<input type=\"textarea\" name=\"commentaire_rabais\" value=\"".$row[4]."\" align=\"top\" maxlength=\"255\" size=\"60\">");
			else
			{          
				print($row[4]);
				print("<input type=\"hidden\" name=\"commentaire_rabais\" value=".$row[4].">");
			}	
	
			print("</td><td bgcolor=#D6E4AC>");
			
				
			if ($row[5] == 'O')
				print("<input type=\"text\" name=\"prix_rabais\" align=top maxlength=10 size=15 value=".$row[2].">");
			else
			{
				print($row[2]);
				print("<input type=\"hidden\" name=\"prix_rabais\" value=".$row[2].">");
			}
			
			
			
			print("</td><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");
	
			if ($row[5] == 'O')	
				print("<input type=text name=poste align=top maxlength=\"10\" size=\"15\" value=".$row[3].">");
			else
			{
				print($row[3]);
				print("<input type=\"hidden\" name=\"poste\" value=".$row[3].">");
			}	
			
			print("</td><td bgcolor=#C8DB8D><font face=Arial,Helvetica size=2>");			
			
			print($row[6]);
			print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");	
			print("<select name=\"etat\">
				<option selected value=\"".$row[5]."\">".$row[5]."</option>
				<option value=\"O\">O</option>
				<option value=\"N\">N</option>
			</select>");
	
			if (($etat != "annul&eacute;") and ($etat != "pass&eacute;") and ($privilege_base == 2))
			{
				print("<input type=\"image\" alt=\"btn_activite\" src=\"bouton0.gif\" border=0 width=15 height=24></form>");
			}
			print("</td></tr>");	
		}	

		//BOUTON AJOUTER
		print("<tr><td bgcolor=#E7EFCE colspan= 6><font face=Arial,Helvetica size=2><div align=right>");
		
		if (($etat != "annul&eacute;") and ($etat != "pass&eacute;") and ($privilege_base == 2))
		{
			print("<font face=Arial,Helvetica size=2>Pour ajouter un rabais : <a href='ajout-rabais.php?Bsession_id=".$Bsession_id."&code_contrat=".$code_contrat."&code_client=".$code_client."&code_rabais=".$row[0]."' target=blank><img src=bouton2.gif border=0></a>");
		}		
		print("</td></tr>");
	print("</table>");
	
print("<center><table cellspacing=0 cellpadding=0 width=100% border=0>");
print("<tr><td bgcolor=white width=27px><img src=coin-bas-gauche.gif></td>");
print("<td bgcolor=#636300 width=100%></td>");
print("<td bgcolor=white width=27px><img src=coin-bas-droit.gif></td>");
print("</tr></table><BR><BR>");		
	

	
}













/*************************************************************************
 * displayTotal
 *
 * T&acirc;che: Afficher les champs de donn&eacute;es des totaux
 *
 ************************************************************************/	
function displayTotal()
{

//Variables globales.
		global $Bsession_id, $code_client, $code_contrat, $date_emission, $type, $poste, $etat, $numero_contrat, $nuite, $privilege_base, $depot_50, $wich_base;
		

//cherche tout les prix du nombre de client
		$sql = "select prix_plein, prix_rabais  
				FROM base_nb_clients 
			   WHERE code_contrat = '$code_contrat'				
				 AND actif = 'O';";
		$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die("Probl&egrave;me de recherche du prix du client!<br>".$sql);
		$row = mysqli_fetch_row($result);
		$nb_plein_prix = $row[0];
		$nb_prix_reel = $row[1];	
		
	

//cherche tout les prix des chalets du contrat
		$sql = "select SUM(prix_plein),
		               SUM(prix_rabais)  
				FROM base_chalets 
				WHERE code_contrat = '$code_contrat'
			      AND actif = 'O'
				  AND reservation = 'N';";
			
		$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die("Probl&egrave;me de recherche des chalets du contrat!<br>".$sql);
		$row = mysqli_fetch_row($result);
		$chalet_plein_prix = $row[0];
		$chalet_prix_reel = $row[1];



//cherche tout les prix de caf&eacute;t&eacute;ria du contrat
		$sql = "select prix_plein, prix_rabais  
				FROM base_cafeteria 
			   WHERE code_contrat = '$code_contrat'
				 AND actif = 'O';";
			
		$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die("Probl&egrave;me de recherche des cafeteria du contrat!<br>".$sql);
		$row = mysqli_fetch_row($result);
		$cafe_plein_prix = $row[0];
		$cafe_prix_reel = $row[1];
		

//cherche tout les prix des activites du contrat
		$sql = "select SUM(prix_plein),
		               SUM(prix_rabais)  
				FROM base_activites 
				WHERE code_contrat = '$code_contrat'
			      AND actif = 'O';";				
			
		$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die("Probl&egrave;me de recherche des activites du contrat!<br>".$sql);
		$row = mysqli_fetch_row($result);
		$activite_plein_prix = $row[0];
		$activite_prix_reel = $row[1];
		
		
		
//cherche tout les prix des locations du contrat
		$sql = "select SUM(prix_plein),
		               SUM(prix_rabais)  
				FROM base_loc_materiels 
				WHERE code_contrat = '$code_contrat'
			      AND actif = 'O';";				
			
		$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die("Probl&egrave;me de recherche des locations du contrat!<br>".$sql);
		$row = mysqli_fetch_row($result);
		$loc_plein_prix = $row[0];
		$loc_prix_reel = $row[1];		
		
		
		
//cherche tout les prix des achats du contrat
		$sql = "select SUM(prix_plein),
		               SUM(prix_rabais)  
				FROM base_vente_materiels 
				WHERE code_contrat = '$code_contrat'
			      AND actif = 'O';";				
			
		$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die("Probl&egrave;me de recherche des achats du contrat!<br>".$sql);
		$row = mysqli_fetch_row($result);
		$vente_plein_prix = $row[0];
		$vente_prix_reel = $row[1];		
		
		
		
//cherche tout les prix des rabais du contrat
		$sql = "select SUM(prix_rabais)
				FROM base_rabais 
				WHERE code_contrat = '$code_contrat'
			      AND actif = 'O';";				
			
		$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die("Probl&egrave;me de recherche des achats du contrat!<br>".$sql);
		$row = mysqli_fetch_row($result);
		$prix_rabais = $row[0];
				
		
		
	$plein_prix = ($chalet_plein_prix + $cafe_plein_prix + $activite_plein_prix + $loc_plein_prix + $vente_plein_prix + $nb_plein_prix);
	$prix_reel = ($chalet_prix_reel + $cafe_prix_reel + $activite_prix_reel + $loc_prix_reel + $vente_prix_reel + $nb_prix_reel);	
	
//Tableau de mise en page.

	print("<center><table cellspacing=0 cellpadding=0 width=750px border=0>");
	print("<tr><td bgcolor=white width=27px><img src=coin-haut-gauche.gif></td>");
	print("<td bgcolor=#636300><font face=Arial,Helvetica size=3 color=white><center><b>TOTAL</b></td>");
	print("<td bgcolor=white width=27px><img src=coin-haut-droit.gif></td>");
	print("</td></tr></table>");	


	print("<table width=750px cellspacing=0 cellpadding=0 border=0>");
	print("<tr><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");

	
//AFFICHAGE PLEIN_PRIX
	print("<div align=right><b>Prix r&eacute;gulier : </b>");
	printf('%01.2f',$plein_prix);
	print(" $<br>");
	print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");

	print("</td></tr>");
	print("<tr><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	
//AFFICHAGE DU RABAIS TOTAl;																			calcul du rabais
	$rabais_tot=$plein_prix-$prix_reel+$prix_rabais;
	print("<div align=right><b>Escompte : </b>");
	printf('%01.2f',$rabais_tot);
	print(" $<br>");	
	print("</td><td bgcolor=#D6E4AC><font face=Arial,Helvetica size=2>");
	print("</td></tr>");
	print("<tr><td bgcolor=#D6E4AC>");
	
	



//////////////////////////////////////////////////////////////
//				CALCUL ET AFFICHAGE DU D&eacute;POT				//
//////////////////////////////////////////////////////////////
	$sql = "select base_contrat.depot, base_contrat.etat, base_contrat.depot_lock
    		  FROM base_contrat
			 WHERE code_contrat = '$code_contrat';";
	$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die("Probl&egrave;me d'application de lecture du depot!<br>".$sql);
	$row = mysqli_fetch_row($result);
	$depot = $row[0];
	$depot_reel = $row[0];
	$ancien_prix = $row[0];
	$etat_contrat = $row[1];
	$depot_lock = $row[2];
	
	if (($prix_reel*0.2) > 200)
	{
		$depot = ($prix_reel*0.2);
	}
	else
	{
		$depot = 200;
	}

  	print("<tr><td bgcolor=#E7EFCE colspan=2><font face=Arial,Helvetica size=2>");


	//pour empecher le calcul du depot automatiquement, le geler a un prix fixe
	print("<form action=\"confirmation-contract.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\" name=\"mod_depot_lock\">");
		print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
		print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
		print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");
		print("<div align=right><b>D&eacute;p&ocirc;t sugg&eacute;r&eacute; : </b>");
		printf('%01.2f',$depot);		
		print(" <B>D&eacute;p&ocirc;t : </B><input type=\"text\" name=\"depot_reel\" value=".$depot_reel." align=\"top\" maxlength=\"10\" size=\"15\">");
	if ($privilege_base == 2)//protection pour les droits de modification	
		print("<input type=\"image\" alt=\"btn_depot_lock\" src=\"bouton0.gif\" border=0 width=18 height=27><br>");		
	print("</form>");
	

//////////////////////////////////////////////////////////////
//				AFFICHAGE DE L'INVESTISSEMENT DES GROUPES	//
//////////////////////////////////////////////////////////////	
	
	print("<form action=\"confirmation-contract.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\" name=\"mod_50\">");
		print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
		print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
		print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");
		print("<div align=right><b>Investissement des groupes : </b>");
		print("<input type=\"text\" name=\"depot_50\" value=".$depot_50." align=\"top\" maxlength=\"10\" size=\"15\">");
	if ($privilege_base == 2)//protection pour les droits de modification	
		print("<input type=\"image\" alt=\"btn_depot_50_lock\" src=\"bouton0.gif\" border=0 width=18 height=27><br><br>");		
	print("</form>");
	

	
//////////////////////////////////////////////////////////////
	
	
	
//AFFICHAGE DU GRAND TOTAL
		$sql = "select credit
     		  FROM base_contrat
			 WHERE code_contrat = '$code_contrat';";
	
		$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die("Probl&egrave;me d'application du credit!<br>".$sql);
		$row = mysqli_fetch_row($result);
		$credit = $row[0];
	
	$grand_total = $prix_reel-$prix_rabais;
	print("<div align=right><b>Grand total : </b>");
	printf('%01.2f',$grand_total);
	print(" $<br>");
	print("</td></tr>");
	print("</table>");
	
print("<center><table cellspacing=0 cellpadding=0 width=750px border=0>");
print("<tr><td bgcolor=white width=27px><img src=coin-bas-gauche.gif></td>");
print("<td bgcolor=#636300 width=746px></td>");
print("<td bgcolor=white width=27px><img src=coin-bas-droit.gif></td>");
print("</tr></table><BR><BR>");	
	



//R&eacute;SERV&eacute; AU BUREAU
	$sql = "select base_envoi_contrat.expedie_le, base_envoi_contrat.recu_le
			FROM base_envoi_contrat
			WHERE base_envoi_contrat.code_contrat = '$code_contrat'";

	$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die("Probl&egrave;me de recherche de la date exp&eacute;di&eacute; ou recu!<br>".$sql);
	$row = mysqli_fetch_row($result);
		
		
	//Tableau de mise en page.
	
		print("<center><table cellspacing=0 cellpadding=0 width=750px border=0>");
		print("<tr><td bgcolor=white width=27px><img src=coin-haut-gauche.gif></td>");
		print("<td bgcolor=#636300><center><font face=Arial,Helvetica size=3 color=white><b>R&eacute;SERV&eacute; AU BUREAU</b></td>");
		print("<td bgcolor=white width=27px><img src=coin-haut-droit.gif></td>");
		print("</td></tr></table>");	
	
	
	print("<table width=750px cellspacing=0 cellpadding=0 border=0>");
	print("<tr><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2><b>");
	
	//EXPEDI&eacute; LE et RECU LE
	print("<form action=\"confirmation-contract.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\" name=\"mod_expedie\">");
		print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
		print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
		print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");
		print("<input type=\"hidden\" name=\"mod_expedie\" value=1>");			
	print("<b>Contrat exp&eacute;di&eacute; le :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<div align=left><input type=\"text\" name=\"expedie\" value=\"".$row[0]."\" align=\"top\" maxlength=\"10\" size=\"10\"></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");	
	print("<b>Re&ccedil;u le :</b></td><td bgcolor=#E7EFCE><font face=Arial,Helvetica size=2>");
	print("<div align=left><input type=\"text\" name=\"recu\" value=\"".$row[1]."\" align=\"top\" maxlength=\"10\" size=\"10\">");	
	if ($privilege_base == 2)	
		print("<input type=\"image\" alt=\"btn_expedie\" src=\"bouton0.gif\" border=0 width=18 height=27>");
	print("</form></td></tr><tr><td colspan=4>");

	
	//PAIEMENT
	print("<table width=750px border=1>");	
	print("<tr><td><font face=Arial,Helvetica size=2><b>");
	print("<b>D&eacute;p&ocirc;t re&ccedil;u le :</b></td><td><font face=Arial,Helvetica size=2>");
	print("<b>Montant :</b></td></td><td><font face=Arial,Helvetica size=2>");
	print("<b>Poste budg&eacute;taire :</b></td></td><td><font face=Arial,Helvetica size=2>");
	print("<b>Commentaire :</b></td></td><td><font face=Arial,Helvetica size=2>");		
	print("supp</td></tr>");
			
	$sql = "select base_depot.recu_le, base_depot.montant, base_depot.commentaire, base_depot.poste, base_depot.code_depot
		  FROM base_depot
		 WHERE base_depot.code_contrat = '$code_contrat';";
	$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die("Probl&egrave;me de recherche dans les paiements<br>".$sql);
	
	
	$paiement_total = 0;
	// boucle et requete pour l'affichage des paiements
	while ($row1 = mysqli_fetch_row($result))
	{
	
		print("<form action=\"confirmation-contract.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\" name=\"supp_depot\">");
		print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
		print("<input type=\"hidden\" name=\"code_depot\" value=".$row1[4].">");	
		print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
		print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");
		print("<input type=\"hidden\" name=\"supp_depot\" value=1>");
	
		print("<tr><td><font face=Arial,Helvetica size=2>");
		print($row1[0]);
		print("</td><td><font face=Arial,Helvetica size=2>");
		print($row1[1]);
		print("</td><td><font face=Arial,Helvetica size=2>");
		print($row1[3]);
		print("</td><td><font face=Arial,Helvetica size=2>");			
		print($row1[2]);
		
		
		if (($etat != "annul&eacute;") and ($etat != "pass&eacute;") and ($privilege_base == 2))
		{
			print("</td><td><font face=Arial,Helvetica size=2>");
			print("<input type=\"image\" alt=\"btn_depot\" src=\"bouton_supp.jpg\" border=0>");
		}
		
		print("</form></td></tr>");
		$paiement_total = $paiement_total + $row1[1];
	}
	print("</table>");	
	print("</td></tr><tr><td bgcolor=#E7EFCE colspan=4><font face=Arial,Helvetica size=2>");	
	//BOUTON AJOUTER

	
	if (($etat != "annul&eacute;") and ($privilege_base == 2))
	{
		print("<div align=right>Pour ajouter un d&eacute;pot : <a href='ajout-depot.php?Bsession_id=".$Bsession_id."&code_contrat=".$code_contrat."' target=blank><img src=bouton2.gif border=0></a>");
	}			
	print("<br><br>");
	$balance = $grand_total - $paiement_total;
	print("Balance &agrave; payer : ");
	printf('%01.2f',$balance);
	print(" $<BR><BR>");


	print("</td></tr><tr><td bgcolor=#D6E4AC colspan=4><font face=Arial,Helvetica size=2>");
	
	
//BOUTON POUR LE RAPPORT SUR LE TYPE DE CLIENT&egrave;LE	
	print("<form action=\"information.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\" name=\"information\">");
		print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
		print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
		print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");			
		print("<div align=right><input type=\"image\" alt=\"btn_information\" src=\"bouton7.gif\" border=0></div>");
	print("</form>");
	
	
	
	
	
//R&eacute;F&eacute;R&eacute; PAR ET COMMENTAIRE	
		$sql = "select base_contrat.refere, base_contrat.commentaire  
				FROM base_contrat 
				WHERE base_contrat.code_contrat = '$code_contrat'";				
			
		$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die("Probl&egrave;me de recherche du r&eacute;f&eacute;rent et des commentaires du contrat!<br>".$sql);
		$row = mysqli_fetch_row($result);	

	print("<font size = 3>");
	print("<form action=\"confirmation-contract.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\" name=\"mod_refere\">");
		print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
		print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
		print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");		
	print("<div align=right>R&eacute;f&eacute;r&eacute; par : </b><input type=\"text\" name=\"refere\" value=\"".$row[0]."\" align=\"top\" maxlength=\"40\" size=\"40\"></div>");
		print("<input type=\"image\" alt=\"btn_refere\" src=\"bouton0.gif\" border=0 width=15 height=24>");
	print("</form></font><BR><BR>");

	print("<form action=\"confirmation-contract.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\" name=\"mod_commentaire\">");
		print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
		print("<input type=\"hidden\" name=\"code_contrat\" value=".$code_contrat.">");
		print("<input type=\"hidden\" name=\"code_client\" value=".$code_client.">");		
	print("<div align=left>Commentaire :<font size=1>(&eacute;crire 'br' entre <> pour que le texte change de ligne &agrave; l'affichage)</div> </font>");
	print("<input type=\"text\" name=\"commentaire\" value=\"".$row[1]."\" align=\"top\" maxlength=\"800\" size=\"100\">");

		print("<input type=\"image\" alt=\"btn_commentaire\" src=\"bouton0.gif\" border=0 width=15 height=24>");	
	print($row[1]."</form><BR></font><BR><BR>");


	//IMPRIMER LE CONTRAT
	print("<div align=right>Pour imprimer le contrat : <a href='imprim-contract.php?Bsession_id=".$Bsession_id."&code_contrat=".$code_contrat."&plein_prix=".$plein_prix."&prix_reel=".$prix_reel."&rabais_tot=".$rabais_tot."&grand_total=".$grand_total."&numero_contrat=".$numero_contrat."&balance=".$balance."&wich_base=".$wich_base."'><img src=bouton8.gif border=0></a></font>");

		$sql = "select code_contrat  
				FROM base_rapport_client
				WHERE code_contrat = '$code_contrat'";				
		$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die("Probl&egrave;me de recherche du r&eacute;f&eacute;rent et des commentaires du contrat!<br>".$sql);
		$row = mysqli_fetch_row($result);
		if(empty($row))
		{	
			//REMPLIR LE RAPPORT CLIENT
			print("<div align=right>Remplir la fiche d'&eacute;valuation : <a href='../rapport/rapport-client.php?Bsession_id=".$Bsession_id."&code_contrat=".$code_contrat."&code_client=".$code_client."&etape=1'><img src=images/bouton_rapport_client.jpg border=0></a></font>");
		}
		
		print("</td></tr></table>");
		
			

print("<center><table cellspacing=0 cellpadding=0 width=750px border=0>");
print("<tr><td bgcolor=white width=27px><img src=coin-bas-gauche.gif></td>");
print("<td bgcolor=#636300 width=746px></td>");
print("<td bgcolor=white width=27px><img src=coin-bas-droit.gif></td>");
print("</tr></table><BR><BR>");

			
			
	
			
}



	

	//Fin du formulaire.

	
	




	
?>

</body>
</html>	
	
	
	
	
