<?php
	
    $db_host    = "localhost";
    $db_user   = "root";
    $db_pass   = "";
   	$db_name   = "test";
	
	$id_reservation = $_GET['id'];
	
	if(isset($_POST['valide']) && $_POST['valide'] == "ok")
 	  {						
					$status = $_POST['selection_status'];
	        		$connexion = mysql_connect($db_host,$db_user,$db_pass); 
		 			mysql_select_db($db_name, $connexion);
					$sql = "UPDATE reservation SET status = '$status' WHERE id='$id_reservation' ";
					echo $sql;	
					$requete = mysql_query( $sql, $connexion ) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 
		 			header("Location: liste_reservation.php");   
	}		

	if(isset($_POST['valide']) && $_POST['valide'] == "annule")
	{  
		header("Location: liste_reservation.php");   
	}			
		
	$connexion = mysql_connect($db_host,$db_user,$db_pass); 
	mysql_select_db($db_name, $connexion);
	
	$requete = "SELECT * FROM reservation WHERE id='$id_reservation' ";
	$result = mysql_query($requete);
	$data = mysql_fetch_array($result);
	
	$id = $data['id'];
	$arrive = $data['arrive'];
	$depart = $data['depart'];
	$status = $data['status']; 

	
?>
	
<script type="text/javascript">

function fct_soumettre()
{
	verif = confirm("Voulez vous vraiment modifier la base de donnée ?");
 	
 	if(verif == true)
 	  { document.getElementById('valide').value="ok";
 	  }
 	
 	if(verif == false)
 	  { document.getElementById('valide').value="stop";
 	  }	

} 

function fct_annuler()
{
 	document.getElementById('valide').value="annule";
} 

</script>

<form action="" method="post" id="editer_bloc" name="editer_bloc" >

		<input type="hidden" name="valide" id="valide" value="">


		<table align="left" cellspacing="1" cellpadding="5" border="0" bgcolor="#D5D5D5" width="800">
		<tr bgcolor="#F1F3F5">
		<td colspan="2">Edition des options de la réservation:</td>
		</tr>
		</tr>
		
		</td>
		</tr>
						
		<tr bgcolor="#FFFFFF">
		<td align="right" valign="top">Nom du bloc :</td>
		<td align="left" valign="middle" colspan="1">
		<input type="text" name="nom_bloc" size="70" maxlength="20" value="" id="nom_bloc" >&nbsp;</td>
		</tr>
		
		
		<tr bgcolor="#FFFFFF">
		<td align="right" valign="top">Status :</td>
		<td align="left" valign="middle" colspan="1">
		<select name="selection_status" size="1" > 
		<option value="Reservation">Reservation</option>
		<option value="Annulation">Annulation</option>
		<option value="Loué">Loué</option> 
		<option value="Payement">Payement</option> 
		</select>
		</tr>
				
		<tr bgcolor="#F1F3F5">
		<td colspan="2" align="center">
		
		<input type='submit' name='soumettre' value='Soumettre' onClick="fct_soumettre()" />
		<input type='submit' name='Annuler' value='Annuler' onClick="fct_annuler()" />  
		
		</td>
		</tr>
		
		</table>
		</div>
		</div>
		
		</form>


		</body>
		</html>