<?php
	session_start();
	
	include('config_inc.php'); 	
	//include('menu.php'); 
	 
	
	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";
	 }
	 
	 
	/* if( isset( $_POST ) )
	   { //var_dump($_POST);
	     //echo $_POST['editor1'];
	     if( get_magic_quotes_gpc() )
			$postedValue = htmlspecialchars( stripslashes( $_POST['editor1'] ) ) ;
		else
			$postedValue = htmlspecialchars( $_POST['editor1'] ) ;
			
			echo $postedValue;
	   
	   }	*/
	 
	 if(isset($_POST['soumettre']) && $_POST['soumettre'] == "Suite")
	  { 	  
	  
	        			$id_catalogue = $_POST['id_catalogue'];
	        			$_SESSION['id_catalogue']=$id_catalogue;
	        			//echo $id_catalogue;
	  				//echo "<br>";
	  				
	  				$connexion = mysql_connect($db_host,$db_user,$db_pass); 
		 			mysql_select_db($db_name, $connexion);
	  				$selection_categorie = $_POST['selection_categorie'];
		        		$sql = "SELECT * FROM categorie WHERE id = '$selection_categorie' ";
 	 	        		$requete = mysql_query( $sql, $connexion ) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 
	 	        		$result = mysql_fetch_assoc($requete);
	     	    			$table = $result['table_article'];
	  				
	  				
	        			$_SESSION['selection_categorie']=$table;
					//echo $table;
	  				//echo "<br>";
	        			
	        			$designation = $_POST['designation'];
	        			$_SESSION['designation']=$designation;
					//echo $designation;
	  				//echo "<br>";
	        			
	        			$reference = $_POST['reference']; 
	        			$_SESSION['reference']=$reference;
					//echo $reference;
	  				//echo "<br>";
	        			
	        			$marque = $_POST['marque']; 
	        			$_SESSION['marque']=$marque;
					//echo $marque;
	  				//echo "<br>";
	  				
	        			$fournisseur = $_POST['fournisseur']; 
					$_SESSION['fournisseur']=$fournisseur;
					//echo $fournisseur;
	  				//echo "<br>";
	  				
	  				$garantie = $_POST['garantie']; 
					$_SESSION['garantie']=$garantie;
	  				
	        			$dispo = $_POST['dispo'];

					switch($dispo)
  					{
					  case 1 :
					          $dispo  = "24H";
					    	  break;
					  case 2 :
					          $dispo = "48H";
					    	  break;
					  case 3 :
					          $dispo = "72H";
					    	  break;  	  		  
					}	
					$_SESSION['dispo']=$dispo;
					//echo $dispo;
	  				//echo "<br>";
	        			
					
					$prix_ttc = $_POST['prix_ttc']; 
					$_SESSION['prix_ttc']=$prix_ttc;
					//echo $prix_ttc;
	  				//echo "<br>";
	  				
	  				$prix_ht = $_POST['prix_ht']; 
	  				$_SESSION['prix_ht']=$prix_ht;
					//echo $prix_ht;
	  				//echo "<br>";
	  				
	        			
					$remise = $_POST['remise']; 
					
					switch($remise)
  					{ case 0 :
					          $remise  = "aucune";
					    	  break;
					  case 1 :
					          $tva  = "un";
					    	  break;
					  case 2 :
					          $tva = "deux";
					    	  break;		  
					}
					$_SESSION['remise']=$remise;
					//echo $remise;
	  				//echo "<br>";
	        			
					$tva = $_POST['tva'];
										
					switch($tva)
  					{
					  case 1 :
					          $tva  = 19.60;
					    	  break;
					  case 2 :
					          $tva = 5.50;
					    	  break;		  
					}
					$_SESSION['tva']=$tva;
					//echo $tva;
	  				//echo "<br>";
	        			
					//$descriptif = $_POST['descriptif']; 
					//$_SESSION['descriptif']=$descriptif;	
					
					
	     				if( get_magic_quotes_gpc() )
						$postedValue = htmlspecialchars( stripslashes( $_POST['editor1'] ) ) ;
					else
						$postedValue = htmlspecialchars( $_POST['editor1'] ) ;
			
					$_SESSION['descriptif']=$postedValue;
									
					//echo $descriptif;
	  				//echo "<br>";
	        			
					$stock = $_POST['stock'];
					$_SESSION['stock']=$stock;
					//echo $stock;
	  				//echo "<br>";
	        			
					$status = $_POST['status']; 										
										
					switch($status)
  					{
					  case "a" :
					          $status  = "actif";
					    	  break;
					  case "c" :
					          $status = "cache";
					    	  break;		  
					}
					$_SESSION['status']=$status;			
	  				//echo $status;
	  				//echo "<br>";
	  				
	  				
	  				$remarques = $_POST['remarques']; 
	        			$_SESSION['remarques']=$remarques;
	        			
	        			$liens = $_POST['liens']; 
	        			$_SESSION['liens']=$liens;
	        			
	        			
	        			
	        			
	  				
	        			
	        			header("Location: saisir_descriptif_article.php?table=$table");
	  
	 
	  }
	 
	 include('menu.php'); 
	
	
	 if(!isset($_SESSION['ajouter_article']))
	  {
		$_SESSION['ajouter_article'] = array();
    		// subdivision 
    		//$_SESSION['description']['champ'] = array();
    		//$_SESSION['description']['saisie'] = array();
	 }
	 
	else { unset($_SESSION['ajouter_article']);
	     }	
	
	
	if( isset($_POST['selection_categorie']) && !empty($_POST['selection_categorie']) ) 
	   {     $selection_categorie = $_POST['selection_categorie'];
	   	
	   }

	/*if(isset($_POST['valide']))
	      {
	 	  if($_POST['valide'] == "ok")
	     	    {
	     	        $connexion = mysql_connect($db_host,$db_user,$db_pass); 
		 	mysql_select_db($db_name, $connexion);
		        $selection_categorie = $_POST['selection_categorie'];
		        $sql = "SELECT * FROM categorie WHERE id = '$selection_categorie' ";
 	 	        $requete = mysql_query( $sql, $connexion ) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 
	 	        $result = mysql_fetch_assoc($requete);
	     	    	$table = $result['table_article'];
 			header("Location: saisir_descriptif_article.php?table=$table");
	           }
	 }	*/

