par
wwwbillgates » 17 juin 2010, 17:29
salut, pour donner plus d'indice, voici un aperçu de la page qui renvoi les valeur vers le panier :
http://localhost/mabouille/templates/pa ... ategorie=3
lorsque je choisi un support et que je l'ajoute au panier, celui-ci n'ajoute que le nom de l'article puis il est impossible de supprimer ni de changer la quantité de l'article.
Voici le code complet de ma page panier :
Concernant les sessions celles-ci sont bien récupéré et bien affiché en echo sur la page ou se trouve le panier. Le problème vient donc forcément de ce petit bout de code avec les opérateur en ternaire.
<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>₪ Une idée cadeau original pour un anniversaire et des cadeaux Personnalisés de départ à la retraite.</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Idée cadeau original pour homme. La boutique des cadeaux originaux pour femme. Idée cadeaux pour anniversaire, noël, saint valentin, départ en retraite...">
<meta name="keywords" content="anniversaire, aniversaire, aniverssaire, idée cadeau, idée cadeaux, idées cadeaux, idee, idée, idées,idee,cadeau, cadeaux, original, cadeau original, originaux, cadeaux originaux, sympathique, caricature, carricature, caricature, insolites, carte personnalisée, perssonalisee, rigolo, pas cher, fun">
</head>
<body>
<link rel="stylesheet" media="screen" type="text/css" title="CSS" href="../../templates/css/pages.css" />
<link rel="stylesheet" media="screen" type="text/css" title="CSS" href="../../templates/css/etape4.css" />
<!-------------------->
<!---- Menu haut
<!-------------------->
<!--connexion mysql-->
<?php include("../../class/bouilleDB.php"); ?>
<!--fonctions-->
<?php include("../../includes/functions/functions.php"); ?>
<!--menu du haut-->
<?php include("../../templates/pages/menu_haut.php"); ?>
<!--script POPUP-->
<?php include("../../includes/scripts/popup.php"); ?>
<!---- page blanche début ---->
<div id="page_blanche">
<!---- Frise ---->
<p >
<img src="../../interface/frise_1.gif" />
<img src="../../interface/frise_2.gif" />
<img src="../../interface/frise_3.gif" />
<img src="../../interface/frise_4.gif" />
<img src="../../interface/frise_5off.gif" />
<img src="../../interface/frise_6off.gif" />
<img src="../../interface/frise_7off.gif" />
</p>
<br />
<!---- Introduction ---->
<p>
Pour continuer votre commande, nous vous invitons à choisir une catégorie pour ajouter vos supports.
</p>
<!---- Catégorie supports ---->
<div class="categories" >
<p>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=1"><img src="../../interface/categorie_papeterie.jpg" alt="Catégorie papeterie et cadres." /></a>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=1">PAPETERIE, CADRES</a>
</p>
<p>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=2"><img src="../../interface/categorie_deco.jpg" alt="Catégorie pour la maison et la déco." /></a>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=2">MAISON, DECO</a>
</p>
<p>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=3"><img src="../../interface/categorie_cuisine.jpg" alt="Catégorie pour la cuisine, vaisselle..." /></a>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=3">VAISSELLE, CUISINE</a>
</p>
<p>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=4"><img src="../../interface/categorie_vetements.jpg" alt="Catégorie tee-shirts, vêtements..." /></a>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=4">T-SHIRTS, VETEMENTS</a>
</p>
<p>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=5"><img src="../../interface/categorie_jeux.jpg" alt="Catégorie jeux, jouets..." /></a>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=5">JEUX, JOUETS</a>
</p>
<p>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=6"><img src="../../interface/categorie_bureau.jpg" alt="Catégorie bureautique, accessoires, numériques..." /></a>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=6">BUREAU, ACCESSOIRES,<br />NUMERIQUE (GRATUITS)</a>
</p>
</div>
<div id="tableau" >
<?php
/***********************/
/*** Fonctions supports
/***********************/
function creationPanier(){
if (!isset($_SESSION['supports'])){
$_SESSION['supports']=array();
$_SESSION['supports']['libelleProduit'] = array();
$_SESSION['supports']['qteProduit'] = array();
$_SESSION['supports']['prixProduit'] = array();
$_SESSION['supports']['optionProduit'] = array();
$_SESSION['supports']['verrou'] = false;
}
return true;
}
//Ajoute un article dans le panier
function ajouterArticle($libelleProduit,$qteProduit,$prixProduit,$optionProduit){
//Si le panier existe
if (creationPanier() and !isVerrouille())
{
//Si le produit existe déjà on ajoute seulement la quantité
$positionProduit = array_search($libelleProduit, $_SESSION['supports']['libelleProduit']);
if ($positionProduit !== false)
{
$_SESSION['supports']['qteProduit'][$positionProduit] += $qteProduit ;
}
else
{
//Sinon on ajoute le produit
array_push( $_SESSION['supports']['libelleProduit'],$libelleProduit);
array_push( $_SESSION['supports']['qteProduit'],$qteProduit);
array_push( $_SESSION['supports']['prixProduit'],$prixProduit);
array_push( $_SESSION['supports']['optionProduit'],$optionProduit);
}
}
else
echo "Un problème est survenu veuillez nous contacter.";
}
//Modifie la quantité d'un article
function modifierQTeArticle($libelleProduit,$qteProduit)
{
//Si le panier éxiste
if (creationPanier() and !isVerrouille())
{
//Si la quantité est positive on modifie sinon on supprime l'article
if ($qteProduit > 0)
{
//Recherche du produit dans le panier
$positionProduit = array_search($libelleProduit, $_SESSION['supports']['libelleProduit']);
if ($positionProduit !== false)
{
$_SESSION['supports']['qteProduit'][$positionProduit] = $qteProduit ;
}
}
else
supprimerArticle($libelleProduit);
}
else
echo "Un problème est survenu veuillez nous contacter.";
}
//Supprime un article du panier
function supprimerArticle($libelleProduit){
//Si le panier existe
if (creationPanier() and !isVerrouille())
{
//Nous allons passer par un panier temporaire
$tmp=array();
$tmp['libelleProduit'] = array();
$tmp['qteProduit'] = array();
$tmp['prixProduit'] = array();
$tmp['optionProduit'] = array();
$tmp['verrou'] = $_SESSION['supports']['verrou'];
for($i = 0; $i < count($_SESSION['supports']['libelleProduit']); $i++)
{
if ($_SESSION['supports']['libelleProduit'][$i] !== $libelleProduit)
{
array_push( $tmp['libelleProduit'],$_SESSION['supports']['libelleProduit'][$i]);
array_push( $tmp['qteProduit'],$_SESSION['supports']['qteProduit'][$i]);
array_push( $tmp['prixProduit'],$_SESSION['supports']['prixProduit'][$i]);
array_push( $tmp['optionProduit'],$_SESSION['supports']['optionProduit'][$i]);
}
}
//On remplace le panier en session par notre panier temporaire à jour
$_SESSION['supports'] = $tmp;
//On efface notre panier temporaire
unset($tmp);
}
else
echo "Un problème est survenu veuillez nous contacter.";
}
//Montant total du panier
function MontantSupports()
{
$total=0;
for($i = 0; $i < count(@$_SESSION['supports']['libelleProduit']); $i++)
{
$total += $_SESSION['supports']['qteProduit'][$i] * $_SESSION['supports']['prixProduit'][$i];
}
return $total;
}
//Fonction de suppression du panier
function supprimePanier(){
unset($_SESSION['supports']);
}
//Permet de savoir si le panier est verrouillé
function isVerrouille(){
if (isset($_SESSION['supports']) and $_SESSION['supports']['verrou'])
return true;
else
return false;
}
//Compte le nombre d'articles différents dans le panier
function compterArticles()
{
if (isset($_SESSION['supports']))
return count($_SESSION['supports']['libelleProduit']);
else
return 0;
}
/****************************************/
/*** Création de sessions d'un support
/****************************************/
// $erreur = false;
// $action = (isset($_POST['action'])? $_POST['action']: (isset($_GET['action'])? $_GET['action']:null )) ;
// if($action !== null)
// {
// if(!in_array($action,array('ajout', 'suppression', 'refresh')))
// $erreur=true;
// $support_titre = (isset($_POST['support_titre'])? $_POST['support_titre']: (isset($_GET['support_titre'])? $_GET['support_titre']:null )) ;
// $support_prix = (isset($_POST['support_prix'])? $_POST['support_prix']: (isset($_GET['support_prix'])? $_GET['support_prix']:null )) ;
// $support_quantite = (isset($_POST['support_quantite'])? $_POST['support_quantite']: (isset($_GET['support_quantite'])? $_GET['support_quantite']:null )) ;
// $support_option = (isset($_POST['support_option'])? $_POST['support_option']: (isset($_GET['support_option'])? $_GET['support_option']:null )) ;
$erreur = false;
$action = (isset($_SESSION['temp']['action'])? $_SESSION['temp']['action']: (isset($_GET['action'])? $_GET['action']:null )) ;
if($action !== null)
{
if(!in_array($action,array('ajout', 'suppression', 'refresh')))
$erreur=true;
$support_titre = (isset($_SESSION['temp']['libelleProduit'])? $_SESSION['temp']['libelleProduit']: (isset($_GET['libelleProduit'])? $_GET['libelleProduit']:null )) ;
$support_prix = (isset($_SESSION['temp']['support_prix'])? $_SESSION['temp']['support_prix']: (isset($_GET['support_prix'])? $_GET['support_prix']:null )) ;
$support_quantite = (isset($_SESSION['temp']['support_quantite'])? $_SESSION['temp']['support_quantite']: (isset($_GET['support_quantite'])? $_GET['support_quantite']:null )) ;
$support_option = (isset($_SESSION['temp']['support_option'])? $_SESSION['temp']['support_option']: (isset($_GET['support_option'])? $_GET['support_option']:null )) ;
echo $support_titre . '<br />';
echo $support_prix . '<br />';
echo $support_quantite . '<br />';
echo $support_option . '<br />';
//echo $_SESSION['temp']['textarea'] . '<br />';
//On traite $support_quantite qui peut etre un entier simple ou un tableau d'entier
if (is_array($support_quantite))
{
$QteArticle = array();
$i=0;
foreach ($support_quantite as $contenu)
{
$QteArticle[$i++] = intval($contenu);
}
}
else
$support_quantite = intval($support_quantite);
}
if (!$erreur)
{
switch($action)
{
Case "ajout":
ajouterArticle($support_titre,$support_quantite,$support_prix,$support_option);
break;
Case "suppression":
supprimerArticle($support_titre);
break;
Case "refresh" :
for ($i = 0 ; $i < count($QteArticle) ; $i++)
{
modifierQTeArticle($_SESSION['supports']['libelleProduit'][$i],round($QteArticle[$i]));
}
break;
Default:
break;
}
}
/**********************************/
/*** Calcules des frais de port
/**********************************/
$pays = 'France';
$reponse = $bdd->prepare("
SELECT *
FROM bouille_fraisdeport
WHERE pays = :pays
");
$reponse->execute(array(
'pays' => $pays
));
$fraisdeport = $reponse->fetch(PDO::FETCH_ASSOC);
If (isset($fraisdeport['prix_mini_1']))
{
$frais_livraison = 0;
if (MontantSupports() > $fraisdeport['prix_mini_1'] and MontantSupports() <= $fraisdeport['prix_mini_2'])
{
$frais_livraison = $fraisdeport['tarif_net_1'];
}
elseif (MontantSupports() > $fraisdeport['prix_mini_2'] and MontantSupports() <= $fraisdeport['prix_mini_3'])
{
$frais_livraison = $fraisdeport['tarif_net_2'];
}
elseif (MontantSupports() > $fraisdeport['prix_mini_3'] and MontantSupports() <= $fraisdeport['prix_mini_4'])
{
$frais_livraison = $fraisdeport['tarif_net_3'];
}
elseif (MontantSupports() > $fraisdeport['prix_mini_4'] and MontantSupports() <= $fraisdeport['prix_mini_5'])
{
$frais_livraison = $fraisdeport['tarif_net_4'];
}
elseif (MontantSupports() > $fraisdeport['prix_mini_5'])
{
$frais_livraison = $fraisdeport['tarif_net_5'];
}
}
/**************/
/*** Panier
/**************/
?>
<form method="post" action="#">
<table>
<tr>
<th class="titre" width="50px" >supp.</th>
<th class="titre" width="400px" >Articles</th>
<th class="titre" width="135px" >Prix unitaire</th>
<th class="titre" width="135px" >Quantité</th>
<th class="titre" width="135px" >Montant TTC</th>
<tr>
</tr>
<td><a href="http://www.mabouille.com/" onmouseover="supp_miseensituation.src = '../../interface/bt_supprimer_push.gif';" onmouseout="supp_miseensituation.src = '../../interface/bt_supprimer.gif';"><img src="../../interface/bt_supprimer.gif" name="supp_miseensituation" ></a></td>
<td class="article" ><?php echo 'Mise en situation : '. $_SESSION['nom_de_la_mise_en_situation'] . ' pour ' . $_SESSION['quantite_de_bouilles'] . ' bouille' . pluriel($_SESSION['quantite_de_bouilles']) . '.'; ?></td>
<td class="article" ><?php echo $_SESSION['prix_de_la_mise_en_situation'] . ' €' ?></td>
<td class="article" >1</td>
<td class="article" ><?php echo $_SESSION['prix_de_la_mise_en_situation'] . ' €' ?></td>
</tr>
<?php
/***************************************************************************/
/*** Suppression de la session magazine lorsque l'on clic sur le bouton X
/***************************************************************************/
if (isset($_POST['supp_magazine']))
{
unset($_SESSION['magazine']['oui_non']);
}
/****************************************/
/*** Afficher la description magazine
/****************************************/
if (@$_SESSION['magazine']['oui_non'] == 1)
{
?>
</tr>
<td><input type="image" value="supp_magazine" name="supp_magazine" src="../../interface/bt_supprimer.gif" onmouseover="this.src='../../interface/bt_supprimer_push.gif'" onmouseout="this.src='../../interface/bt_supprimer.gif'" /></td>
<td class="article" ><?php echo 'Présentation comme une 1ère de couv\' :<br /> <span class="presentation_mag" ><strong>date :</strong> ' . $_SESSION['magazine']['date'] . '<br /> <strong>titre :</strong> ' . $_SESSION['magazine']['titre'] . '<br /> <strong>texte1 :</strong> ' . $_SESSION['magazine']['texte1'] . '<br /> <strong>texte2 :</strong> ' . $_SESSION['magazine']['texte2'] . '</span>'; ?></td>
<td class="article" ><?php echo $_SESSION['magazine']['prix'] . ' €' ?></td>
<td class="article" >1</td>
<td class="article" ><?php echo $_SESSION['magazine']['prix'] . ' €' ?></td>
</tr>
<?php
}
?>
<?php
if (creationPanier())
{
$nbArticles=count($_SESSION['supports']['libelleProduit']);
if ($nbArticles <= 0)
{
?>
</tr>
<td></td>
<td>Vous devez ajouter au moins 1 support dans votre panier.</td>
<td></td>
<td></td>
<td></td>
</tr>
<?php
}
else
{
for ($i=0 ;$i < $nbArticles ; $i++)
{
?>
</tr>
<td><a href="<?php echo htmlspecialchars("../../templates/pages/etape4_supports.php?action=suppression&support_titre=".rawurlencode($_SESSION['supports']['libelleProduit'][$i])); ?>" onmouseover="choisirfond.src = '../../interface/bt_supprimer_push.gif';" onmouseout="choisirfond.src = '../../interface/bt_supprimer.gif';"><img src="../../interface/bt_supprimer.gif" name="choisirfond" ></a></td>
<td class="article" ><?php echo htmlspecialchars($_SESSION['supports']['libelleProduit'][$i]) . ' ' . htmlspecialchars($_SESSION['supports']['optionProduit'][$i]); ?></td>
<td class="article" ><?php echo htmlspecialchars($_SESSION['supports']['prixProduit'][$i]) . ' €' ?></td>
<td class="article" ><?php echo "<input type=\"text\" size=\"4\" name=\"support_quantite[]\" value=\"".htmlspecialchars($_SESSION['supports']['qteProduit'][$i])."\"/>"; ?></td>
<td class="article" ><?php echo htmlspecialchars($_SESSION['supports']['prixProduit'][$i]) * htmlspecialchars($_SESSION['supports']['qteProduit'][$i]) . ' €' ?></td>
</tr>
<?php
}
?>
</tr>
<th></th>
<th></th>
<th></th>
<th class="titre" >Montant TTC</th>
<th class="titre" ><?php echo MontantSupports() + $_SESSION['prix_de_la_mise_en_situation'] + $_SESSION['magazine']['prix'] . ' €'; ?></th>
</tr>
</tr>
<td></td>
<td class="minitexte_panier" >*Frais de livraison offert à partir de 100€ du total en supports</td>
<th></th>
<th class="titre" >Frais de livraison*</th>
<th class="titre" ><?php echo $frais_livraison . ' €' ?></th>
</tr>
</tr>
<th></th>
<th></th>
<th></th>
<th class="titre" >TOTAL TTC</th>
<th class="titre" ><?php echo MontantSupports() + $_SESSION['prix_de_la_mise_en_situation'] + $_SESSION['magazine']['prix'] + $frais_livraison . ' €'; ?></th>
</tr>
</table>
<input class="recalculer" type="image" value="refresh" src="../../interface/bt_recalculer.gif" onmouseover="this.src='../../interface/bt_recalculer_push.gif'" onmouseout="this.src='../../interface/bt_recalculer.gif'">
<input type="hidden" name="action" value="refresh"/>
<?php
}
}
?>
<br />
<form method="post" action="traitement.php">
<label for="cheque">Si vous disposez d'un chèque cadeau saisissez le code ici :</label> <input type="text" name="cheque" id="cheque" />
</form>
<p class="minitexte_panier" >
Dans le cas ou le montant de la commande serait inférieur à la valeur du bon cadeau,<br />
aucun remboursement ne pourra être effectué. Les bons cadeaux sont non cumulables.
</p>
<form action="../../templates/pages/etape5_identification.php" method="post" id="to_etape5">
<p class="boutons_valider" >
<!--- <a href="../../index.php" onmouseover="continuer.src = '../../interface/bt_continuachat_push.gif';" onmouseout="continuer.src = '../../interface/bt_continuachat.gif';"><img src="../../interface/bt_continuachat.gif" name="continuer" ></a> --->
<a href="../../templates/pages/etape5_identification.php" onmouseover="valider.src = '../../interface/bt_validerpanier_push.gif';" onmouseout="valider.src = '../../interface/bt_validerpanier.gif';" onclick="valider_etape4(document.getElementById('to_etape5'));"><img src="../../interface/bt_validerpanier.gif" name="valider" ></a>
</p>
</form>
</div>
</div>
<!---- page blanche fin ---->
<!---- copyright ---->
<br />
<?php include("copyright.php"); ?>
</body>
</html>
salut, pour donner plus d'indice, voici un aperçu de la page qui renvoi les valeur vers le panier :
[url]http://localhost/mabouille/templates/pages/etape4_supports_categorie.php?categorie=3[/url]
lorsque je choisi un support et que je l'ajoute au panier, celui-ci n'ajoute que le nom de l'article puis il est impossible de supprimer ni de changer la quantité de l'article.
Voici le code complet de ma page panier :
Concernant les sessions celles-ci sont bien récupéré et bien affiché en echo sur la page ou se trouve le panier. Le problème vient donc forcément de ce petit bout de code avec les opérateur en ternaire.
[php]
<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>₪ Une idée cadeau original pour un anniversaire et des cadeaux Personnalisés de départ à la retraite.</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Idée cadeau original pour homme. La boutique des cadeaux originaux pour femme. Idée cadeaux pour anniversaire, noël, saint valentin, départ en retraite...">
<meta name="keywords" content="anniversaire, aniversaire, aniverssaire, idée cadeau, idée cadeaux, idées cadeaux, idee, idée, idées,idee,cadeau, cadeaux, original, cadeau original, originaux, cadeaux originaux, sympathique, caricature, carricature, caricature, insolites, carte personnalisée, perssonalisee, rigolo, pas cher, fun">
</head>
<body>
<link rel="stylesheet" media="screen" type="text/css" title="CSS" href="../../templates/css/pages.css" />
<link rel="stylesheet" media="screen" type="text/css" title="CSS" href="../../templates/css/etape4.css" />
<!-------------------->
<!---- Menu haut
<!-------------------->
<!--connexion mysql-->
<?php include("../../class/bouilleDB.php"); ?>
<!--fonctions-->
<?php include("../../includes/functions/functions.php"); ?>
<!--menu du haut-->
<?php include("../../templates/pages/menu_haut.php"); ?>
<!--script POPUP-->
<?php include("../../includes/scripts/popup.php"); ?>
<!---- page blanche début ---->
<div id="page_blanche">
<!---- Frise ---->
<p >
<img src="../../interface/frise_1.gif" />
<img src="../../interface/frise_2.gif" />
<img src="../../interface/frise_3.gif" />
<img src="../../interface/frise_4.gif" />
<img src="../../interface/frise_5off.gif" />
<img src="../../interface/frise_6off.gif" />
<img src="../../interface/frise_7off.gif" />
</p>
<br />
<!---- Introduction ---->
<p>
Pour continuer votre commande, nous vous invitons à choisir une catégorie pour ajouter vos supports.
</p>
<!---- Catégorie supports ---->
<div class="categories" >
<p>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=1"><img src="../../interface/categorie_papeterie.jpg" alt="Catégorie papeterie et cadres." /></a>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=1">PAPETERIE, CADRES</a>
</p>
<p>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=2"><img src="../../interface/categorie_deco.jpg" alt="Catégorie pour la maison et la déco." /></a>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=2">MAISON, DECO</a>
</p>
<p>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=3"><img src="../../interface/categorie_cuisine.jpg" alt="Catégorie pour la cuisine, vaisselle..." /></a>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=3">VAISSELLE, CUISINE</a>
</p>
<p>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=4"><img src="../../interface/categorie_vetements.jpg" alt="Catégorie tee-shirts, vêtements..." /></a>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=4">T-SHIRTS, VETEMENTS</a>
</p>
<p>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=5"><img src="../../interface/categorie_jeux.jpg" alt="Catégorie jeux, jouets..." /></a>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=5">JEUX, JOUETS</a>
</p>
<p>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=6"><img src="../../interface/categorie_bureau.jpg" alt="Catégorie bureautique, accessoires, numériques..." /></a>
<a href="../../templates/pages/etape4_supports_categorie.php?categorie=6">BUREAU, ACCESSOIRES,<br />NUMERIQUE (GRATUITS)</a>
</p>
</div>
<div id="tableau" >
<?php
/***********************/
/*** Fonctions supports
/***********************/
function creationPanier(){
if (!isset($_SESSION['supports'])){
$_SESSION['supports']=array();
$_SESSION['supports']['libelleProduit'] = array();
$_SESSION['supports']['qteProduit'] = array();
$_SESSION['supports']['prixProduit'] = array();
$_SESSION['supports']['optionProduit'] = array();
$_SESSION['supports']['verrou'] = false;
}
return true;
}
//Ajoute un article dans le panier
function ajouterArticle($libelleProduit,$qteProduit,$prixProduit,$optionProduit){
//Si le panier existe
if (creationPanier() and !isVerrouille())
{
//Si le produit existe déjà on ajoute seulement la quantité
$positionProduit = array_search($libelleProduit, $_SESSION['supports']['libelleProduit']);
if ($positionProduit !== false)
{
$_SESSION['supports']['qteProduit'][$positionProduit] += $qteProduit ;
}
else
{
//Sinon on ajoute le produit
array_push( $_SESSION['supports']['libelleProduit'],$libelleProduit);
array_push( $_SESSION['supports']['qteProduit'],$qteProduit);
array_push( $_SESSION['supports']['prixProduit'],$prixProduit);
array_push( $_SESSION['supports']['optionProduit'],$optionProduit);
}
}
else
echo "Un problème est survenu veuillez nous contacter.";
}
//Modifie la quantité d'un article
function modifierQTeArticle($libelleProduit,$qteProduit)
{
//Si le panier éxiste
if (creationPanier() and !isVerrouille())
{
//Si la quantité est positive on modifie sinon on supprime l'article
if ($qteProduit > 0)
{
//Recherche du produit dans le panier
$positionProduit = array_search($libelleProduit, $_SESSION['supports']['libelleProduit']);
if ($positionProduit !== false)
{
$_SESSION['supports']['qteProduit'][$positionProduit] = $qteProduit ;
}
}
else
supprimerArticle($libelleProduit);
}
else
echo "Un problème est survenu veuillez nous contacter.";
}
//Supprime un article du panier
function supprimerArticle($libelleProduit){
//Si le panier existe
if (creationPanier() and !isVerrouille())
{
//Nous allons passer par un panier temporaire
$tmp=array();
$tmp['libelleProduit'] = array();
$tmp['qteProduit'] = array();
$tmp['prixProduit'] = array();
$tmp['optionProduit'] = array();
$tmp['verrou'] = $_SESSION['supports']['verrou'];
for($i = 0; $i < count($_SESSION['supports']['libelleProduit']); $i++)
{
if ($_SESSION['supports']['libelleProduit'][$i] !== $libelleProduit)
{
array_push( $tmp['libelleProduit'],$_SESSION['supports']['libelleProduit'][$i]);
array_push( $tmp['qteProduit'],$_SESSION['supports']['qteProduit'][$i]);
array_push( $tmp['prixProduit'],$_SESSION['supports']['prixProduit'][$i]);
array_push( $tmp['optionProduit'],$_SESSION['supports']['optionProduit'][$i]);
}
}
//On remplace le panier en session par notre panier temporaire à jour
$_SESSION['supports'] = $tmp;
//On efface notre panier temporaire
unset($tmp);
}
else
echo "Un problème est survenu veuillez nous contacter.";
}
//Montant total du panier
function MontantSupports()
{
$total=0;
for($i = 0; $i < count(@$_SESSION['supports']['libelleProduit']); $i++)
{
$total += $_SESSION['supports']['qteProduit'][$i] * $_SESSION['supports']['prixProduit'][$i];
}
return $total;
}
//Fonction de suppression du panier
function supprimePanier(){
unset($_SESSION['supports']);
}
//Permet de savoir si le panier est verrouillé
function isVerrouille(){
if (isset($_SESSION['supports']) and $_SESSION['supports']['verrou'])
return true;
else
return false;
}
//Compte le nombre d'articles différents dans le panier
function compterArticles()
{
if (isset($_SESSION['supports']))
return count($_SESSION['supports']['libelleProduit']);
else
return 0;
}
/****************************************/
/*** Création de sessions d'un support
/****************************************/
// $erreur = false;
// $action = (isset($_POST['action'])? $_POST['action']: (isset($_GET['action'])? $_GET['action']:null )) ;
// if($action !== null)
// {
// if(!in_array($action,array('ajout', 'suppression', 'refresh')))
// $erreur=true;
// $support_titre = (isset($_POST['support_titre'])? $_POST['support_titre']: (isset($_GET['support_titre'])? $_GET['support_titre']:null )) ;
// $support_prix = (isset($_POST['support_prix'])? $_POST['support_prix']: (isset($_GET['support_prix'])? $_GET['support_prix']:null )) ;
// $support_quantite = (isset($_POST['support_quantite'])? $_POST['support_quantite']: (isset($_GET['support_quantite'])? $_GET['support_quantite']:null )) ;
// $support_option = (isset($_POST['support_option'])? $_POST['support_option']: (isset($_GET['support_option'])? $_GET['support_option']:null )) ;
$erreur = false;
$action = (isset($_SESSION['temp']['action'])? $_SESSION['temp']['action']: (isset($_GET['action'])? $_GET['action']:null )) ;
if($action !== null)
{
if(!in_array($action,array('ajout', 'suppression', 'refresh')))
$erreur=true;
$support_titre = (isset($_SESSION['temp']['libelleProduit'])? $_SESSION['temp']['libelleProduit']: (isset($_GET['libelleProduit'])? $_GET['libelleProduit']:null )) ;
$support_prix = (isset($_SESSION['temp']['support_prix'])? $_SESSION['temp']['support_prix']: (isset($_GET['support_prix'])? $_GET['support_prix']:null )) ;
$support_quantite = (isset($_SESSION['temp']['support_quantite'])? $_SESSION['temp']['support_quantite']: (isset($_GET['support_quantite'])? $_GET['support_quantite']:null )) ;
$support_option = (isset($_SESSION['temp']['support_option'])? $_SESSION['temp']['support_option']: (isset($_GET['support_option'])? $_GET['support_option']:null )) ;
echo $support_titre . '<br />';
echo $support_prix . '<br />';
echo $support_quantite . '<br />';
echo $support_option . '<br />';
//echo $_SESSION['temp']['textarea'] . '<br />';
//On traite $support_quantite qui peut etre un entier simple ou un tableau d'entier
if (is_array($support_quantite))
{
$QteArticle = array();
$i=0;
foreach ($support_quantite as $contenu)
{
$QteArticle[$i++] = intval($contenu);
}
}
else
$support_quantite = intval($support_quantite);
}
if (!$erreur)
{
switch($action)
{
Case "ajout":
ajouterArticle($support_titre,$support_quantite,$support_prix,$support_option);
break;
Case "suppression":
supprimerArticle($support_titre);
break;
Case "refresh" :
for ($i = 0 ; $i < count($QteArticle) ; $i++)
{
modifierQTeArticle($_SESSION['supports']['libelleProduit'][$i],round($QteArticle[$i]));
}
break;
Default:
break;
}
}
/**********************************/
/*** Calcules des frais de port
/**********************************/
$pays = 'France';
$reponse = $bdd->prepare("
SELECT *
FROM bouille_fraisdeport
WHERE pays = :pays
");
$reponse->execute(array(
'pays' => $pays
));
$fraisdeport = $reponse->fetch(PDO::FETCH_ASSOC);
If (isset($fraisdeport['prix_mini_1']))
{
$frais_livraison = 0;
if (MontantSupports() > $fraisdeport['prix_mini_1'] and MontantSupports() <= $fraisdeport['prix_mini_2'])
{
$frais_livraison = $fraisdeport['tarif_net_1'];
}
elseif (MontantSupports() > $fraisdeport['prix_mini_2'] and MontantSupports() <= $fraisdeport['prix_mini_3'])
{
$frais_livraison = $fraisdeport['tarif_net_2'];
}
elseif (MontantSupports() > $fraisdeport['prix_mini_3'] and MontantSupports() <= $fraisdeport['prix_mini_4'])
{
$frais_livraison = $fraisdeport['tarif_net_3'];
}
elseif (MontantSupports() > $fraisdeport['prix_mini_4'] and MontantSupports() <= $fraisdeport['prix_mini_5'])
{
$frais_livraison = $fraisdeport['tarif_net_4'];
}
elseif (MontantSupports() > $fraisdeport['prix_mini_5'])
{
$frais_livraison = $fraisdeport['tarif_net_5'];
}
}
/**************/
/*** Panier
/**************/
?>
<form method="post" action="#">
<table>
<tr>
<th class="titre" width="50px" >supp.</th>
<th class="titre" width="400px" >Articles</th>
<th class="titre" width="135px" >Prix unitaire</th>
<th class="titre" width="135px" >Quantité</th>
<th class="titre" width="135px" >Montant TTC</th>
<tr>
</tr>
<td><a href="http://www.mabouille.com/" onmouseover="supp_miseensituation.src = '../../interface/bt_supprimer_push.gif';" onmouseout="supp_miseensituation.src = '../../interface/bt_supprimer.gif';"><img src="../../interface/bt_supprimer.gif" name="supp_miseensituation" ></a></td>
<td class="article" ><?php echo 'Mise en situation : '. $_SESSION['nom_de_la_mise_en_situation'] . ' pour ' . $_SESSION['quantite_de_bouilles'] . ' bouille' . pluriel($_SESSION['quantite_de_bouilles']) . '.'; ?></td>
<td class="article" ><?php echo $_SESSION['prix_de_la_mise_en_situation'] . ' €' ?></td>
<td class="article" >1</td>
<td class="article" ><?php echo $_SESSION['prix_de_la_mise_en_situation'] . ' €' ?></td>
</tr>
<?php
/***************************************************************************/
/*** Suppression de la session magazine lorsque l'on clic sur le bouton X
/***************************************************************************/
if (isset($_POST['supp_magazine']))
{
unset($_SESSION['magazine']['oui_non']);
}
/****************************************/
/*** Afficher la description magazine
/****************************************/
if (@$_SESSION['magazine']['oui_non'] == 1)
{
?>
</tr>
<td><input type="image" value="supp_magazine" name="supp_magazine" src="../../interface/bt_supprimer.gif" onmouseover="this.src='../../interface/bt_supprimer_push.gif'" onmouseout="this.src='../../interface/bt_supprimer.gif'" /></td>
<td class="article" ><?php echo 'Présentation comme une 1ère de couv\' :<br /> <span class="presentation_mag" ><strong>date :</strong> ' . $_SESSION['magazine']['date'] . '<br /> <strong>titre :</strong> ' . $_SESSION['magazine']['titre'] . '<br /> <strong>texte1 :</strong> ' . $_SESSION['magazine']['texte1'] . '<br /> <strong>texte2 :</strong> ' . $_SESSION['magazine']['texte2'] . '</span>'; ?></td>
<td class="article" ><?php echo $_SESSION['magazine']['prix'] . ' €' ?></td>
<td class="article" >1</td>
<td class="article" ><?php echo $_SESSION['magazine']['prix'] . ' €' ?></td>
</tr>
<?php
}
?>
<?php
if (creationPanier())
{
$nbArticles=count($_SESSION['supports']['libelleProduit']);
if ($nbArticles <= 0)
{
?>
</tr>
<td></td>
<td>Vous devez ajouter au moins 1 support dans votre panier.</td>
<td></td>
<td></td>
<td></td>
</tr>
<?php
}
else
{
for ($i=0 ;$i < $nbArticles ; $i++)
{
?>
</tr>
<td><a href="<?php echo htmlspecialchars("../../templates/pages/etape4_supports.php?action=suppression&support_titre=".rawurlencode($_SESSION['supports']['libelleProduit'][$i])); ?>" onmouseover="choisirfond.src = '../../interface/bt_supprimer_push.gif';" onmouseout="choisirfond.src = '../../interface/bt_supprimer.gif';"><img src="../../interface/bt_supprimer.gif" name="choisirfond" ></a></td>
<td class="article" ><?php echo htmlspecialchars($_SESSION['supports']['libelleProduit'][$i]) . ' ' . htmlspecialchars($_SESSION['supports']['optionProduit'][$i]); ?></td>
<td class="article" ><?php echo htmlspecialchars($_SESSION['supports']['prixProduit'][$i]) . ' €' ?></td>
<td class="article" ><?php echo "<input type=\"text\" size=\"4\" name=\"support_quantite[]\" value=\"".htmlspecialchars($_SESSION['supports']['qteProduit'][$i])."\"/>"; ?></td>
<td class="article" ><?php echo htmlspecialchars($_SESSION['supports']['prixProduit'][$i]) * htmlspecialchars($_SESSION['supports']['qteProduit'][$i]) . ' €' ?></td>
</tr>
<?php
}
?>
</tr>
<th></th>
<th></th>
<th></th>
<th class="titre" >Montant TTC</th>
<th class="titre" ><?php echo MontantSupports() + $_SESSION['prix_de_la_mise_en_situation'] + $_SESSION['magazine']['prix'] . ' €'; ?></th>
</tr>
</tr>
<td></td>
<td class="minitexte_panier" >*Frais de livraison offert à partir de 100€ du total en supports</td>
<th></th>
<th class="titre" >Frais de livraison*</th>
<th class="titre" ><?php echo $frais_livraison . ' €' ?></th>
</tr>
</tr>
<th></th>
<th></th>
<th></th>
<th class="titre" >TOTAL TTC</th>
<th class="titre" ><?php echo MontantSupports() + $_SESSION['prix_de_la_mise_en_situation'] + $_SESSION['magazine']['prix'] + $frais_livraison . ' €'; ?></th>
</tr>
</table>
<input class="recalculer" type="image" value="refresh" src="../../interface/bt_recalculer.gif" onmouseover="this.src='../../interface/bt_recalculer_push.gif'" onmouseout="this.src='../../interface/bt_recalculer.gif'">
<input type="hidden" name="action" value="refresh"/>
<?php
}
}
?>
<br />
<form method="post" action="traitement.php">
<label for="cheque">Si vous disposez d'un chèque cadeau saisissez le code ici :</label> <input type="text" name="cheque" id="cheque" />
</form>
<p class="minitexte_panier" >
Dans le cas ou le montant de la commande serait inférieur à la valeur du bon cadeau,<br />
aucun remboursement ne pourra être effectué. Les bons cadeaux sont non cumulables.
</p>
<form action="../../templates/pages/etape5_identification.php" method="post" id="to_etape5">
<p class="boutons_valider" >
<!--- <a href="../../index.php" onmouseover="continuer.src = '../../interface/bt_continuachat_push.gif';" onmouseout="continuer.src = '../../interface/bt_continuachat.gif';"><img src="../../interface/bt_continuachat.gif" name="continuer" ></a> --->
<a href="../../templates/pages/etape5_identification.php" onmouseover="valider.src = '../../interface/bt_validerpanier_push.gif';" onmouseout="valider.src = '../../interface/bt_validerpanier.gif';" onclick="valider_etape4(document.getElementById('to_etape5'));"><img src="../../interface/bt_validerpanier.gif" name="valider" ></a>
</p>
</form>
</div>
</div>
<!---- page blanche fin ---->
<!---- copyright ---->
<br />
<?php include("copyright.php"); ?>
</body>
</html>
[/php]