<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Rapports pr&eacute;sence et entretien des camps</title>
<link href="/scoutsmm.qc.ca/base/baseCSS.css" rel="stylesheet" type="text/css">
<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) and ($privilege_base != 1))
	die("Vous n'avez pas les droits!");
	

	
$question_texte[0] = "Accueil lors de votre arriv&eacute;e";
$question_texte[1] = "Propret&eacute; du chalet ou emplacement";
$question_texte[2] = "Accessoire de fonctionnement<BR>(cuisine, toilette, produits entretiens)";
$question_texte[3] = "Services offerts par le personnel (soutien)";
$question_texte[4] = "&Eacute;tat du mat&eacute;riel lou&eacute; de plein air";
$question_texte[5] = "&Eacute;tat du mat&eacute;riel pr&ecirc;t&eacute; par la base";
$question_texte[6] = "Glissade";
$question_texte[7] = "Patinoire";
$question_texte[8] = "Raquette";
$question_texte[9] = "H&eacute;bertisme";
$question_texte[10] = "Volleyball";
$question_texte[11] = "Sentier";
$question_texte[12] = "Tir &agrave; l'arc";
$question_texte[13] = "Canots";
$question_texte[14] = "Kayak";
$question_texte[15] = "Rabaska";
$question_texte[16] = "Escalade";
$question_texte[17] = "Construction radeau";
$question_texte[18] = "Sentier &eacute;cologique";
$question_texte[19] = "Astronomie";
$question_texte[20] = "Autres";
$question_texte[21] = "Animation en g&eacute;n&eacute;ral";
$question_texte[22] = "Service";	
$question_texte[23] = "Qualit&eacute;";
$question_texte[24] = "Quantit&eacute;";
$question_texte[25] = "D&eacute;part de votre groupe";
$question_texte[26] = "Ensemble de votre s&eacute;jour";
	

		
	
