<?php

	session_start();
	
	$_SESSION['database']="local";
	
	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";
	 }


	$id_catalogue = $_GET['id'];
	$table = $_GET['table'];
	
	$connexion = mysql_connect($db_host,$db_user,$db_pass); 
	mysql_select_db($db_name, $connexion);
	
	$requete = "SELECT * FROM lave_linge WHERE id_catalogue='$id_catalogue' ";
	$result = mysql_query($requete);
	$data = mysql_fetch_array($result);
	
	
										
	$designation = $data['designation'];
	
	$modele = $data['modele']; 
	$marque = $data['marque']; 
	$fournisseur = $data['fournisseur']; 
	$prix_ttc = $data['prix_ttc']; 
	$prix_ht = $data['prix_ht']; 
	$dispo = $data['dispo']; 


	 
	   
	 if(isset($_POST['valide']))
	      {
			  if($_POST['valide'] == "ok")
				{
					
					$connexion = mysql_connect($db_host,$db_user,$db_pass); 
					mysql_select_db($db_name, $connexion);

					$element = $_POST['categorie'];
					$requete = "SELECT * FROM categorie WHERE id='$element' ";
	   		        	$result = mysql_query($requete);
		                	$data = mysql_fetch_array($result);
					$table = $data['table'];
										
					$id_catalogue = $_POST['id_catalogue'] ; // = "refLV464";
					$designation = $_POST['designation']; // = "appareil";
					$reference = $_POST['reference']; // = "nada";
					$modele = $_POST['modele']; // = "XP33_fd";
					$marque = $_POST['marque']; // = "Bosch";
					$fournisseur = $_POST['fournisseur']; // = "Pulsat";
					$prix_ttc = $_POST['prix_ttc']; // = "850";
					$prix_ht = $_POST['prix_ht']; // = "714.10";
					$dispo = $_POST['dispo']; // = "714.10";
					
					switch($dispo)
  					{
					  case 1 :
					          $dispo  = "24H";
					    	  break;
					  case 2 :
					          $dispo = "48H";
					    	  break;
					  case 3 :
					          $dispo = "72H";
					    	  break;  	  		  
					}									

					$tva = $_POST['tva'];								
										
					switch($tva)
  					{
					  case 1 :
					          $tva  = 19.60;
					    	  break;
					  case 2 :
					          $tva = 5.50;
					    	  break;		  
					}
										
					$remise = $_POST['choix_remise']; 
					$stock = $_POST['stock'];
							
					$status = $_POST['status']; 										
										
					switch($status)
  					{
					  case "a" :
					          $status  = "actif";
					    	  break;
					  case "c" :
					          $status = "cache";
					    	  break;		  
					}												




	$date = date("d-m-Y"); 
	$heure = date("H:i");

	 //création de la requête SQL:
	 $sql = "INSERT INTO refrigerateur ( id, marque, id_catalogue, fournisseur, modele, dispo , prix_ttc, prix_ht, remise, tva, designation, stock, date, heure, status) 
 	  VALUES('', '$marque', '$id_catalogue', '$fournisseur' ,  '$modele', '$dispo' , '$prix_ttc', '$prix_ht','$remise','$tva','$designation','$stock','$date','$heure','$status')"; 
 
    	$requete = mysql_query($sql);
        header("Location: liste_article.php");

	        		}      

	   }	  


