<?php

	session_start();

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

	

	if(isset($_GET['action']))
	  {
	     if($_GET['action'] == "charge" ) 
               {  
        		$indice = $_GET['elem'];
			
			$connexion = mysql_connect("localhost", "root", "");
	                mysql_select_db("boutique", $connexion);

			
			$requete = "SELECT * FROM panier WHERE id='$indice' ";
     			$result = mysql_query($requete);
			$panier_liste=mysql_fetch_array($result);
			
			//print_r($panier_liste);
			
	    		$articles = explode("," , $panier_liste['panier']);
	  	     	
	  	     	//echo "+++++";
	  	     	//print_r($articles);
	  	     	
	  	     	$nb_articles = count($articles)/4; 
			
			//echo $nb_articles;
			
			 // 0 3 6 
			 
			$connexion = mysql_connect("localhost", "root", "");
       		   	mysql_select_db("boutique", $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 lave_linge WHERE modele='$ref'";
			         $result = mysql_query($requete);
				 $data  = mysql_fetch_assoc($result);
		
				 $select['id'] = $data['id'];
	      			 $select['designation'] = $data['modele'];	
				 $select['qte'] = $articles[2+$ptr];
				 $select['prix_ttc'] = $data['prix_ttc'];
				 $select['prix_ht'] = $data['prix_ht'];
				 
				 
				 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 + 4;
				 
				 
		        }
			
			header('Location: rafraichir_panier.php');
			
			
	  }	

	}

	
?>






<!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>Materiel.net</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>
			</head>
            
            
 <body class="gecko">
 
 
 <div id="page">

			<!-- header -->

			<div id="header">
				<h1><a name="top" href="/">Materiel.net</a></h1>
			</div>
			

			<!-- nav -->
				<div id="nav">
				<div class="GHeadMenu">

<ul class="nav-line">

<li class=""><a href="../acceuil.php" style="" title="Accueil"><span>Accueil</span></a></li>

<li class="Bonnes affaires"><a href="../catalogue/affaires.php" style="background-image:url(/live/97759.gif);" title="Bonnes affaires"><span>affaires</span></a></li>

<li class="Gros menager"><a href="../catalogue/gros_menager.php" style="background-image:url(/live/97760.gif);" title="Gros menager"><span>Gros Ménager</span></a></li>

<li class="Petit menager"><a href="../catalogue/petit_menager.php" style="background-image:url(/live/97761.gif);" title=" Petit ménager"><span>PEtit Menager</span></a></li>

<li class="Images"><a href="../catalogue/image.php" style="background-image:url(/live/97762.gif);" title="Images"><span>Images</span></a></li>

<li class="Son"><a href="../catalogue/son.php" style="background-image:url(/live/97763.gif);" title="SON"><span>SON</span></a></li>

<li class="Video"><a href="../catalogue/video.php" style="background-image:url(/live/97764.gif);" title="Video"><span>Video</span></a></li>

<li class="Photo et camescope"><a href="../catalogue/photo_camescope.php" style="background-image:url(/live/97769.gif);" title="Photo / cam&eacute;scopes">Photo / cam&eacute;scopes</a></li>

<li class="Telephonie"><a href="../catalogue/telephonie.php" style="background-image:url(/live/97770.gif);" title="T&eacute;l&eacute;phonie">T&eacute;l&eacute;phonie </a></li>

</ul>
<ul class="nav-line">

<li class="art de la table"><a href="../catalogue/art_de_la_table.php" style="background-image:url(/live/97766.gif);" title="Art de la table"><span>Art de la table</span></a></li>

<li class="Accessoires"><a href="../catalogue/accessoires.php" style="background-image:url(/live/97767.gif);" title="Accessoires &amp;Consommables"><span>accessoires &amp;consommables</span></a></li>

<li class="Chauffage & clim"><a href="../catalogue/chauffage_clim.php" style="background-image:url(/live/97768.gif);" title="Chauffage &amp; Clim"><span>chauffage &amp; clim</span></a></li>

<li class="Automobiles"><a href="../catalogue/automobile.php" style="background-image:url(/live/97769.gif);" title="Automobiles"><span>Automobiles</span></a></li>

<li class="GPS"><a href="../catalogue/gps.php" style="background-image:url(/live/97770.gif);" title="GPS"><span> GPS</span></a></li>

<li class="MP3"><a href="../catalogue/mp3.php" style="background-image:url(/live/97771.gif);" title="AUDIO / MP3 / MP4"><span>AUDIO / MP3 / MP4</span></a></li></ul>
			  </div>
				<!--cached-->			</div>


			<!-- 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="../images/BskHeaderIco.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>
			<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/ProdAlerteBg.jpg) no-repeat scroll 
center center rgb(255, 255, 255); width: 400px; position: absolute; 
z-index: 999; display: none;">
			<div style="background: 
url(../images/FooterBarBg.gif) repeat scroll center 
center transparent; padding: 1px; color: rgb(255, 255, 255); 
font-weight: bold;">
				<table width="100%">
					<tbody><tr>
						<td width="49%">Ajouter un favori</td>
						<td style="text-align: right;" width="51%">
							<img src="panier_fichiers/ProdAlerteClose.gif" alt="Fermer" 
style="cursor: pointer;" onclick="ShowHideElem('AlertPanelFavorites')" 
height="14" width="13">
						</td>
					</tr>
				</tbody></table>
			</div>
					<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 des 
favoris</div>
		</div>
        
        