if ($etape == 1)//CREATION DUN RAPPORT DANS LA BASE DE DONNEE
{
	//trouve les donn&eacute;es de l'usager
	$sql_usager = "SELECT usager
					FROM usager
					WHERE bidsession = '$Bsession_id';";
	$result_usager = mysql_query($sql_usager) or die("Probl&egrave;me de recherche du client!".$sql_usager."<br>");
	$row_usager = mysql_fetch_row ($result_usager);
	$referant = ($row_usager[0]);
	
	//trouve les donnees du contrat
	$sql = "SELECT base_clients.organisme, base_contrat.numero_contrat, base_contrat.date_debut, base_contrat.date_fin
        	FROM base_clients, base_contrat
		    WHERE base_clients.code_client = '$code_client'
			AND base_contrat.code_contrat = '$code_contrat'
			AND base_contrat.num_client = '$code_client';";
	$result = mysql_query($sql) or die("Probl&egrave;me de recherche du client!".$sql."<br>");
	$row = mysql_fetch_row ($result);

	$nom = $row[0];
	$num_contrat = $row[1];
	$date_debut = $row[2];
	$date_fin = $row[3];
	
	//trouve les chalets
	$sql_chalet = "SELECT base_ref1chalets.nom
	   		  FROM base_ref1chalets, base_chalets
			 WHERE base_chalets.code_contrat = '$code_contrat'
			   AND base_chalets.reservation = 'N'
			   AND base_chalets.actif = 'O'
               AND base_ref1chalets.num_chalet = base_chalets.num_chalet;";
	$result_chalet = mysql_query($sql_chalet) or die ("Ne peut lire dans la table base_ref1chalets<br><br>".$sql_chalet);

	
		
	print("<center><table width=580px cellspacing=0 cellpadding=0 border=1>");
	
	print("<tr>");
	print("<td colspan=5 valign=top><h2><B>Nom de l'unit&eacute; ou du groupe :</B> ".$nom."<BR>");
	print("<B>Contrat :</B> ".$num_contrat."<BR>");
	print("<B>Chalet ou emplacement :</B> ");
	while ($row_chalet = mysql_fetch_row ($result_chalet))
	{
		print($row_chalet[0].", ");
	}
	print("<BR>");
	print("<B>Date du s&eacute;jour :</B> ".$date_debut." au ".$date_fin."<BR>");
	print("<B>Personne ressource :</B> ".$referant."<BR><BR></td></tr>");
			
	
	//question	   
	print("<form action=\"rapport-client.php?Bsession_id=".$_GET['Bsession_id']."\" method=\"get\">");
	print("<input type=\"hidden\" name=\"Bsession_id\" value=\"".$_GET['Bsession_id']."\">");
	print("<input type=\"hidden\" name=\"referant\" value=\"".$referant."\">");
	print("<input type=\"hidden\" name=\"code_client\" value=\"".$code_client."\">");
	print("<input type=\"hidden\" name=\"code_contrat\" value=\"".$code_contrat."\">");
	print("<input type=\"hidden\" name=\"etape\" value=\"2\">");	
	
	print("<tr>");
	print("<td  bgcolor=#E7EFCE valign=top><h1><center>Charte d'&eacute;valuation</td>");
	print("<td width=70px bgcolor=#E7EFCE valign=top><h2><center><B>M&eacute;diocre<BR>1</B></td>");
	print("<td width=70px bgcolor=#E7EFCE valign=top><h2><center><B>Passable<BR>2</B></td>");
	print("<td width=70px bgcolor=#E7EFCE valign=top><h2><center><B>Bon<BR>3</B></td>");
	print("<td width=70px bgcolor=#E7EFCE valign=top><h2><center><B>Excellent<BR>4</B></td>");
	print("</tr>");
	

	$i = 0;
	while ($question_texte[$i])
	{
		if ($i == 6)// sous titre
		{
			print("<tr><td bgcolor=#E7EFCE valign=top><h2><B>Activit&eacute;s sans moniteur propos&eacute; par la base</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>M&eacute;diocre<BR>1</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>Passable<BR>2</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>Bon<BR>3</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>Excellent<BR>4</B></td>");
			print("</tr>");
		}	
		if ($i == 12)
		{
			print("<tr><td bgcolor=#E7EFCE valign=top><h2><B>Ateliers avec moniteur</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>M&eacute;diocre<BR>1</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>Passable<BR>2</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>Bon<BR>3</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>Excellent<BR>4</B></td>");
			print("</tr>");
		}
		if ($i == 22)
		{
			print("<tr><td bgcolor=#E7EFCE valign=top><h2><B>Service alimentaire</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>M&eacute;diocre<BR>1</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>Passable<BR>2</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>Bon<BR>3</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>Excellent<BR>4</B></td>");
			print("</tr>");
		}	
		if ($i == 25)
		{
			print("<tr><td colspan=5 bgcolor=#E7EFCE><h2>&nbsp;</td></tr>");
		}	
	
	
		//question
		print("<tr>");
		print("<td valign=top><h2>".$question_texte[$i]."</td>");
		print("<td><center><input type=radio name=choix".($i+1)." value=1></td>");
		print("<td><center><input type=radio name=choix".($i+1)." value=2></td>");
		print("<td><center><input type=radio name=choix".($i+1)." value=3></td>");
		print("<td><center><input type=radio name=choix".($i+1)." value=4></td>");
		print("</tr>");
		$i++;
	}
	
	print("");
	print("<tr><td colspan=5 bgcolor=#E7EFCE><BR><h2><B>Suggestions ou commentaires sur votre s&eacute;jours<BR>");
	print("</B><center><textarea name=commentaire rows=5 cols=66 wrap=PHYSICAL></textarea></td></tr>");
	
	
	//bouton ajouter
	print("<tr><td colspan=5 bgcolor=#E7EFCE>");
	print("<b><BR>");	
	print("<input type=\"submit\" value=\"Enregistrer\"><br><br></form>");
	
	print("</td></tr></table>");
	
	
	
}


