{% extends 'base.html.twig' %}
{% block title %}Mon panier - La Boutique Belge{% endblock %}
{% block content %}
<h1>Mon panier</h1>
<p class="mt-3 mb-5">Retrouvez l'ensemble des produits que vous avez ajoutés à votre panier.</p>
{% if cart|length > 0 %}
<table class="table mt-3">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">Produit</th>
<th scope="col">Quantité</th>
<th scope="col">Prix</th>
<th scope="col">Total</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
{% set total = 0 %}
{% for product in cart %}
<tr>
<td>
<img src="/uploads/{{ product.product.illustration }}" height="75" alt="{{ product.product.name }}">
</td>
<td>{{ product.product.name }}</td>
<td>
{% if app.user and product.product.productId is not empty %}
<a href="{{ path('decrease_to_cart', { 'id': product.product.productId }) }}">
<img src="{{ asset('assets/img/minus.png') }}" height="12" alt="Ajouter un produit">
</a>
{% elseif not app.user %}
<a href="{{ path('decrease_to_cart', { 'id': product.product.id }) }}">
<img src="{{ asset('assets/img/minus.png') }}" height="12" alt="Ajouter un produit">
</a>
{% endif %}
{{ product.quantity }}
{% if app.user and product.product.productId is not empty %}
<a href="{{ path('add_to_cart', { 'id': product.product.productId }) }}">
<img src="{{ asset('assets/img/plus.png') }}" height="12" alt="Retirer une quantité au produit">
</a>
{% elseif not app.user %}
<a href="{{ path('add_to_cart', { 'id': product.product.id }) }}">
<img src="{{ asset('assets/img/plus.png') }}" height="12" alt="Retirer une quantité au produit">
</a>
{% endif %}
</td>
<td>{{ (product.product.price / 100) | number_format(2, ',', '.') }} €</td>
<td>{{ ((product.product.price * product.quantity) / 100) | number_format(2, ',', '.') }} €</td>
<td>
{% if app.user and product.product.productId is not empty %}
<a href="{{ path('add_to_cart', { 'id': product.product.productId }) }}">
<img src="{{ asset('assets/img/plus.png') }}" height="12" alt="Retirer une quantité au produit">
</a>
<a href="{{ path('delete_to_cart', { 'id': product.product.productId }) }}">
<img src="{{ asset('assets/img/delete.png') }}" height="12" alt="Supprimer mon produit">
</a>
{% elseif not app.user %}
<a href="{{ path('delete_to_cart', { 'id': product.product.id }) }}">
<img src="{{ asset('assets/img/delete.png') }}" height="12" alt="Supprimer mon produit">
</a>
{% endif %}
</td>
</tr>
{% set total = total + (product.product.price * product.quantity) %}
{% endfor %}
</tbody>
</table>
<div class="text-right mb-5">
<b>Nombre de produits :</b> {{ cart|length }}
<br>
<b>Total de mon panier :</b> {{ (total / 100) | number_format(2, ',', '.') }} €
<br>
<a href="{{ path('order') }}" class="btn btn-success btn-block">Valider mon panier</a>
</div>
{% else %}
<hr>
<p><b>Votre panier est vide</b></p>
{% endif %}
{% endblock %}