<?php

       session_start();
       
       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($_SESSION['identifiant']) && isset($_SESSION['password']) && isset($_SESSION['prenom'])) 
	     {  
			$email = $_SESSION['email'];	
									 
			//$connexion = mysql_connect("localhost", "root", "");
		 	$connexion = mysql_connect($db_host,$db_user,$db_pass); 
		 	mysql_select_db($db_name, $connexion);

			$requete = "SELECT * FROM panier WHERE email='$email' ";
			$result = mysql_query($requete);
				
			$nombre = mysql_num_rows($result);	
			
			// on a trouver une ou plusieurs shopping liste
			if($nombre > 0)	
			  {			
			     $ptr = 0;
	
			     while($row = mysql_fetch_assoc($result))
	    		          {
   				    $id_cmd[$ptr] = $row["id"];
		    		    $ptr = $ptr + 1;
	    		          }
				
			     //print_r($id_cmd);	
			
			     $requete = "SELECT * FROM panier WHERE email='$email' ";
			     $result = mysql_query($requete);
			     $panier_liste=mysql_fetch_array($result);

			     $indice = $panier_liste['id'];
			     
			     $titre = $panier_liste['titre'];
			     
			     //echo $indice;
			     
			     $articles = explode("-" , $panier_liste['panier']);
			     
			     //XXX789- washer- lave-linge Bosh XXX789- 1- 1200.00
			     
			     //X28Z-22, lave_linge, 1, 721.5, NTH82K, lave_linge, 1, 479.5
			     
	  	    	     $nb_articles = count($articles)/5; 
	                     //echo ">>>" .$nb_articles; 
			     //print_r($articles);   
			     $flag_shopping_liste = True;  
		 	}
		 	else { $flag_shopping_liste = False;
		 	     }	
		 
		 
		 }
	else { // page de redirection pour les truand
			 echo '<body onLoad="alert(\'Membre non reconnu...\')">'; 
             //echo '<meta http-equiv="refresh" content="0;URL=intrusion.htm">'; 
	     }

?>




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

</head>


<body class="gecko">

				<div id="page">

			<!-- header -->

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

?>					
	

<div id="section">


<div id="client">
	<table class="CatTitle" border="0" cellpadding="0" cellspacing="0" 
width="100%">
		<tbody><tr>
			<th height="40">Mon espace perso <img 
src="../images/BskHeaderArrow.gif" alt="" height="11" width="8">
				<hr>
			</th>
			<td rowspan="2" width="50"><img 
src="../images/people-icon.png" alt="" height="48" width="48"></td>
		</tr>
		<tr>
			<td style="vertical-align: top;" height="40"><a 
href="../acceuil.php">Accueil</a> &gt; <a 
href="../compte/compte.php">mon espace perso</a>
 &gt; ma shopping list</td>
		</tr>
	</tbody></table>

	<table border="0" cellpadding="0" cellspacing="0" width="950">
		<tbody><tr>
			<td colspan="2"><div class="EpWelcome">
	<h3>Bienvenue <?php echo $_SESSION['prenom']; ?> dans votre espace perso !</h3>
	<div>Via cet espace qui vous est dédié sur E_M&eacute;nager.com, vous pourrez 
gérer votre compte client, vos adresses, consulter la liste et 
l&#8217;évolution de vos dernières commandes, de vos avoirs, de vos codes de 
promotions et profiter de bien d&#8217;autres fonctionnalités.</div>
</div></td>
		</tr>
		<tr>
			<td style="vertical-align: top;" width="270"><div class="clientmenu">
	<div style="margin-left: 10px;">

<table class="EpMenu" style="cursor: pointer;" onclick="document.location.href='../compte/compte.php';" width="266">

			<tbody><tr>
				<td style="vertical-align: middle; text-align: center;" width="84">
<img src="../images/User_Folder.jpg" alt="Mon compte personnel" 
border="0" height="64" width="64"></td>
				<td width="181">
					<div class="EpTitre">MON COMPTE CLIENT :</div>
					<div class="EpDesc">Consulter ou mettre à jour mon adresse e-mail, 