?>

		<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
		<html dir="ltr" lang="en">

		<head>

		<title>Administration - En cours de développement</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  
		<link rel="stylesheet" href="default.css" type="text/css">
		<link rel="stylesheet" href="onglet.css" type="text/css" media="screen" />
		<link rel="stylesheet" href="theme.css" type="text/css">
		
		<script type="text/javascript" src="javascript.js"></script>
  
		</head>
		
		<body>

		<div id="header"><h1>Administration</h1>
		<div class="membre">Vous Ãªtes connectÃ© en tant que <b><?php echo $_SESSION['admin_identifiant']; ?> </b></div>
		</div>		

		<?php include('menu.php'); ?>

		<div class="menu">
		<img src="./images/add.png" alt="" title="" width="12" height="12" />&nbsp;
		<a href="?C1=CA&C2=CA&C3=insert">Cr&eacute;er une cat&eacute;gorie</a>&nbsp;</div>

		

		<div class="heading">Edition du produit</div>


		<form action="" method="post" id="ajouter_produit" name="ajouter_produit" onsubmit="return mess();">
		  

		<table align="left" cellspacing="1" cellpadding="5" border="0" bgcolor="#D5D5D5" width="800">
		<tr bgcolor="#F1F3F5">
		<td colspan="2">&nbsp;</td>
		</tr>
		</tr>
	
		
		
		</td>
		</tr>
						
		<tr bgcolor="#FFFFFF">
		<td align="right" valign="top">ID catalogue :</td>
		<td align="left" valign="middle" colspan="1">
		<input type="text" name="id_catalogue" size="70" maxlength="20" value="<?php echo $id_catalogue; ?>" id="" >&nbsp;</td>
		</tr>
		
		<input type="hidden" name="valide" id="valide" value="">
		
		<tr bgcolor="#FFFFFF">
		<td align="right" valign="top">Désignation :</td>
		<td align="left" valign="middle" colspan="1">
		<input type="text" name="designation" size="30" maxlength="40" value="" id="">&nbsp;</td>
		</tr>
		
		<tr bgcolor="#FFFFFF">
		<td align="right" valign="top">R&eacute;f&eacute;rence :</td>
		<td align="left" valign="middle" colspan="1">
		<input type="text" name="reference" size="30" maxlength="40" value="" id="">&nbsp;</td>
		</tr>
		
		<tr bgcolor="#FFFFFF">
		<td align="right" valign="top">Marque :</td>
		<td align="left" valign="middle" colspan="1">
		<input type="text" name="marque" size="30" maxlength="40" value="" id="">&nbsp;</td>
		</tr>
		
		<tr bgcolor="#FFFFFF">
		<td align="right" valign="top">Modéle :</td>
		<td align="left" valign="middle" colspan="1">
		<input type="text" name="modele" size="30" maxlength="40" value="" id="">&nbsp;</td>
		</tr>
		
		<tr bgcolor="#FFFFFF">
		<td align="right" valign="top">Fournisseur :</td>
		<td align="left" valign="middle" colspan="1">
		<input type="text" name="fournisseur" size="30" maxlength="40" value="" id="">&nbsp;</td>
		</tr>
		
		<tr bgcolor="#FFFFFF">
		<td align="right">Disponibilité :</td>
		<td align="left">
		<select name="dispo" size="1">
		<option value="1" selected="selected">24H</option>
		<option value="2">48H</option>
		<option value="3">72H</option>
	
		</select></td>
		</tr>
		
		
		
		<tr bgcolor="#FFFFFF">
		<td align="right" valign="top">Prix TTC:</td>
		<td align="left" valign="middle" colspan="1">
		<input type="text" name="prix_ttc" size="10" maxlength="10" value="" id="">&nbsp;<b>&euro;</b>
		</td>
		</tr>
		
		<tr bgcolor="#FFFFFF">
		<td align="right" valign="top">Prix HT:</td>
		<td align="left" valign="middle" colspan="1">
		<input type="text" name="prix_ht" size="10" maxlength="10" value="" id="">&nbsp;<b>&euro;</b>
		</td>
		</tr>
		
		
		
		<tr bgcolor="#FFFFFF">
		<td align="right">Remise :</td>
		<td align="left">
		<select name="remise" size="1">
		<option value="0">Non d&eacute;finie</option>
		<option value="1" selected="selected">En % sur le prix HT</option>
		<option value="2">En &euro; sur le prix HT</option>
		</select>&nbsp;
		<input type="text" name="choix_remise" size="7" maxlength="12" value="" />
		<b class="green">Laissez vide ce champ si pas de remise</b>
		</td>
		</tr>
		
		<tr bgcolor="#FFFFFF">
		<td align="right">TVA :</td>
		<td align="left">
		<select name="tva" size="1">
		<option value="1" selected="selected">19.60 %</option>
		<option value="2">5.50 %</option>
		</select></td>
		</tr>
		
		<tr bgcolor="#FFFFFF">
		<td align="right" valign="top">Descriptif :</td>
		<td align="left" valign="middle" colspan="1"><textarea name="descriptif" rows="12" cols="90" id="">
		</textarea>&nbsp;</td>
		</tr>
			
		<tr bgcolor="#FFFFFF">
		<td align="right" valign="top">Stock :</td>
		<td align="left" valign="middle" colspan="1">
		<input type="number" name="stock" size="5" maxlength="5" value="" id="">&nbsp;</td>
		</tr>
		
			
		<tr bgcolor="#FFFFFF">
		<td align="right">Status :</td>
		<td align="left">
		<select name="status">
		<option value="a" selected="selected">Produit actif</option>
		<option value="c">Produit cach&eacute;</option>
		</select>
		</td>
		</tr>
			

				
		<tr bgcolor="#F1F3F5">
		<td colspan="2" align="center">
		
		<input type="submit" value="Valider" />
		
		
		</td>
		</tr>
		
		
		</table>
		</div>
		</div>
		
		</form>
	



</body></html>