templates/cart/index.html.twig line 1

  1. {% extends 'base.html.twig' %}
  2. {% block stylesheets %}
  3.     {{ parent() }}
  4.     <link rel="stylesheet" href="{{ asset('css/utilities.css?v={{ random() }}') }}">
  5. {% endblock %}
  6. {% block body %}
  7.     <div class="my-cart container ">
  8.         <div class="row">
  9.             <div class="col">
  10.                 <div class="d-flex justify-content-between align-items-center">
  11.                     <h1 class="title-cart text-uppercase fw-bold">
  12.                         votre panier : {% if carts[0] is not defined %} Votre panier est vide !{% endif %}
  13.                     </h1>
  14.                 </div>
  15.                 <div class="row">
  16.                     <div class="col w-75 mb-5">
  17.                         <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>
  18.                         <table id="myTable" class="table mt-1 tableCart">
  19.                             <thead class="fw-light theadCart">
  20.                             <tr class="trCart">
  21.                                 <th class="th-image align-middle thCart"></th>
  22.                                 <th class="th-name align-middle thCart">Nom du produit</th>
  23.                                 <th class="th-dlu  align-middle thCart">DLUC</th>
  24.                                 <th class="th-unitPrice text-center align-middle thCart">Prix pro. unitaire<br/>
  25.                                     <span class="price-format-tva">(HTVA)</span>
  26.                                 </th>
  27.                                 <th class="th-quantity text-center align-middle thCart">Quantité</th>
  28.                                 <th class="th-subtotal text-center align-middle thCart">Sous-total<br/>
  29.                                     <span class="price-format-tva">(HTVA)</span>
  30.                                 </th>
  31.                                 <th class="th-delete text-center align-middle thCart"></th>
  32.                             </tr>
  33.                             </thead>
  34.                             <tbody class="tbodyCart">
  35.                             {% set userRole = informations[0].AdditionalCompanyInformation[0].companyTypePro %}
  36.                             {% for product in carts %}
  37.                                 {% if product.totalQuantity is defined %}
  38.                                     {% if product.totalQuantity >= 4 %}
  39.                                         {% set price = (product.totalPrice / 100) * rebate %}
  40.                                         <tr class="trCart">
  41.                                             {# _____IMAGE______ #}
  42.                                             <td class=" align-middle text-center tdImageProduct tdCart">
  43.                                                 <img src="/img/products/{{ product.image }}" alt="{{ product.name }}" width="80" height="80">
  44.                                             </td>
  45.                                             {# _____NOM DU PRODUIT______ #}
  46.                                             <td class="align-middle tdCart">
  47.                                                 {% if product.reference is not empty %}
  48.                                                     <span class="product-cart-ref product-cart-reference text-center">{{ product.reference }}</span>
  49.                                                 {% endif %}
  50.                                                 {% if product.nut is not null and product.nut is not empty %}
  51.                                                     <span class="product-cart-ref product-cart-nut text-center">{{ product.nut }}</span>
  52.                                                 {% endif %}
  53.                                                 {% if (product.cnk is not empty and product.cnk is not null and userRole == 'Pharmacien') %}
  54.                                                     <span class="product-cart-ref product-cart-cnk text-center">{{ product.cnk }}</span>
  55.                                                 {% endif %}
  56.                                                 {% if (product.ean is not empty and product.ean is not null) %}
  57.                                                     <span class="product-cart-ref product-cart-ean text-center">{{ product.ean }}</span>
  58.                                                 {% endif %}
  59.                                                 {% if product.newRef is defined and product.newRef %}
  60.                                                     <span class="product-cart-ref text-center product-cart-newref text-light">nouvelle référence -2%</span>
  61.                                                 {% endif %}
  62.                                                 {% 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 %}
  63.                                                     <span class="product-cart-ref product-cart-tva text-center text-light text-nowrap">
  64.                                                         <i class="fa-solid fa-triangle-exclamation"></i>
  65.                                                         {% if informations[0].AdditionalCompanyInformation[0].companyCountry == "Belgique" %}
  66.                                                             TVA 21
  67.                                                         {% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "France" %}
  68.                                                             TVA 20
  69.                                                         {% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "Luxembourg" %}
  70.                                                             TVA 17
  71.                                                         {% endif %}%</span>
  72.                                                 {% endif %}
  73.                                                 <br/>
  74.                                                 {% if product.shockActionDiscountPercent %}
  75.                                                     <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>
  76.                                                     <br />
  77.                                                 {% endif %}
  78.                                                 <span class="product-name-cart fw-bold">{{ product.name }}</span>
  79.                                             </td>
  80.                                             {# ______DLU_______ #}
  81.                                             <td class="align-middle tdCart ">
  82.                                                 {% if product.dlus is not empty %}
  83.                                                     <span class="dluLasted text-nowrap">{{ product.dlus.dlu|date('d-m-Y') | default('DLUC non disponible') }}</span>
  84.                                                     {% if product.dlus.lotNumber is not null %}
  85.                                                         <br/><span class="lot">Lot : <span class="lotNumberLasted">{{ product.dlus.lotNumber }}</span></span>
  86.                                                     {% endif %}
  87.                                                 {% else %}
  88.                                                     <span class="productCartDlu">DLUC non disponible</span>
  89.                                                 {% endif %}
  90.                                             </td>
  91.                                             {# ______PRIX UNITAIRE_______ #}
  92.                                             <td class="text-center align-middle tdCart tdPriceUnite">
  93.                                                 {% if product.discountID != null and product.totalQuantity > 11 %}
  94.                                                     {{ truncateDecimal(product.publicPrice,2) }}€ (prix public)
  95.                                                 {% else %}
  96.                                                     {{ truncateDecimal(product.price,2) }}€
  97.                                                 {% endif %}
  98.                                                 <br/>
  99.                                                 {% set viewPourcentRebate = false %}
  100.                                                 {% if product.totalRebate is defined and product.totalRebate != 0.0 %}
  101.                                                     {% if product.actionShock == false and product.discountID == null %}
  102.                                                         {% set viewPourcentRebate = true %}
  103.                                                     {% elseif product.actionShock == false and product.discountID != null and product.totalQuantity < 12 %}
  104.                                                         {% set viewPourcentRebate = true %}
  105.                                                     {% elseif product.actionShock and product.discountID == null %}
  106.                                                         {% set viewPourcentRebate = false %}
  107.                                                     {% elseif product.actionShock == false and product.discountID != null %}
  108.                                                         {% set viewPourcentRebate = false %}
  109.                                                     {% endif %}
  110.                                                 {% endif %}
  111.                                                 {% if viewPourcentRebate %}
  112.                                                     {% if rebateNatura != null and rebate == 13 and product.brand == "NaturaMedicatrix" %}
  113.                                                         {% if product.newRef is defined and product.newRef %}
  114.                                                             <span class="pourcentRebateUnit">- {{ product.rebatePercent }}%</span>
  115.                                                             {% else %}
  116.                                                                 <span class="pourcentRebateUnit">- {{ product.rebatePercent }}%</span>
  117.                                                         {% endif %}
  118.                                                     {% elseif rebateNatura != null and rebate == 19 and product.brand == "NaturaMedicatrix" %}
  119.                                                         {% if product.newRef is defined and product.newRef %}
  120.                                                             <span class="pourcentRebateUnit">- {{ product.rebatePercent }}%</span>
  121.                                                             {% else %}
  122.                                                                 <span class="pourcentRebateUnit">- {{ product.rebatePercent }}%</span>
  123.                                                         {% endif %}
  124.                                                     {% else %}
  125.                                                         {% if product.newRef is defined and product.newRef %}
  126.                                                             <span class="pourcentRebateUnit">- {{ product.rebatePercent }}%</span>
  127.                                                             {% else %}
  128.                                                                 <span class="pourcentRebateUnit">- {{ product.rebatePercent }}%</span>
  129.                                                         {% endif %}
  130.                                                     {% endif %}
  131.                                                     <br/>
  132.                                                     <span class="cart-reduction alert alert-success align-middle fw-bold " >{{ truncateDecimal(product.reductionUniteItem,2) }}€ </span>
  133.                                                 {% elseif viewPourcentRebate == false and product.actionShock %}
  134.                                                     <span class="pourcentRebateUnit">- {{ product.rebatePercent }}%</span>
  135.                                                     <br/>
  136.                                                     <span class="cart-reduction alert alert-success align-middle fw-bold " >{{ truncateDecimal(product.reductionUniteItem,2) }}€ </span>
  137.                                                 {% elseif viewPourcentRebate == false and product.actionShock == false and product.discountID != null and product.totalQuantity > 11 %}
  138.                                                     <span class="pourcentRebateUnit">- {{ product.sprebate }} %</span>
  139.                                                     <br/>
  140.                                                     <span class="cart-reduction alert alert-success align-middle fw-bold" >{{ truncateDecimal(product.reductionUniteItem,2) }}€ </span>
  141.                                                 {% endif %}
  142.                                             </td>
  143.                                             {# ______QUANTITY_______ #}
  144.                                             <td class="text-center align-middle tdCart tdQuantity">
  145.                                                 <div class="quantity-controls d-flex">
  146.                                                     <button type="button" class="btn-quantity-change decrease-quantity" aria-label="Decrease quantity" data-action_name="quantity-decrease" data-id_product="{{ product.id }}">
  147.                                                         <span><i class="fa-solid fa-minus"></i></span>
  148.                                                     </button>
  149.                                                     <div class="quantity-display d-flex justify-content-center align-items-center mx-2">{{ product.totalQuantity }}</div>
  150.                                                     <button type="button" class="btn-quantity-change increase-quantity" aria-label="Increase quantity" data-action_name="quantity-increase" data-id_product="{{ product.id }}">
  151.                                                         <span><i class="fa-solid fa-plus"></i></span>
  152.                                                     </button>
  153.                                                 </div>
  154.                                                 {% for item in freeProduct %}
  155.                                                     {% if item['name'] == product.name %}
  156.                                                         <p class="freeProductCart"><i class="fa-solid fa-gift"></i><br/>
  157.                                                             <span class="freeProductCartText">+ {{ item['free'] }} gratuit(s)</span></p>
  158.                                                     {% endif %}
  159.                                                 {% endfor %}
  160.                                             </td>
  161.                                             {# _____SOUS-TOTAL______ #}
  162.                                             <td class="text-center align-middle tdCart tdSousTotal">
  163.                                                 {% if product.discountID != null and product.totalQuantity > 11 %}
  164.                                                     <span class="old-price-cart text-decoration-line-through align-middle">{{ product.totalPricePublic|number_format(2, '.', ',') }}€ (prix public)</span><br/>
  165.                                                     <span class="new-price-cart fw-bold">&#150;{{ truncateDecimal(product.totalRebate, 2) }}€</span>
  166.                                                     <br/> <span class="cart-reduction alert alert-success align-middle fw-bold promotionCartGreen">{{ truncateDecimal(product.PriceRebateInclude, 2) }}€ </span>
  167.                                                 {% elseif product.totalRebate is defined %}
  168.                                                     {% if product.totalRebate != 0.0 or product.totalRebate != null %}
  169.                                                         <span class="old-price-cart text-decoration-line-through align-middle">{{ product.totalPrice|number_format(2, '.', ',') }}€</span><br/>
  170.                                                         <span class="new-price-cart fw-bold">{{ truncateDecimal(product.PriceRebateInclude, 2) }}€</span>
  171.                                                         <br/> <span class="cart-reduction alert alert-success align-middle fw-bold promotionCartGreen">&#150;{{ truncateDecimal(product.totalRebate, 2) }}€ </span>
  172.                                                     {% else %}
  173.                                                         <span class="new-price-cart fw-bold">{{ truncateDecimal(product.PriceRebateInclude, 2) }}€</span>
  174.                                                     {% endif %}
  175.                                                 {% else %}
  176.                                                     {% if product.newRef is defined and product.newRef and product.totalQuantity > 1 %}
  177.                                                         <span class="new-price-cart fw-bold text-decoration-line-through">{{ truncateDecimal(product.totalPrice, 2) }}€</span>
  178.                                                         <br>
  179.                                                         <span class="cart-reduction alert alert-success align-middle fw-bold promotionCartGreen">&#150;2% </span>
  180.                                                         <br>
  181.                                                         <span class="new-price-cart fw-bold">{{ truncateDecimal(product.PriceRebateInclude, 2) }}€</span>
  182.                                                     {% else %}
  183.                                                         <span class="new-price-cart fw-bold">{{ truncateDecimal(product.totalPrice, 2) }}€</span>
  184.                                                     {% endif %}
  185.                                                         {# <span class="new-price-cart fw-bold">{{ truncateDecimal(product.PriceRebateInclude, 2) }}€</span>#}
  186.                                                 {% endif %}
  187.                                             </td>
  188.                                             {# _____DELETE______ #}
  189.                                             <td class="text-center align-middle text-danger tdCart tdDeleteProduct">
  190.                                                 <a class="text-decoration-none text-danger" href="{{ path('cartRemoveProduct', {'productID' : product.productId}) }}">
  191.                                                     <i class="fa-solid fa-xmark"></i>
  192.                                                 </a>
  193.                                             </td>
  194.                                         </tr>
  195.                                         {% set price = 0 %}
  196.                                     {% else %}
  197.                                         {% set price = 0 %}
  198.                                         <tr class="trCart">
  199.                                             {# _____IMAGE______ #}
  200.                                             <td class="align-middle tdImageProduct tdCart"><img src="/img/products/{{ product.image }}" alt="{{ product.name }}" width="80" height="80"></td>
  201.                                             {# _____NOM DU PRODUIT______ #}
  202.                                             <td class="align-middle tdCart">
  203.                                                 {% if product.reference is not empty %}
  204.                                                     <span class="product-cart-ref product-car-reference text-center">{{ product.reference }}</span>
  205.                                                 {% endif %}
  206.                                                 {% if product.nut is not null and product.nut is not empty %}
  207.                                                     <span class="product-cart-ref product-car-nut text-center">{{ product.nut }}</span>
  208.                                                 {% endif %}
  209.                                                 {% if (product.cnk is not empty and product.cnk is not null and userRole == 'Pharmacien') %}
  210.                                                     <span class="product-cart-ref product-car-cnk text-center">{{ product.cnk }}</span>
  211.                                                 {% endif %}
  212.                                                 {% if (product.ean is not empty and product.ean is not null) %}
  213.                                                     <span class="product-cart-ref product-cart-ean text-center">{{ product.ean }}</span>
  214.                                                 {% endif %}
  215.                                                 {% if product.newRef is defined and product.newRef %}
  216.                                                     <span class="product-cart-ref text-center product-cart-newref text-light">nouvelle référence -2%</span>
  217.                                                 {% endif %}
  218.                                                 {% 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 %}
  219.                                                     <span class="product-cart-ref bg-danger product-cart-ean text-center text-light"><i class="fa-solid fa-triangle-exclamation"></i>
  220.                                                         {% if informations[0].AdditionalCompanyInformation[0].companyCountry == "Belgique" %}
  221.                                                             TVA 21
  222.                                                         {% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "France" %}
  223.                                                             TVA 20
  224.                                                         {% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "Luxembourg" %}
  225.                                                             TVA 17
  226.                                                         {% endif %} %</span>
  227.                                                 {% endif %}
  228.                                                 <br/>
  229.                                                 <span class="product-name-cart fw-bold">{{ product.name }}</span>
  230.                                             </td>
  231.                                             {# ______DLU_______ #}
  232.                                             <td class="align-middle tdCart">
  233.                                                 {% if product.dlus is not empty %}
  234.                                                     <span class="dluLasted">{{ product.dlus.dlu|date('d-m-Y') | default('DLUC non disponible') }}</span>
  235.                                                     {% if product.dlus.lotNumber is not null %}
  236.                                                         <br/> <span>Lot : <span class="lotNumberLasted">{{ product.dlus.lotNumber }}</span></span>
  237.                                                     {% endif %}
  238.                                                 {% else %}
  239.                                                     <span class="productCartDlu">DLUC non disponible</span>
  240.                                                 {% endif %}
  241.                                             </td>
  242.                                             {# _____PRIX UNITAIRE______ #}
  243.                                             <td class="text-center align-middle tdCart tdPriceUnite">
  244.                                                 {{ truncateDecimal(product.price, 2) }}€ <br>
  245.                                                 {% if product.newRef is defined and product.newRef %}
  246.                                                     <span class="pourcentRebateUnit">- 2%</span><br>
  247.                                                     <span class="cart-reduction alert alert-success align-middle fw-bold " >{{ truncateDecimal(product.reductionUniteItem,2) }}€ </span>
  248.                                                 {% endif %}
  249.                                             </td>
  250.                                             {# _____QUANTITE______ #}
  251.                                             <td class="text-center align-middle tdCart tdQuantity">
  252.                                                 <div class="quantity-controls d-flex">
  253.                                                     <button type="button" class="btn-quantity-change decrease-quantity" aria-label="Decrease quantity" data-action_name="quantity-decrease" data-id_product="{{ product.id }}">
  254.                                                         <span><i class="fa-solid fa-minus"></i></span>
  255.                                                     </button>
  256.                                                     <div class="quantity-display d-flex justify-content-center align-items-center mx-2">{{ product.totalQuantity }}</div>
  257.                                                     <button type="button" class="btn-quantity-change increase-quantity" aria-label="Increase quantity" data-action_name="quantity-increase" data-id_product="{{ product.id }}">
  258.                                                         <span><i class="fa-solid fa-plus"></i></span>
  259.                                                     </button>
  260.                                                 </div>
  261.                                             </td>
  262.                                             {# _____SOUS-TOTAL______ #}
  263.                                             <td class="text-center align-middle tdCart tdSousTotal">
  264.                                                 {% if product.newRef is defined and product.newRef and product.totalQuantity > 1 %}
  265.                                                     <span class="new-price-cart fw-bold text-decoration-line-through">{{ truncateDecimal(product.totalPrice, 2) }}€</span>
  266.                                                     <br>
  267.                                                     <span class="cart-reduction alert alert-success align-middle fw-bold promotionCartGreen">&#150;2% </span>
  268.                                                     <br>
  269.                                                     <span class="new-price-cart fw-bold">{{ truncateDecimal(product.PriceRebateInclude, 2) }}€</span>
  270.                                                     {% else %}
  271.                                                         <span class="new-price-cart fw-bold">{{ truncateDecimal(product.totalPrice, 2) }}€</span>
  272.                                                 {% endif %}
  273.                                             </td>
  274.                                             {# _____DELETE_____ #}
  275.                                             <td class="text-center align-middle text-danger tdCart tdDeleteProduct">
  276.                                                 <a class="text-decoration-none text-danger" href="{{ path('cartRemoveProduct', {'productID' : product.productId}) }}"><i class="fa-solid fa-xmark"></i></a>
  277.                                             </td>
  278.                                         </tr>
  279.                                     {% endif %}
  280.                                 {% endif %}
  281.                             {% endfor %}
  282.                             {% if phFlyers > 0 %}
  283.                                 <tr class="trCart">
  284.                                     {# _____IMAGE______ #}
  285.                                     <td class="align-middle tdImageProduct tdCart"><img src="/img/products/{{ flyersProduct.image }}" alt="{{ flyersProduct.name }}" width="80" height="80"></td>
  286.                                     {# _____NOM DU PRODUIT______ #}
  287.                                     <td class="align-middle tdCart">
  288.                                         <span class="product-name-cart fw-bold">{{ flyersProduct.name }}</span>
  289.                                     </td>
  290.                                     {# ______DLU_______ #}
  291.                                     <td class="align-middle tdCart"></td>
  292.                                     {# _____PRIX UNITAIRE______ #}
  293.                                     <td class="text-center align-middle tdCart tdPriceUnite">
  294.                                         {{ truncateDecimal(0, 2) }}€
  295.                                     </td>
  296.                                     {# _____QUANTITE______ #}
  297.                                     <td class="text-center align-middle tdCart tdQuantity tdQuantityFlyers">
  298.                                         {{ phFlyers }}
  299.                                     </td>
  300.                                     {# _____SOUS-TOTAL______ #}
  301.                                     <td class="text-center align-middle tdCart tdSousTotal">
  302.                                         <span class="new-price-cart fw-bold">{{ truncateDecimal(0, 2) }}€</span>
  303.                                     </td>
  304.                                     {# _____DELETE_____ #}
  305.                                     <td class="text-center align-middle text-danger tdCart tdDeleteProduct"></td>
  306.                                 </tr>
  307.                             {% endif %}
  308.                             </tbody>
  309.                         </table>
  310.                         
  311.                         <!-- Bouton Recommander -->
  312.                         <div class="mt-3 mb-3">
  313.                             <a href="{{ path('ordersHistory') }}" class="modern-btn-small-primary">
  314.                                 <i class="fa-solid fa-history me-2"></i>
  315.                                 Recommander facilement vos dernières commandes
  316.                             </a>
  317.                         </div>
  318.                         <!-- Option Flyers -->
  319.                         {% if countFaInCart is defined and countFaInCart >= 2 %}
  320.                         <div class="mb-3 flyers-option">
  321.                             <div class="d-flex align-items-center">
  322.                                 <span class="me-3">Souhaitez-vous recevoir les Flyers pH FR gratuits ?</span>
  323.                                 <div class="form-check form-switch">
  324.                                     <input type="checkbox" class="form-check-input" id="wantFlyers" name="wantFlyers" {% if wantFlyers %}checked{% endif %}>
  325.                                     <label class="form-check-label ms-1" for="wantFlyers">{{ wantFlyers ? 'Oui' : 'Non' }}</label>
  326.                                 </div>
  327.                             </div>
  328.                             <div class="small text-success mt-1">
  329.                                 <i class="fa-solid fa-circle-info me-1"></i>
  330.                                 <span>{{ phFlyers }} flyers seront ajoutés gratuitement à votre commande.</span>
  331.                             </div>
  332.                         </div>
  333.                         {% endif %}
  334.                         
  335.                         <hr>
  336.                         
  337.                         <div class="mt-3">
  338.                             <label for="messageNewRef">
  339.                                 <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>
  340.                                 <p class="fw-bolder">Colisage par 2.</p>
  341.                                 <p class="fw-bolder">Remise de 2% supplémentaire.</p>
  342.                             </label>
  343.                             <textarea name="messageNewRef" id="messageNewRef" cols="50" rows="10"></textarea>
  344.                         </div>
  345.                     </div>
  346.                     <!-------- SECTION ORDER -------->
  347.                     <div class="cart-order col-xs-12 col-sm-12 col-md-3 text-center">
  348.                         <div class="text-md-start">
  349.                             <div class="card-body">
  350.                                 <h2 class="title-order-card text-uppercase">Votre commande</h2>
  351.                                 {% if missingItems is defined and missingItems != 0 %}
  352.                                     {% if missingItems >= 48 %}
  353.                                         <p class="text-center mb-2 border border-success border-2">Vous avez atteint la remise maximale.</p>
  354.                                     {% else %}
  355.                                         <p class="text-center mb-2 border border-success border-2">Encore {{ missingItems }} articles pour obtenir la Remise suivante!</p>
  356.                                     {% endif %}
  357.                                     <p class="text-danger">Colisage par 4.</p>
  358.                                 {% endif %}
  359.                                 {% set viewPourcentRebate = false %}
  360.                                 {% for item in carts %}
  361.                                     {% if item.totalRebate is defined  %}
  362.                                         {% if item.actionShock == false %}
  363.                                             {% set viewPourcentRebate = true %}
  364.                                         {% endif %}
  365.                                     {% endif %}
  366.                                 {% endfor %}
  367.                                 {% if viewPourcentRebate and rebate > 0 %}
  368.                                     <h2 class="title-order-card mb-1">avec votre remise de: {{ rebate }}%</h2>
  369.                                 {% endif %}
  370.                                 
  371.                                 <div class="d-flex flex-column">
  372.                                     {%  for rebate in rebates %}
  373.                                         <p class="lh-sm">
  374.                                             Remise {{rebate.pourcentRebate}}% (min {{rebate.min}} unités, panachage possible) 
  375.                                             {% if rebate.excludedProducts is not null %}
  376.                                                 <br/><span style="font-size: 0.9rem;">excepté pour ces références: {{rebate.excludedProducts|join(', ')}}</span>
  377.                                             {%  endif %}
  378.                                         </p>
  379.                                     {% endfor %}
  380.                                     {%  for rebate in specificRebates %}
  381.                                         <p class="lh-sm">
  382.                                             Remise {{rebate.pourcentRebate}}% (min {{rebate.min}} unités d'une même référence) 
  383.                                             {% if rebate.specificProducts is not null %}
  384.                                                 <br/><span style="font-size: 0.9rem;">uniquement pour ces références: {{rebate.specificProducts|join(', ')}}</span>
  385.                                             {%  endif %}
  386.                                         </p>
  387.                                     {% endfor %}
  388.                                 </div>
  389.                               
  390.                                 <ul class="list-group list-group-flush">
  391.                                     <li class="id-command" hidden>
  392.                                         {% if carts[0] is defined %}{{ carts[0].commandNumber }}{% endif %}
  393.                                     </li>
  394.                                     <li class="list-group-item d-flex justify-content-between align-items-center border-0 px-0 pb-0">
  395.                                         <div>
  396.                                             Produits HTVA
  397.                                             {% if informations[0].AdditionalCompanyInformation[0].companyCountry == "Belgique" %}
  398.                                                 6
  399.                                             {% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "France" %}
  400.                                                 5.5
  401.                                             {% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "Luxembourg" %}
  402.                                                 3
  403.                                             {% endif %}
  404.                                             %:
  405.                                         </div>
  406.                                         <span class="total-tva-6">{{ truncateDecimal(carts['TotalPriceProductLowVatHtva'], 2) }}€</span>
  407.                                     </li>
  408.                                     <li class="list-group-item d-flex justify-content-between align-items-center border-0 px-0 pb-0">
  409.                                         <div>
  410.                                             Produits HTVA
  411.                                             {% if informations[0].AdditionalCompanyInformation[0].companyCountry == "Belgique" %}
  412.                                                 21
  413.                                             {% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "France" %}
  414.                                                 20
  415.                                             {% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "Luxembourg" %}
  416.                                                 17
  417.                                             {% endif %}
  418.                                             %:
  419.                                         </div>
  420.                                         <span class="total-tva-6">{{ truncateDecimal(carts['TotalPriceProductHighVatHtva'], 2) }}€</span>
  421.                                     </li>
  422.                                     <li class="list-group-item d-flex justify-content-between align-items-start border-0 px-0 mb-1">
  423.                                         <div>
  424.                                             <strong>Total (HTVA):</strong>
  425.                                         </div>
  426.                                         <span><strong class="price-total-remise-tvac">{{ truncateDecimal(carts['totalPriceAllProductHtva'], 2) }}€</strong></span>
  427.                                     </li>
  428.                                     <li class="list-group-item d-flex justify-content-between align-items-center border-0 px-0 pb-0">
  429.                                         <div>
  430.                                             TVA
  431.                                             {% if informations[0].AdditionalCompanyInformation[0].companyCountry == "Belgique" %}
  432.                                                 6
  433.                                                 {% set tvauser = 6 %}
  434.                                             {% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "France" %}
  435.                                                 5.5
  436.                                                 {% set tvauser = 5.5 %}
  437.                                             {% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "Luxembourg" %}
  438.                                                 3
  439.                                                 {% set tvauser = 3 %}
  440.                                             {% endif %}
  441.                                             %:
  442.                                         </div>
  443.                                         <span class="total-tva-6">{{ truncateDecimal(carts['TotalPriceProductLowVatTvac'], 2) }}€</span>
  444.                                     </li>
  445.                                     <li class="list-group-item d-flex justify-content-between align-items-center border-0 px-0 pb-0">
  446.                                         <div>
  447.                                             TVA
  448.                                             {% if informations[0].AdditionalCompanyInformation[0].companyCountry == "Belgique" %}
  449.                                                 21
  450.                                                 {% set tvauser = 21 %}
  451.                                             {% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "France" %}
  452.                                                 20
  453.                                                 {% set tvauser = 20 %}
  454.                                             {% elseif informations[0].AdditionalCompanyInformation[0].companyCountry == "Luxembourg" %}
  455.                                                 17
  456.                                                 {% set tvauser = 17 %}
  457.                                             {% endif %}
  458.                                             %:
  459.                                         </div>
  460.                                         <span class="total-tva-6">{{ truncateDecimal(carts['TotalPriceProductHighVatTvac'], 2) }}€</span>
  461.                                     </li>
  462.                                     {% if freeTransport %}
  463.                                         <li class="list-group-item d-flex justify-content-between align-items-start border-0 px-0 mb-3">
  464.                                             <div>
  465.                                                 <strong>Prix total remisé (TVAC):</strong>
  466.                                             </div>
  467.                                             <span><strong class="price-total-remise-tvac">{{ truncateDecimal(carts['totalPriceTvacWithRebate'], 2) }}€</strong></span>
  468.                                         </li>
  469.                                     {% else %}
  470.                                         <li class="list-group-item d-flex justify-content-between align-items-start border-0 px-0 mb-3">
  471.                                             <div>
  472.                                                 Frais de livraison:
  473.                                             </div>
  474.                                             <span class="price-delivery">{{ costDelivery }}€</span>
  475.                                         </li>
  476.                                         <li class="list-group-item d-flex justify-content-between align-items-start border-0 px-0 mb-3">
  477.                                             <div>
  478.                                                 <strong>Prix total remisé (TVAC):</strong>
  479.                                             </div>
  480.                                             <span><strong class="price-total-remise-tvac">{{ truncateDecimal(carts['totalPriceTvacWithRebate'] + costDelivery, 2) }}€</strong></span>
  481.                                         </li>
  482.                                     {% endif %}
  483.                                     <li class="list-group-item d-flex flex-column justify-content-between align-items-center px-0 text-delivery">
  484.                                         {% if freeTransport %}
  485.                                             Vous avez atteint le FRANCO de 300€, livraison gratuite.
  486.                                         {% else %}
  487.                                             <p>Les coûts de livraison sont de: {{ costDelivery }}€</p>
  488.                                             <p style="font-weight: bold;">FRANCO de 300€</p>
  489.                                         {% endif %}
  490.                                     </li>
  491.                                 </ul>
  492.                             </div>
  493.                         </div>
  494.                         <hr/>
  495.                         <!---------- SECTION ADRESSE LIVRAISON ---------->
  496.                         <h3 class="title-order-billing mt-5 text-uppercase">Adresse de Livraison</h3>
  497.                         {% if address != true %}
  498.                             <!-- Adress choice delivery -->
  499.                             <div class="choice-address-delivery card alert alert-primary">
  500.                                 <p class="text-uppercase text-center my-0"><i class="fa-solid fa-plus"></i>
  501.                                     Nouvelle adresse de livraison
  502.                                 </p>
  503.                             </div>
  504.                         {% endif %}
  505.                         {% if address %}
  506.                             {% for myAddress in address %}
  507.                                 {% if loop.first %}
  508.                                     <div id="delivery-address"
  509.                                          class="first-address-delivery actived-address open-modal-block">
  510.                                         <div class="card mt-3 mb-0">
  511.                                             <div class="home-address hovered-block">
  512.                                                 <i class="fa-solid fa-truck-fast"></i>
  513.                                                 <div class="informations-address">
  514.                                                     <span class="id-address" hidden>{{ myAddress.id }}</span>
  515.                                                     <span class="companyName-address">{{ myAddress.companyName }}</span>
  516.                                                     <span class="firstname-address">{{ myAddress.firstName }}</span>
  517.                                                     <span class="name-address">{{ myAddress.name }}</span><br/>
  518.                                                     <span class="street-address">{{ myAddress.address }}</span>,
  519.                                                     <span class="cp-address">{{ myAddress.postal }}</span>
  520.                                                     <span class="town-address">{{ myAddress.town }}</span><br/>
  521.                                                     <span class="country-address">{{ myAddress.country }}</span><br/>
  522.                                                     <span class="tel-address">{{ myAddress.phoneNumber }}</span>
  523.                                                 </div>
  524.                                             </div>
  525.                                         </div>
  526.                                     </div>
  527.                                 {% endif %}
  528.                                 {% if loop.last %}
  529.                                     <div class="checkbox-order text-left mb-5 mt-2">
  530.                                         <p class="new-order-delivery"><i class="fa-solid fa-angle-right"></i>
  531.                                             Choisir une autre adresse de livraison
  532.                                         </p>
  533.                                     </div>
  534.                                 {% endif %}
  535.                             {% endfor %}
  536.                         {% endif %}
  537.                         <div class="mb-3">
  538.                             <span>Adresse de facturation</span></br>
  539.                             <span>identique livraison?</span>
  540.                             <input type="checkbox" name="adresse_check" class="adresse_check" id="adresse_check">
  541.                         </div>
  542.                         {% if joker %}
  543.                             <span>Jokers restants: <span class="text-success joker_numb">{{ jokerNumber }}</span></span>
  544.                             <label for="check_joker">Transport gratuit. Utiliser un joker.</label>
  545.                             <input type="checkbox" name="joker" class="check_joker" id="check_joker">
  546.                             <span id="jokerMessage"></span>
  547.                         {% endif %}
  548.                         <!---------- ADRESSE DE FACTURATION ---------->
  549.                         <div class="global_div_facturation">
  550.                             <h3 class="title-order-billing billing-title text-uppercase mt-1">
  551.                                 Adresse de Facturation
  552.                             </h3>
  553.                             <!-- ADDRESS CHOICE DELIVERY -->
  554.                             {% if address != true %}
  555.                                 <div class="choice-address-delivery card alert alert-primary">
  556.                                     <p class="text-uppercase text-center my-0"><i class="fa-solid fa-plus"></i>
  557.                                         Nouvelle adresse de facturation
  558.                                     </p>
  559.                                 </div>
  560.                             {% endif %}
  561.                             {% if address %}
  562.                                 {% for myAddress in address %}
  563.                                     {% if loop.first %}
  564.                                         <div id="delivery-billing"
  565.                                              class="first-address-delivery open-modal-block-change">
  566.                                             <div class="card mt-3">
  567.                                                 <div class="home-address home-address-billing hovered-block">
  568.                                                     <i class="fa-solid fa-file-pen"></i>
  569.                                                     <div class="informations-address">
  570.                                                         <span class="id-address" hidden>{{ myAddress.id }}</span>
  571.                                                         <span class="companyName-address">{{ myAddress.companyName }}</span>
  572.                                                         <span class="firstname-address">{{ myAddress.firstName }}</span>
  573.                                                         <span class="name-address">{{ myAddress.name }}</span><br/>
  574.                                                         <span class="street-address">{{ myAddress.address }}</span>,
  575.                                                         <span class="cp-address">{{ myAddress.postal }}</span>
  576.                                                         <span class="town-address">{{ myAddress.town }}</span><br/>
  577.                                                         <span class="country-address">{{ myAddress.country }}</span><br/>
  578.                                                         <span class="tel-address">{{ myAddress.phoneNumber }}</span>
  579.                                                     </div>
  580.                                                 </div>
  581.                                             </div>
  582.                                         </div>
  583.                                     {% endif %}
  584.                                     {% if loop.last %}
  585.                                         <div class="checkbox-order text-left mb-5 mt-2">
  586.                                             <p class="new-order-billing"><i class="fa-solid fa-angle-right"></i>
  587.                                                 Choisir une autre adresse de facturation
  588.                                             </p>
  589.                                         </div>
  590.                                     {% endif %}
  591.                                 {% endfor %}
  592.                             {% endif %}
  593.                         </div>
  594.                         <div>
  595.                             <button class="btn btn-success btn-send-command mb-3 ">Envoyer ma commande</button>
  596.                         </div>
  597.                     </div>
  598.                 </div>
  599.                 <!-- MODAL ADRESSES LIVRAISON/FACTURATION -->
  600.                 {% block modal_content %}
  601.                     {% include "modalAddress/modal_address.html.twig" %}
  602.                 {% endblock %}
  603.                 <!--END MODAL-->
  604.             </div>
  605.         </div>
  606.     </div>
  607. {% endblock %}
  608. {% block javascripts %}
  609.     <script>
  610.         $(document).ready(function () {
  611.             var totalJokers = {{ jokerNumber }};
  612.             $(document).on('click', '.btn-quantity-change', function(){
  613.                 var move = $(this).data("action_name");
  614.                 var id_product = $(this).data('id_product');
  615.                 $.ajax({
  616.                     url: "{{ path('addtocartfromcart') }}",
  617.                     data: {
  618.                         'id_product': id_product,
  619.                         'move' : move
  620.                     },
  621.                     dataType: "json",
  622.                     success: function (data) {
  623.                         location.reload();
  624.                     }
  625.                 });
  626.             })
  627.             $('#check_joker').change(function() {
  628.                 if ($(this).prop('checked')) {
  629.                     totalJokers--; // décrémenter le nombre de jokers lorsqu'il est utilisé
  630.                     $('.joker_numb').empty().html(totalJokers);
  631.                     $('#jokerMessage').html("Un joker utilisé, il vous reste <span class='text-success'>" + totalJokers + "</span> joker(s) cette année.");
  632.                     $('.text-delivery').html("Livraison gratuite lors de l'utilisation du joker.");
  633.                 } else {
  634.                     totalJokers++;
  635.                     $('.joker_numb').empty().html(totalJokers);
  636.                     $('#jokerMessage').text("");
  637.                     $('.text-delivery').html("Les coûts de livraison vous seront communiqués avant la livraison.");
  638.                 }
  639.             });
  640.             
  641.             // Gestion de la case à cocher des flyers
  642.             $('#wantFlyers').change(function() {
  643.                 // Mise à jour du label immédiatement pour feedback visuel
  644.                 $(this).next('label').text($(this).prop('checked') ? 'Oui' : 'Non');
  645.                 
  646.                 // Appel AJAX pour mettre à jour la préférence côté serveur
  647.                 $.ajax({
  648.                     url: "{{ path('toggleFlyers') }}",
  649.                     type: "GET",
  650.                     success: function() {
  651.                         // Rechargement de la page pour refléter les changements
  652.                         location.reload();
  653.                     }
  654.                 });
  655.             });
  656.             $(document).on('click', '.btn-send-command', function () {
  657.                 $(this).attr('disabled', true);
  658.                 // Récupérer les valeurs de tous les éléments avec la classe "lotNumberLasted"
  659.                 var lotNumbers = $('.lotNumberLasted').map(function() {
  660.                     return $(this).html(); // Vous pouvez utiliser .text() à la place de .html() si vous n'avez que du texte
  661.                 }).get(); // Convertir le résultat en un tableau JavaScript
  662.                 $.ajax({
  663.                     // type: "POST",
  664.                     url: "{{ path('cartSend') }}",
  665.                     data: {
  666.                         'totalPriceWithVat': $('.price-total-remise-tvac').html(),
  667.                         'totalRemise': $('.price-total-remise').html(),
  668.                         'totalPriceProductLowVatHtva': '{{ carts['TotalPriceProductLowVatHtva'] }}',
  669.                         'totalPriceProductHighVatHtva': '{{ carts['TotalPriceProductHighVatHtva'] }}',
  670.                         'totalPriceProductLowVatTvac': '{{ carts['TotalPriceProductLowVatTvac'] }}',
  671.                         'totalPriceProductHighVatTvac': {{ carts['TotalPriceProductHighVatTvac'] }},
  672.                         'totalPriceAllProductHtva': {{ carts['totalPriceAllProductHtva'] }},
  673.                         'totalPriceTvacWithRebate': {{ carts['totalPriceTvacWithRebate'] }},
  674.                         'idCommande': $('.id-command').html(),
  675.                         'idUser': '{{ user.id }}',
  676.                         'total-price-tvac-no-reduct': $('.total-price-tvac-no-reduct').html(),
  677.                         'deliveryAddress': $('#delivery-address .id-address').html(),
  678.                         'deliveryBilling': $('#delivery-billing .id-address').html(),
  679.                         'addressCheck': $('#adresse_check').is(':checked'),
  680.                         'joker': $('.check_joker').is(':checked'),
  681.                         'rebatePourcent': '{{ rebate }}',
  682.                         'lotNumbers': lotNumbers,
  683.                         'messageNewRef': $('#messageNewRef').val()
  684.                     },
  685.                     dataType: "json",
  686.                     success: function (data) {
  687.                         console.log(data)
  688.                         if (data === 'profile') {
  689.                             location.href = '/account/profile';
  690.                         } else {
  691.                             location.href = '/';
  692.                         }
  693.                     }
  694.                 });
  695.             });
  696.             // enlève le module livraison si facturation identique livraison.
  697.             $(document).on('change', '.adresse_check', function () {
  698.                 if ($(this).is(':checked')) {
  699.                     $('.global_div_facturation').hide();
  700.                 } else {
  701.                     $('.global_div_facturation').show();
  702.                 }
  703.             });
  704.             //OUVRE LE MODAL POUR CHOISIR UNE ADRESSE
  705.             $('.my-cart .open-modal-block ').click(function () {
  706.                 $('#addressModal').modal('show');
  707.             });
  708.             //CHANGE L'ADRESSE PAR L'ADRESSE SELECTIONEE DANS LE MODAL
  709.             $('#addressModal .modal-body .card').click(function () {
  710.                 $('.modal-body .card').removeClass('address-active');
  711.                 $(this).addClass('address-active');
  712.                 let selectedAddress = $('.modal-body .address-active');
  713.                 // Vérifie si une adresse est sélectionnée et change dans le template correspondant
  714.                 let newAddress = selectedAddress.html();
  715.                 if (selectedAddress.length > 0) {
  716.                     if ($('.body-modal-billing').length > 0) {
  717.                         $('#delivery-billing').html(newAddress);
  718.                     } else {
  719.                         $('#delivery-address').html(newAddress);
  720.                     }
  721.                 }
  722.                 $('#addressModal').modal('hide');
  723.             });
  724.             //CHANGE LE TEMPLATE CLIQUE LIVRAISON
  725.             $('.new-order-delivery, .open-modal-block').click(function () {
  726.                 // Modifie le texte du h1 du modal
  727.                 $('#addressModal .modal-title').text('Choisir une adresse de livraison');
  728.                 $('#addressModal').modal('show');
  729.             });
  730.             //CHANGE LE TEMPLATE CLIQUE FACTURATION
  731.             $('.new-order-billing, .open-modal-block-change').click(function () {
  732.                 // Ajoute la classe au modal body
  733.                 $('.modal-body').addClass('body-modal-billing');
  734.                 // Modifie le texte du h1 du modal
  735.                 $('#addressModal .modal-title').text('Choisir une adresse de facturation');
  736.                 $('#addressModal').modal('show');
  737.                 // Enlève la classe du modal body lorsque le modal se ferme
  738.                 $('#addressModal').on('hidden.bs.modal', function () {
  739.                     $('.modal-body').removeClass('body-modal-billing');
  740.                 });
  741.                 $('#addressModal').modal('hide');
  742.             });
  743.         });
  744.     </script>
  745. {% endblock %}