mon adresse de facturation, mes abonnements, etc.</div>
				</td>
			</tr>
		</tbody></table>
		<table class="EpMenu" style="cursor: pointer;" 
onclick="document.location.href='../commande/suivi_commande.php';" width="266">
			<tbody><tr>
				<td style="vertical-align: middle; text-align: center;" width="84">
<img
 src="../images/Forklift-Containers-64.png" alt="Mon compte personnel" 
border="0" height="64" width="64"></td>
				<td width="181">
					<div class="EpTitre">SUIVI DE MES COMMANDES :</div>
					<div class="EpDesc">La liste de mes commandes en cours et passées 
sur Materiel.net, leur état de traitement, leur détail, date, etc.</div>
				</td>
			</tr>
		</tbody></table>
				<table class="EpMenu" style="cursor: pointer;" 
onclick="document.location.href='../compte/adresse_livraison.php';" width="266">
			<tbody><tr>
				<td style="vertical-align: middle; text-align: center;" width="84"><img
 src="../images/addressbook_icon.jpg" alt="Mon carnet d'adresse" 
border="0" height="68" width="68"></td>
				<td width="181">
					<div class="EpTitre">Mon carnet d'adresses :</div>
					<div class="EpDesc">Ajouter, modifier ou supprimer mes adresses de 
livraison.</div>
				</td>
			</tr>
		</tbody></table>
				<table class="EpMenu" style="cursor: pointer;" 
onclick="document.location.href='sav.html';" width="266">
			<tbody><tr>
				<td style="vertical-align: middle; text-align: center;" width="84"><img
 src="../images/sav.gif" alt="Service après vente" 
border="0" height="64" width="64"></td>
				<td width="181">
					<div class="EpTitre">Service après vente :</div>
					<div class="EpDesc">Toutes les informations sur le SAV et sur les 
demandes de retour.</div>
				</td>
			</tr>
		</tbody></table>
					<table class="EpMenu" style="cursor: pointer;" 
onclick="document.location.href='parrainage.html';" width="266">
				<tbody><tr>
					<td style="vertical-align: middle; text-align: center;" width="84">
						<img src="cpte_parrainage_on.gif" alt="Mes 
parrainages" border="0" height="70" width="64"></td>
					<td width="181">
						<div class="EpTitre">MES PARRAINAGES :</div>
						<div class="EpDesc">Parrainez vos amis et gagnez des crédits 
d&#8217;achats d&#8217;une valeur de 10&#8364; !</div>
					</td>
				</tr>
			</tbody></table>
					<table class="EpMenu" style="cursor: pointer;" 
onclick="document.location.href='avoir.html';" width="266">
			<tbody><tr>
				<td style="vertical-align: middle; text-align: center;" width="84"><img
 src="../images/100euro_bills_icon.jpg" alt="Mes avoirs" border="0" 
height="64" width="64"></td>
				<td width="181">
					<div class="EpTitre">MES AVOIRS :</div>
					<div class="EpDesc">Consulter mes avoirs et leurs utilisations.</div>
				</td>
			</tr>
		</tbody></table>
		<table class="EpMenu" style="cursor: pointer;" 
onclick="document.location.href='shopping_liste.php';" width="266">
			<tbody><tr style="background: 
url(../images/EpMenuBg.gif) repeat-x scroll center 
bottom transparent;">
				<td style="vertical-align: middle; text-align: center;" width="84"><img
 src="../images/shoping_list_128x128.png" alt="Mes avoirs" border="0" 
height="74" width="63"></td>
				<td width="181">
					<div class="EpTitre">MA SHOPPING LIST:</div>
					<div class="EpDesc">Mes paniers enregistrés, mes achats à venir, ma
 sélection de cadeaux pour mon anniversaire. </div>
				</td>
			</tr>
		</tbody></table>
		<table class="EpMenu" style="cursor: pointer;" 