if ($etape ==2)//ENREGISTREMENT DU RAPPORT CREE A LETAPE 1
{
	$tot_question[0] = $choix1;
	$tot_question[1] = $choix2;
	$tot_question[2] = $choix3;
	$tot_question[3] = $choix4;
	$tot_question[4] = $choix5;
	$tot_question[5] = $choix6;
	$tot_question[6] = $choix7;
	$tot_question[7] = $choix8;
	$tot_question[8] = $choix9;
	$tot_question[9] = $choix10;
	$tot_question[10] = $choix11;
	$tot_question[11] = $choix12;
	$tot_question[12] = $choix13;
	$tot_question[13] = $choix14; 
	$tot_question[14] = $choix15;
	$tot_question[15] = $choix16;
	$tot_question[16] = $choix17;
	$tot_question[17] = $choix18;
	$tot_question[18] = $choix19;
	$tot_question[19] = $choix20;
	$tot_question[20] = $choix21;
	$tot_question[21] = $choix22;
	$tot_question[22] = $choix23;
	$tot_question[23] = $choix24;
	$tot_question[24] = $choix25;
	$tot_question[25] = $choix26;
	$tot_question[26] = $choix27;
	
	$date = date('Y-m-d H:i:s');
	$sql = "INSERT INTO base_rapport_client
			   	SET code_client = '$code_client',
					code_contrat = '$code_contrat',
					referant = '$referant',
					question1 = '$tot_question[0]',
					question2 = '$tot_question[1]',
					question3 = '$tot_question[2]',
					question4 = '$tot_question[3]',
					question5 = '$tot_question[4]',
					question6 = '$tot_question[5]',
					question7 = '$tot_question[6]',
					question8 = '$tot_question[7]',
					question9 = '$tot_question[8]',
					question10 = '$tot_question[9]',
					question11 = '$tot_question[10]',
					question12 = '$tot_question[11]',
					question13 = '$tot_question[12]',
					question14 = '$tot_question[13]',	
					question15 = '$tot_question[14]',	
					question16 = '$tot_question[15]',	
					question17 = '$tot_question[16]',	
					question18 = '$tot_question[17]',	
					question19 = '$tot_question[18]',	
					question20 = '$tot_question[19]',	
					question21 = '$tot_question[20]',
					question22 = '$tot_question[21]',
					question23 = '$tot_question[22]',
					question24 = '$tot_question[23]',
					question25 = '$tot_question[24]',
					question26 = '$tot_question[25]',
					question27 = '$tot_question[26]',
					commentaire = '$commentaire',
					date_emission = '$date';";
	$result = mysql_query($sql) or die("Probl&egrave;me de cr&eacute;ation du rapport!<br>".$sql);
	
	print("<center>L'enregistrement &agrave; &eacute;t&eacute; un succ&egrave;s.<br><br><br>");
	print("<a href=\"../menu-base.php?Bsession_id=$Bsession_id\">");
	print("<img src=bouton5.gif border=0></a>");	
	historique("../historique.txt","Enregistrement du rapport client , code_contrat".num_contrat."",$Bsession_id);
}




if ($etape == 3)//LISTE DES RAPPORTS CLIENTS
{
	print("<h1><center>RAPPORT DE LA CLIENT&Egrave;LE</center></h1><BR><BR>");
	print("<center><table cellspacing=0 cellpadding=0 border=1>");
	print("<tr>");	
	print("<td bgcolor=#E7EFCE valign=top><h2><center><B>Contrat</B></td>");
	print("<td bgcolor=#E7EFCE valign=top><h2><center><B>Client</B></td>");
	print("<td bgcolor=#E7EFCE valign=top><h2><center><B>Chalet ou emplacement</B></td>");
	print("<td bgcolor=#E7EFCE valign=top><h2><center><B>Date du s&eacute;jour</B></td>");
	print("<td bgcolor=#E7EFCE valign=top><h2><center><B></B></td>");
	print("</tr>");

	$sql = "select base_rapport_client.code_client, base_rapport_client.code_contrat, base_contrat.numero_contrat, base_clients.organisme, base_rapport_client.code_rapport
					FROM base_rapport_client, base_contrat, base_clients
					WHERE base_contrat.code_contrat = base_rapport_client.code_contrat
					AND base_rapport_client.code_client = base_clients.code_client
					ORDER BY base_rapport_client.date_emission";				
	$result = mysql_query($sql) or die("Probl&egrave;me de recherche du r&eacute;f&eacute;rent et des commentaires du contrat!<br>".$sql);
	while ($row = mysql_fetch_row ($result))
	{
		$code_contrat = $row[1];
		$code_client = $row[0];
	
		//trouve les donnees du contrat
		$sql_base = "SELECT base_clients.organisme, base_contrat.numero_contrat, base_contrat.date_debut, base_contrat.date_fin
	        	FROM base_clients, base_contrat
			    WHERE base_clients.code_client = '$code_client'
				AND base_contrat.code_contrat = '$code_contrat'
				AND base_contrat.num_client = '$code_client';";
		$result_base = mysql_query($sql_base) or die("Probl&egrave;me de recherche du client!".$sql_base."<br>");
		$row_base = mysql_fetch_row ($result_base);
	
		$nom = $row_base[0];
		$num_contrat = $row_base[1];
		$date_debut = $row_base[2];
		$date_fin = $row_base[3];
	
		//trouve les chalets
		$sql_chalet = "SELECT base_ref1chalets.nom
		   		  FROM base_ref1chalets, base_chalets
				 WHERE base_chalets.code_contrat = '$code_contrat'
				   AND base_chalets.reservation = 'N'
				   AND base_chalets.actif = 'O'
	               AND base_ref1chalets.num_chalet = base_chalets.num_chalet;";
		$result_chalet = mysql_query($sql_chalet) or die ("Ne peut lire dans la table base_ref1chalets<br><br>".$sql_chalet);
	


		
		print("<tr>");
		print("<td valign=top><h2>".$num_contrat."</td>");
		print("<td valign=top><h2>".$nom."</td>");
		
		print("<td valign=top><h2>");
		while ($row_chalet = mysql_fetch_row ($result_chalet))
		{
			print($row_chalet[0].", ");
		}
		print("</td>");

		print("<td valign=top><h2>".$date_debut." au ".$date_fin."</td>");
		print("<td valign=top><h2><a href='rapport-client.php?Bsession_id=".$Bsession_id."&code_contrat=".$code_contrat."&code_client=".$code_client."&etape=4'>Consulter</a></td>");
		print("</tr>");
	
		
		
	}
	
	print("</table><BR><BR>");
	print("<a href=rapport.php?Bsession_id=".$Bsession_id.">RETOUR</a><BR><BR><BR>");
	
	
}


