<html>

 <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Nouveau client</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");
require("../historique.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)
	die("Vous n'avez pas les droits!");

	$etape = $_GET['etape'];
  $organisme = $_GET['organisme'];
	$type = $_GET['type'];
	$org_tel = $_GET['org_tel'];
	$mod_org_tel_poste = $_GET['mod_org_tel_poste'];
	$org_tel_poste = $_GET['org_tel_poste'];
	$org_tel_poste = $_GET['org_tel_poste'];
	$mod_org_ad_civile = $_GET['mod_org_ad_civile'];
	$org_ad_civile = $_GET['org_ad_civile'];
	$mod_org_rue = $_GET['mod_org_rue'];
	$org_rue = $_GET['org_rue'];
	$mod_org_ville = $_GET['mod_org_ville'];
	$org_ville = $_GET['org_ville'];
	$mod_org_province = $_GET['mod_org_province'];
	$org_province = $_GET['org_province'];
	$mod_org_pays = $_GET['mod_org_pays'];
	$org_pays = $_GET['org_pays'];
	$mod_org_code_postal = $_GET['mod_org_code_postal'];
	$org_code_postal = $_GET['org_code_postal'];
	$nom = $_GET['nom'];
	$mod_prenom = $_GET['mod_prenom'];
	$prenom = $_GET['prenom'];
	$mod_tel_reside = $_GET['mod_tel_reside'];
	$client_tel_reside = $_GET['client_tel_reside'];
	$mod_tel_fax = $_GET['mod_tel_fax'];
	$client_tel_fax = $_GET['client_tel_fax'];
	$mod_tel_autre = $_GET['mod_tel_autre'];
	$client_tel_autre = $_GET['client_tel_autre'];
	$mod_client_ad_civile = $_GET['mod_client_ad_civile'];
	$client_ad_civique = $_GET['client_ad_civique'];
	$mod_client_rue = $_GET['mod_client_rue'];
	$client_rue = $_GET['client_rue'];
	$mod_client_app = $_GET['mod_client_app'];
	$client_app = $_GET['client_app'];
	$mod_client_ville = $_GET['mod_client_ville'];
	$client_ville = $_GET['client_ville'];
	$mod_client_province = $_GET['mod_client_province'];
	$client_province = $_GET['client_province'];
	$mod_client_pays = $_GET['mod_client_pays'];
	$client_pays = $_GET['client_pays'];
	$mod_client_code_postal = $_GET['mod_client_code_postal'];
	$client_code_postal = $_GET['client_code_postal'];
	$od_client_courriel = $_GET['od_client_courriel'];
	$client_courriel = $_GET['client_courriel'];
	$mod_commentaire = $_GET['mod_commentaire'];
	$commentaire = $_GET['commentaire'];
  $credit = $_GET['credit'];
	$ville = $_GET['ville'];
  $province = $_GET['province'];
  $pays = $_GET['pays'];
  $code_postal = $_GET['code_postal'];
  $courriel = $_GET['courriel'];
	
	
historique("../historique.txt","MENU NOUVEAU CLIENT",$Bsession_id);	

if (empty($etape))
{

	//Afficher les champs d'entr&eacute;e des informations du nouveau dossier.
	displayFields();

//	pageDebug("&Eacute;tape 0");
}
if ($etape == '1')
{ 
	if (empty($organisme))
	{
		$organisme = "aucun";
	}
//*************************************************************************
// cr&eacute;er le nouveau enregistrement dans la table clients
 	$sql = "insert into base_clients
			set organisme = '$organisme',
				type = '$type',
			    org_tel = '$org_tel',
				org_tel_poste = '$org_tel_poste',
				org_ad_civile = '$org_ad_civile', 
				org_rue = '$org_rue',
				org_ville = '$org_ville',
				org_province = '$org_province', 
				org_pays = '$org_pays',
				org_code_postal = '$org_code_postal', 
				credit = '$credit',
				
				nom = '$nom',
				prenom = '$prenom',
				client_tel_reside = '$tel',
				client_tel_fax = '$tel_fax',
				client_tel_autre = '$tel_autre',
				client_ad_civique = '$ad_civique',
				client_rue = '$rue',
				client_app = '$app',
				client_ville = '$ville',
				client_province = '$province',
				client_pays = '$pays',
				client_code_postal = '$code_postal',
				client_courriel = '$courriel',
				commentaire = '$commentaire',
				date_inscription = now(),
				mis_a_jour = now();";
			
	$result = mysql_query($sql) or die("Probl&egrave;me de cr&eacute;ation!<br>");
historique("../historique.txt","---Creation du client ".$organisme.", ".$nom."".$prenom."",$Bsession_id);	

//Confirmation de l'enregistrement ************************************************************

	print("<center><table cellspacing=0 cellpadding=0 width=200px border=0>");
	print("<tr><td bgcolor=white width=27px><img src=coin-haut-gauche.gif></td>");
	print("<td bgcolor=#636300 width=100%><center><font face=Arial,Helvetica size=3 color=white><b>Confirmation</b></td>");
	print("<td bgcolor=white width=27px><img src=coin-haut-droit.gif></td>");
	print("</td></tr><tr><td colspan=3 bgcolor=#E7EFCE>");	
	print("<BR><b><center>L'enregistrement &agrave; &eacute;t&eacute; un succ&egrave;s.</b><BR> <colspan=3</td></tr><tr><td colspan=3 bgcolor=#E7EFCE><center>");
	
if ($lien == 2)//de contrat
{

	$sql = "select organisme, nom, prenom, code_client 
			from base_clients
			where base_clients.nom like '$nom'
			and base_clients.prenom like '$prenom'
			and base_clients.organisme like '$organisme';";
	$result = mysql_query($sql) or die ("ne peut aller chercher le client");
	$row = mysql_fetch_row ($result);

	//Afficher le bouton vers le nouveau contrat.
	print("<form action=\"../contract/nouveau-contract1.php?Bsession_id=$Bsession_id&code_client=".$row[3]."\" method=\"post\" name=\"nouveaucontrat\">");
	print("<input type=\"hidden\" name=\"client\" value=".$row[3].">");
	print("<input type=\"hidden\" name=\"code_client\" value=".$row[3].">");
	print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
	print("<input type=\"submit\" name=\"nouveau_contrat\" value=\"Suivant\"></form>");
}
if ($lien == 1)//de client
{
	//Afficher le bouton de nouveau client.
	print("<form action=\"nouveau-client.php\" method=\"post\" name=\"nouveauclient\">");
	print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
	print("<input type=\"hidden\" name=\"lien\" value=".$lien.">");	
	print("<input type=\"submit\" name=\"nouveau_client\" value=\"Nouveau client\"></form>");
	
	//Afficher le bouton de retour menu client.
	print("<form action=\"client.php\" method=\"post\" name=\"client\">");
	print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
	print("<input type=\"submit\" name=\"menu_client\" value=\"menu client\"></form>");
	
	//Afficher le bouton de retour au menu principal.
	print("<form action=\"../menu-base.php\" method=\"post\" name=\"principal\">");
	print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
	print("<input type=\"submit\" name=\"menu_principal\" value=\"Menu Principal\"></form>");
}	

print("</td></tr></table>");

print("<center><table cellspacing=0 cellpadding=0 width=200px 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>");	
	
}
 
 
 
 
 
 /*************************************************************************
 * displayFields
 *
 * Tāche: Afficher les champs d'ajout de donn&eacute;es ainsi que le bouton
 *        de soumission des donn&eacute;es d'ajout.
 *
 ************************************************************************/
function displayFields()
{ 
//Variables globales.

    //pour l'organisme
	global $Bsession_id, $lien, $organisme, $type, $org_tel, $org_tel_poste, $org_ad_civile, $org_rue, $org_ville, 
		   $org_province, $org_ville, $org_pays, $org_code_postal, $credit, 
	//pour le client	    
		   $nom, $prenom, $tel, $tel_fax, $tel_autre, $ad_civile, $rue, $app, $ville, $province, 
		   $pays, $code_postal, $commentaire ;

		   
	//Formulaire d'ajout d'un nouveau membre.
	print ("<form action=\"nouveau-client.php\" method=\"get\" name=\"champ\">
		    <input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">
			<input type=\"hidden\" name=\"etape\" value=1>");
			print("<input type=\"hidden\" name=\"lien\" value=".$lien.">");
			
			
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>Ajout d'un nouveau client</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=750px border=0><tr><td valign=top>");			
//***************POUR L'ORGANISME***************************
	//Tableau de mise en page.
	print("<table cellspacing=0 cellpadding=0 width=375px height=400px border=0>");
	
	//ORGANISME
	print("<tr><td bgcolor=#E7EFCE><b>");
	print("ORGANISME:<br><br>");
	
	print("Organisme: ");
	print("</b></td><td bgcolor=#E7EFCE><div align=right><br><br>");
	print("<input type=\"text\" value=\"$organisme\" name=\"organisme\" align=\"top\" maxlength=\"100\" size=\"25\">");

	//TYPE
	print("</td></tr><tr><td bgcolor=#E7EFCE><b>");
	print("Type:");
	print("</b>");
	print("</td><td bgcolor=#E7EFCE><div align=right>");
	print("<select name=\"type\">
			<option selected value=\"SMM\">SMM</option>
			<option value=\"Ext\">Scouts ext</option>
			<option value=\"Famille\">Famille</option>
			<option value=\"District\">District</option>
			<option value=\"Trio\">Trio</option>
			<option value=\"Autres\">Autres</option>			
		</select>");
		
	//T&Eacute;L&Eacute;PHONE
	print("</div></td></tr><tr><td bgcolor=#E7EFCE><b>");
	print("T&eacute;l&eacute;phone: ");
	print("</b></td><td bgcolor=#E7EFCE><div align=right>");
	print("<input type=\"text\" value=\"$org_tel\" name=\"org_tel\" align=\"top\" maxlength=\"15\" size=\"25\">");	
	
	//POSTE
	print("</div></td></tr><tr><td bgcolor=#E7EFCE><b>");
	print("Tel poste: ");
	print("</b></td><td bgcolor=#E7EFCE><div align=right>");
	print("<input type=\"text\" value=\"$org_tel_poste\" name=\"org_tel_poste\" align=\"top\" maxlength=\"15\" size=\"25\">");	
	
	//ADRESSE CIVIQUE
	print("</div></td></tr><tr><td bgcolor=#E7EFCE><b>");
	print("Adresse civile: ");
	print("</b></td><td bgcolor=#E7EFCE><div align=right>");
	print("<input type=\"text\" value=\"$org_ad_civile\" name=\"org_ad_civile\" align=\"top\" maxlength=\"5\" size=\"25\">");	
	
	//RUE
	print("</div></td></tr><tr><td bgcolor=#E7EFCE><b>");
	print("Rue: ");
	print("</b></td><td bgcolor=#E7EFCE><div align=right>");
	print("<input type=\"text\" value=\"$org_rue\" name=\"org_rue\" align=\"top\" maxlength=\"100\" size=\"25\">");	
	
	//VILLE
	print("</div></td></tr><tr><td bgcolor=#E7EFCE><b>");
	print("Ville: ");
	print("</b></td><td bgcolor=#E7EFCE><div align=right>");
	print("<input type=\"text\" value=\"$org_ville\" name=\"org_ville\" align=\"top\" maxlength=\"100\" size=\"25\">");	
	
	//PROVINCE
	print("</div></td></tr><tr><td bgcolor=#E7EFCE><b>");
	print("Province: ");
	print("</b></td><td bgcolor=#E7EFCE><div align=right>");
	print("<input type=\"text\" value=\"Qu&eacute;bec\" name=\"org_province\" align=\"top\" maxlength=\"100\" size=\"25\">");

	//PAYS
	print("</div></td></tr><tr><td bgcolor=#E7EFCE><b>");
	print("Pays: ");
	print("</b></td><td bgcolor=#E7EFCE><div align=right>");
	print("<input type=\"text\" value=\"Canada\" name=\"org_pays\" align=\"top\" maxlength=\"100\" size=\"25\">");
	
	//CODE POSTAL
	print("</div></td></tr><tr><td bgcolor=#E7EFCE><b>");
	print("Code postal: ");
	print("</b></td><td bgcolor=#E7EFCE><div align=right>");
	print("<input type=\"text\" value=\"$org_code_postal\" name=\"org_code_postal\" align=\"top\" maxlength=\"7\" size=\"25\">");	

	//CREDIT
	print("</div></td></tr><tr><td bgcolor=#E7EFCE><b>");
	print("Cr&eacute;dit: ");
	print("</b></td><td bgcolor=#E7EFCE><div align=right>");
	print("<input type=\"text\" value=\"$credit\" name=\"credit\" align=\"top\" maxlength=\"10\" size=\"25\">");	
	
	
	print("</td></tr></table>");
	print("</td><td valign=top>");	
//***************POUR LE CLIENT***************************
	//Tableau de mise en page.
	print("<table cellspacing=0 cellpadding=0 width=375px height=400px border=0>");

	//NOM
	print("<tr><td bgcolor=#C8DB8D><b>");
	print("CONTACT:<br><br>");	
	
	print("Nom: ");
	print("</b></td><td bgcolor=#C8DB8D><div align=right><br><br>");
	print("<input type=\"text\" value=\"$nom\" name=\"nom\" align=\"top\" maxlength=\"100\" size=\"25\">");
	
	//PRENOM
	print("<tr><td bgcolor=#C8DB8D><b>");
	print("Pr&eacute;nom: ");
	print("</b></td><td bgcolor=#C8DB8D><div align=right>");
	print("<input type=\"text\" value=\"$prenom\" name=\"prenom\" align=\"top\" maxlength=\"100\" size=\"25\">");

	//TELEPHONE
	print("<tr><td bgcolor=#C8DB8D><b>");
	print("T&eacute;l&eacute;phone: ");
	print("</b></td><td bgcolor=#C8DB8D><div align=right>");
	print("<input type=\"text\" value=\"$tel\" name=\"tel\" align=\"top\" maxlength=\"15\" size=\"25\">");	
	
	//TELEPHONE FAX
	print("<tr><td bgcolor=#C8DB8D><b>");
	print("Fax: ");
	print("</b></td><td bgcolor=#C8DB8D><div align=right>");
	print("<input type=\"text\" value=\"$tel_fax\" name=\"tel_fax\" align=\"top\" maxlength=\"15\" size=\"25\">");
	
	//TELEPHONE AUTRE
	print("<tr><td bgcolor=#C8DB8D><b>");
	print("Autre tel: ");
	print("</b></td><td bgcolor=#C8DB8D><div align=right>");
	print("<input type=\"text\" value=\"$tel_autre\" name=\"tel_autre\" align=\"top\" maxlength=\"15\" size=\"25\">");
	
	//ADRESSE CIVIL
	print("<tr><td bgcolor=#C8DB8D><b>");
	print("Adresse civile: ");
	print("</b></td><td bgcolor=#C8DB8D><div align=right>");
	print("<input type=\"text\" value=\"$ad_civique\" name=\"ad_civique\" align=\"top\" maxlength=\"100\" size=\"25\">");	
	
	//RUE
	print("<tr><td bgcolor=#C8DB8D><b>");
	print("Rue: ");
	print("</b></td><td bgcolor=#C8DB8D><div align=right>");
	print("<input type=\"text\" value=\"$rue\" name=\"rue\" align=\"top\" maxlength=\"100\" size=\"25\">");	
	
	//APPARTEMENT
	print("<tr><td bgcolor=#C8DB8D><b>");
	print("App: ");
	print("</b></td><td bgcolor=#C8DB8D><div align=right>");
	print("<input type=\"text\" value=\"$app\" name=\"app\" align=\"top\" maxlength=\"10\" size=\"25\">");
		
	//VILLE
	print("<tr><td bgcolor=#C8DB8D><b>");
	print("Ville: ");
	print("</b></td><td bgcolor=#C8DB8D><div align=right>");
	print("<input type=\"text\" value=\"$ville\" name=\"ville\" align=\"top\" maxlength=\"100\" size=\"25\">");	
	
	//PROVINCE
	print("<tr><td bgcolor=#C8DB8D><b>");
	print("Province: ");
	print("</b></td><td bgcolor=#C8DB8D><div align=right>");
	print("<input type=\"text\" value=\"Qu&eacute;bec\" name=\"province\" align=\"top\" maxlength=\"100\" size=\"25\">");
	
	//PAYS
	print("<tr><td bgcolor=#C8DB8D><b>");
	print("Pays: ");
	print("</b></td><td bgcolor=#C8DB8D><div align=right>");
	print("<input type=\"text\" value=\"Canada\" name=\"pays\" align=\"top\" maxlength=\"100\" size=\"25\">");
	
	//CODE POSTAL
	print("<tr><td bgcolor=#C8DB8D><b>");
	print("Code postal: ");
	print("</b></td><td bgcolor=#C8DB8D><div align=right>");
	print("<input type=\"text\" value=\"$code_postal\" name=\"code_postal\" align=\"top\" maxlength=\"7\" size=\"25\">");

	//COURRIEL
	print("<tr><td bgcolor=#C8DB8D><b>");
	print("Courriel: ");
	print("</b></td><td bgcolor=#C8DB8D><div align=right>");
	print("<input type=\"text\" value=\"$courriel\" name=\"courriel\" align=\"top\" maxlength=\"50\" size=\"25\">");
	
	//COMMENTAIRE
	print("<tr><td bgcolor=#C8DB8D><b>");
	print("Commentaire: ");
	print("</b></td><td bgcolor=#C8DB8D><div align=right>");
	print("<input type=\"text\" value=\"$commentaire\" name=\"commentaire\" align=\"top\" maxlength=\"255\" size=\"25\">");	
	print("</td></tr></table>");
print("</center></div></td></tr><tr><td colspan=2 bgcolor=#D6E4AC>");
	
	//bouton de soumission	
	print("<center><br>");
	print("<input type=\"submit\" value=\"Soumettre\">");	
 	print("</form></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>");	
	
	
//BAS DE PAGE**********************************************************************
	
print("<table width=100%><tr><td width=50%>");
print("<div align=right>");	
	//Afficher le bouton de retour au menu client.
	print("<form action=\"client.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"post\" name=\"client\">");
	print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
	print("<input type=\"submit\" name=\"menu_client\" value=\"Menu client\"></form>");
print("</td><td width=50%>");
print("<div align=left>");	
	//Afficher le bouton de retour au menu principal.
	print("<form action=\"../menu-base.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"post\" name=\"principal\">");
	print("<input type=\"hidden\" name=\"Bsession_id\" value=".$_GET['Bsession_id'].">");
	print("<input type=\"submit\" name=\"menu_principal\" value=\"Menu Principal\"></form>");
print("</td><tr></table>");	
	//Fin du formulaire.
}
	
	




	
?>

</body>
</html>	
	
	
	
	