onclick="document.location.href='alerte.html';" width="266">
			<tbody><tr>
				<td style="vertical-align: middle; text-align: center;" width="84"><img
 src="EpIcoAlerte.gif" alt="Mes alertes" border="0" 
height="74" width="63"></td>
				<td width="181">
					<div class="EpTitre">MES ALERTES:</div>
					<div class="EpDesc">Consulter mes alertes. </div>
				</td>
			</tr>
		</tbody></table>
	</div>
</div></td>






				<td style="vertical-align: top;" width="100%">
				<div style="border: 1px solid rgb(154, 154, 154); margin-left: 20px; margin-right: 5px; padding: 12px;">
				<table border="0" cellpadding="0" cellspacing="0" width="100%">
				<tbody><tr>
				<td style="text-align: center;" width="13%"><img src="../images/shoping_list_128x128.png" alt="" height="119" 
				width="108" /></td>

				<td style="padding: 12px;" width="87%">
				<div class="EpTitre">MA SHOPPING LIST  :</div>
				<div class="EpDesc">Avec votre Shopping List, gérez vos paniers 
				enregistrés sur notr site. Préparez ainsi vos achats à venir, vos 
				sélections de cadeaux a envoyer à vos amis ou votre famille pour votre 
				prochain anniversaire, etc. </div>					</td>
				</tr>
				</tbody></table>

<?php
		if($flag_shopping_liste == False)				
  		  {				
		    echo "<div style=\"text-align: center;\">Aucun panier enregistré actuellement</div>";	
		  }		
		
		else {		
			
			if(isset($_GET['action']) )
          			  {			 
          	
	      				if($_GET['action'] == "change")
	        			{
     		     			  //echo '<body onLoad="alert(\'On charge le panier selectionné...\')">'; 
	             			  $indice = $_GET['elem'];
	             			  //echo $indice;
		     			$requete = "SELECT * FROM panier WHERE id='$indice' ";
		     			$result = mysql_query($requete);
  	             			$panier_liste=mysql_fetch_array($result);
					$titre = $panier_liste['titre'];
		     			$articles = explode("-" , $panier_liste['panier']);
	  	     			$nb_articles = count($articles)/5; 
  	             
                			}
              
                
              				if($_GET['action'] == "supprime")
	        			{    $indice = $_GET['elem'];
     		     			$requete="DELETE FROM panier WHERE id='$indice' ";
		     			mysql_query($requete) or die(mysql_error());
  	             			header("Location: shopping_liste.php");
                			}  

			         }       
			
			
			echo "			
					<hr style=\"border: 1px dotted rgb(153, 153, 153);\" size=\"1\">
				        <div style=\"margin-top: 20px; color: rgb(0, 102, 204);	text-transform: uppercase;\">Mon Dernier Panier Enregistré :  $titre</div>
				        <hr style=\"border: 1px dotted rgb(153, 153, 153);\" size=\"1\">
				        <div id=\"AlertPanelEmail\" style=\"left: 30%; border: 2px solid rgb(51, 51, 51); background: 
					url(&quot;/images/gui/main/ProdAlerteBg.jpg&quot;) no-repeat scroll 
					center center rgb(255, 255, 255); width: 400px; position: absolute; 
					z-index: 999; display: none;\">
					
					<div style=\"background: url(&quot;/images/gui/main/FooterBarBg.gif&quot;) repeat scroll center 
					center transparent; padding: 1px; 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=\"ProdAlerteClose.gif\" alt=\"Fermer\" style=\"cursor: 
					pointer;\" onclick=\"ShowHideElem('AlertPanelEmail')\" height=\"14\" width=\"13\"></td>
					</tr>
					</tbody></table>
					</div>
							
							
							
					<div style=\"padding: 3px; text-align: left;\">
					<p>Vous pouvez envoyer ce panier par e-mail à adresse de votre choix.	</p>

					<form action=\"panier.php?action=charge&elem=$indice\" method=\"post\" >
					<table class=\"showbox\" cellpadding=\"6\" cellspacing=\"2\">
					<tbody><tr>
					<td valign=\"top\"><label for=\"e-mail\">Adresse e-mail :</label></td>
					<td valign=\"top\">
					<input size=\"40\" id=\"e-mail\" name=\"e-mail\" type=\"text\">
					<div id=\"email-error\" style=\"visibility: hidden;\">adresse e-mail n'est pas valide</div>
					</td>
					</tr>
					<tr>
					<td>
					<input autocomplete=\"off\" id=\"ref\" name=\"ref\" value=\"8767265\" type=\"hidden\">
					<input autocomplete=\"off\" id=\"op\" 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>


					<table class=\"EpBsk BskProdList\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
					<thead>
					<tr>
					<th width=\"64%\">Produits</th>
					<th style=\"text-align: center;\" width=\"12%\">Quantité</th>
					<th style=\"text-align: center;\" width=\"10%\">Prix TTC</th>
					<th style=\"text-align: right;\" width=\"9%\">Dispo</th>
					</tr>
					</thead> ";
?>		


				<tbody>

<?php

	
	$ptr = 0;
	$affiche_prix = 0;
        
        //0 1 2  3 4 5
       
        
        //REF456- washer- lave_linge Brandt REF456- 3- 2397.81
        
        //P221-tablea - lave_linge - 1 -714.2 -VV3474-tttd -lave_linge - 1 - 551.5
        
	for($i=0;$i<$nb_articles;$i++)
	   { $ref = trim($articles[$i+$ptr+0]);
	     $table = trim($articles[$i+$ptr+1]);
	     $produit = trim($articles[$i+$ptr+2]);
	     $qte = trim($articles[$i+$ptr+3]);
	     $prix = trim($articles[$i+$ptr+4]);	
	     
	     $affiche_prix = $affiche_prix + $prix;
	     
	     $affiche_article = $ref ." " .$produit; 
	    
	   //$articles[$ptr]

		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, 'BskLine1');\" onmouseover=\"PlLineSwitch(this, '', true);\"> ";

		         }

		echo "<td class=\"Component\">$affiche_article";
		
		echo " </td>
			<td style=\"text-align: center;\">$qte</td>
			<td style=\"text-align: right;\">
			<span class=\"Price\" style=\"\">$prix &#8364;</span>
			</td>
			<td style=\"text-align: center;\">
			<img src=\"StockVert.gif\" alt=\"En stock\" title=\"En stock\">
			</td>
			</tr> ";
			
			$ptr = $ptr + 4;

	   }	

