1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
<?php
session_start();
//-------------------------------------------------------------------DEBUT d'init des variables
if (!isset($_SESSION['total'])) $_SESSION['total']=0;
if (!isset($_GET['ajoutPanier'])) $ajoutPanier=""; //init de ajouter si non declaré
else $ajoutPanier=$_GET['ajoutPanier'];
if (!isset($_GET['modifPanier'])) $modifPanier=""; //init de modifier si non declaré
else $modifPanier=$_GET['modifPanier'];
if (!isset($_GET['suppPanier'])) $suppPanier=""; //init de suppPanier si non declaré
else $suppPanier=$_GET['suppPanier'];
if (!isset($_GET['enregistreCommande'])) $enregistreCommande=""; //init de enregistreCommande si non declaré
else $enregistreCommande=$_GET['enregistreCommande'];
if (!isset($_GET['article'])) $article=""; //init de article si non declaré
else $article=$_GET['article'];
if (isset($_SESSION['liste'])) $liste=$_SESSION['liste']; //recup de la liste de la session
//-------------------------------------------------------------------FIN d'init des variables
?>
<?php require_once('Connections/ConexionBoutiqueAua.php'); ?>
<?php
mysql_select_db($database_ConexionBoutiqueAua, $ConexionBoutiqueAua);
//-------------------------------------------------------------------AJOUT PANIER
if ($ajoutPanier=="AJOUTER")
{
$reference=$_GET['reference'];
$nb=$_POST['quantite']; //par defaut la quantité = 1, remplacé par quantite
$prix=$_GET['prix'];
$totalarticle= $prix * $nb;
$liste[]=array($reference,$nb,$prix,$prix,$totalarticle);
$_SESSION['liste']=$liste;
//ajoute un article à la liste
}
//-------------------------------------------------------------------MODIF PANIER
if ($modifPanier=="ACTUALISER")
{
for ($i=0;$i<count($liste);$i++)
{
$nbi='nb'.$i;
$liste[$i][1]=$_GET["$nbi"]; //recup du nbr d'article dans la liste
$liste[$i][4]=$liste[$i][1]*$liste[$i][2]; //prixArticle=nbre*prixUnitaire
}
$_SESSION['liste']=$liste; //maj de la liste
}
//-------------------------------------------------------------------SUPP PANIER
if ($suppPanier=="SUPPRIMER")
{
for ($i=0;$i<count($liste);$i++)
{
if($article==$i)
array_push($liste,$i,1,0);
//suppression de l'article
}
$_SESSION['liste']=$liste;
//maj de la liste
}
//--------------------------------------------------------------------COMMANDER
if ($enregistreCommande=="COMMANDER")
{
if(!isset($_GET['action']))
$_SESSION['action']="ENREGISTRER"; //memorise l'action
header("Location: commande.php");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>panier</title>
</head>
<body>
<table width="617" >
<tr>
<td align="left" >Mon panier</td>
</tr>
<tr>
<td align="center">
<?php if(isset($liste))
{ // affiche le tableau si il y a au moin 1 article ?>
<form id="form2" name="form2" method="get" action="panier.php">
<table width="98%">
<tr>
<td width="113">Références</td>
<td width="190">Désignation</td>
<td width="54">Quantité</td>
<td width="81">Prix unité</td>
<td width="63">Prix total</td>
<td width="68">Supprimer</td>
</tr>
<?php
$total=0.00; //initialisation du total de la commande a 0
for ($i=0;$i<count($liste);$i++)
{ //debut du bloc for
$query_rsPanier="select * from articles where reference = '".$liste[$i][0]."'";
$rsPanier = mysql_query($query_rsPanier, $ConexionBoutiqueAua) or die(mysql_error());
$row_rsPanier = mysql_fetch_assoc($rsPanier); /*definition et execution de la requete sql afin de recuperer les infos de l'article stockees dans la base (titre...)*/
?>
<tr>
<td><?php echo $row_rsPanier['reference'] ?></td>
<td><?php echo $row_rsPanier['designation'] ?></td>
<td>
<input name="nb<?php echo $i ?>" type="text" value="<?php echo $liste[$i][1]; ?> " size="4" /></td>
<td><?php echo $row_rsPanier['prix'] ?></td>
<td ><?php echo $liste[$i][4] ?></td>
<td>
<a href="panier.php?article=<?php echo $row_rsPanier['reference'] ?>&suppPanier=SUPPRIMER" >
<img src="images/picto_supprimer.png" width="20" height="14" border="0" />
</a>
</td>
</tr>
<?php
$total+=$liste[$i][2] * $liste[$i][1];
} //fin du bloc for
$_SESSION['total']=$total; //memorise le total dans la session
?>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td>Total :</td>
<td><?php echo $total; ?> Euros</td>
<td> </td>
</tr>
</table>
<table width="100%">
<tr>
<td>Si vous avez modifiez la quantité, cliquez pour actualiser :</td>
<td><input type="submit" name="modifPanier" value="ACTUALISER" /></td>
</tr>
<tr>
<td>Vous disposez d'un code client ? :</td>
<td width="41%">
<input name="textfield" type="text" size="6" />
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>
<table width="334">
<tr>
<td width="50%">Total HT</td>
<td width="83"> </td>
</tr>
<tr>
<td>Frais de port et emballage (hors france métropolitaine, nous consulter)</td>
<td> </td>
</tr>
<tr>
<td>TVA (19,60%)</td>
<td> </td>
</tr>
<tr>
<td>Total TTC</td>
<td> </td>
</tr>
</table>
</td>
<td>
<label>Indiquez votre pays de livraison<br />
<select name="select">
<option selected="selected">France</option>
<option>Allemagne</option>
</select>
</label>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>
<input type="submit" name="Submit53" value="Continuer mes achats" />
</td>
<td>
<input type="submit" name="enregistreCommande" value="COMMANDER" />
</td>
</tr>
</table>
</form>
<?php } //fin du test isset($liste) ?>
</td>
</tr>
</table>
</body>
</html> |
Partager