<?php

	session_start();
	
	include('../config_inc.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_name   = "analogde";
	     //$db_type   = "mysql";	
	 }
	

	$_SESSION['validation_commande'] = "non"; 

	
	//$table = $_SESSION['table'];

	
	if(!isset($_SESSION['panier']))
	  {
    			/* Initialisation du panier */
    				$_SESSION['panier'] = array();
    				/* Subdivision du panier */
    				$_SESSION['panier']['id_catalogue'] = array();
    				$_SESSION['panier']['reference'] = array();
    				$_SESSION['panier']['marque'] = array();
    				$_SESSION['panier']['table'] = array();
    				$_SESSION['panier']['qte'] = array();
    				$_SESSION['panier']['designation'] = array();
    				$_SESSION['panier']['prix_ttc'] = array();
    				$_SESSION['panier']['prix_ht'] = array();
    				$_SESSION['panier']['dispo'] = array(); 
   	  }

	

	if(isset($_GET['action']))
	  {
	     if($_GET['action'] == "charge" ) 
               {  
               		$table = $_GET['table'];
        		$indice = $_GET['elem'];

			$connexion = mysql_connect($db_host,$db_user,$db_pass); 
	                mysql_select_db($db_name, $connexion);

			
			$requete = "SELECT * FROM panier WHERE id='$indice' ";
			
   			$result = mysql_query($requete);
			$panier_liste=mysql_fetch_array($result);
			
			//print_r($panier_liste);
			//Array ( [0] => REF456- washer- lave_linge Brandt - 3- 2397.81 ) 
	    		$articles = explode("-" , $panier_liste['panier']);
	  	     	
	  	     	//echo "+++++";
	  	     	//print_r($articles);
	  	     	
	  	     	$nb_articles = count($articles)/5; 
			
			//echo $nb_articles;
			
			$connexion = mysql_connect($db_host,$db_user,$db_pass); 
       		   	mysql_select_db($db_name, $connexion);
			 
			$ptr = 0;
			 
			//NTH82K, lave_linge, 3, 1438.5, X28Z-22, 3, 2164.5 
			// 0      1    2      3       4   5 
			for($i=0;$i<$nb_articles;$i++)
			{ 
				 $ref = $articles[$ptr];
				 $ref = trim($ref);
				 $requete = "SELECT * FROM $table WHERE reference ='$ref'";
			         $result = mysql_query($requete);
				 $data  = mysql_fetch_assoc($result);
				 
				 $select['id_catalogue'] = $data['id_catalogue'];
				 $select['reference'] = $data['reference'];
				 $select['marque'] = $data['marque'];
				 $select['table'] = $table;
	      			 $select['qte'] = $articles[3+$ptr]; //$_POST['qte'];
				 $select['designation'] = $data['designation'] ." " .$data['marque'] ." " .$data['reference'];	
				 $select['prix_ttc'] = $data['prix_ttc'];
				 $select['prix_ht'] = $data['prix_ht'];
				 $select['dispo'] = $data['dispo'];
				 
				 if(in_array($ref, $_SESSION['panier']['designation']))
	  	                   { $position = array_search($ref, $_SESSION['panier']['designation']);
 	                    	    // modifie qte
 	                  	    $_SESSION['panier']['qte'][$position] = $_SESSION['panier']['qte'][$position] + $articles[2+$ptr];;
		       	           }  		
				 else
				      {
				       ajout($select);
				      }
				 $ptr = $ptr + 5;
				 
		        }
			
			header('Location: panier02.php');
			
	  }	

	}

	if(isset($_POST['operation']))
		   	  {
		  	    if($_POST['operation'] == "update")	
		  	      {  echo "bilan";
		  	         $pos = $_POST['index'];
		  	         $_SESSION['panier']['qte'][$pos] = $_POST['qte'];
		  	         header('Location: ajouter_panier02.php'); 
		  	      }
		  	  }     
		  
		   	
		   	if(isset($_GET['caddie']))
		   	  {
		   	      $ref = $_GET['ref']; 
		   	      $caddie = $_GET['caddie']; 
		   	      $table = $_GET['table']; 

		   		if( $caddie=="ajout" )
	                  	  {     //echo '<body onLoad="alert(\'ajouter un produit au panier ...\')">'; 	
	                    		if(in_array($ref, $_SESSION['panier']['reference']))
	  	                  	  { $position = array_search($ref, $_SESSION['panier']['reference']);
	 	                    	    $_SESSION['panier']['qte'][$position] = $_SESSION['panier']['qte'][$position] + $_POST['qte'];
		       	            	    // mise à jour
		       	            	    header('Location: rafraichir_panier02.php');
		       	            	    //var_dump($_SESSION['panier']);
		       	          	}  		
	                  	
	                  		else {  $connexion = mysql_connect($db_host,$db_user,$db_pass); 
       		   	                	mysql_select_db($db_name, $connexion);

				        	$requete = "SELECT * FROM $table WHERE reference='$ref'";
			                	$result = mysql_query($requete);
				        	$data  = mysql_fetch_assoc($result);
		
						if(isset($_POST['qte']))
	 	                    	          { $quantite = $_POST['qte'];
	 	                    	          }	
	 	                    	    else { $quantite = 1;
	 	                    	    	 }  
		
						$select['id_catalogue'] = $data['id_catalogue'];
				        	$select['reference'] = $data['reference'];
				        	$select['marque'] = $data['marque'];
				        	$select['table'] = $table;
	      			        	$select['qte'] = $quantite ; //$_POST['qte'];
				        	$select['designation'] = $data['designation'] ." " .$data['marque'] ." " .$data['reference'];	
				        	$select['prix_ttc'] = $data['prix_ttc'];
				        	$select['prix_ht'] = $data['prix_ht'];
				        	$select['dispo'] = $data['dispo'];
				        	
				        	ajout($select);
				        	header('Location: rafraichir_panier02.php');
				        	
				        	/*echo "<pre>";
				        	var_dump($select);
				        	echo "</pre>";
				        	
				        	echo "<br>";
				        	
				        	echo "<pre>";
				        	var_dump($select);
				        	echo "</pre>";*/

		                    	}		  	   
		   	         }
		   	
		   	}	
		   	  
		   	//echo ">>>> " .$table;
		   	
		   	//echo "<pre>";
			//var_dump($_SESSION['panier']);
			//echo "</pre>";
		   	
		   	if(isset($_GET['action']) && isset($_GET['indice']) )
		   	  {
		   	  	if($_GET['action'] == "plus")
		                  {  
		                    $_SESSION['panier']['qte'][$_GET['indice']] = $_SESSION['panier']['qte'][$_GET['indice']]+1;
			            $_GET['action'] ="";
			            header('Location: rafraichir_panier02.php');
			          }
		   	
		   	        if($_GET['action'] == "moins")
		                  { //echo '<body onLoad="alert(\'Plus\')">'; 
		                   $_SESSION['panier']['qte'][$_GET['indice']] = $_SESSION['panier']['qte'][$_GET['indice']]-1;
             		           header('Location: rafraichir_panier02.php');
             		           if($_SESSION['panier']['qte'][$_GET['indice']] == 0)	
                                     {   
                            	        $indice =  $_GET['indice'];  
		         		array_splice($_SESSION['panier']['id_catalogue'], $indice, 1);
		         		array_splice($_SESSION['panier']['reference'], $indice, 1);
			 		array_splice($_SESSION['panier']['designation'], $indice, 1);
			 		array_splice($_SESSION['panier']['marque'], $indice, 1);
			 		array_splice($_SESSION['panier']['table'], $indice, 1);
			 		array_splice($_SESSION['panier']['qte'], $indice, 1);
			 		array_splice($_SESSION['panier']['prix_ttc'], $indice, 1);
				 	array_splice($_SESSION['panier']['prix_ht'], $indice, 1);
				 	array_splice($_SESSION['panier']['dispo'], $indice, 1);
				 	
			             }
		                  }
		   	  	
		   	  	
			 	if($_GET['action'] == "efface")
		           	  {   // header('Location: proto.php');
		                	$indice =  $_GET['indice'];  
		         		array_splice($_SESSION['panier']['id_catalogue'], $indice, 1);
		         		array_splice($_SESSION['panier']['reference'], $indice, 1);
			 		array_splice($_SESSION['panier']['designation'], $indice, 1);
			 		array_splice($_SESSION['panier']['marque'], $indice, 1);
			 		array_splice($_SESSION['panier']['table'], $indice, 1);
			 		array_splice($_SESSION['panier']['qte'], $indice, 1);
			 		array_splice($_SESSION['panier']['prix_ttc'], $indice, 1);
				 	array_splice($_SESSION['panier']['prix_ht'], $indice, 1);
				 	array_splice($_SESSION['panier']['dispo'], $indice, 1);
				 	
			 		$nb_articles = count($_SESSION['panier']['reference']);
			 		header('Location: rafraichir_panier02.php');
			           }
				
			 }
				
			if(isset($_GET['action']) )
		          {
			    if($_GET['action'] == "vide")
		              {  unset($_SESSION['panier']);
 		                 header('Location: rafraichir_panier02.php');
			      }	   
			  }
			  
			            //var_dump($_SESSION['panier']);

			$contenu = count($_SESSION['panier']['reference']);

			$compte_articles = 0;

			if($contenu != 0)
	  		  { for($i=0;$i<count($_SESSION['panier']['reference']);$i++)
	       		       { $compte_articles = $compte_articles +  $_SESSION['panier']['qte'][$i];
	       		       }

				//echo "<div>Votre panier contient "; 
	        		//echo $compte_articles; 
	        		//echo " article(s)</div> ";
	  		  }

			if($contenu == 0)
	  		  { //echo "<div>Votre panier est vide </div>";
	  		  }

			$_SESSION['nb_article_panier'] = $compte_articles;
			
			//echo "Nombre d'articles : " .$_SESSION['nb_article_panier'];