?>

					</tbody>

					<tfoot>
					<tr class="EpBskEndLine">
					<td colspan="4" style="text-align: right;"><img src="BskMail.gif" alt="Envoyer ce panier par e-mail" 
					style="cursor: pointer; border-right: 1px solid rgb(89, 89, 89);" 
					onclick="ShowHideElem('AlertPanelEmail')" title="Envoyer ce panier par 
					e-mail" border="0" height="28" width="220"></td>
					</tr>
					<tr>
					
					<td colspan="4" height="45">
					<form action="panier02.php?action=charge&table=<?php echo $table; ?>&elem=<?php echo $indice; ?> " method="post">
					<table align="right" border="0" cellpadding="0" cellspacing="0">
					<tbody><tr>
					
					<td class="totbutton1">
					TOTAL TTC			</td>
					<td id="total" class="totbutton2"> <?php echo $affiche_prix; ?> &#8364;
						</td>
					<td>
					<input name="image" src="../images/transfert_panier.gif" type="image">
					<input autocomplete="off" name="op" value="load-basket" type="hidden">
					<input autocomplete="off" name="ref" value="8767265" type="hidden">
					</td>
					</tr>
					</tbody></table>
					</form>
					</td>
					</tr>
					</tfoot>

				    <p>&nbsp;</p>
				    <p>&nbsp;</p>
				    <p>&nbsp;</p>
				    <p>&nbsp;</p>
				</table>
				
				<a name="ListBsk"></a>
				<div style="margin-top: 20px; color: rgb(0, 102, 204); text-transform: uppercase;">tous mes paniers en attente</div>
				<hr style="border: 1px dotted rgb(153, 153, 153);" size="1">
				<table class="EpCmdList" style="margin-top: 10px;" border="0" cellpadding="0" cellspacing="0" width="100%">
				
				<tbody><tr>
				<th width="41%">Nom</th>
				<th width="12%">Date</th>
				<th colspan="2">&nbsp;</th>
				</tr>
				
				<tr class="HLine">
				<td width="41%"></td>
				<td width="12%"></td>
				<td width="45%"></td>
				<td width="2%"></td>
				</tr>
                        
