<?php

	session_start();
	
//PhpMyShopping
	
	if($_SESSION['database']=="local")
	  {
	     $db_host    = "localhost";
	     $db_user   = "root";
	     $db_pass   = "";
     	     $db_name   = "boutique";

	 }
	
	if($_SESSION['database']=="public")
	  {
  	     $db_host    = "sql2";
   	     $db_user   = "analogde";
 	     $db_pass   = "rainbow";
    	     //$db_type   = "mysql";
	     $db_name   = "analogde";
	 }
	 
	 
	 $connexion = mysql_connect($db_host,$db_user,$db_pass); 
   	 mysql_select_db($db_name, $connexion);
	 //$sql = "SELECT * FROM clients ";
	 $sql = 'SELECT nom,prenom,heure,date,total_ttc FROM commandes'; 

	 //exécution de la requête:
  	$requete = mysql_query( $sql, $connexion ) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	//affichage des données:
	
/*    if(isset($_POST['orderStatus']))
	 {	//echo $_POST['orderStatus'];
	    if($_POST['orderStatus'] == "CV" )
		  {
			  while($data = mysql_fetch_assoc($requete))
			       {
				    // on affiche les informations de l'enregistrement en cours
						echo  $data['nom'];
			      } 
		  }
	 }*/
	
	

?>


<!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>Administration</title>

<link rel="stylesheet" href="default.css" 
type="text/css">




</head>

<body>


<div id="header"><h1>Administration</h1>

<div class="membre">Vous êtes connecté en tant qu'<b>admin</b></div>
</div>




<div class="heading">Liste des commandes 
<form action="commandes.php" method="POST">
<select name="orderStatus" size="1" onchange="submit()">
<option value="CA">Commandes en attente de paiement</option>
<option value="CS">Commandes en attente - rupture de stock</option>
<option value="CC">Commandes en cours de préparation</option>
<option value="CV">Commandes validée</option>
<option value="CT">Commandes en cours de livraison</option>
<option value="CL">Commandes livrée</option>
</select>&nbsp;<b>::</b>&nbsp;
<input name="valieOrderStatus" value="Afficher" type="submit">
</form>
</div>






<div id="list">

		  <table class="list">
			<tr>
			  <th align="center" width="1%">&nbsp;</th>
			  <th align="left" width="40%">Client
				<!--[ <a href="?cat1=Co&cat2=0&debut=0&field=FirstName&order=ASC&orderStatus=CA"><img src="images/arrow_up.jpg" title="up" alt="up" border="0" /></a> <a href="?cat1=Co&cat2=0&debut=0&field=FirstName&order=DESC&orderStatus=CA"><img src="images/arrow_down.jpg" title="down" alt="down" border="0" /></a> ]-->
			  </th>
			  <th align="right" nowrap="nowrap" width="19%">Montant total</th>
			  <th align="center" nowrap="nowrap" width="19%">Date de commande
				<!--[ <a href="?cat1=Co&cat2=0&debut=0&field=BillNumber&order=ASC&orderStatus=CA"><img src="images/arrow_up.jpg" title="up" alt="up" border="0" /></a> <a href="?cat1=Co&cat2=0&debut=0&field=BillNumber&order=DESC&orderStatus=CA"><img src="images/arrow_down.jpg" title="down" alt="down" border="0" /></a> ]-->

			  </th>
			  <th align="center" nowrap="nowrap" width="20%">Num Commande
				<!--[ <a href="?cat1=Co&cat2=0&debut=0&field=BillNumber&order=ASC&orderStatus=CA"><img src="images/arrow_up.jpg" title="up" alt="up" border="0" /></a> <a href="?cat1=Co&cat2=0&debut=0&field=BillNumber&order=DESC&orderStatus=CA"><img src="images/arrow_down.jpg" title="down" alt="down" border="0" /></a> ]-->
			  </th>
			<th align="center" width="1%">&nbsp;</th>
		  </tr>

<?php

	if(isset($_POST['orderStatus']))
	 {	//echo $_POST['orderStatus'];
	    if($_POST['orderStatus'] == "CV" )
		  {
			  while($data = mysql_fetch_assoc($requete))
			       {
					   $client = $data['prenom']. " " .$data['nom'];
					   $info = $data['date']. " " .$data['heure'];
					   $montant = $data['total_ttc'];
					   
				    // on affiche les informations de l'enregistrement en cours
					
						
echo "  <tr class=\"row2\" onmouseover=\"this.className='highlight'\" onmouseout=\"this.className='row2'\">
        <td align=\"center\">
		<a href=\"?C1=CL&C2=CO&C3=edit&IDO=9\"><img src=\"view.png\" border=\"0\" alt=\"View\" \"Voir le detail de la commande\" /></a></td>
		<td nowrap=\"nowrap\" align=\"left\">$client</td>
		<td nowrap=\"nowrap\" align=\"right\">$montant &nbsp;&euro;</td>
		<td nowrap=\"nowrap\" align=\"center\">$info</td>
		<td align=\"center\">210051200001</td>
		<td class=\"center\" width=\"1%\">
		<a href=\"?C1=CL&C2=CO&C3=delete_confirm&IDO=9&debut=0&IDC=2236&field=BillNumber&order=DESC&orderStatus=CA\"><img src=\"delete.png\" alt=\"Effacer\" title=\"Effacer\" /></a></td>
			</tr> ";
						
						
						
			      } 
		  }
	 }


?>



		<tr>
		  <td colspan="6">
		  
		  </td>
		</tr>
		</table>




</body>
</html>
