templates/cart/index.html.twig line 1
{% extends 'base.html.twig' %}
{% block stylesheets %}
{{ parent() }}
<link rel="stylesheet" href="{{ asset('css/utilities.css?v={{ random() }}') }}">
{% endblock %}
{% block body %}
<div class="my-cart container ">
<div class="row">
<div class="col">
<div class="d-flex justify-content-between align-items-center">
<h1 class="title-cart text-uppercase fw-bold">
votre panier : {% if carts[0] is not defined %} Votre panier est vide !{% endif %}
</h1>
</div>
<div class="row">
<div class="col w-75 mb-5">
<h6 class="mb-0 mt-5 text-secondary">**Prix indicatif - Décimale arrondie - De légères variations sont possibles sur la facture finale.</h6>
<table id="myTable" class="table mt-1 tableCart">
<thead class="fw-light theadCart">
<tr class="trCart">
<th class="th-image align-middle thCart"></th>
<th class="th-name align-middle thCart">Nom du produit</th>
<th class="th-dlu align-middle thCart">DLUC</th>
<th class="th-unitPrice text-center align-middle thCart">Prix pro. unitaire<br/>
<span class="price-format-tva">(HTVA)</span>
</th>
<th class="th-quantity text-center align-middle thCart">Quantité</th>
<th class="th-subtotal text-center align-middle thCart">Sous-total<br/>
<span class="price-format-tva">(HTVA)</span>
</th>
<th class="th-delete text-center align-middle thCart"></th>
</tr>
</thead>
<tbody class="tbodyCart">
{% set userRole = informations[0].AdditionalCompanyInformation[0].companyTypePro %}
{% for product in carts %}
{% if product.totalQuantity is defined %}
{% if product.totalQuantity >= 4 %}
{% set price = (product.totalPrice / 100) * rebate %}
<tr class="trCart">
{# _____IMAGE______ #}
<td class=" align-middle text-center tdImageProduct tdCart">
<img src="/img/products/{{ product.image }}" alt="{{ product.name }}" width="80" height="80">
</td>
{# _____NOM DU PRODUIT______ #}
<td class="align-middle tdCart">
{% if product.reference is not empty %}
<span class="product-cart-ref product-cart-reference text-center">{{ product.reference }}</span>
{% endif %}
{% if product.nut is not null and product.nut is not empty %}
<span class="product-cart-ref product-cart-nut text-center">{{ product.nut }}</span>
{% endif %}
{% if (product.cnk is not empty and product.cnk is not null and userRole == 'Pharmacien') %}
<span class="product-cart-ref product-cart-cnk text-center">{{ product.cnk }}</span>
{% endif %}
{% if (product.ean is not empty and product.ean is not null) %}
<span class="product-cart-ref product-cart-ean text-center">{{ product.ean }}</span>
{% endif %}
{% if product.newRef is defined and product.newRef %}
<span class="product-cart-ref text-center product-cart-newref text-light">nouvelle référence -2%</span>
{% endif %}
{% if product.tvaBe is not empty and product.tvaBe == 21.0 or product.tvaBe is not empty and product.tvaBe == 20.0 or product.tvaFr is not empty and product.tvaLu == 17.0 %}
<span class="product-cart-ref product-cart-tva text-center text-light text-nowrap">
<i class="fa-solid fa-triangle-exclamation"></i>
{% if informations[0].AdditionalCompanyInformation[0].companyCountry == "Belgique" %}
TVA 21
{% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "France" %}
TVA 20
{% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "Luxembourg" %}
TVA 17
{% endif %}%</span>
{% endif %}
<br/>
{% if product.shockActionDiscountPercent %}
<span class="product-cart-ref {{product.shockActionType.value == 'shock_action' ? 'bg-primary' :''}} product-cart-tva text-center text-light text-uppercase"> <i class="fa-solid fa-triangle-exclamation"></i>{{shockActionTypes[product.shockActionType.value]}} {{product.shockActionDiscountPercent}}%</span>
<br />
{% endif %}
<span class="product-name-cart fw-bold">{{ product.name }}</span>
</td>
{# ______DLU_______ #}
<td class="align-middle tdCart ">
{% if product.dlus is not empty %}
<span class="dluLasted text-nowrap">{{ product.dlus.dlu|date('d-m-Y') | default('DLUC non disponible') }}</span>
{% if product.dlus.lotNumber is not null %}
<br/><span class="lot">Lot : <span class="lotNumberLasted">{{ product.dlus.lotNumber }}</span></span>
{% endif %}
{% else %}
<span class="productCartDlu">DLUC non disponible</span>
{% endif %}
</td>
{# ______PRIX UNITAIRE_______ #}
<td class="text-center align-middle tdCart tdPriceUnite">
{% if product.discountID != null and product.totalQuantity > 11 %}
{{ truncateDecimal(product.publicPrice,2) }}€ (prix public)
{% else %}
{{ truncateDecimal(product.price,2) }}€
{% endif %}
<br/>
{% set viewPourcentRebate = false %}
{% if product.totalRebate is defined and product.totalRebate != 0.0 %}
{% if product.actionShock == false and product.discountID == null %}
{% set viewPourcentRebate = true %}
{% elseif product.actionShock == false and product.discountID != null and product.totalQuantity < 12 %}
{% set viewPourcentRebate = true %}
{% elseif product.actionShock and product.discountID == null %}
{% set viewPourcentRebate = false %}
{% elseif product.actionShock == false and product.discountID != null %}
{% set viewPourcentRebate = false %}
{% endif %}
{% endif %}
{% if viewPourcentRebate %}
{% if rebateNatura != null and rebate == 13 and product.brand == "NaturaMedicatrix" %}
{% if product.newRef is defined and product.newRef %}
<span class="pourcentRebateUnit">- {{ product.rebatePercent }}%</span>
{% else %}
<span class="pourcentRebateUnit">- {{ product.rebatePercent }}%</span>
{% endif %}
{% elseif rebateNatura != null and rebate == 19 and product.brand == "NaturaMedicatrix" %}
{% if product.newRef is defined and product.newRef %}
<span class="pourcentRebateUnit">- {{ product.rebatePercent }}%</span>
{% else %}
<span class="pourcentRebateUnit">- {{ product.rebatePercent }}%</span>
{% endif %}
{% else %}
{% if product.newRef is defined and product.newRef %}
<span class="pourcentRebateUnit">- {{ product.rebatePercent }}%</span>
{% else %}
<span class="pourcentRebateUnit">- {{ product.rebatePercent }}%</span>
{% endif %}
{% endif %}
<br/>
<span class="cart-reduction alert alert-success align-middle fw-bold " >{{ truncateDecimal(product.reductionUniteItem,2) }}€ </span>
{% elseif viewPourcentRebate == false and product.actionShock %}
<span class="pourcentRebateUnit">- {{ product.rebatePercent }}%</span>
<br/>
<span class="cart-reduction alert alert-success align-middle fw-bold " >{{ truncateDecimal(product.reductionUniteItem,2) }}€ </span>
{% elseif viewPourcentRebate == false and product.actionShock == false and product.discountID != null and product.totalQuantity > 11 %}
<span class="pourcentRebateUnit">- {{ product.sprebate }} %</span>
<br/>
<span class="cart-reduction alert alert-success align-middle fw-bold" >{{ truncateDecimal(product.reductionUniteItem,2) }}€ </span>
{% endif %}
</td>
{# ______QUANTITY_______ #}
<td class="text-center align-middle tdCart tdQuantity">
<div class="quantity-controls d-flex">
<button type="button" class="btn-quantity-change decrease-quantity" aria-label="Decrease quantity" data-action_name="quantity-decrease" data-id_product="{{ product.id }}">
<span><i class="fa-solid fa-minus"></i></span>
</button>
<div class="quantity-display d-flex justify-content-center align-items-center mx-2">{{ product.totalQuantity }}</div>
<button type="button" class="btn-quantity-change increase-quantity" aria-label="Increase quantity" data-action_name="quantity-increase" data-id_product="{{ product.id }}">
<span><i class="fa-solid fa-plus"></i></span>
</button>
</div>
{% for item in freeProduct %}
{% if item['name'] == product.name %}
<p class="freeProductCart"><i class="fa-solid fa-gift"></i><br/>
<span class="freeProductCartText">+ {{ item['free'] }} gratuit(s)</span></p>
{% endif %}
{% endfor %}
</td>
{# _____SOUS-TOTAL______ #}
<td class="text-center align-middle tdCart tdSousTotal">
{% if product.discountID != null and product.totalQuantity > 11 %}
<span class="old-price-cart text-decoration-line-through align-middle">{{ product.totalPricePublic|number_format(2, '.', ',') }}€ (prix public)</span><br/>
<span class="new-price-cart fw-bold">–{{ truncateDecimal(product.totalRebate, 2) }}€</span>
<br/> <span class="cart-reduction alert alert-success align-middle fw-bold promotionCartGreen">{{ truncateDecimal(product.PriceRebateInclude, 2) }}€ </span>
{% elseif product.totalRebate is defined %}
{% if product.totalRebate != 0.0 or product.totalRebate != null %}
<span class="old-price-cart text-decoration-line-through align-middle">{{ product.totalPrice|number_format(2, '.', ',') }}€</span><br/>
<span class="new-price-cart fw-bold">{{ truncateDecimal(product.PriceRebateInclude, 2) }}€</span>
<br/> <span class="cart-reduction alert alert-success align-middle fw-bold promotionCartGreen">–{{ truncateDecimal(product.totalRebate, 2) }}€ </span>
{% else %}
<span class="new-price-cart fw-bold">{{ truncateDecimal(product.PriceRebateInclude, 2) }}€</span>
{% endif %}
{% else %}
{% if product.newRef is defined and product.newRef and product.totalQuantity > 1 %}
<span class="new-price-cart fw-bold text-decoration-line-through">{{ truncateDecimal(product.totalPrice, 2) }}€</span>
<br>
<span class="cart-reduction alert alert-success align-middle fw-bold promotionCartGreen">–2% </span>
<br>
<span class="new-price-cart fw-bold">{{ truncateDecimal(product.PriceRebateInclude, 2) }}€</span>
{% else %}
<span class="new-price-cart fw-bold">{{ truncateDecimal(product.totalPrice, 2) }}€</span>
{% endif %}
{# <span class="new-price-cart fw-bold">{{ truncateDecimal(product.PriceRebateInclude, 2) }}€</span>#}
{% endif %}
</td>
{# _____DELETE______ #}
<td class="text-center align-middle text-danger tdCart tdDeleteProduct">
<a class="text-decoration-none text-danger" href="{{ path('cartRemoveProduct', {'productID' : product.productId}) }}">
<i class="fa-solid fa-xmark"></i>
</a>
</td>
</tr>
{% set price = 0 %}
{% else %}
{% set price = 0 %}
<tr class="trCart">
{# _____IMAGE______ #}
<td class="align-middle tdImageProduct tdCart"><img src="/img/products/{{ product.image }}" alt="{{ product.name }}" width="80" height="80"></td>
{# _____NOM DU PRODUIT______ #}
<td class="align-middle tdCart">
{% if product.reference is not empty %}
<span class="product-cart-ref product-car-reference text-center">{{ product.reference }}</span>
{% endif %}
{% if product.nut is not null and product.nut is not empty %}
<span class="product-cart-ref product-car-nut text-center">{{ product.nut }}</span>
{% endif %}
{% if (product.cnk is not empty and product.cnk is not null and userRole == 'Pharmacien') %}
<span class="product-cart-ref product-car-cnk text-center">{{ product.cnk }}</span>
{% endif %}
{% if (product.ean is not empty and product.ean is not null) %}
<span class="product-cart-ref product-cart-ean text-center">{{ product.ean }}</span>
{% endif %}
{% if product.newRef is defined and product.newRef %}
<span class="product-cart-ref text-center product-cart-newref text-light">nouvelle référence -2%</span>
{% endif %}
{% if product.tvaBe is not empty and product.tvaBe == 21.0 or product.tvaBe is not empty and product.tvaBe == 20.0 or product.tvaFr is not empty and product.tvaLu == 17.0 %}
<span class="product-cart-ref bg-danger product-cart-ean text-center text-light"><i class="fa-solid fa-triangle-exclamation"></i>
{% if informations[0].AdditionalCompanyInformation[0].companyCountry == "Belgique" %}
TVA 21
{% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "France" %}
TVA 20
{% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "Luxembourg" %}
TVA 17
{% endif %} %</span>
{% endif %}
<br/>
<span class="product-name-cart fw-bold">{{ product.name }}</span>
</td>
{# ______DLU_______ #}
<td class="align-middle tdCart">
{% if product.dlus is not empty %}
<span class="dluLasted">{{ product.dlus.dlu|date('d-m-Y') | default('DLUC non disponible') }}</span>
{% if product.dlus.lotNumber is not null %}
<br/> <span>Lot : <span class="lotNumberLasted">{{ product.dlus.lotNumber }}</span></span>
{% endif %}
{% else %}
<span class="productCartDlu">DLUC non disponible</span>
{% endif %}
</td>
{# _____PRIX UNITAIRE______ #}
<td class="text-center align-middle tdCart tdPriceUnite">
{{ truncateDecimal(product.price, 2) }}€ <br>
{% if product.newRef is defined and product.newRef %}
<span class="pourcentRebateUnit">- 2%</span><br>
<span class="cart-reduction alert alert-success align-middle fw-bold " >{{ truncateDecimal(product.reductionUniteItem,2) }}€ </span>
{% endif %}
</td>
{# _____QUANTITE______ #}
<td class="text-center align-middle tdCart tdQuantity">
<div class="quantity-controls d-flex">
<button type="button" class="btn-quantity-change decrease-quantity" aria-label="Decrease quantity" data-action_name="quantity-decrease" data-id_product="{{ product.id }}">
<span><i class="fa-solid fa-minus"></i></span>
</button>
<div class="quantity-display d-flex justify-content-center align-items-center mx-2">{{ product.totalQuantity }}</div>
<button type="button" class="btn-quantity-change increase-quantity" aria-label="Increase quantity" data-action_name="quantity-increase" data-id_product="{{ product.id }}">
<span><i class="fa-solid fa-plus"></i></span>
</button>
</div>
</td>
{# _____SOUS-TOTAL______ #}
<td class="text-center align-middle tdCart tdSousTotal">
{% if product.newRef is defined and product.newRef and product.totalQuantity > 1 %}
<span class="new-price-cart fw-bold text-decoration-line-through">{{ truncateDecimal(product.totalPrice, 2) }}€</span>
<br>
<span class="cart-reduction alert alert-success align-middle fw-bold promotionCartGreen">–2% </span>
<br>
<span class="new-price-cart fw-bold">{{ truncateDecimal(product.PriceRebateInclude, 2) }}€</span>
{% else %}
<span class="new-price-cart fw-bold">{{ truncateDecimal(product.totalPrice, 2) }}€</span>
{% endif %}
</td>
{# _____DELETE_____ #}
<td class="text-center align-middle text-danger tdCart tdDeleteProduct">
<a class="text-decoration-none text-danger" href="{{ path('cartRemoveProduct', {'productID' : product.productId}) }}"><i class="fa-solid fa-xmark"></i></a>
</td>
</tr>
{% endif %}
{% endif %}
{% endfor %}
{% if phFlyers > 0 %}
<tr class="trCart">
{# _____IMAGE______ #}
<td class="align-middle tdImageProduct tdCart"><img src="/img/products/{{ flyersProduct.image }}" alt="{{ flyersProduct.name }}" width="80" height="80"></td>
{# _____NOM DU PRODUIT______ #}
<td class="align-middle tdCart">
<span class="product-name-cart fw-bold">{{ flyersProduct.name }}</span>
</td>
{# ______DLU_______ #}
<td class="align-middle tdCart"></td>
{# _____PRIX UNITAIRE______ #}
<td class="text-center align-middle tdCart tdPriceUnite">
{{ truncateDecimal(0, 2) }}€
</td>
{# _____QUANTITE______ #}
<td class="text-center align-middle tdCart tdQuantity tdQuantityFlyers">
{{ phFlyers }}
</td>
{# _____SOUS-TOTAL______ #}
<td class="text-center align-middle tdCart tdSousTotal">
<span class="new-price-cart fw-bold">{{ truncateDecimal(0, 2) }}€</span>
</td>
{# _____DELETE_____ #}
<td class="text-center align-middle text-danger tdCart tdDeleteProduct"></td>
</tr>
{% endif %}
</tbody>
</table>
<!-- Bouton Recommander -->
<div class="mt-3 mb-3">
<a href="{{ path('ordersHistory') }}" class="modern-btn-small-primary">
<i class="fa-solid fa-history me-2"></i>
Recommander facilement vos dernières commandes
</a>
</div>
<!-- Option Flyers -->
{% if countFaInCart is defined and countFaInCart >= 2 %}
<div class="mb-3 flyers-option">
<div class="d-flex align-items-center">
<span class="me-3">Souhaitez-vous recevoir les Flyers pH FR gratuits ?</span>
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" id="wantFlyers" name="wantFlyers" {% if wantFlyers %}checked{% endif %}>
<label class="form-check-label ms-1" for="wantFlyers">{{ wantFlyers ? 'Oui' : 'Non' }}</label>
</div>
</div>
<div class="small text-success mt-1">
<i class="fa-solid fa-circle-info me-1"></i>
<span>{{ phFlyers }} flyers seront ajoutés gratuitement à votre commande.</span>
</div>
</div>
{% endif %}
<hr>
<div class="mt-3">
<label for="messageNewRef">
<p class="fw-bolder">Pour toute commande d'une nouvelle référence pour votre magasin, veuillez l'indiquer dans le champ de texte ci-dessous.</p>
<p class="fw-bolder">Colisage par 2.</p>
<p class="fw-bolder">Remise de 2% supplémentaire.</p>
</label>
<textarea name="messageNewRef" id="messageNewRef" cols="50" rows="10"></textarea>
</div>
</div>
<!-------- SECTION ORDER -------->
<div class="cart-order col-xs-12 col-sm-12 col-md-3 text-center">
<div class="text-md-start">
<div class="card-body">
<h2 class="title-order-card text-uppercase">Votre commande</h2>
{% if missingItems is defined and missingItems != 0 %}
{% if missingItems >= 48 %}
<p class="text-center mb-2 border border-success border-2">Vous avez atteint la remise maximale.</p>
{% else %}
<p class="text-center mb-2 border border-success border-2">Encore {{ missingItems }} articles pour obtenir la Remise suivante!</p>
{% endif %}
<p class="text-danger">Colisage par 4.</p>
{% endif %}
{% set viewPourcentRebate = false %}
{% for item in carts %}
{% if item.totalRebate is defined %}
{% if item.actionShock == false %}
{% set viewPourcentRebate = true %}
{% endif %}
{% endif %}
{% endfor %}
{% if viewPourcentRebate and rebate > 0 %}
<h2 class="title-order-card mb-1">avec votre remise de: {{ rebate }}%</h2>
{% endif %}
<div class="d-flex flex-column">
{% for rebate in rebates %}
<p class="lh-sm">
Remise {{rebate.pourcentRebate}}% (min {{rebate.min}} unités, panachage possible)
{% if rebate.excludedProducts is not null %}
<br/><span style="font-size: 0.9rem;">excepté pour ces références: {{rebate.excludedProducts|join(', ')}}</span>
{% endif %}
</p>
{% endfor %}
{% for rebate in specificRebates %}
<p class="lh-sm">
Remise {{rebate.pourcentRebate}}% (min {{rebate.min}} unités d'une même référence)
{% if rebate.specificProducts is not null %}
<br/><span style="font-size: 0.9rem;">uniquement pour ces références: {{rebate.specificProducts|join(', ')}}</span>
{% endif %}
</p>
{% endfor %}
</div>
<ul class="list-group list-group-flush">
<li class="id-command" hidden>
{% if carts[0] is defined %}{{ carts[0].commandNumber }}{% endif %}
</li>
<li class="list-group-item d-flex justify-content-between align-items-center border-0 px-0 pb-0">
<div>
Produits HTVA
{% if informations[0].AdditionalCompanyInformation[0].companyCountry == "Belgique" %}
6
{% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "France" %}
5.5
{% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "Luxembourg" %}
3
{% endif %}
%:
</div>
<span class="total-tva-6">{{ truncateDecimal(carts['TotalPriceProductLowVatHtva'], 2) }}€</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center border-0 px-0 pb-0">
<div>
Produits HTVA
{% if informations[0].AdditionalCompanyInformation[0].companyCountry == "Belgique" %}
21
{% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "France" %}
20
{% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "Luxembourg" %}
17
{% endif %}
%:
</div>
<span class="total-tva-6">{{ truncateDecimal(carts['TotalPriceProductHighVatHtva'], 2) }}€</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-start border-0 px-0 mb-1">
<div>
<strong>Total (HTVA):</strong>
</div>
<span><strong class="price-total-remise-tvac">{{ truncateDecimal(carts['totalPriceAllProductHtva'], 2) }}€</strong></span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center border-0 px-0 pb-0">
<div>
TVA
{% if informations[0].AdditionalCompanyInformation[0].companyCountry == "Belgique" %}
6
{% set tvauser = 6 %}
{% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "France" %}
5.5
{% set tvauser = 5.5 %}
{% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "Luxembourg" %}
3
{% set tvauser = 3 %}
{% endif %}
%:
</div>
<span class="total-tva-6">{{ truncateDecimal(carts['TotalPriceProductLowVatTvac'], 2) }}€</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center border-0 px-0 pb-0">
<div>
TVA
{% if informations[0].AdditionalCompanyInformation[0].companyCountry == "Belgique" %}
21
{% set tvauser = 21 %}
{% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "France" %}
20
{% set tvauser = 20 %}
{% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "Luxembourg" %}
17
{% set tvauser = 17 %}
{% endif %}
%:
</div>
<span class="total-tva-6">{{ truncateDecimal(carts['TotalPriceProductHighVatTvac'], 2) }}€</span>
</li>
{% if freeTransport %}
<li class="list-group-item d-flex justify-content-between align-items-start border-0 px-0 mb-3">
<div>
<strong>Prix total remisé (TVAC):</strong>
</div>
<span><strong class="price-total-remise-tvac">{{ truncateDecimal(carts['totalPriceTvacWithRebate'], 2) }}€</strong></span>
</li>
{% else %}
<li class="list-group-item d-flex justify-content-between align-items-start border-0 px-0 mb-3">
<div>
Frais de livraison:
</div>
<span class="price-delivery">{{ costDelivery }}€</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-start border-0 px-0 mb-3">
<div>
<strong>Prix total remisé (TVAC):</strong>
</div>
<span><strong class="price-total-remise-tvac">{{ truncateDecimal(carts['totalPriceTvacWithRebate'] + costDelivery, 2) }}€</strong></span>
</li>
{% endif %}
<li class="list-group-item d-flex flex-column justify-content-between align-items-center px-0 text-delivery">
{% if freeTransport %}
Vous avez atteint le FRANCO de 300€, livraison gratuite.
{% else %}
<p>Les coûts de livraison sont de: {{ costDelivery }}€</p>
<p style="font-weight: bold;">FRANCO de 300€</p>
{% endif %}
</li>
</ul>
</div>
</div>
<hr/>
<!---------- SECTION ADRESSE LIVRAISON ---------->
<h3 class="title-order-billing mt-5 text-uppercase">Adresse de Livraison</h3>
{% if address != true %}
<!-- Adress choice delivery -->
<div class="choice-address-delivery card alert alert-primary">
<p class="text-uppercase text-center my-0"><i class="fa-solid fa-plus"></i>
Nouvelle adresse de livraison
</p>
</div>
{% endif %}
{% if address %}
{% for myAddress in address %}
{% if loop.first %}
<div id="delivery-address"
class="first-address-delivery actived-address open-modal-block">
<div class="card mt-3 mb-0">
<div class="home-address hovered-block">
<i class="fa-solid fa-truck-fast"></i>
<div class="informations-address">
<span class="id-address" hidden>{{ myAddress.id }}</span>
<span class="companyName-address">{{ myAddress.companyName }}</span>
<span class="firstname-address">{{ myAddress.firstName }}</span>
<span class="name-address">{{ myAddress.name }}</span><br/>
<span class="street-address">{{ myAddress.address }}</span>,
<span class="cp-address">{{ myAddress.postal }}</span>
<span class="town-address">{{ myAddress.town }}</span><br/>
<span class="country-address">{{ myAddress.country }}</span><br/>
<span class="tel-address">{{ myAddress.phoneNumber }}</span>
</div>
</div>
</div>
</div>
{% endif %}
{% if loop.last %}
<div class="checkbox-order text-left mb-5 mt-2">
<p class="new-order-delivery"><i class="fa-solid fa-angle-right"></i>
Choisir une autre adresse de livraison
</p>
</div>
{% endif %}
{% endfor %}
{% endif %}
<div class="mb-3">
<span>Adresse de facturation</span></br>
<span>identique livraison?</span>
<input type="checkbox" name="adresse_check" class="adresse_check" id="adresse_check">
</div>
{% if joker %}
<span>Jokers restants: <span class="text-success joker_numb">{{ jokerNumber }}</span></span>
<label for="check_joker">Transport gratuit. Utiliser un joker.</label>
<input type="checkbox" name="joker" class="check_joker" id="check_joker">
<span id="jokerMessage"></span>
{% endif %}
<!---------- ADRESSE DE FACTURATION ---------->
<div class="global_div_facturation">
<h3 class="title-order-billing billing-title text-uppercase mt-1">
Adresse de Facturation
</h3>
<!-- ADDRESS CHOICE DELIVERY -->
{% if address != true %}
<div class="choice-address-delivery card alert alert-primary">
<p class="text-uppercase text-center my-0"><i class="fa-solid fa-plus"></i>
Nouvelle adresse de facturation
</p>
</div>
{% endif %}
{% if address %}
{% for myAddress in address %}
{% if loop.first %}
<div id="delivery-billing"
class="first-address-delivery open-modal-block-change">
<div class="card mt-3">
<div class="home-address home-address-billing hovered-block">
<i class="fa-solid fa-file-pen"></i>
<div class="informations-address">
<span class="id-address" hidden>{{ myAddress.id }}</span>
<span class="companyName-address">{{ myAddress.companyName }}</span>
<span class="firstname-address">{{ myAddress.firstName }}</span>
<span class="name-address">{{ myAddress.name }}</span><br/>
<span class="street-address">{{ myAddress.address }}</span>,
<span class="cp-address">{{ myAddress.postal }}</span>
<span class="town-address">{{ myAddress.town }}</span><br/>
<span class="country-address">{{ myAddress.country }}</span><br/>
<span class="tel-address">{{ myAddress.phoneNumber }}</span>
</div>
</div>
</div>
</div>
{% endif %}
{% if loop.last %}
<div class="checkbox-order text-left mb-5 mt-2">
<p class="new-order-billing"><i class="fa-solid fa-angle-right"></i>
Choisir une autre adresse de facturation
</p>
</div>
{% endif %}
{% endfor %}
{% endif %}
</div>
<div>
<button class="btn btn-success btn-send-command mb-3 ">Envoyer ma commande</button>
</div>
</div>
</div>
<!-- MODAL ADRESSES LIVRAISON/FACTURATION -->
{% block modal_content %}
{% include "modalAddress/modal_address.html.twig" %}
{% endblock %}
<!--END MODAL-->
</div>
</div>
</div>
{% endblock %}
{% block javascripts %}
<script>
$(document).ready(function () {
var totalJokers = {{ jokerNumber }};
$(document).on('click', '.btn-quantity-change', function(){
var move = $(this).data("action_name");
var id_product = $(this).data('id_product');
$.ajax({
url: "{{ path('addtocartfromcart') }}",
data: {
'id_product': id_product,
'move' : move
},
dataType: "json",
success: function (data) {
location.reload();
}
});
})
$('#check_joker').change(function() {
if ($(this).prop('checked')) {
totalJokers--; // décrémenter le nombre de jokers lorsqu'il est utilisé
$('.joker_numb').empty().html(totalJokers);
$('#jokerMessage').html("Un joker utilisé, il vous reste <span class='text-success'>" + totalJokers + "</span> joker(s) cette année.");
$('.text-delivery').html("Livraison gratuite lors de l'utilisation du joker.");
} else {
totalJokers++;
$('.joker_numb').empty().html(totalJokers);
$('#jokerMessage').text("");
$('.text-delivery').html("Les coûts de livraison vous seront communiqués avant la livraison.");
}
});
// Gestion de la case à cocher des flyers
$('#wantFlyers').change(function() {
// Mise à jour du label immédiatement pour feedback visuel
$(this).next('label').text($(this).prop('checked') ? 'Oui' : 'Non');
// Appel AJAX pour mettre à jour la préférence côté serveur
$.ajax({
url: "{{ path('toggleFlyers') }}",
type: "GET",
success: function() {
// Rechargement de la page pour refléter les changements
location.reload();
}
});
});
$(document).on('click', '.btn-send-command', function () {
$(this).attr('disabled', true);
// Récupérer les valeurs de tous les éléments avec la classe "lotNumberLasted"
var lotNumbers = $('.lotNumberLasted').map(function() {
return $(this).html(); // Vous pouvez utiliser .text() à la place de .html() si vous n'avez que du texte
}).get(); // Convertir le résultat en un tableau JavaScript
$.ajax({
// type: "POST",
url: "{{ path('cartSend') }}",
data: {
'totalPriceWithVat': $('.price-total-remise-tvac').html(),
'totalRemise': $('.price-total-remise').html(),
'totalPriceProductLowVatHtva': '{{ carts['TotalPriceProductLowVatHtva'] }}',
'totalPriceProductHighVatHtva': '{{ carts['TotalPriceProductHighVatHtva'] }}',
'totalPriceProductLowVatTvac': '{{ carts['TotalPriceProductLowVatTvac'] }}',
'totalPriceProductHighVatTvac': {{ carts['TotalPriceProductHighVatTvac'] }},
'totalPriceAllProductHtva': {{ carts['totalPriceAllProductHtva'] }},
'totalPriceTvacWithRebate': {{ carts['totalPriceTvacWithRebate'] }},
'idCommande': $('.id-command').html(),
'idUser': '{{ user.id }}',
'total-price-tvac-no-reduct': $('.total-price-tvac-no-reduct').html(),
'deliveryAddress': $('#delivery-address .id-address').html(),
'deliveryBilling': $('#delivery-billing .id-address').html(),
'addressCheck': $('#adresse_check').is(':checked'),
'joker': $('.check_joker').is(':checked'),
'rebatePourcent': '{{ rebate }}',
'lotNumbers': lotNumbers,
'messageNewRef': $('#messageNewRef').val()
},
dataType: "json",
success: function (data) {
console.log(data)
if (data === 'profile') {
location.href = '/account/profile';
} else {
location.href = '/';
}
}
});
});
// enlève le module livraison si facturation identique livraison.
$(document).on('change', '.adresse_check', function () {
if ($(this).is(':checked')) {
$('.global_div_facturation').hide();
} else {
$('.global_div_facturation').show();
}
});
//OUVRE LE MODAL POUR CHOISIR UNE ADRESSE
$('.my-cart .open-modal-block ').click(function () {
$('#addressModal').modal('show');
});
//CHANGE L'ADRESSE PAR L'ADRESSE SELECTIONEE DANS LE MODAL
$('#addressModal .modal-body .card').click(function () {
$('.modal-body .card').removeClass('address-active');
$(this).addClass('address-active');
let selectedAddress = $('.modal-body .address-active');
// Vérifie si une adresse est sélectionnée et change dans le template correspondant
let newAddress = selectedAddress.html();
if (selectedAddress.length > 0) {
if ($('.body-modal-billing').length > 0) {
$('#delivery-billing').html(newAddress);
} else {
$('#delivery-address').html(newAddress);
}
}
$('#addressModal').modal('hide');
});
//CHANGE LE TEMPLATE CLIQUE LIVRAISON
$('.new-order-delivery, .open-modal-block').click(function () {
// Modifie le texte du h1 du modal
$('#addressModal .modal-title').text('Choisir une adresse de livraison');
$('#addressModal').modal('show');
});
//CHANGE LE TEMPLATE CLIQUE FACTURATION
$('.new-order-billing, .open-modal-block-change').click(function () {
// Ajoute la classe au modal body
$('.modal-body').addClass('body-modal-billing');
// Modifie le texte du h1 du modal
$('#addressModal .modal-title').text('Choisir une adresse de facturation');
$('#addressModal').modal('show');
// Enlève la classe du modal body lorsque le modal se ferme
$('#addressModal').on('hidden.bs.modal', function () {
$('.modal-body').removeClass('body-modal-billing');
});
$('#addressModal').modal('hide');
});
});
</script>
{% endblock %}