<?php


			print_r($_POST);

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

		   		if( $caddie=="ajout" )
	                  	  {
	                        	//echo '<body onLoad="alert(\'ajouter un produit au panier ...\')">'; 	
	                    		if(in_array($id, $_SESSION['panier']['designation']))
	  	                  	  { $position = array_search($id, $_SESSION['panier']['designation']);
	 	                    	    // modifie qte
	 	                    	    $_SESSION['panier']['qte'][$position] = $_SESSION['panier']['qte'][$position] + $_POST['qte'];
		       	            	    header('Location: rafraichir_panier.php');
		       	            	    //   var_dump($_SESSION['panier']);
		       	          	}  		
	                  	
	                  		else {  $connexion = mysql_connect("localhost", "root", "");
       		   	                	mysql_select_db("boutique", $connexion);

				        	$requete = "SELECT * FROM lave_linge WHERE modele='$id'";
			                	$result = mysql_query($requete);
				        	$data  = mysql_fetch_assoc($result);
		
				        	$select['id'] = $data['id'];
	      			        	$select['qte'] = $_POST['qte'];
				        	$select['designation'] = $data['modele'];	
				        	$select['prix_ttc'] = $data['prix_ttc'];
				        	$select['prix_ht'] = $data['prix_ht'];
				        	ajout($select);
				        	header('Location: rafraichir_panier.php');

		                    	}		  	   
		   	         }
		   	
		   	}	
		   	  
		   	
		   	
		   	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_panier.php');
			          }
		   	
		   	        if($_GET['action'] == "moins")
		                  { //echo '<body onLoad="alert(\'Plus\')">'; 
		                   $_SESSION['panier']['qte'][$_GET['indice']] = $_SESSION['panier']['qte'][$_GET['indice']]-1;
             		           header('Location: ajouter_panier.php');
             		           if($_SESSION['panier']['qte'][$_GET['indice']] == 0)	
                                     {   
                            	        $action = "efface";
			             }
		                  }
		   	  	
		   	  	
			 	if($action == "efface")
		           	  {    
		                	$indice =  $_GET['indice'];  
		         		array_splice($_SESSION['panier']['id'], $indice, 1);
			 		array_splice($_SESSION['panier']['designation'], $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);
				 	print_r($_SESSION['panier']);   
			 		$nb_articles = count($_SESSION['panier']['id']);
			 		header('Location: rafraichir_panier.php');
			           }
		           
			        
			  }
			  
			            //var_dump($_SESSION['panier']);
				
			   	


?>

<?php
function ajout($select)
{
    array_push($_SESSION['panier']['id'],$select['id']);
    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']);
} 

?>	


        
        
        

<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;">

<div id="Img111" style="width:10Opx; height:10Opx; overflow:hidden; "><img src="aaa.jpg" alt="Kit" /></div>
<script type="text/javascript">LastImgPH = document.getElementById("Img111");</script>		
<div id="Img222" style="width:10Opx; height:10Opx; overflow:hidden; visibility:hidden; position:absolute;">
<img src="bbb.jpg" alt="Padlock 2 - 8 Go" /></div>

<div id="Img333" style="width:10Opx; height:10Opx; overflow:hidden; visibility:hidden; position:absolute;">
<img src="ccc.jpg" alt="P7P55D Premium" /></div>

<div id="Img444" style="width:10Opx; height:10Opx; overflow:hidden; visibility:hidden; position:absolute;">
<img src="ddd.jpg" alt="P7P55D Premium" /></div>



								&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="panier.nt.html?op=empty">
						<img src="../images/BskProdRem.gif" alt="Vider le panier"
						 title="Vider le panier" border="0" height="13" width="11">
						</a>
						</th>
						</tr>
						
<?php

	$toto = 8;

		$total = 0;


		for($i=0;$i<count($_SESSION['panier']['id']);$i++)
	       { $total+=$_SESSION['panier']['prix_ttc'][$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);\"> ";

		         }



                      

                        
                 echo  "    
                        
                      	<td>
						<a href=\"Black.html\">&nbsp;toto</a>
						</td>
						<td style=\"text-align: center;\">
						<a href=\"panier.nt.html?op=proddec&amp;prod=41645\">
						<img src=\"../images/BskProdLess.gif\" alt=\"\" border=\"0\" height=\"11\" width=\"11\">
						</a>
						<span class=\"Qte\">&nbsp;1&nbsp;</span>
						<a href=\"panier.nt.html?op=prodinc&amp;prod=41645\">
						<img src=\"../images/BskProdMore.gif\" alt=\"\" border=\"0\" height=\"11\" width=\"11\">
						</a>
						</td>
						<td style=\"text-align: right;\">
                        <span class=\"Price\">129,99 &#8364;</span>
                        </td>
						<td style=\"text-align: center;\">
						<img src=\"../images/StockVert.gif\" alt=\"En stock\" title=\"En stock\">		
                        </td>
						<td style=\"text-align: center;\">
						<td style=\"text-align: center;\">
                        <a title=\"Supprimer\" href=\"panier.nt.html?op=proddel&amp;prod=41645\">
                        <img src=\"../images/BskProdRem.gif\" alt=\"Supprimer\" border=\"0\" height=\"13\" width=\"11\">
                        </a>
                        </td>
						</tr> ";
                        
   ?>                       
                        
                        
					  
                      </tbody>
                      </table>

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


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

			<!-- aside -->
			<div id="aside"></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>