if ($etape == 4)//CONSULTEZ LES RAPPORTS CLIENTS
{

	//trouve les donn&eacute;es de l'usager
	$sql_usager = "SELECT usager
					FROM usager
					WHERE bidsession = '$Bsession_id';";
	$result_usager = mysql_query($sql_usager) or die("Probl&egrave;me de recherche du client!".$sql_usager."<br>");
	$row_usager = mysql_fetch_row ($result_usager);
	$referant = ($row_usager[0]);
	
	//trouve les donnees du contrat
	$sql = "SELECT base_clients.organisme, base_contrat.numero_contrat, base_contrat.date_debut, base_contrat.date_fin
        	FROM base_clients, base_contrat
		    WHERE base_clients.code_client = '$code_client'
			AND base_contrat.code_contrat = '$code_contrat'
			AND base_contrat.num_client = '$code_client';";
	$result = mysql_query($sql) or die("Probl&egrave;me de recherche du client!".$sql."<br>");
	$row = mysql_fetch_row ($result);

	$nom = $row[0];
	$num_contrat = $row[1];
	$date_debut = $row[2];
	$date_fin = $row[3];
	
	//trouve les chalets
	$sql_chalet = "SELECT base_ref1chalets.nom
	   		  FROM base_ref1chalets, base_chalets
			 WHERE base_chalets.code_contrat = '$code_contrat'
			   AND base_chalets.reservation = 'N'
			   AND base_chalets.actif = 'O'
               AND base_ref1chalets.num_chalet = base_chalets.num_chalet;";
	$result_chalet = mysql_query($sql_chalet) or die ("Ne peut lire dans la table base_ref1chalets<br><br>".$sql_chalet);




	print("<center><table width=580px cellspacing=0 cellpadding=0 border=1>");
	
	print("<tr>");
	print("<td colspan=5 valign=top><h2><B>Nom de l'unit&eacute; ou du groupe :</B> ".$nom."<BR>");
	print("<B>Contrat :</B> ".$num_contrat."<BR>");
	print("<B>Chalet ou emplacement :</B> ");
	while ($row_chalet = mysql_fetch_row ($result_chalet))
	{
		print($row_chalet[0].", ");
	}
	print("<BR>");
	print("<B>Date du s&eacute;jour :</B> ".$date_debut." au ".$date_fin."<BR>");
	print("<B>Personne ressource :</B> ".$referant."<BR><BR></td></tr>");
			
	
	//question	   
	
	print("<tr>");
	print("<td  bgcolor=#E7EFCE valign=top><h1><center>Charte d'&eacute;valuation</td>");
	print("<td width=70px bgcolor=#E7EFCE valign=top><h2><center><B>M&eacute;diocre<BR>1</B></td>");
	print("<td width=70px bgcolor=#E7EFCE valign=top><h2><center><B>Passable<BR>2</B></td>");
	print("<td width=70px bgcolor=#E7EFCE valign=top><h2><center><B>Bon<BR>3</B></td>");
	print("<td width=70px bgcolor=#E7EFCE valign=top><h2><center><B>Excellent<BR>4</B></td>");
	print("</tr>");
	
	//VA CHERCHER LES QUESTIONS
	$sql_question = "select question1, question2, question3, question4, question5, question6, question7, question8, question9, question10,
	question11, question12, question13, question14, question15, question16, question17, question18,
	question19, question20, question21, question22, question23, question24, question25, question26, question27, commentaire  
			FROM base_rapport_client
			WHERE code_contrat = '$code_contrat'";				
	$result_question = mysql_query($sql_question) or die("Probl&egrave;me de recherche du r&eacute;f&eacute;rent et des commentaires du contrat!<br>".$sql_question);
	$row_question = mysql_fetch_row ($result_question);
	
	

	$i = 0;
	$j = 0;
	while ($question_texte[$i])
	{
		if ($i == 6)// sous titre
		{
			print("<tr><td bgcolor=#E7EFCE valign=top><h2><B>Activit&eacute;s sans moniteur propos&eacute; par la base</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>M&eacute;diocre<BR>1</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>Passable<BR>2</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>Bon<BR>3</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>Excellent<BR>4</B></td>");
			print("</tr>");
		}	
		if ($i == 12)
		{
			print("<tr><td bgcolor=#E7EFCE valign=top><h2><B>Ateliers avec moniteur</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>M&eacute;diocre<BR>1</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>Passable<BR>2</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>Bon<BR>3</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>Excellent<BR>4</B></td>");
			print("</tr>");
		}
		if ($i == 22)
		{
			print("<tr><td bgcolor=#E7EFCE valign=top><h2><B>Service alimentaire</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>M&eacute;diocre<BR>1</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>Passable<BR>2</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>Bon<BR>3</B></td>");
			print("<td bgcolor=#E7EFCE><h2><center><B>Excellent<BR>4</B></td>");
			print("</tr>");
		}	
		if ($i == 25)
		{
			print("<tr><td colspan=5 bgcolor=#E7EFCE><h2>&nbsp;</td></tr>");
		}	
	
	
		//question
		print("<tr>");
		print("<td valign=top><h2>".$question_texte[$i]."</td>");
		if ($row_question[$i] == 1)
			print("<td><center><img src=images/coche.jpg></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>");
		if ($row_question[$i] == 2)
			print("<td>&nbsp;</td><td><center><img src=images/coche.jpg></td><td>&nbsp;</td><td>&nbsp;</td>");
		if ($row_question[$i] == 3)
			print("<td>&nbsp;</td><td>&nbsp;</td></td><td><center><img src=images/coche.jpg></td><td>&nbsp;</td>");
		if ($row_question[$i] == 4)
			print("<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>&nbsp;</td><td><center><img src=images/coche.jpg></td>");
			
			
			
			

		print("</tr>");
		$i++;
	}
	
	print("");
	print("<tr><td colspan=5 bgcolor=#E7EFCE><BR><h2><B>Suggestions ou commentaires sur votre s&eacute;jours<BR><BR>");
	print("</B><i>".$row_question[$i++]."</i><BR><BR></td></tr>");
	

	print("</td></tr></table><BR><BR><BR>");
	print("<a href=rapport-client.php?Bsession_id=".$Bsession_id."&etape=3>RETOUR</a><BR><BR><BR>");

}






/*BAS DE PAGE**********************************************************************

if (($etape != 4) and ($etape !=5 ))
{	
print("<BR><BR><hr><table width=100%><tr><td width=50%><center>");
	//Afficher le bouton de retour au menu principal.

	print("<a href='rapport.php?Bsession_id=".$Bsession_id."'><img src=bouton2.gif border=0></a>");
	
	print("<a href='../menu-base.php?Bsession_id=".$_GET['Bsession_id']."'><img src=bouton1.gif border=0></a>");

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


	
?>

</body>
</html>	
	
	
	
	