?>

<?php

$config['toolbar'] = array(
	array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' , 'StrikeThrough','-','Subscript','Superscript'),
	array('Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'),
	array('Styles','Format','Font','FontSize'),
	array('TextColor','BGColor'),
	array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'),
	array('NumberedList','BulletedList','OrderedList','UnorderedList','-','Outdent','Indent'),

);

$config['skin'] = 'v2';

$config['width'] = 600;			
$config['length'] = 200;	
$config['resize_enabled'] = false;	


include_once "ckeditor.php";
$CKEditor = new CKEditor();
$CKEditor->basePath = '../ckeditor/';
$initialValue = "rien";

?>

<!--
		<!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>		

-->		



		<div class="heading">Ajouter un article</div>


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

		<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="" id="" >&nbsp;</td>
		</tr>
		
		<input type="hidden" name="valide" id="valide" value="">

		
	
		<tr bgcolor="#FFFFFF">
		<td align="right" valign="top">Choix de la catégorie :</td>
		<td align="left" valign="middle" colspan="1">
	<!--	<input type="file" name="fichier_descriptif" />&nbsp;</td> -->
		<select name="selection_categorie" size="1" onChange="submit()">
		<option value="X">--[ SELECTION ]--</option>
		
<?php

		$connexion = mysql_connect($db_host,$db_user,$db_pass); 
		mysql_select_db($db_name, $connexion);
		$sql = "SELECT * FROM categorie";
		$option = mysql_query($sql) ;
		
		while($val=mysql_fetch_array($option))
		     {
			
			$element = $val['table_article'];
			$id_categorie = $val['id'] ;
			//echo $id_categorie;
			//$_SESSION['selection_table']=$val['table_article'];
   		        
   		      /*  if( isset($selection_categorie) && !empty($selection_categorie) ) 
   		          {*/
   		          
   		          
   		             if($selection_categorie == $id_categorie)
   		               {	 echo "<option value=$id_categorie selected >$element</option>";
   		               }
   		     /*   }    */   
   		        
   		        else {
   		        	 echo "<option value=$id_categorie >$element</option>";
   		             }
		     }     
		
?>		
		
		</select>
		</tr>
		
		<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">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" valign="top">Garantie :</td>
		<td align="left" valign="middle" colspan="1">
		<input type="text" name="garantie" 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="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>
-->

		<?php $CKEditor->editor("editor1", $initialValue, $config);	?>
		</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="#FFFFFF">
		<td align="right" valign="top">Remarques :</td>
		<td align="left" valign="middle" colspan="1"><textarea name="remarques" rows="12" cols="90" id="">
		</textarea>&nbsp;</td>
		</tr>
			
			
		<tr bgcolor="#FFFFFF">
		<td align="right" valign="top">Liens :</td>
		<td align="left" valign="middle" colspan="1"><textarea name="liens" rows="12" cols="90" id="">
		</textarea>&nbsp;</td>
		</tr>	

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


</body></html>


<?php

		/*<div class="menu">
		<img src="add.png" alt="" title="" width="12" height="12" />&nbsp;
		<a href="saisir_descriptif_article.php">Saisir descriptif de l'article</a>&nbsp;
		
		<img src="add.png" alt="" title="" width="12" height="12" />&nbsp;
		<a href="saisir_criteres_filtrage.php">Saisir critéres de filtrage</a>&nbsp;
		
		</div>*/
		
//window.location.replace("http://www.un-site.com/une-page.htm");

?>		


