{% extends 'base.html.twig' %}
{% block body %}
<div class="container-fluid">
<h1 class="mb-3 d-flex justify-content-between">
<span>Panier
{% if cart.date is defined %}<small><small class="badge text-white bg-primary ml-2">( {{ cart.date|replace({'-': "/"}) }} )</small></small>{% endif %}
</span>
{% if cart_details is not empty %}
<form action="/panier" method="POST" class="d-print-none">
<input type="hidden" name="reset_cart" value="true">
<button type="submit" class="btn btn-sm bg-danger text-white" style="display: inline-block;">
<i class="fas fa-trash"></i><span class="d-none d-md-inline"> Vider le panier</span>
</button>
</form>
{% endif %}
</h1>
{% if cart_details is not empty %}
{# {{ dump(cart_details) }} #}
{% set totalPanier = 0 %}
{% set totalAPayer = 0 %}
{% for formule in cart_details %}
{% if formule.forfaits is defined %}
<div class="card mb-4">
<h4 class="card-header d-flex justify-content-between">
Formule : {{ formule.obj_formule.getDesignation() }}
<form action="/panier" class="d-print-none" method="POST">
<input type="hidden" name="remove_formule" value="{{ formule.obj_formule.getCode() }}">
<button type="submit" title="Supprimer la fomule" class="btn btn-sm bg-secondary text-white" style="display: inline-flex;">
<i class="fas fa-trash"></i><span class="msg-remove_formule"> Supprimer la formule</span>
</button>
</form>
</h4>
<div class="card-body">
{% set totalFormule = 0 %}
{% set acompteFormuleAnniversaire = 0 %}
{% for forfait in formule.forfaits %}
<h5>{{ forfait.obj_forfait.getDesignation() }}</h5>
{% if forfait.activity is defined %}
{% if formule.obj_formule.getCode() != "anniversaire" %}
<p class="mb-1">
<u>Créneau réservé :</u>
</p>
<ul class="pl-4">
{% for activity in forfait.activity %}
<li><b>{{ activity.obj_activity.getDesignation() }}
{% if activity.creneau is defined %}
à {{ activity.creneau }}
{% endif %}
</b> ({{ activity.participants }} personnes {% if activity.creneau is defined %} x {{ activity.parties }} parties{% endif %})</li>
{% endfor %}
</ul>
{% else %}
<p class="mb-1">
<u>Créneau d'anniversaire réservé :</u>
</p>
<p>Le <b>{{ cart.date|replace({'-': "/"}) }}</b> à <b>{{ forfait.infos_anniv.creneau_anniv }}</b> pour <b>{{ forfait.infos_anniv.nbreParticipants }} personnes</b></p>
<p class="mb-1">
<u>Activités à créneaux réservées :</u>
</p>
<ul class="pl-4">
{% for activity in forfait.activity %}
<li><b>{{ activity.obj_activity.getDesignation() }}</b> : {{ activity.parties }} partie(s)</li>
{% endfor %}
</ul>
<p><b>Vous serez recontacté.e rapidement par la Team 10.55 pour les horaires de vos activités à créneaux.</b></p>
{% endif %}
{% endif %}
<p class="mb-1"><u>Tarifs :</u></p>
<ul class="pl-4">
{% for tarif in forfait.tarifs %}
{% if forfait.tarifs|length == 1 and formule.obj_formule.getCode() == "anniversaire" and acompteFormuleAnniversaire == 0 %}
{% set totalAPayer = totalAPayer + ( tarif.obj_tarif.getPriceTtc() * 4) %}
{% set acompteFormuleAnniversaire = tarif.obj_tarif.getPriceTtc() * 4 %}
{% endif %}
{% set totalFormule = totalFormule + (tarif.qty) * tarif.obj_tarif.getPriceTtc() %}
<li>{{ tarif.obj_tarif.getDesignation() }} : <span class="text-white badge bg-primary px-2 py-1">{{ tarif.qty }} x {{ tarif.obj_tarif.getPriceTtc() }}€</span></li>
{% endfor %}
</ul>
{% if forfait.options is not empty %}
<p class="mb-1"><u>Options :</u></p>
<ul class="pl-4">
{% for option in forfait.options %}
{% set totalFormule = totalFormule + (option.qty) * option.obj_option.getPriceTtc() %}
<li>{{ option.obj_option.getDesignation() }} : <span class="text-white badge bg-primary px-2 py-1">{{ option.qty }} x {{ option.obj_option.getPriceTtc() }}€</span></li>
{% endfor %}
</ul>
{% endif %}
<hr>
{% endfor %}
{% set totalPanier = totalPanier + totalFormule %}
{% if formule.obj_formule.getCode() != "anniversaire" %}
{% set totalAPayer = totalAPayer + totalFormule %}
{% endif %}
<div class="d-flex justify-content-end">
<span><b>Total formule :</b> <span class="bg-light border px-2 py-1"><b>{{ totalFormule }}€</b></span> <span class="badge">(TTC)</span></span>
</div>
{% if formule.obj_formule.getCode() == "anniversaire" and acompteFormuleAnniversaire != 0 %}
<div class="d-flex justify-content-end mt-2">
<span class="badge"><b>Acompte :</b> <span class="bg-light border px-2 py-1"><b>{{ acompteFormuleAnniversaire }}€</b></span> <span>(TTC)</span></span>
</div>
{% endif %}
</div>
</div>
{% if formule.obj_formule.getCode() == "anniversaire" %}
<div class="card mb-4">
<form id="customer_comment" method="POST" action="/panier" class="p-0" style="">
<div class="card-header h6 alert alert-warning mb-2">Souhaitez-vous ajouter un commentaire à votre réservation d'anniversaire ?</div>
<div class="card-body pt-2 pb-3">
{# {{ dump() }} #}
{% if cart['birthday_customer_comment'] is defined %}
{% set birthday_customer_comment = cart['birthday_customer_comment'] %}
{% set txt_btn_bcc = "Modifier le commentaire" %}
{% else %}
{% set birthday_customer_comment = "" %}
{% set txt_btn_bcc = "Ajouter le commentaire" %}
{% endif %}
<textarea id="birthday_customer_comment" name="birthday_customer_comment" class="form-control">{{ birthday_customer_comment }}</textarea>
<button type="submit" class="mt-2 btn btn-secondary">{{ txt_btn_bcc }}</button>
</div>
</form>
</div>
{% endif %}
{% endif %}
{% endfor %}
<div class="mb-4">
<div class="d-flex justify-content-end">
<div class="card pt-2 px-2">
<form id="formcodepromo" method="POST" action="/panier" class="p-0" style="">
<div class="d-inline-flex mr-md-2 mb-2">
{# <div class="alert alert-danger">
Bon numérique en maintenance !<br><small>si vous souhaitez payer avec votre e-ticket, <br>revenez un peu plus tard, <br>ce moyen de paiement est en maintenance</small>
</div> #}
<div class="input-group">
<input id="bon_numerique" name="bon_numerique" class="form-control" placeholder="E-ticket" type="text">
<div class="input-group-append">
<button type="submit" class="btn btn-secondary">Utiliser mon E-ticket</button>
</div>
</div>
</div>
{% if cart.code_promo is not defined %}
<div class="d-inline-flex mb-2">
<div class="input-group">
<input id="codepromo" name="codepromo" class="form-control" placeholder="Code Promo" type="text">
<input id="totalPanier" name="totalPanier" class="form-control" type="hidden" value="{{ totalPanier }}">
<div class="input-group-append">
<button type="submit" class="btn btn-secondary">Utiliser mon code</button>
</div>
</div>
</div>
{% endif %}
</form>
{% if alert_voucher is defined and alert_voucher != '' %}
<p id="error_reduction" class="h6 mb-2 text-danger">
{{ alert_voucher }}
</p>
{% else %}
<p id="error_reduction" class="h6 mb-2 alert alert-danger d-none">
</p>
{% endif %}
{% if code_promo_response is defined and code_promo_response.error is defined and code_promo_response.error != null %}
<p id="error_reduction" class="h6 mb-2 text-danger">
{{ code_promo_response.error }}
</p>
{% else %}
<p id="error_reduction" class="h6 mb-2 alert alert-danger d-none">
</p>
{% endif %}
</div>
</div>
</div>
<div class="card mb-4">
{% if cart.bon_numerique is defined %}
{% for bon in cart.bon_numerique %}
<div class="card-body d-flex justify-content-end">
{% set valeur_promo = "-" ~ (bon.total) ~ "€" %}
{% set totalPanier = (totalPanier - bon.total) %}
{% set totalAPayer = (totalAPayer - bon.total) %}
{% if totalPanier < 0 %}
{% set totalPanier = 0 %}
{% endif %}
{% if totalAPayer < 0 %}
{% set totalAPayer = 0 %}
{% endif %}
<form action="/panier" class="d-print-none" method="POST">
<input type="hidden" name="remove_bon_numerique" value="{{ bon.bon }}">
<button type="submit" title="Retirer ce E-ticket" class="btn btn-sm bg-white text-danger" style="display: inline-flex;">
<i class="fas fa-trash mt-1"></i><span class="msg-remove_bon_numerique py-1 ml-2 bg-danger text-white" style="line-height:1;"> Retirer ce Bon</span>
</button>
</form>
<div class="text-danger">
E-ticket [{{ bon.bon }}] :
<span class="h5"><span class="badge bg-danger text-white border-danger px-2 py-1">{{ valeur_promo }}</span></span>
</div>
</div>
{% endfor %}
{% endif %}
{% if cart.code_promo is defined %}
<div class="card-body d-flex justify-content-end">
{% if cart.code_promo.getTypeReduction() == 'percentage' %}
{% set percent_promo = "-" ~ (cart.code_promo.getPercent() * 100) ~ "%" %}
{% set valeur_promo = "-" ~ (totalPanier * cart.code_promo.getPercent()) ~ "€" %}
{% set totalPanier = (totalPanier - (totalPanier * cart.code_promo.getPercent())) %}
<div class="text-danger">
Code promo [{{ cart.code_promo.getCode() }}] ({{ percent_promo }}) :
<span class="h5"><span class="badge bg-danger text-white border-danger px-2 py-1">{{ valeur_promo }}</span></span>
</div>
{% else %}
{% set valeur_promo = "-" ~ (cart.code_promo.getReduction()) ~ "€" %}
{% endif %}
</div>
{% endif %}
{% if totalPanier != totalAPayer %}
<h5 class="card-header d-flex justify-content-end">
Total panier : <span class="badge bg-light border px-2 py-1"><b>{{ totalPanier }}€</b></span> <span class="badge"><small>(TTC)</small></span></span>
</h5>
<h4 class="card-header d-flex justify-content-end">
Total à payer : <span class="badge bg-success text-white border px-2 py-1"><b>{{ totalAPayer }}€</b></span> <span class="badge"><small>(TTC)</small></span></span>
</h4>
{% else %}
<h4 class="card-header d-flex justify-content-end">
Total panier : <span class="badge bg-success text-white border px-2 py-1"><b>{{ totalPanier }}€</b></span> <span class="badge"><small>(TTC)</small></span></span>
</h4>
{% endif %}
</div>
<div class="container-fluid d-print-none">
<div class="row justify-content-between">
<a href="/" class="btn btn-secondary btn-lg ladda-button d-flex align-items-center" id="etape0" data-style="zoom-out" >
<span class="h3 mb-0">< </span>
<span class="ladda-label">Ajouter une formule</span>
</a>
<a href="/paiement" class="btn btn-primary btn-lg ladda-button d-flex align-items-center" id="etape3" data-style="zoom-out" >
<span class="ladda-label">Finaliser ma réservation</span>
<span class="h3 mb-0"> ></span>
</a>
</div>
</div>
{% else %}
<div class="py-5">
<h3 class="text-center alert alert-warning">Votre panier est vide</h3>
</div>
{% endif %}
</div>
{% endblock %}