?>

<?php
function ajout($select)
{
    array_push($_SESSION['panier']['id_catalogue'],$select['id_catalogue']);	
    array_push($_SESSION['panier']['reference'],$select['reference']);
    array_push($_SESSION['panier']['marque'],$select['marque']);
    array_push($_SESSION['panier']['table'],$select['table']);
    array_push($_SESSION['panier']['qte'],$select['qte']);
    array_push($_SESSION['panier']['designation'],$select['designation']);
    array_push($_SESSION['panier']['prix_ttc'],$select['prix_ttc']);
    array_push($_SESSION['panier']['prix_ht'],$select['prix_ht']);
    array_push($_SESSION['panier']['dispo'],$select['dispo']);
	
} 

?>	

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="fr" xmlns="http://www.w3.org/1999/xhtml" lang="fr"><head>

	
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Patrice Delpy</title>

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

<meta http-equiv="content-style-type" content="text/css">
<!--
<style type="text/css">
	.CodeCoup { font-size:14px; font-weight:bold; color:#0066FF; margin-top:16px; }
	.ValidatorError { margin:10px; padding:10px;color:#990000; font-weight:bold; }
	.BskLine1.Error td ,	
	.BskLine2.Error td { background: #FF6F75; }
	.Nav {padding: 5px; font-weight:bold; color: #CCC}
	.Nav a {color: #3E76BA; text-decoration:none;}	
	.Nav a:hover {color: #B71800;}	
	#email-error {font-weight:bold;text-align:left;color:#DF0900;}	
	span.help {		cursor: help;		border-bottom: 1px dotted #3E76BA;	}	
	div#help-container {		position: absolute;		background: #FFF;		border: 2px solid #333;		padding: 3px;		margin-top: 10px;	}	div#help-container p#help-message {		padding: 0px;		margin: 0px;	}	#GBodyCtc .message.warning {		color: #B91900;		padding: 25px 0 25px 85px;	}
</style>

-->


<script type="text/javascript" src="tools.js"></script>

<script type="text/javascript">
	
	function HidePanel()
	 {
		for (var i=0; i < arguments.length ; i++)
		 {
			if(typeof document.getElementById(arguments[i]) != 'undefined')
				document.getElementById(arguments[i]).style.display = 'none';
		}
	}
	function CheckEmail(event) 
	{
		var email = document.getElementById('e-mail').value;
		if( ! new RegExp(/^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/i).test(email))
			{
			document.getElementById('email-error').style.visibility = 'visible';
			return false;
		}
		return true;
	}
	
	
</script>



</head>
            
            
 <body class="gecko">
 
 
 <div id="page">

<!-- header -->

<div id="header">
<h1><a name="top" href="/">Panier - Patrice Delpy</a></h1>
</div>
		
<?php
	include("../menu_site.php")

?>			



<!-- section :content -->
<div id="section">


<div id="panier" style="overflow: auto;">

<div style="float: left; width: 745px; padding: 0pt 0pt 0pt 5px;">
<table class="BskTitle" border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody><tr>
<th height="40" width="689">
Mon panier <img src="../images/PuceBleue.gif" alt="" height="11" width="8">
<hr>
</th>

<td rowspan="2" width="56"><img src="caddie_icone.jpg" alt="" height="66" width="57"></td>
</tr>
<tr>

<td style="vertical-align: top;" height="26"><a href="../acceuil.php">Accueil &gt;</a></td>
</tr>
</tbody></table>




<div class="ProdSpecOps"></div>
<br>

<?php

	
	/*if(isset($_SESSION['nb_article_panier']))
	   {*/
	      if(count($_SESSION['panier']['reference']) == 0)
	        { //header('Location: zero.php');
	          echo "<div align=\"center\">
	                <img src=\"../images/panier_vide.jpg\" alt=\"Votre panier est vide\" title=\"Votre panier est vide\" /></div>
	                </div>";

	        }		
	        
	      if(count($_SESSION['panier']['reference']) != 0)  
	         { echo "
	         	  <table class=\"BskSectionTitle\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
			  <tbody><tr>
			  <td nowrap=\"nowrap\" width=\"95%\">Contenu de mon panier </td>
			  <td nowrap=\"nowrap\" width=\"5%\">&nbsp;</td>
			  </tr>
			  </tbody>
			  </table>
			  <div id=\"AlertPanelFavorites\" style=\"left: 30%; border: 2px solid rgb(51, 51, 51);
			  background: url(../images/panier_message_fond.jpg) no-repeat scroll 
			  center center rgb(255, 255, 255); width: 400px; position: absolute; z-index: 999; display: none;\">
			  <div style=\"background: url(../images/panier_barre_fond.gif) repeat scroll center center transparent; padding: 1px; 
			  color: rgb(255, 255, 255); font-weight: bold;\"> 
			  </div>  
			  </div>  ";
	     
		   echo "
			  <table class=\"Bsk\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
			  <td width=\"22%\" height=\"130\" style=\"text-align:center;border-bottom:1px solid #383838;\">
			  &nbsp;</td>
			
			  <td style=\"vertical-align: top; border-left: 1px solid rgb(144, 144, 144); border-bottom: 1px solid rgb(56, 56, 56);\" 
			  width=\"78%\">


			  <table class=\"BskProdList\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
			  <tbody>
                          <tr>
			  <th style=\"text-align: center;\" width=\"58%\">Produits</th>
			  <th style=\"text-align: center;\" width=\"10%\">Quantité</th>
			  <th style=\"text-align: right;\" width=\"12%\">Prix TTC</th>
			  <th style=\"text-align: center;\" width=\"10%\">Dispo.</th>
			  <th style=\"text-align: center;\" width=\"5%\">&nbsp;</th>
			  <th style=\"text-align: center;\" width=\"5%\">
			  <a href=\"panier02.php?action=vide\">
			  <img src=\"../images/BskProdRem.gif\" alt=\"Vider tout le panier\" title=\"Vider le panier\" border=\"0\" height=\"13\"
			  width=\"11\">
			  </a>
			  </th>
			  </tr> ";
						

	
			  //var_dump($_SESSION); 

		          $total_ttc = 0;
		          $total_ht = 0;


			  for($i=0;$i<count($_SESSION['panier']['reference']);$i++)
	                     { $total_ttc+=$_SESSION['panier']['prix_ttc'][$i]*$_SESSION['panier']['qte'][$i];
		               $total_ht+=$_SESSION['panier']['prix_ht'][$i]*$_SESSION['panier']['qte'][$i];

		     	       $prix = "prix".$i;
		               $boite ="elem".$i;

         	               if($i%2 ==0)
		                 { // echo 'Le nombre entré est pair';
		                   echo "<tr class=\"BskLine1\" onmouseout=\"PlLineBack(this, 'BskLine1');\" onmouseover=\"PlLineSwitch(this, '', true);\"> ";
	 	                 }
	    
		           else  { // echo 'le nombre entré est impair';
		                   echo "<tr class=\"BskLine2\" onmouseout=\"PlLineBack(this, 'BskLine2');\" onmouseover=\"PlLineSwitch(this, '', true);\"> ";
		                 }
                        
                        
                        
                        	$a = $_SESSION['panier']['designation'][$i];
                        	$b = $_SESSION['panier']['qte'][$i];
                        	$c = $_SESSION['panier']['prix_ttc'][$i];
                        	$d = $_SESSION['panier']['dispo'][$i];
                        	
                        	switch($d)
  		      			{
			  		case "24H" :
			          			$dispo_logo  = "../images/stock_vert.gif";
			          			$dispo_descriptif = "En stock";
			    	  			break;
			  		case "48H" :
			          			$dispo_logo  = "../images/stock_bleu.gif";
			          			$dispo_descriptif = "En cours d'approvisionnement";
			    	  			break;
			  		case "72H" :
			          			$dispo_logo  = "../images/stock_rouge.gif";
			          			$dispo_descriptif = "Rupture de stock";
			    	  			break;  	  		  
					}	
                        
                        	echo "
	                      		<td>
					<a href=\"Black.html\"> $a </a>
					</td>
					<td style=\"text-align: center;\">
					<a href=\"panier02.php?action=moins&indice=$i\">
					<img src=\"../images/BskProdLess.gif\" alt=\"\" border=\"0\" height=\"11\" width=\"11\">
					</a>
					<span class=\"Qte\">&nbsp; $b &nbsp;</span>
					<a href=\"panier02.php?action=plus&indice=$i\">
					<img src=\"../images/BskProdMore.gif\" alt=\"\" border=\"0\" height=\"11\" width=\"11\">
					</a>
					</td>
					<td style=\"text-align: right;\">
                        		<span class=\"Price\">$c &#8364;</span>
                        		</td> ";
                        		
                        	echo "	
					<td style=\"text-align: center;\">
					<img src=\"$dispo_logo\" alt=\"$dispo_descriptif\" title=\"$dispo_descriptif\">		
                        		</td> ";

				
				 echo "
					<td style=\"text-align: center;\">
					<td style=\"text-align: center;\">
        	                	<a title=\"Supprimer\" href=\"panier02.php?action=efface&indice=$i\">
                	        	<img src=\"../images/BskProdRem.gif\" alt=\"Supprimer\" border=\"0\" height=\"13\" width=\"11\">
                        		</a>
                        		</td>
					</tr> ";
		          }

					
					echo "  
		                      		</tbody>
                		      		</table>
                      				</td>
		      				</tr>
		      				</tbody>
		      				</table>

	
						<table id=\"BskCoupOn\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
						<tbody><tr>
						<td colspan=\"2\" style=\"text-align: right;\">
						<img src=\"../images/panier_mail.gif\" alt=\"Envoyer ce panier par e-mail\" 
						style=\"border-right: 1px solid rgb(89, 89, 89); cursor: pointer;\"
						onclick=\"HidePanel('AlertPanelBasket', 'AlertPanelFavorites');ShowHideElem('AlertPanelEmail')\" 
						title=\"Envoyer ce panier par e-mail\" width=\"220\" border=\"0\" height=\"28\">
	
						<div id=\"AlertPanelEmail\" style=\"border: 2px solid rgb(51, 51, 51); background: rgb(255, 255, 255)
						url(../images/panier_message_fond.jpg) no-repeat scroll center center; left: 30%; -moz-background-clip:
						border; -moz-background-origin: padding; -moz-background-inline-policy: 
						continuous; width: 400px; position: absolute; z-index: 999; display: none;\">
	
						<div style=\"padding: 1px; background: transparent url(../images/panier_barre_fond.gif) repeat scroll
						center center; -moz-background-clip: border; -moz-background-origin: padding; 
						-moz-background-inline-policy: continuous; color: rgb(255, 255, 255); font-weight: bold;\">
						<table width=\"100%\">
						<tbody><tr>
						<td width=\"49%\">Envoyer ce panier par e-mail</td>
						<td style=\"text-align: right;\" width=\"51%\">
						<img src=\"../images/panier_barre_fermer.gif\" alt=\"Fermer\" style=\"cursor: pointer;\"
						onclick=\"ShowHideElem('AlertPanelEmail')\" width=\"13\" height=\"14\"></td>
						</tr>
						</tbody>
						</table>
						</div>
	
						<div style=\"padding: 3px; text-align: left;\">
						<p>Vous pouvez envoyer ce panier par e-mail à l'adresse de votre choix.</p>

						<form action=\"panier.nt.html\" method=\"post\" onsubmit=\"return CheckEmail(event);\">
						<table class=\"showbox\" cellpadding=\"6\" cellspacing=\"2\">
						<tbody><tr>
						<td style=\"vertical-align: top;\"><label for=\"e-mail\">Adresse e-mail :</label></td>
						<td style=\"vertical-align: top;\">
						<input size=\"40\" id=\"e-mail\" name=\"e-mail\" type=\"text\">
						<div id=\"email-error\" style=\"visibility: hidden;\">L'adresse e-mail n'est pas valide</div>
						</td>
						</tr>
						<tr>

						<td><input autocomplete=\"off\" name=\"op\" value=\"e-mail\" type=\"hidden\"></td>
						<td style=\"text-align: right;\">
						<input value=\"Envoyer\" type=\"submit\">
						</td>
						</tr>
						</tbody></table>
						</form>
						</div>
						</div>

						<img src=\"../images/panier_sauver.gif\" alt=\"Sauvegarder le panier\" style=\"cursor: pointer;\" 
						onclick=\"HidePanel('AlertPanelEmail', 'AlertPanelFavorites');ShowHideElem('AlertPanelBasket')\" 
						title=\"Sauvegarder le panier\" width=\"170\" border=\"0\" height=\"28\">
	
						<a href=\"impression_panier.php\" target=\"_blank\">
						<img src=\"../images/panier_imprimer.gif\" alt=\"Imprimer le panier\" title=\"Imprimer le panier\" width=\"169\"
						border=\"0\" height=\"28\"></a>
						<div id=\"AlertPanelBasket\" style=\"border: 2px solid rgb(51, 51, 51); background: rgb(255, 255, 255) 
						url(../images/panier_message_fond.jpg) no-repeat scroll center center; left: 30%; -moz-background-clip:
						border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; width: 400px;
						position: absolute; z-index: 999; display: none;\">
						
						<div style=\"padding: 1px; background: transparent url(../images/panier_barre_fond.gif) repeat scroll 
						center center; -moz-background-clip: border; -moz-background-origin: padding;
						-moz-background-inline-policy: continuous; color: rgb(255, 255, 255); font-weight: bold;\">
						<table width=\"100%\">
						<tbody><tr>

						<td width=\"49%\">Enregistrer le panier</td>
						<td style=\"text-align: right;\" width=\"51%\">
						<img src=\"../images/panier_barre_fermer.gif\" alt=\"Fermer\" 
						style=\"cursor: pointer;\" onclick=\"ShowHideElem('AlertPanelBasket')\" width=\"13\" height=\"14\"></td>
						</tr>
						</tbody>
						</table>
						</div> ";
						
						
						//// pour le debuug - doit être modifier
						$_SESSION['login']= "connecter";

	
						if($_SESSION['login'] == "deconnecter")
	  					   {
	  					     echo "  <div style=\"padding: 3px; text-align: left;\">
						             <div style=\"height: 100px; top: 30px; position: relative; text-align: center;
						             font-weight: bold; color: rgb(203, 20, 0);\">
							     Vous devez être identifié avec votre compte client pour enregistrer votre panier</div>
							     </div>
							     </div>
							     </td>
							     </tr> ";
	 					   }		

					        if($_SESSION['login'] == "connecter" && $_SESSION['nb_article_panier']== 0)
	  					  { 

						     echo "  <div style=\"padding: 3px; text-align: left;\">
							<div style=\"height: 100px; top: 30px; position: relative; text-align: center; font-weight: bold; color: rgb(203, 20, 0);\">
							Impossible de sauver un panier vide !</div>
							</div>
							</div>
							</td>
							</tr> ";
						 }

						if($_SESSION['login'] == "connecter" && $_SESSION['nb_article_panier']!= 0)
						  { 
						     echo " <div style=\"text-align:right; padding:3px; text-align:left;\">
						    	    <div>
					     	    	    <p>
						   	    Vous pouvez enregistrer votre panier pour pouvoir y acceder ulterieurement dans votre espace personnel.								</p>
							    <form method=\"post\" action=\"sauvegarder_panier.php\">
							    <table cellspacing=\"2\" cellpadding=\"6\" class=\"showbox\">
							    <tr>
							    <td><label for=\"baskettitle\"><b>Titre du panier :</b></label></td>
							    <td><input type=\"text\" size=\"40\" name=\"titre\" id=\"titre\" value=\"\" /></td>
							    </tr>
							    <tr>
							    <td><input type=\"hidden\" name=\"op\" value=\"save\" /></td>
							    <td style=\"text-align:right;\"><input type=\"submit\" value=\"Enregistrer\" /></td>
							    </tr>
							    </table>
							    </form>
							    </div>
							    </div> ";

	  					}	
	
	
					       echo "   <tr>
							<td colspan=\"2\" class=\"LivBlock\" 
							style=\"background: transparent url(../images/panier_separation.gif) no-repeat scroll 
							center center; 	-moz-background-clip: border; -moz-background-origin: padding; 
							-moz-background-inline-policy: continuous; height: 1px;\" height=\"80\"><br></td>
							</tr>
							<tr> ";
	
/*
	<td style="text-align: center; vertical-align: middle;" colspan="2">
	<div class="message warning">
	<span class="ValidatorError">Code coupon invalide ou périmé</span>
	</div>
	</td>
	</tr>
	<tr>
*/
					      echo "	
							<td style=\"text-align: left; vertical-align: middle; padding-left: 10px; color: 
							rgb(62, 118, 186);\" width=\"35%\" height=\"80\">
							Si vous disposez d'un code de réduction, saisissez-le ici et cliquez sur OK.<br>
							Limité à 1  coupon de réduction par commande uniquement.
							</td>
	
							<td style=\"vertical-align: top;\" height=\"80\">
							<div class=\"CodeCoup\" style=\"background: transparent url(../images/panier_coupon.gif) no-repeat 
							scroll 0% 0%; padding-left: 70px; padding-top: 22px; -moz-background-clip: border; 
							-moz-background-origin: padding; -moz-background-inline-policy: continuous; min-height: 70px;\">
							<form method=\"post\" action=\"panier.nt.html\">
							<input name=\"coupon\" id=\"coupon\" type=\"text\">
							<input name=\"Submit\" value=\"OK\" type=\"submit\">
							<input autocomplete=\"off\" name=\"op\" value=\"coupon\" type=\"hidden\">
							</form>
						
							</div>
							</td>
							</tr>
							<tr>
							<td style=\"text-align: center; vertical-align: middle;\" colspan=\"2\">
							</td>
							</tr>
							</tbody>
							</table> ";
	
                      			    echo "	
                      
					 	        <table class=\"LivBlock\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
	    						<tbody><tr>
							<td width=\"100%\" style=\"background: url(&quot;/images/gui/main/BskSep.gif&quot;) no-repeat
							scroll center center transparent; height: 1px;\"></td>
							</tr>
							<tr>
		
						        <td style=\"background: url(../images/BskSep.gif) no-repeat scroll center 
							center transparent; height: 1px;\"></td>
							</tr>
							<tr>
		
        						<td style=\"text-align: right; height: 60px; border-bottom: 1px solid
 							rgb(204, 204, 204); vertical-align: middle;\">

							<form method=\"get\" action=\"panier.nt.html\">
							<table align=\"right\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
							<tbody><tr>
        
							<td class=\"totbutton1\">		
							TOTAL TTC	
							</td>
							<td id=\"total\" class=\"totbutton2\">
							$total_ttc &#8364;
							</td>
							<td>
		
        						<a href=\"validation_commande.php\">
							<img src=\"../images/btn_passorder.gif\" type=\"image\" alt=\"Passez votre commande\"></a>
        							
		
							</tr>
							</tbody>
        						</table>
							</form>

		

							</td>		
							</tr>
							</tbody>
							</table>
							<br>		
	  						</div> ";

			}
		
		/*}*/

?>



	<!-- Right Side -->
</div>			</div>

			<!-- aside -->
			<div id="aside">
			<div id="search-bar">

			<form method="get" action="search.html">
			<input type="text" name="search" title="Recherche"/>
			<input type="submit" value="Rechercher" />
			</form>
			</div>
			

<?php
            
            //if(isset($_SESSION['connexion']))
			 
			    if($_SESSION['utilisateur_login']== "valide")
				  {         //echo '<body onLoad="alert(\'Identification par le panel.\')">'; 
							echo "
								<div id=\"account\" class=\"on\">
								<ul>
								<li class=\"icon\"><a href=\"../compte/compte.php\">Mon espace perso</a></li>
								<li class=\"logout\"><a href=\"../compte/logout.php\" title=\"Me d&eacute;connecter\">Me d&eacute;connecter</a></li>
								</ul>
								<div class=\"panel\">
								<ul class=\"buttons\">
								<li class=\"account\"><a href=\"../compte/compte.php\">Mon compte client</a></li>
								<li class=\"orders\"><a href=\"../commande/suivi_commande.php\">Mes commandes</a></li>
								<li class=\"addresses\"><a href=\"../compte/adresse_livraison.php\">Mon carnet d'adresse</a></li>
								<li class=\"repairs\"><a href=\"../compte/sav.html\">Mes retours S.A.V</a></li>
								<li class=\"parrainages\"><a href=\"../compte/parrainage.html\">Mes parrainages</a></li>
								<li class=\"refunds\"><a href=\"../compte/avoir.html\">Mes avoirs</a></li>
								<li class=\"carts\"><a href=\"../panier/shopping_liste.php\">Mes paniers</a></li>
								<li class=\"alertes\"><a href=\"../compte/alerte.html\">Mes alertes</a></li>
								</ul>
								</div>
								</div> ";
					
				     }
					 
					 else {
						 		echo "
						 		<div id=\"account\">
								<ul>
								<li class=\"icon\"><a href=\"../compte/login.php\">Mon espace perso</a></li>
								</ul>

								<div class=\"panel\">
								<form action=\"../compte/check.php\" method=\"post\">
								<dl>
								<dt><label for=\"login\">Votre nom utilisateur</label></dt>
								<dd><input name=\"login\" id=\"login\" maxlength=\"20\" type=\"text\"></dd>
								<dt><label for=\"pass\">Votre mot de passe</label></dt>
								<dd><input name=\"pass\" id=\"pass\" maxlength=\"10\" type=\"password\"></dd>
								</dl>
								<input value=\"Connexion\" type=\"submit\">
								<hr>
								<ul class=\"buttons\">
								<li class=\"register\"><a href=\"../compte/creation_compte.php\">Créer mon compte</a></li>
								<li class=\"password\"><a href=\"../compte/sendpass.php\">Mot de passe oublié ?</a></li>
								</ul>
								</form>
								</div>
								</div> ";
						 
					      }
					 
					 
			 

?>


<?php


	$_SESSION['total_ttc_panier'] = $total_ttc;
	$_SESSION['total_ht_panier'] = $total_ht;
	
	$_SESSION['nb_article_panier'] = $compte_articles;


	if($compte_articles == 0)
      {
		echo " <div id=\"basket\" >
				<ul>
				<li id=\"BasketProdCount\"><a href=\"panier.html\">Votre panier est vide</a></li>
				<li id=\"BasketAmount\"></li>
				</ul>
				</div>
				</div>  ";
	  }


	if($compte_articles != 0)
	  {

		
                $mess1 = $compte_articles ." " ."article" ; 
		
		if($compte_articles >1)
		  { $mess1 = $mess1 ."s";
		  }	
		
		$mess2 = $total_ttc ." &euro";
		

		echo "   <div id=\"basket\" class=\"on\">
 			     <ul>
		     	 <li id=\"BasketProdCount\"><a href=\"panier02.php\">$mess1</a></li>  
		    	 <li id=\"BasketAmount\">$mess2</li> 
				 </ul>
				 </div>
			     </div> ";
	  }


?>

			<!-- footer -->
		</div>
	<div style="visibility: hidden; opacity: 0; display: none;" 
class="MultiBoxContainer"><iframe style="position: absolute; top: -20px;
 left: -20px; width: 115%; height: 115%; visibility: hidden; opacity: 
0;" src="javascript:void(0);" name="mulitBoxIframe" id="multiBoxIframe" 
scrolling="no" frameborder="1"></iframe><div class="MultiBoxContent"></div><div
 class="MultiBoxClose"></div><div style="height: 0px;" 
class="MultiBoxControlsContainer"><div class="MultiBoxControls"><div 
class="MultiBoxPrevious"></div><div class="MultiBoxNext"></div><div 
class="MultiBoxTitle"></div><div class="MultiBoxNumber"></div><div 
class="MultiBoxDescription"></div><div style="clear: both;">

</div>
</div>
</div>
</div>


</body>
</html>