<?php

	

	
	//X28Z-22, table, lave_linge, 1, 721.5, NTH82K, table, lave_linge, 1, 479.5
	for($i=0;$i<sizeof($id_cmd);$i++)
	   {
	   		$nb_articles = 0;
	   		$ptr = 0;
	   	
	   		$requete = "SELECT * FROM panier WHERE id='$id_cmd[$i]' ";
			$result = mysql_query($requete);
	        	$val=mysql_fetch_array($result);
		        $decoupe = explode("-" , $val['panier']);
		        
	  	        $nb_produits = count($decoupe)/5; 
		        
		        for($j=0;$j<$nb_produits;$j++)
		            { $nb_articles = $nb_articles + $decoupe[3+$ptr];
		              $ptr = $ptr + 5;
		           }	
		        
	        
	        if($i%2 ==0)
		       { // echo 'Le nombre entré est pair';
		         echo "<tr class=\"Line1\" style=\"height: 25px;\"> ";
	 	       }
	    
		   else  {
		           // echo 'le nombre entré est impair';
      		       echo " <tr class=\"Line2\" style=\"height: 25px;\"> ";
		         }


			echo " 
			<td class=\"Prod\" height=\"25\">
			
			
			<a href=\"shopping_liste.php?action=change&elem=$val[id]\">$val[titre]</a></td>
			<td style=\"text-align: center;\" height=\"25\">$val[date]</td>

	        <td height=\"25\"><span class=\"EpBskQte\">$nb_articles</span> article pour un montant total de <span class=\"EpBskPrice\">$val[total_ttc] &#8364;</span></td>
			<td height=\"25\">
			<a href=\"shopping_liste.php?action=supprime&elem=$val[id]\">
			
			<img src=\"../images/BskProdRem.gif\" alt=\"Supprimer le panier \" border=\"0\" height=\"13\" width=\"11\"></a></td></tr>

			 ";
			
	   }
	   
	   
	   	echo "				<tr class=\"EpListBLine\">
							<td></td>
							<td colspan=\"3\" style=\"text-align: center;\"></td>
						</tr>
					</tbody></table> ";
					
	}
                        
?>   					
					
					
					
				</div>
				</td>
				</tr>
				</tbody>
				</table>
				</div>
				</div>

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

			<form method="get" action="http://www.materiel.net/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=\"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> ";
						 
					      }
					 
					 
	if($_SESSION['nb_article_panier']!=0)
	  {  	
	     $mess1 = $_SESSION['nb_article_panier'] ." " ."article" ; 
             if($_SESSION['nb_article_panier'] >1)
               { $mess1 = $mess1 ."s";
	       }
            $mess2 = $_SESSION['total_ttc_panier'] ." &euro";		
	  	
	    echo "
	  		<div id=\"basket\" class=\"on\">
      			<ul>
      			<li id=\"BasketProdCount\"><a href=\"../panier/panier.php\">$mess1</a></li>  
      			<li id=\"BasketAmount\">$mess2</li> 
      			</ul>
		        </div>
      			</div>  "; 
	  }						 
	else
	{  echo "
		  <div id=\"basket\" >
		  <ul>
		  <li id=\"BasketProdCount\"><a href=\"../panier/panier.php\">Votre panier est vide</a></li>
		  <li id=\"BasketAmount\"></li>
		  </ul>
		  </div>	
  		  </div> ";
	}						 


?>

			<!-- footer -->
			</div>
			</body>
			</html>