<?php
	session_start ();
	
	error_reporting(0);
	
	if (!isset($_SESSION['nom']) && !isset($_SESSION['password']))
	{  
			header("Location: login.php");   
	}
	
	include('fonctions.php');
	charger_configuration();
	
	if($_SESSION['year'] == "")
	{
		// année en court par défaut
		$_SESSION['year']= date('Y');
	}
	
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Espace réservation</title>
</head>		

<style>
	.titre {
	margin-left:50px;
	margin-top:50px;
	font-size: 26px;
	}

    .pied {
    border: 1px solid black;
    width:70%;
    margin:20 20%; 
    text-align:center;
    }
	
	.footer{
	height: 50px;
	position: absolute;
	bottom: 0;
}

</style>

<script>

function getXhr()
{
			var xhr = null; 
			if(window.XMLHttpRequest) // Firefox et autres
			   xhr = new XMLHttpRequest(); 
			else if(window.ActiveXObject)
			{ // Internet Explorer 
			   try 
			   {
					xhr = new ActiveXObject("Msxml2.XMLHTTP");
			   } 
			   catch (e) 
			   {
					xhr = new ActiveXObject("Microsoft.XMLHTTP");
			   }
			}
			else 
			{ 
				// XMLHttpRequest non supportÃ© par le navigateur 
				alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
				xhr = false; 
			} 

			return xhr;
}

function change(num)
 {
			var xhr = getXhr();
								
			xhr.onreadystatechange = function()
			{
				// On ne fait quelque chose que si on a tout reÃ§u et que le serveur est ok
				if(xhr.readyState == 4 && xhr.status == 200)
				{
					retour = xhr.responseText;
					//alert(retour);	
					location.reload(); 		
				}
			}

			xhr.open("POST","ajax_selection_annee.php",true);
			xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			
			var year = num.value;	
			xhr.send("year="+year);
 
}
</script>


<head>		
<body>
	
	<link rel="stylesheet" href="menu_style.css" type="text/css">

	<div id='cssmenu'>
	<ul>
		<li class='active'><a href='home.php'><span>Home</span></a></li>
		<li><a href='selection_planning_mois.php'><span>Planning</span></a></li>
		<li><a href='selection_gestion_mois.php'><span>Gestion</span></a></li>
		<li><a href='selection_statistique_mois.php'><span>Statistiques</span></a></li>
<?php

		if($_SESSION['nom'] == "admin")
		{ 	
			echo '<li><a href="deplacer_un_rendezvous_admin.php"><span>Déplacer</span></a></li>';
			echo '<li><a href="configuration.php"><span>Configuration</span></a></li>';
		}
		else
		{
			echo '<li><a href="deplacer_un_rendezvous_user.php"><span>Déplacer</span></a></li>';
		}
		
		if($_SESSION['nom'] == "admin" && $_SESSION['mode_debug'] == "yes")
		{
			$infos_mode = "    Mode debug"; 
		}
		if($_SESSION['nom'] == "admin" && $_SESSION['mode_debug'] == "no")
		{
			$infos_mode = "    Mode prod"; 
		}
		
	
		
?>
		<li><a href='change_password.php'><span>Changer password</span></a></li>
		<li><a href='logout.php'><span>Déconnexion</span></a></li>
		<li><a href='#'><span><?php echo $_SESSION['nom'] .' ' .$_SESSION['prenom'] .' connecté' .'  ' .$infos_mode ?></span></a></li>
		<li><a href='#'><span><?php echo $_SESSION['year']; ?></span></a></li>
	</ul>
	</div>

	<div class ='titre' id ='titre'>
	<p>Interface réservation</p>
	
		
	<p>Choisir l'année : 
	<select onchange='change(this)'>
	<option value=choix>Choix</option>
	<option value=2015>2015</option>
	<option value=2016>2016</option>
	<option value=2017>2017</option>
	<option value=2018>2018</option>
	</select>
	</p>	
	
		
	<div class ='footer' >
	<center>Patrice Delpy &copy; - Revision Octobre 2017</center>
	</div>
	
	</div>
	

</body>
</html>