Skip to content

Commit

Permalink
Ajout du panier dans la boutique
Browse files Browse the repository at this point in the history
  • Loading branch information
AngryKiller committed Jul 2, 2018
1 parent 680740b commit ebf5432
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 10 deletions.
25 changes: 15 additions & 10 deletions pages/boutique.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
<hr>
<h3 class="text-center" style="color: white;">Bonjour <?php echo $_Joueur_['pseudo']; ?></h3>
<h4 class="text-center" style="color: white;">Vous avez <strong><?php if(isset($_Joueur_['tokens'])) echo $_Joueur_['tokens'] . ' <img style="width: 25px;" src="./theme/default/img/jeton.png" />'; ?></h4></strong>
<center><a href="?&page=token" class="btn btn-success btn-lg">Acheter des <?php echo $monnaie ?>s</a></center>
<center><a href="?&page=token" class="btn btn-success btn-lg">Acheter des <?php echo $monnaie ?>s</a>
<a href="?&page=panier" class="btn btn-warning btn-lg"><i class="fa fa-shopping-cart" aria-hidden="true"></i> Panier ( <?php echo $_Panier_->compterArticle().($_Panier_->compterArticle()>1 ? ' articles' : ' article') ?>)</a>
</center>
<?php } else { ?>
<hr>
<center>
Expand Down Expand Up @@ -142,15 +144,18 @@
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Annuler</button>
<?php if($_Joueur_['tokens'] >= $infosOffre['offre']['prix'])
if(($enLigne AND $infosCategories['connection']) OR !$infosCategories['connection']) { ?> <a href="?&action=achat&offre=<?php echo $_GET['offre']; ?>" class="btn btn-success">Acheter</a>
<?php } else{ ?> Connectez vous sur le serveur voulu...
<?php }
else
echo '<button class="btn btn-primary">Il vous manque '. ($infosOffre['offre']['prix'] - $_Joueur_['tokens']) .' jetons...</button>';
?>
</div>
<?php if(($enLigne AND $infosCategories['connection']) OR !$infosCategories['connection']) { ?>
<form action="index.php" method="GET" class="form-inline">
<input type="hidden" name="action" value="addOffrePanier"/>
<input type="hidden" name="offre" value="<?php echo $_GET['offre']; ?>"/>
<label for="quantite" class="form-control mb-1 mr-sm-1">Quantité: </label>
<input type="number" class="form-control mb-1 mr-sm-1" id="quantite" min="0" name="quantite" value="1" />
<button type="submit" class="btn btn-success mb-2">Ajouter au panier</button>
</form><?php } else{ ?>
Connectez vous sur le serveur voulu... <?php }
?>
</div><button type="button" class="btn btn-danger" data-dismiss="modal" style="width: 100%;
border-radius: 0px;">Annuler</button>
</div>
</div>
</div>
Expand Down
71 changes: 71 additions & 0 deletions pages/panier.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<div class="jumbotron parallax" data-parallax="scroll" data-image-src="theme/<?php echo $_Serveur_['General']['theme'];?>/img/jumbotron.png">
<div class="container">
<h1> Boutique - Panier </h1>
<br/>
<p> Achetez plusieurs items en déboursant une seule fois </p>
</div>
</div>
<div class="container">

<?php
if(isset($_GET['success']) && $_GET['success'] == 'true')
{
echo '<div class="alert alert-success"><center><strong>Votre achat a été effectué !</strong></center></div>';
}
?>
<table class="table table-striped table-bordered">
<thead class="thead-inverse">
<tr>
<th>Item/Grade</th>
<th>Description</th>
<th>Quantite</th>
<th>Prix Unitaire</th>
<th>Sous-Total</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php $nbArticles = $_Panier_->compterArticle();
$precedent = 0;
if($nbArticles == 0 )
echo '<tr><td colspan="6"><center>Votre panier est vide </center></td></tr>';
else
{
for($i = 0; $i < $nbArticles; $i++)
{
?>
<tr>
<td><?php $_Panier_->infosArticle(htmlspecialchars($_SESSION['panier']['id'][$i]), $nom, $infos); echo $nom; ?></td>
<td><?php echo $infos; ?></td>
<td><?php echo htmlspecialchars($_SESSION['panier']['quantite'][$i]); ?></td>
<td class="w-25 text-center"><?php echo htmlspecialchars($_SESSION['panier']['prix'][$i]); ?> <i class="fas fa-gem"></i></td>
<td class="w-25 text-center"><?php $precedent += htmlspecialchars($_SESSION['panier']['prix'][$i])*htmlspecialchars($_SESSION['panier']['quantite'][$i]);
echo $precedent; ?> <i class="fas fa-gem"></i></td>
<td><a href="?action=supprItemPanier&id=<?php echo htmlspecialchars($_SESSION['panier']['id'][$i]); ?>" class="btn btn-danger link" title="supprimer l'item du panier"><i class="fa fa-trash"></i></a></td>
</tr>
<?php
}
if(!empty($_SESSION['panier']['reduction']))
{
echo '<tr><td>'.htmlspecialchars($_SESSION['panier']['code']).'</td><td>'.htmlspecialchars($_SESSION['panier']['reduction_titre']).'</td><td>1</td><td class="w-25 text-center">-'. $_SESSION['panier']['reduction']*100 .'%</td><td></td><td><a href="?action=retirerReduction" class="btn btn-danger link" title="supprimer la réduction"><i class="fa fa-trash"></i></a></td></tr>';
}
}
?>
<tr>
<td>Total:</td>
<td class="w-25 text-center" colspan="5"><?php echo number_format($_Panier_->montantGlobal(), 0, ',', ' '); ?> <i class="fas fa-gem"></i></td>
</tr>
</tbody>
</table>
<form class="form-inline" action="?action=ajouterCode" method="POST">
<div class="form-group">
<input type="text" class="form-control" required id="codepromo" name="codepromo" placeholder="Code promo" style="border:0px;">
</div>
<button type="submit" class="btn btn-primary link" style="border:0px;">Envoyer</button>
</form>
<div class="text-right">
<a href="?action=viderPanier"><button class="btn btn-lg btn-danger hvr-float-shadow">Vider le panier !</button></a>
<a href="?action=achat"><button class="btn btn-lg btn-primary hvr-float-shadow">Acheter !</button></a>
</div>
</div>
</div>

0 comments on commit ebf5432

Please sign in to comment.