templates/front/command/basket.html.twig line 1

Open in your IDE?
  1. {% extends 'base_front.html.twig' %}
  2. {% block meta %}
  3.     <title>Mon panier</title>
  4.     <meta name="description" content="{{ products|length }} produits pour le moment">
  5. {% endblock %}
  6. {% block style %}
  7.     <style>
  8.         .indicationSupp:hover {
  9.             
  10.         }
  11.         .inputQtyOpt {
  12.             width: 63px;
  13.             height: 39px;
  14.             padding: 0 5px;
  15.             text-align: center;
  16.             background-color: transparent;
  17.             border: 1px solid #efefef;
  18.         }
  19.         .imgOptModal {
  20.             height:50px;
  21.             border-radius:2px
  22.         }
  23.         .modifProdSess {
  24.             color: white !important;
  25.             display: flex;
  26.             align-items: center;
  27.         }
  28.         {# css loading... #}
  29.         #MyLoading {
  30.             visibility: hidden;
  31.         }
  32.         #MyLoading.MyShow {
  33.             visibility: visible;
  34.         }
  35.         @media screen and (max-width: 576px) {
  36.             .modifProdSess {
  37.                 padding: 8px 7px;
  38.                 font-size: 7px;
  39.             }
  40.             .indicationSupp {
  41.                 padding: 10px 15px;
  42.             }
  43.         }
  44.         {# modadl option #}
  45.         @media screen and (min-width: 800px) {    
  46.             .myWidth {
  47.                 max-width: 800px;
  48.             }
  49.         }
  50.         {# choice option #}
  51.         .labold {
  52.             font-weight: 500;
  53.             font-size: 18px;
  54.         }
  55.         .mt9 {
  56.             margin-top: 9px;
  57.         }
  58.         .myPadding {
  59.             padding: 8px 0px;
  60.         }
  61.     </style>
  62. {% endblock %}
  63. {% block body %}
  64.     <!-- Modal -->
  65.     {# Modal modif groupe d'option #}
  66.     <div class="modal fade" id="modalOptionGP" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
  67.         <div class="modal-dialog myWidth" role="document">
  68.             <div class="modal-content">
  69.                 {# <form action=""> #}
  70.                     <div class="modal-header">
  71.                         <h5 class="modal-title" id="">Modifier les groupes d'options</h5>
  72.                         <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  73.                             <span aria-hidden="true">&times;</span>
  74.                         </button>
  75.                     </div>
  76.                     <div class="modal-body">
  77.                         <div class="row" id="valeurgropOption">
  78.                             {# <input type="hidden" id="id_optionmodal">
  79.                             <div class="col-lg-6 col-12" >
  80.                                 <div id="optionsimage">
  81.                                     {# <img src="{{ asset(constant('App\\Services\\File::IMAGE_PRODUCT_DIR') ~ product.photos.toArray()[0].url) }}" alt=""> #}
  82.                                 {# </div>
  83.                             </div>  #}
  84.                             
  85.                             {# <div class="col-lg-6 col-12"  style="display: block"> #}
  86.                                 {# <div class="row">
  87.                                     <div class="col-8">
  88.                                         <label for="" class="labold">Couleur</label>
  89.                                         <div class="custom-checkbox myPadding" style="position: relative">
  90.                                             <input type="checkbox" name="" id="vert" class="custom-control-input">
  91.                                             <label for="vert" class="custom-control-label" style="margin-left: 25px;">Vert (3€)</label>
  92.                                         </div>
  93.                                         <div class="custom-checkbox myPadding" style="position: relative">
  94.                                             <input type="checkbox" name="" id="rouge" class="custom-control-input">
  95.                                             <label for="rouge" class="custom-control-label" style="margin-left: 25px;">Rouge (4€)</label>
  96.                                         </div>
  97.                                         <div class="custom-checkbox myPadding" style="position: relative">
  98.                                             <input type="checkbox" name="" id="bleu" class="custom-control-input">
  99.                                             <label for="bleu" class="custom-control-label" style="margin-left: 25px;">Bleu (6€)</label>
  100.                                         </div>
  101.                                     </div>
  102.                                     <div class="col-4">
  103.                                         <label for="qt1" class="mt9">Quantité</label>
  104.                                         <input type="number" name="" min="0" id="" class="form-control">
  105.                                         <input type="number" name="" min="0" id="" class="form-control">
  106.                                         <input type="number" name="" min="0" id="" class="form-control">
  107.                                     </div>
  108.                                 </div><br>
  109.                                 <div class="row">
  110.                                     <div class="col-8">
  111.                                         <label class="labold" for="">Taille</label>
  112.                                         <select name="" id="" class="form-control wide" style="display: block !important;">    
  113.                                             <option value="">M (6€)</option>
  114.                                             <option value="">L (8€)</option>
  115.                                             <option value="">XL (10€)</option>
  116.                                         </select>    
  117.                                     </div>
  118.                                     <div class="col-4">
  119.                                         <label for="qt1" class="mt9">Quantité</label>
  120.                                         <input type="number" name="" min="0" id="" class="form-control">
  121.                                     </div>
  122.                                 </div><br>
  123.                                 <div class="row">
  124.                                     <div class="col-8">
  125.                                         <label class="labold" for="">Type tissu</label>
  126.                                         <select name="" id="" class="form-control wide" style="display: block !important;">
  127.                                             <option value="">Semi-cotton (2€)</option>
  128.                                             <option value="">Cotton (4€)</option>
  129.                                             <option value="">t-shirt rétréci (5€)</option>
  130.                                         </select>
  131.                                     </div>
  132.                                     <div class="col-4">
  133.                                         <label for="qt1" class="mt9">Quantité</label>
  134.                                         <input type="number" name="" min="0" id="" class="form-control">
  135.                                     </div>
  136.                                 </div><br> #}
  137.                             {# </div> #}
  138.                         </div>
  139.                     </div>
  140.                     {# {% endfor %}
  141.                     {% endif %} #}
  142.                     <div class="modal-footer">
  143.                         <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
  144.                         <button type="submit" class="btn btn-primary" id="" onclick="validechoiModalGroupoption()">Ok</button>
  145.                     </div>
  146.                 {# </form> #}
  147.             </div>
  148.         </div>
  149.     </div>
  150.     {# Fin Modal modif groupe d'option #}
  151.     {# Modal faire part #}
  152.     <div class="modal fade" id="modifAchatFairePart" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
  153.     {% set idSessOpt = app.session.get('idProduit') %}
  154.     
  155.         <div class="modal-dialog" role="document" style="max-width: 700px">
  156.             <div class="modal-content">
  157.                 <form action="{{path('update_option')}}" method="POST">
  158.                     <div class="modal-header">
  159.                         <h5 class="modal-title" id="exampleModalLongTitle">Modifier les options</h5>
  160.                         <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  161.                             <span aria-hidden="true">&times;</span>
  162.                         </button>
  163.                     </div>
  164.                     <div class="modal-body">
  165.                         {# <span class="font-weight-bold">Options disponibles :</span><span id="MyLoadingFP"> Chargement en cours...</span> #}
  166.                         <div class="containerOptionFP pl-3 row">
  167.                                 
  168.                             <div class="col-lg-5 col-12">
  169.                                 <input type="hidden" id="id_produit">
  170.                                 <input type="hidden" id="price_produit">
  171.                                 <input type="hidden" id="qte_produit">
  172.                                 <div id="tousOptions"></div>
  173.                             </div>
  174.                             <div class="col-lg-7 col-12">
  175.                                <div class="m-info">Si vous souhaitez ajouter une option différente de celle d'avant, cochez votre choix et modifiez-le si nécessaire</div>
  176.                                <div class="forme_options" style="display: none !important">
  177.                                 <form action="">
  178.                                     <input type="hidden" id="id_optionFP">
  179.                                     <input type="hidden" id="name_optionFP">
  180.                                     <input type="hidden" id="image_optionFP">
  181.                                     <div class="optionFP_color">
  182.                                         <label for="optionFP_color">Couleur</label>
  183.                                         <select name="" id="optionFP_color" class="wide form-control">
  184.                                         </select>
  185.                                     </div>
  186.                                     <div class="optionFP_format">
  187.                                         <label for="optionFP_format">Format</label>
  188.                                         <select name="" id="optionFP_format" class="wide form-control">
  189.                                         </select>
  190.                                     </div>
  191.                                     <div class="optionFP_finition">
  192.                                         <label for="optionFP_finition">Finition</label>
  193.                                         <select name="" id="optionFP_finition" class="wide form-control">    
  194.                                         </select>
  195.                                     </div>
  196.                                     <div class="optionFP_papier">
  197.                                         <label for="optionFP_papier">Papier</label>
  198.                                         <select name="" id="optionFP_papier" class="wide form-control">
  199.                                         </select>
  200.                                     </div>
  201.                                     <div class="optionFP_etiquette">
  202.                                         <label for="optionFP_etiquette">Etiquette</label>
  203.                                         <select name="" id="optionFP_etiquette" class="wide form-control">
  204.                                         </select>
  205.                                     </div>
  206.                                     <div class="optionFP_ruban">
  207.                                         <label for="optionFP_ruban">Ruban</label>
  208.                                         <select name="" id="optionFP_ruban" class="wide form-control">
  209.                                         </select>
  210.                                     </div>
  211.                                     <div class="optionFP_quantite">
  212.                                         <label for="optionFP_quantite">Quantite</label>
  213.                                         <select name="" id="optionFP_quantite" class="wide form-control">
  214.                                         </select>
  215.                                     </div>
  216.                                     <div class="validerModifFP mt-3">
  217.                                         <button class="btn btn-secondary" type="button" onclick="Anulleroption()">Annuler</button>
  218.                                         <button class="btn btn-primary" type="button" onclick="validechoioption()">Valider</button>
  219.                                     </div>
  220.                                 </form>
  221.                             </div>
  222.                             </div>
  223.                         </div>
  224.                         {# {% endset %} #}
  225.                     <!-- form modifsession prod -->
  226.                     </div>
  227.                     <div class="modal-footer">
  228.                         <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
  229.                         <button type="submit" class="btn btn-primary" onclick="validechoiModaloption()">Modifier</button>
  230.                     </div>
  231.                 </form>
  232.             </div>
  233.         </div>
  234.     </div>
  235.     {# Fin modal faire Part #}    
  236.     <div class="modal fade" id="modifAchatProd" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
  237.     {% set idSessOpt = app.session.get('idProduit') %}
  238.     
  239.         <div class="modal-dialog" role="document">
  240.             <div class="modal-content">
  241.                 <form action="{{path('update_option')}}" method="POST">
  242.                     <div class="modal-header">
  243.                         <h5 class="modal-title" id="exampleModalLongTitle">Modifier les options</h5>
  244.                         <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  245.                             <span aria-hidden="true">&times;</span>
  246.                         </button>
  247.                     </div>
  248.                     <div class="modal-body">
  249.                     <!-- form modifsession prod -->
  250.                         {# <div class="form-group">
  251.                             <label for="quantity_product">Quantité</label><br>
  252.                             <div class="quantity buttons_added">
  253.                                 <input type="button" value="-" class="minus">
  254.                                 <input id="quantity_product" type="number" step="1" min="1" max="" name="quantity" value="1" title="Qty" class="input-text qty text" size="4" pattern="" inputmode="">
  255.                                 <input type="button" value="+" class="plus">
  256.                             </div>
  257.                         </div> #}
  258.                         <span class="font-weight-bold">Options disponibles :</span><span id="MyLoading"> Chargement en cours...</span>
  259.                         <div class="containerOption pl-3 row">
  260.                             <div class="oneOption col-12 row">
  261.                                 <div class="col-8">
  262.                                     <div class="row">
  263.                                         <div class="col-4">
  264.                                             <img src="/upload/produits/vernis-a-ongles-laques-fuchsia-fiesta-1-62a2e00ab1b53.jpeg" style="height:50px;border-radius:2px">
  265.                                         </div>
  266.                                         <div class="col-4">
  267.                                             <img src="/upload/produits/vernis-a-ongles-laques-fuchsia-fiesta-1-62a2e00ab1b53.jpeg" style="height:50px;border-radius:2px">
  268.                                         </div>
  269.                                     </div>
  270.                                     <div class="custom-checkbox" style="position: relative">
  271.                                         <input type="checkbox" data-price="" name="" value="" class="custom-control-input" id="checkbo">
  272.                                         <label class="custom-control-label" for="checkbo">
  273.                                             <strong style="margin-left: 31px;">10 €</strong>
  274.                                             <span>-
  275.                                             Name option</span>
  276.                                             </label>
  277.                                     </div>
  278.                                 </div>
  279.                                 <div class="col-4">
  280.                                     <div style="height:36px"></div>
  281.                                     <input type="number" name="" id="" class="inputQtyOpt" min="1" value="1"/>
  282.                                 </div>
  283.                             </div>
  284.                             <div class="oneOption col-12 row">
  285.                                 <div class="col-8">
  286.                                     <div class="row">
  287.                                         <div class="col-4">
  288.                                             <img src="/upload/produits/vernis-a-ongles-laques-fuchsia-fiesta-1-62a2e00ab1b53.jpeg" style="height:50px;border-radius:2px">
  289.                                         </div>
  290.                                         <div class="col-4">
  291.                                             <img src="/upload/produits/vernis-a-ongles-laques-fuchsia-fiesta-1-62a2e00ab1b53.jpeg" style="height:50px;border-radius:2px">
  292.                                         </div>
  293.                                     </div>
  294.                                     <div class="custom-checkbox" style="position: relative">
  295.                                         <input type="checkbox" data-price="" name="" value="" class="custom-control-input" id="checkbo1">
  296.                                         <label class="custom-control-label" for="checkbo1">
  297.                                             <strong style="margin-left: 31px;">10 €</strong>
  298.                                             -
  299.                                             Name option</label>
  300.                                     </div>
  301.                                 </div>
  302.                                 <div class="col-4">
  303.                                     <div style="height:36px"></div>
  304.                                     <input type="number" name="" id="" class="inputQtyOpt" min="1" value="1"/>
  305.                                 </div>
  306.                             </div>
  307.                             <div class="oneOption col-12 row">
  308.                                 <div class="col-8">
  309.                                     <div class="row">
  310.                                         <div class="col-4">
  311.                                             <img src="/upload/produits/vernis-a-ongles-laques-fuchsia-fiesta-1-62a2e00ab1b53.jpeg" style="height:50px;border-radius:2px">
  312.                                         </div>
  313.                                         <div class="col-4">
  314.                                             <img src="/upload/produits/vernis-a-ongles-laques-fuchsia-fiesta-1-62a2e00ab1b53.jpeg" style="height:50px;border-radius:2px">
  315.                                         </div>
  316.                                     </div>
  317.                                     <div class="custom-checkbox" style="position: relative">
  318.                                         <input type="checkbox" data-price="" name="" value="" class="custom-control-input" id="checkbo2">
  319.                                         <label class="custom-control-label" for="checkbo2">
  320.                                             <strong style="margin-left: 31px;">10 €</strong>
  321.                                             -
  322.                                             Name option</label>
  323.                                     </div>
  324.                                 </div>
  325.                                 <div class="col-4">
  326.                                     <div style="height:36px"></div>
  327.                                     <input type="number" name="" id="" class="inputQtyOpt" min="1" value="1"/>
  328.                                 </div>
  329.                             </div>
  330.                         </div>
  331.                         {# {% endset %} #}
  332.                     <!-- form modifsession prod -->
  333.                     </div>
  334.                     <div class="modal-footer">
  335.                         <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
  336.                         <button type="submit" class="btn btn-primary">Modifier</button>
  337.                     </div>
  338.                 {# {% endfor %}
  339.             {% endif %} #}
  340.                 </form>
  341.             </div>
  342.         </div>
  343.     </div>
  344.     
  345.     <!-- Modal -->
  346.     <div class="content mt-5 mb-5" style="margin-bottom:100px!important">
  347.         <div class="container">
  348.             <div class="row mb-5">
  349.                 <div class="tab-pane fade active show" id="allguest" role="tabpanel" aria-labelledby="allguest-tab" style="width:100%">
  350.                     <div class="card-body row justify-content-between">
  351.                         <h3>Mon panier ({{ products|length }}
  352.                             produit
  353.                             {% if products|length > 1 %}s
  354.                             {% endif %})</h3>
  355.                         <a href="{{path('pdf_generate')}} " class="btn btn-primary float-right">Télécharger mon devis</a>
  356.                     </div>
  357.                     <div class="table-responsive" style="width:100%">
  358.                         <table class="table mt-4">
  359.                             <thead>
  360.                                 <tr>
  361.                                     <th class="wedding-budget-event">Designation</th>
  362.                                     <th class="wedding-budget-estimate">Aperçu</th>
  363.                                     <th class="wedding-budget-estimate">Prix à l'unité</th>
  364.                                     <th class="wedding-budget-actual">Quantité</th>
  365.                                     <th class="wedding-budget-paid">Total produit</th>
  366.                                     <th class="wedding-budget-paid"></th>
  367.                                 </tr>
  368.                             </thead>
  369.                             <tbody>
  370.                                 {% if pack %}
  371.                                     <tr>
  372.                                         <td>{{ pack.name }}</td>
  373.                                         <td><img src="{{ asset(constant('App\\Services\\File::IMAGE_PRODUCT_DIR')) ~ pack.image }}" style="height:50px;border-radius:2px"></td>
  374.                                         <td>
  375.                                             <span class="total-amount">{{ pack.price|number_format(2, '.') }}€</span>
  376.                                         </td>
  377.                                         <td>1</td>
  378.                                         <td>
  379.                                             <span class="total-amount">{{ pack.price|number_format(2, '.') }}€</span>
  380.                                         </td>
  381.                                         <td class="paid-total">
  382.                                             <a href="{{ path('front_my_basket_remove_pack', {'id': pack.id}) }}" class="btn btn-rounded btn-default">Supprimer du panier</a>
  383.                                         </td>
  384.                                     </tr>
  385.                                 {% endif %}
  386.                                 {% set TotalPriceProduct = 0 %}
  387.                                 {% set totOpt = 0 %}
  388.                                 {% set totGpOpt = 0 %}
  389.                                 {% for product in products %}
  390.                                     {% set optionObjectByProd = filter_service.getProductOptionByProduit(product.product) %}
  391.                                     
  392.                                     {# Product added #}
  393.                                         <tr class="border-bottom" style="border-top: 1px solid #dee2e6 !important;"> 
  394.                                         <td>{{ product.product.name }}
  395.                                             {% set isClothing = null %}
  396.                                             {% for subcategory in product.product.subCategories %}
  397.                                                 {% if subcategory.isClothing %}
  398.                                                     {% set isClothing = true %}
  399.                                                 {% endif %}
  400.                                             {% endfor %}
  401.                                             {% if isClothing %}
  402.                                                 <br><strong>Taille :
  403.                                                     {{ product.size }}</strong>
  404.                                             {% endif %}
  405.                                             {% set isColor = null %}
  406.                                             {% for subcategory in product.product.subCategories %}
  407.                                             
  408.                                                 {% if subcategory.isColor %}
  409.                                                     {% set isColor = true %}
  410.                                                 {% endif %}
  411.                                             {% endfor %}
  412.                                             {% if isColor %}
  413.                                                 <br><strong>Couleur :
  414.                                                     {{ product.color }}</strong>
  415.                                             {% endif %}
  416.                                         </td>
  417.                                         <td>
  418.                                             {% if product.product.photos.first != false %}
  419.                                                 <img src="{{ asset(constant('App\\Services\\File::IMAGE_PRODUCT_DIR')) ~ product.product.photos.first.url }}" style="height:50px;border-radius:2px">
  420.                                             {% else %}
  421.                                                 <img src="{{ asset('images/vecteezy_vector-gear-logo-design-with-multi-colors-range_6172776.jpg') }}" style="height:50px;border-radius:2px">
  422.                                             {% endif %}
  423.                                         </td>
  424.                                         {% if product.promo %}
  425.                                             {% set ProductPrice = product.product.price - product.promo %}
  426.                                         {% else %}
  427.                                             {% set ProductPrice = product.product.price %}
  428.                                         {% endif %}
  429.                                         <td class="estimate-total">
  430.                                             <span class="total-amount">
  431.                                                 {% if product.promo %}
  432.                                                     <small>
  433.                                                         <del>{{ product.product.price|number_format(2, '.') }}€</del>
  434.                                                     </small>
  435.                                                     <strong>{{ ProductPrice|number_format(2, '.') }}€</strong>
  436.                                                 {% else %}
  437.                                                     {{ ProductPrice|number_format(2, '.') }}€
  438.                                                 {% endif %}
  439.                                             </span><br>
  440.                                             {% if product.promo %}(code promo -{{ product.promo }}€)
  441.                                             {% endif %}
  442.                                         </td>
  443.                                         {# Quantity product #}
  444.                                         <td class="actual-total">{{ product.quantity }}</td>
  445.                                         {% set TotalWithQuantity = product.quantity * ProductPrice %}
  446.                                         {% set TotalPriceProduct = TotalPriceProduct + TotalWithQuantity %}
  447.                                         <td class="paid-total">
  448.                                             <span class="total-amount">{{ TotalWithQuantity|number_format(2, '.') }}€</span>
  449.                                         </td>
  450.                                         <td class="paid-total d-flex justify-content-around" style="column-gap: 5px;">
  451.                                             <a href="{{ path('front_my_basket_remove_product', {'id': product.product.id}) }}" class="btn btn-rounded btn-danger indicationSupp" title="Supprimer du panier" style="font-size: 17px;display: flex;align-items: center;"><i class="fa fa-trash" aria-hidden="true"></i></a>
  452.                                             {# Supprimer du panier #}
  453.                                             {# onclick="getOptionByIdProd({{product.product.id}})" data-id="{{product.product.id}}" #}
  454.                                             <!-- Button trigger modal -->
  455.                                         {% for subcategory in product.product.subCategories %}
  456.                                             {% if subcategory.subCategorySlug != "faire-part" %}
  457.                                                 <a onclick="getGroupOption({{product.product.id}})" data-id="{{product.product.id}}" class="btn btn-rounded btn-default modifProdSess" data-toggle="modal" data-target="#modalOptionGP">
  458.                                                     Ajouter des options
  459.                                                 </a>
  460.                                             {% else %}
  461.                                                 <a onclick="ajouterOptions('{{product.product.id}}','{{product.quantity}}','{{ProductPrice}}','{{ app.request.getSchemeAndHttpHost() }}');" id="ajoutOption" class="btn btn-rounded btn-default modifProdSess" data-toggle="modal">
  462.                                                     Ajouter des options
  463.                                                 </a>
  464.                                                 {# data-target="#modifAchatFairePart" #}
  465.                                             {% endif %}
  466.                                         {% endfor %}
  467.                                         </td>
  468.                                     </tr>
  469.                                     {# Fin Product added #}
  470.                                     {# Option #}
  471.                                     {% for subCategories in product.product.subCategories.snapshot %}
  472.                                         {% if subCategories.subCategorySlug != "faire-part" %}
  473.                                         
  474.                                             {% for key,option in product.options %}
  475.                                                 {% set optionObject = filter_service.getProductOption(key) %}
  476.                                                 {# {% set TotalPriceProduct = TotalPriceProduct + optionObject.price %} #}
  477.                                                 <tr class="" style="background:#fff">
  478.                                                     <td class="pl-4">
  479.                                                         <strong>Option :</strong>
  480.                                                         {{ optionObject.name }}</td>
  481.                                                         {# {% if isClothing %}
  482.                                                             <br><strong>Taille :
  483.                                                                 {{ product.size }}</strong>
  484.                                                         {% endif %} #}
  485.                                                     <td>
  486.                                                     {# {% if optionObject.image1 %}
  487.                                                         <img src="{{ asset(constant('App\\Services\\File::IMAGE_PRODUCT_DIR')) ~ optionObject.image1 }}" style="height:50px;border-radius:2px">
  488.                                                     {% endif %} #}
  489.                                                     </td>
  490.                                                     <td class="estimate-total">
  491.                                                         {# <span class="total-amount">{{ optionObject.price|number_format(2, '.') }}€</span> #}
  492.                                                         <span class="total-amount"></span>
  493.                                                     </td>
  494.                                                     {# qty option #}
  495.                                                     <td></td>
  496.                                                     {# {% set totalOpt = null %}
  497.                                                     {% for key,qty in product.qtyOption %}
  498.                                                         {% if optionObject.id == key %}
  499.                                                             <td class="actual-total">{{qty}}</td>
  500.                                                             {% set totqtyOpt = optionObject.price * qty %}
  501.                                                             <td class="paid-total">
  502.                                                                 <span class="total-amount">{{ totqtyOpt|number_format(2, '.') }}€</span>
  503.                                                             </td>
  504.                                                             {% set totOpt = totOpt + totqtyOpt %}
  505.                                                         {% endif %} 
  506.                                                     {% endfor %} #}
  507.                                                     {# qty option #}
  508.                                                     <td class="paid-total"></td>
  509.                                                 </tr>
  510.                                                 
  511.                                                 {% for valOption in option %}
  512.                                                     <tr>
  513.                                                         <td class="pl-5">{{ valOption["valeur"] }}</td>
  514.                                                         <td></td>
  515.                                                         <td class="estimate-total"><span class="total-amount">{{ valOption["prix"] }} €</span></td>
  516.                                                         <td>{{ valOption["qte"] ? valOption["qte"] : 1 }}</td>
  517.                                                         {# <pre>
  518.                                                             {{ dump(valOption["qte"]) }}
  519.                                                         </pre> #}
  520.                                                         {% set totval = valOption["prix"] * (valOption["qte"] ? valOption["qte"] : 1)  %}
  521.                                                         <td class="estimate-total"><span class="total-amount">{{ totval }} €</spna></td>
  522.                                                         {% set totGpOpt = totGpOpt + totval %}
  523.                                                     </tr>
  524.                                                 {% endfor %}
  525.                                             {% endfor %}
  526.                                         {% else %}
  527.                                             {% if product.options_farep is defined %}
  528.                                                 {% for option in product.options_farep %}
  529.                                             
  530.                                                     <tr style="background:#fff">
  531.                                                         <td class="pl-4">
  532.                                                             <strong>Option :</strong>
  533.                                                             {{ option.nomoption }}
  534.                                                             
  535.                                                                 {# <br><strong>Format :
  536.                                                                     {{ option.form }}</strong>
  537.                                                                 <br><strong>Finition :
  538.                                                                     {{ option.finition }}</strong>
  539.                                                                 <br><strong>Papier :
  540.                                                                     {{ option.papier}}</strong>
  541.                                                                 <br><strong>Etiquette :
  542.                                                                     {{ option.etiquette}} #}
  543.                                                                     </strong></td>
  544.                                                             
  545.                                                         <td>
  546.                                                         {% if option.imageoption %}
  547.                                                             <img src="{{ asset(constant('App\\Services\\File::IMAGE_PRODUCT_DIR')) ~ option.imageoption }}" style="height:50px;border-radius:2px">
  548.                                                         {% endif %}
  549.                                                         </td>
  550.                                                         <td class="estimate-total">
  551.                                                             <span class="total-amount">{{ option.price|number_format(2, '.') }}€</span>
  552.                                                         </td> 
  553.                                                         {# qty option #}
  554.                                                         {# {% set totalOpt = null %}#}
  555.                                                         
  556.                                                                 <td class="actual-total">{{option.quantite}}</td>
  557.                                                                 {% set totqtyOpt = option.price * option.quantite %}
  558.                                                                 <td class="paid-total">
  559.                                                                     <span class="total-amount">{{ totqtyOpt|number_format(2, '.') }}€</span>
  560.                                                                 </td>
  561.                                                                 {% set totOpt = totOpt + totqtyOpt %}
  562.                                                             
  563.                                                         <td class="paid-total"></td>
  564.                                                     </tr>
  565.                                                 {% endfor %}
  566.                                             {% endif %}
  567.                                             
  568.                                         {% endif %}     
  569.                                     {% endfor %}
  570.                                     {# Fin Option #}
  571.                                 {% endfor %}
  572.                                 {% if pack or products is not empty %}
  573.                                     <tr>
  574.                                         <td>TOTAL :</td>
  575.                                         <td></td>
  576.                                         <td></td>
  577.                                         <td></td>
  578.                                         {% if pack %}
  579.                                             {% set TotalPriceProduct = TotalPriceProduct + pack.price  %}
  580.                                         {% endif %}
  581.                                         {% set totOptions = totOpt + totGpOpt %}
  582.                                         <td>{{ (TotalPriceProduct + totOptions)|number_format(2, '.') }}€</td>
  583.                                     </tr>
  584.                                 {% endif %}
  585.                                 {% if not pack and products is empty %}
  586.                                     <tr>
  587.                                         <td>Aucun produit ajouté au panier</td>
  588.                                     </tr>
  589.                                 {% endif %}
  590.                             </tbody>
  591.                         </table>
  592.                     </div>
  593.                     <div class="card-footer" style="height:70px">
  594.                         {% if products|length > 0 or pack is not null %}
  595.                             {% if is_granted('ROLE_ENTERPRISE') == false %}
  596.                                 <div class="float-left">
  597.                                     {{ form_start(form, {'attr': {'class': 'form-inline'}}) }}
  598.                                     <div class="form-group">
  599.                                         {{ form_widget(form.codePromo) }}
  600.                                     </div>
  601.                                     <button type="submit" class="btn btn-default ml-3">Valider</button>
  602.                                     {{ form_end(form) }}
  603.                                     {% if isMessagePromo is defined and isMessagePromo %}
  604.                                         <span style="color:green">Code promo valide !</span>
  605.                                     {% endif %}
  606.                                 </div>
  607.                                 <div class="float-right">
  608.                                     <a href="{{ path('front_command_livraison') }}" class="btn btn-primary">Commander</a>
  609.                                 </div>
  610.                             {% endif %}
  611.                         {% endif %}
  612.                     </div>
  613.                 </div>
  614.             </div>
  615.         </div>
  616.     </div>
  617. {% endblock %}
  618. {% block javascript %}
  619.     <script>
  620.         function wcqib_refresh_quantity_increments() {
  621.             jQuery("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").each(function (a, b) {
  622.                 var c = jQuery(b);
  623.                 c.addClass("buttons_added"),
  624.                     c.children().first().before('<input type="button" value="-" class="minus" />'),
  625.                     c.children().last().after('<input type="button" value="+" class="plus" />')
  626.             })
  627.         }
  628.         String.prototype.getDecimals || (String.prototype.getDecimals = function () {
  629.             var a = this,
  630.                 b = ("" + a).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
  631.             return b ? Math.max(0, (b[1] ? b[1].length : 0) - (b[2] ? + b[2] : 0)) : 0
  632.         }),
  633.             jQuery(document).ready(function () {
  634.                 wcqib_refresh_quantity_increments()
  635.             }),
  636.             jQuery(document).on("updated_wc_div", function () {
  637.                 wcqib_refresh_quantity_increments()
  638.             }),
  639.             jQuery(document).on("click", ".plus, .minus", function () {
  640.                 var a = jQuery(this).closest(".quantity").find(".qty"),
  641.                     b = parseFloat(a.val()),
  642.                     c = parseFloat(a.attr("max")),
  643.                     d = parseFloat(a.attr("min")),
  644.                     e = a.attr("step");
  645.                 b && "" !== b && "NaN" !== b || (b = 0),
  646.                     "" !== c && "NaN" !== c || (c = ""),
  647.                     "" !== d && "NaN" !== d || (d = 0),
  648.                     "any" !== e && "" !== e && void 0 !== e && "NaN" !== parseFloat(e) || (e = 1),
  649.                     jQuery(this).is(".plus") ? c && b >= c ? a.val(c) : a.val((b + parseFloat(e)).toFixed(e.getDecimals())) : d && b <= d ? a.val(d) : b > 0 && a.val((b - parseFloat(e)).toFixed(e.getDecimals())),
  650.                     a.trigger("change")
  651.             });
  652.     </script>
  653.     <script>
  654.         {# Lading script... #}
  655.         const loader = document.querySelector('#MyLoading');
  656.         function afficheLoading() {
  657.             loader.classList.add('MyShow');
  658.         }
  659.         function cacherLoading() {
  660.             loader.classList.remove('MyShow');
  661.         }
  662.         {# Fin Lading script... #}
  663.         const containerOpt = document.querySelector('.containerOption');
  664.         
  665.         
  666.         function getOptionByIdProd(idProd) {
  667.             afficheLoading();
  668.             
  669.             const data = {
  670.                 idProd: idProd
  671.             };
  672.             let datas = new FormData();
  673.             datas.append("data", JSON.stringify(data));
  674.             if (containerOpt.children) {
  675.                 var first = containerOpt.firstElementChild;
  676.                 while (first) {
  677.                     first.remove();
  678.                     first = containerOpt.firstElementChild;
  679.                 }
  680.             }
  681.             fetch(`/get-option/${idProd}`)
  682.             .then(response => response.json())
  683.             .then(data => {
  684.                 cacherLoading();
  685.                 console.log(data);
  686.                 data[0].map((item)=>{
  687.                     //console.log("idOpt vao miditra",item.id);
  688.                     let objQty = data[1].qty;
  689.                     let idProd = document.createElement('input');
  690.                     idProd.type = "hidden";
  691.                     idProd.value = data[2];
  692.                     idProd.setAttribute('name','idProd');
  693.                     let oneOpt = document.createElement('div');
  694.                     oneOpt.classList.add('col-12');
  695.                     oneOpt.classList.add('row');
  696.                     let col8 = document.createElement('div');
  697.                     col8.classList.add('col-8');
  698.                     let row = document.createElement('div');
  699.                     row.classList.add('row');
  700.                     let col4a = document.createElement('div');
  701.                     col4a.classList.add('col-4');
  702.                     let col4b = document.createElement('div');
  703.                     col4b.classList.add('col-4');
  704.                     let img1 = document.createElement('img');
  705.                     img1.classList.add('imgOptModal');
  706.                     // image
  707.                     if (item.image1 == null){
  708.                         img1.style.display = "none";
  709.                     } else {
  710.                         img1.src = `/upload/produits/${item.image1}`;
  711.                     }
  712.                     let img2 = document.createElement('img');
  713.                     img2.classList.add('imgOptModal');
  714.                     if (item.image2 == null){
  715.                         img2.style.display = "none";
  716.                     } else {
  717.                         img2.src = `/upload/produits/${item.image2}`;
  718.                     }
  719.                     let customCheckBox = document.createElement('div');
  720.                     customCheckBox.classList.add('custom-checkbox');
  721.                     customCheckBox.style.position = "relative";
  722.                     let inputCheckBox = document.createElement('input');
  723.                     inputCheckBox.type = "checkbox";
  724.                     inputCheckBox.classList.add('custom-control-input');
  725.                     inputCheckBox.classList.add('option-checkbox');
  726.                     inputCheckBox.setAttribute('id',`idCheck${item.id}`);
  727.                     inputCheckBox.setAttribute('name',`options[${item.id}]`);
  728.                     inputCheckBox.setAttribute('value',`${item.price}`);
  729.                     // checked if already in session
  730.                     for (const idOpt in objQty) {
  731.                         if(item.id == idOpt){
  732.                             inputCheckBox.checked = true;
  733.                         }
  734.                     }
  735.                     let customControlLabel = document.createElement('label');
  736.                     customControlLabel.classList.add('custom-control-label');
  737.                     customControlLabel.setAttribute('for',`idCheck${item.id}`);
  738.                     
  739.                     let nameStrong = document.createElement('strong');
  740.                     nameStrong.innerHTML = `${item.price} €`;
  741.                     nameStrong.style.marginLeft = "31px";
  742.                     let nameSpan = document.createElement('span');
  743.                     nameSpan.innerHTML = `- ${item.name}`;
  744.                     let nameSpan2 = document.createElement('span');
  745.                     nameSpan2.innerHTML = `<button type="button">modif</button>`;
  746.                     let col4 = document.createElement('div');
  747.                     col4.classList.add('col-4');
  748.                     let myheight = document.createElement('div');
  749.                     myheight.style.height = "36px";
  750.                     let inputQty = document.createElement('input');
  751.                     inputQty.type = "number";
  752.                     inputQty.classList.add('inputQtyOpt');
  753.                     inputQty.setAttribute('min','1');
  754.                     inputQty.setAttribute('id',`QtyidCheck${item.id}`);
  755.                     inputQty.setAttribute('name',`QtyOption[${item.id}]`);
  756.                     inputQty.setAttribute('value','1');
  757.                     // get value qty in session
  758.                     for (const idOpt in objQty) {
  759.                         if(item.id == idOpt) {
  760.                             inputQty.setAttribute('value',`${objQty[idOpt]}`);
  761.                         } 
  762.                     }
  763.                     col4.appendChild(myheight);
  764.                     col4.appendChild(inputQty);
  765.                     col4a.appendChild(img1);
  766.                     col4b.appendChild(img2);
  767.                     row.appendChild(col4a);
  768.                     row.appendChild(col4b);
  769.                     customControlLabel.appendChild(nameStrong);
  770.                     customControlLabel.appendChild(nameSpan);
  771.                     customCheckBox.appendChild(inputCheckBox);
  772.                     customCheckBox.appendChild(customControlLabel);
  773.                     col8.appendChild(row);
  774.                     col8.appendChild(customCheckBox);
  775.                     oneOpt.appendChild(idProd);
  776.                     oneOpt.appendChild(col8);
  777.                     oneOpt.appendChild(col4);
  778.                     containerOpt.appendChild(oneOpt);
  779.                 });
  780.                 
  781.                 /*let idp = document.createElement("p");
  782.                 idp.textContent = data;
  783.                 containerOpt.appendChild(idp);*/
  784.                 /*fetch('/get-option')
  785.                 .then(obj => obj.json())
  786.                 .then(objjs => console.log(objjs));*/
  787.                 if(data) {
  788.                     const optionCheckbox = document.querySelectorAll('.option-checkbox');
  789.                     
  790.                     for (var i = 0; i < optionCheckbox.length; i++) {
  791.                         let qtyOpt = document.getElementById(`Qty${optionCheckbox[i].id}`);
  792.                         // disable unchecked checkbox
  793.                         if(!optionCheckbox[i].checked) {
  794.                             qtyOpt.disabled = true;
  795.                             qtyOpt.style.display = "none";
  796.                         }
  797.                         optionCheckbox[i].addEventListener('change', (optMod) => {
  798.                             if (optMod.target.checked) {
  799.                                 qtyOpt.disabled = false;
  800.                                 qtyOpt.style.display = "block";
  801.                             } else {
  802.                                 qtyOpt.disabled = true;
  803.                                 qtyOpt.style.display = "none";
  804.                             }
  805.                         })
  806.                     }
  807.                 }
  808.             });
  809.         }
  810.     </script>
  811.     <script>
  812.     function getGroupOption(id_prod) {
  813.         // console.log('kokokoko',url);
  814.         console.log('isID',id_prod);
  815.         // var id_product=314;
  816.         $("#valeurgropOption").html("");
  817.         fetch(`/tous-options-groups/${id_prod}`)
  818.         .then(response=> response.json())
  819.         .then(data=>{
  820.             console.log('tous option', data);
  821.             $("#valeurgropOption").append(data);
  822.         });
  823.         
  824.     }
  825.     function validechoiModalGroupoption() {
  826.         // $("#modalOptionGP").modal("hide");
  827.         
  828.         var url = window.location.href.split('/');
  829.         var param_url = url[0]+'//'+url[2];
  830.         const formData = new FormData();
  831.         var idProduit = $('#id_produit').val();
  832.         console.log("id_porduit",idProduit);
  833.         
  834.         var goption= document.getElementsByClassName('goption');
  835.         var labels =new Array();
  836.         for (let i = 0; i < goption.length; i++) {
  837.             var id_goption = goption[i].id.split("_");
  838.             var label= document.getElementsByClassName('label_'+id_goption[1]);
  839.             var hidden= document.getElementsByClassName('hidden_'+id_goption[1]);
  840.             var qte= document.getElementsByClassName('qte_'+id_goption[1]);
  841.             
  842.             // console.log('labeb',label);
  843.             var compter=0;
  844.             
  845.             var lab =new Array();
  846.             var qt =new Array();
  847.             for (let l = 0; l < label.length; l++) {
  848.             console.log('type', label[l].type);
  849.                 if (label[l].type=="checkbox" && label[l].checked) {
  850.                     
  851.                     lab[compter] = hidden[l].value;
  852.                     qt[compter] = qte[l].value;
  853.                     compter++
  854.                 }
  855.                 if (label[l].type=="select-one" && label[l].value != "") {    
  856.                     lab[compter] = label[l].value;
  857.                     qt[compter] = qte[l].value;
  858.                     compter++
  859.                 }
  860.             }
  861.             labels[i] = {idoption: id_goption[1], labelo: lab, qte: qt};
  862.         }
  863.             console.log('valin label',labels);
  864.             
  865.             // localStorage.setItem('produit_groups', JSON.stringify(labels));
  866.             
  867.             formData.append("modifGroupOption", JSON.stringify(labels));
  868.             fetch(`${param_url}/updateOptionGroups/${idProduit}`, {
  869.             method: "POST",
  870.             body: formData
  871.                 })
  872.                 .then(response=> response.json())
  873.                 .then(data=>{
  874.                 console.log('data_io',data);
  875.                 if (data.message == "ok") {
  876.                     window.location.reload();
  877.                 }
  878.                 $("#modalOptionGP").modal("hide");
  879.             });
  880.     }
  881.     </script>
  882.     <script>
  883.     function ajouterOptions(idproduit,qte,prix,url) { 
  884.         
  885.         fetch(`${url}/tousoption/${idproduit}`)
  886.         .then(response=> response.json())
  887.         .then(data=>{
  888.             var templ="";
  889.             var tousId=[];
  890.             console.log("cocher",data.opt_pre);
  891.             for (let i = 0; i < data.options.length; i++) {
  892.                 tousId.push(data.options[i].id);
  893.                 templ+=`<div class="oneOptionFP">
  894.                             <div class="row">
  895.                 
  896.                                 <div class="col-4">
  897.                                     <img id="optionbtn1img" src="/upload/produits/${data.options[i].image1}" style="height:50px;border-radius:2px">
  898.                                 </div>
  899.                                 <div class="col-4">
  900.                                     <img id="optionbtn1img" src="/upload/produits/${data.options[i].image2}" style="height:50px;border-radius:2px">
  901.                                 </div>
  902.                             </div>
  903.                             <div class="custom-checkbox my-1" style="position: relative">
  904.                                 <input type="checkbox" data-price="${data.options[i].price}" data-id="${data.options[i].id}" name="" value="" class="custom-control-input checkboxFP" id="checkboFP_${[i]}">
  905.                                 <label class="custom-control-label position-relative" for="checkboFP_${[i]}">
  906.                                     <strong style="margin-left: 31px;">${data.options[i].price}</strong>
  907.                                     <span>-
  908.                                     ${data.options[i].name}</span>
  909.                                     </label>
  910.                                 <button class="btn" id="boutonModif_${[i]}" onclick="modifOption('${data.options[i].id}');" type="button" style="display: none">Modifier</button>
  911.                             </div>
  912.                         </div>`;            
  913.             }
  914.         
  915.             $('#id_produit').val(idproduit);
  916.             $('#price_produit').val(prix);
  917.             $('#qte_produit').val(qte);
  918.             $('#modifAchatFairePart').modal("show");
  919.             $('#tousOptions').html(templ);
  920.             for (let k = 0; k < tousId.length; k++) {
  921.                console.log('atooo',tousId,tousId.length);
  922.                 console.log('dataio',data.opt_pre);
  923.                 // for (let a = 0; a < data.opt_pre.length; a++) {
  924.                     // console.log('avvvvvi',data.opt_pre.length);
  925.                     for(var i in data.opt_pre) {
  926.                         if(tousId[k]== data.opt_pre[i].idoption){
  927.                             console.log("tonga aty ihany");
  928.                             $('#checkboFP_'+[k]).prop('checked', true);    
  929.                         }
  930.                     }
  931.                 // }
  932.                 for (const key in $('#checkboFP_'+[k])) {
  933.                     if ($('#checkboFP_'+[k])[key].checked) {    
  934.                         $('#boutonModif_'+[k]).attr("style", "display: block !important");
  935.                     }
  936.                     else{
  937.                         var evt = document.getElementById('checkboFP_'+[k]);
  938.                         evt.addEventListener('change',(event) => {
  939.                             if (event.target.checked) {
  940.                                 $('#boutonModif_'+[k]).attr("style", "display: block !important");
  941.                             }else{
  942.                                 $('#boutonModif_'+[k]).attr("style", "display: none !important");
  943.                                 $(".forme_options").attr("style", "display: none !important")
  944.                                 $(".m-info").attr("style", "display: block !important")
  945.                             }
  946.                         });
  947.                     }
  948.                 }
  949.             }
  950.         });
  951.     }
  952.     function modifOption(idopt) {
  953.         
  954.         var url = window.location.href.split('/');
  955.         var param_url = url[0]+'//'+url[2];
  956.         fetch(`${param_url}/option/${idopt}`)
  957.         .then(response=> response.json())
  958.         .then(data=>{
  959.         
  960.             $(".m-info").attr("style", "display: none !important")
  961.             $(".forme_options").attr("style", "display: block !important")
  962.             $(".nice-select").attr("style", "display: none !important");
  963.             $("#id_optionFP").val(idopt);
  964.             $("#name_optionFP").val(data.options.name);
  965.             $("#image_optionFP").val(data.options.image1);
  966.     
  967.             if ( typeof data.options.colorsOption != "undefined" && data.options.colorsOption != null && data.options.colorsOption.length != null && data.options.colorsOption.length > 0) {
  968.                 var colorso ="";
  969.                 for (let i = 0; i < data.options.colorsOption.length; i++) {
  970.                     colorso +='<option>'+ data.options.colorsOption[i]+'</option>'
  971.                 }
  972.                 $("#optionFP_color").html(colorso);
  973.                 $(".optionFP_color").attr("style", "display: block !important");
  974.                 $("#optionFP_color").attr("style", "display: block !important");
  975.             }
  976.             else{
  977.                 $(".optionFP_color").attr("style", "display: none !important");
  978.             }
  979.             if (typeof data.options.format != "undefined" && data.options.format != null && data.options.format.length != null && data.options.format.length > 0) {
  980.                 var formatopt ="";
  981.                 for (let i = 0; i < data.options.format.length; i++) {
  982.                     formatopt +='<option>'+data.options.format[i]+'</option>'
  983.                 }
  984.                 $("#optionFP_format").html(formatopt);
  985.                 $(".optionFP_format").attr("style", "display: block !important");
  986.                 $("#optionFP_format").attr("style", "display: block !important");
  987.             }
  988.             else{
  989.                 $(".optionFP_format").attr("style", "display: none !important");
  990.             }
  991.             if (typeof data.options.finition != "undefined" && data.options.finition != null && data.options.finition.length != null && data.options.finition.length > 0) {
  992.                 var finitions ="";
  993.                 for (let i = 0; i < data.options.finition.length; i++) {
  994.                     finitions +='<option>'+data.options.finition[i]+'</option>'
  995.                 }
  996.                 $("#optionFP_finition").html(finitions);
  997.                 $(".optionFP_finition").attr("style", "display: block !important");
  998.                 $("#optionFP_finition").attr("style", "display: block !important");
  999.             }
  1000.             else{
  1001.                 $(".optionFP_finition").attr("style", "display: none !important");
  1002.             }
  1003.             if (typeof data.options.papier != "undefined" && data.options.papier != null && data.options.papier.length != null && data.options.papier.length > 0) {
  1004.                 var papiers ="";
  1005.                 for (let i = 0; i < data.options.papier.length; i++) {
  1006.                     papiers +='<option>'+data.options.papier[i]+'</option>'
  1007.                 }
  1008.                 $("#optionFP_papier").html(papiers);
  1009.                 $(".optionFP_papier").attr("style", "display: block !important");
  1010.                 $("#optionFP_papier").attr("style", "display: block !important");
  1011.             }
  1012.             else{
  1013.                 $(".optionFP_papier").attr("style", "display: none !important");
  1014.             }
  1015.             if (typeof data.options.quantite != "undefined" && data.options.quantite != null && data.options.quantite.length != null && data.options.quantite.length > 0) {
  1016.                 var quantites ="";
  1017.                 for (let i = 0; i < data.options.quantite.length; i++) {
  1018.                     quantites +='<option>'+data.options.quantite[i]+'</option>'
  1019.                 }
  1020.                 $("#optionFP_quantite").html(quantites);
  1021.                 $(".optionFP_quantite").attr("style", "display: block !important");
  1022.                 $("#optionFP_quantite").attr("style", "display: block !important");
  1023.             }
  1024.             else{
  1025.                 $(".optionFP_quantite").attr("style", "display: none !important");
  1026.             }
  1027.             if (typeof data.options.etiquette != "undefined" && data.options.etiquette != null && data.options.etiquette.length != null && data.options.etiquette.length > 0) {
  1028.                 var etiquettes ="";
  1029.                 for (let i = 0; i < data.options.etiquette.length; i++) {
  1030.                     etiquettes +='<option>'+data.options.etiquette[i]+'</option>'
  1031.                 }
  1032.                 $("#optionFP_etiquette").html(etiquettes);
  1033.                 $(".optionFP_etiquette").attr("style", "display: block !important");
  1034.                 $("#optionFP_etiquette").attr("style", "display: block !important");
  1035.             }
  1036.             else{
  1037.                 $(".optionFP_etiquette").attr("style", "display: none !important");
  1038.             }
  1039.             if (typeof data.options.ruban != "undefined" && data.options.ruban != null && data.options.ruban.length != null && data.options.ruban.length > 0) {
  1040.                 var rubans ="";
  1041.                 for (let i = 0; i < data.options.ruban.length; i++) {
  1042.                     rubans +='<option>'+data.options.ruban[i]+'</option>'
  1043.                 }
  1044.                 $("#optionFP_ruban").html(rubans);
  1045.                 $(".optionFP_ruban").attr("style", "display: block !important");
  1046.                 $("#optionFP_ruban").attr("style", "display: block !important");
  1047.             }
  1048.             else{
  1049.                 $(".optionFP_ruban").attr("style", "display: none !important");
  1050.             }
  1051.         });    
  1052.     }
  1053.     function Anulleroption() {
  1054.         $(".forme_options").attr("style", "display: none !important")
  1055.         $(".m-info").attr("style", "display: block !important")
  1056.     }
  1057.     function validechoioption() {
  1058.         $(".forme_options").attr("style", "display: none !important")
  1059.         $(".m-info").attr("style", "display: block !important")
  1060.         const data = {
  1061.                 idoption: $("#id_optionFP").val(),
  1062.                 nomoption: $("#name_optionFP").val(),
  1063.                 imageoption: $("#image_optionFP").val(),
  1064.                 color: $("#optionFP_color").val(),
  1065.                 form: $("#optionFP_format").val(),
  1066.                 finition: $("#optionFP_finition").val(),
  1067.                 papier: $("#optionFP_papier").val(),
  1068.                 quantite: $("#optionFP_quantite").val(),
  1069.                 etiquette: $("#optionFP_etiquette").val(),
  1070.                 ruban: $("#optionFP_ruban").val(),
  1071.             };
  1072.         localStorage.setItem($("#id_optionFP").val(), JSON.stringify(data));
  1073.             
  1074.     }
  1075.     function validechoiModaloption() {
  1076.         var url = window.location.href.split('/');
  1077.         var param_url = url[0]+'//'+url[2];
  1078.         const formData = new FormData();
  1079.         var idProduit = $('#id_produit').val();
  1080.         formData.append("quantity",$('#qte_produit').val());
  1081.         formData.append("price",$('#price_produit').val());
  1082.        if (Object.keys(localStorage).length != 0) {
  1083.         var values = [],
  1084.         keys = Object.keys(localStorage),
  1085.         i = keys.length;
  1086.      
  1087.         while ( i-- ) {
  1088.             values.push( localStorage.getItem(keys[i]) );
  1089.             localStorage.removeItem(keys[i]);
  1090.         }
  1091.         
  1092.         formData.append("tail",values.length);
  1093.         console.log("zzzzz",values);
  1094.         for (let j = 0; j < values.length; j++) {    
  1095.            formData.append("OpId_"+j, values[j]);
  1096.         }
  1097.        }
  1098.        
  1099.         var checkOpt = document.querySelectorAll('.checkboxFP');
  1100.         console.log("fff", checkOpt);
  1101.         console.log("eee", checkOpt.length);
  1102.         var valeur=[];
  1103.         for (var p = 0; p < checkOpt.length; p++) {
  1104.             
  1105.             if (checkOpt[p].checked) {
  1106.                 var idOpt = checkOpt[p].getAttribute('data-id');
  1107.                 valeur.push(idOpt);
  1108.             }
  1109.         }
  1110.             formData.append("idoptions",valeur);
  1111.        
  1112.         fetch(`${param_url}/updateOptionFairepart/${idProduit}`, {
  1113.             method: "POST",
  1114.             body: formData
  1115.         })
  1116.         .then(response=> response.json())
  1117.         .then(data=>{
  1118.           console.log('data_io',data);
  1119.           if (data.message == "ok") {
  1120.             window.location.reload();
  1121.           }
  1122.        $("#modifAchatFairePart").modal("hide");
  1123.         });
  1124.     }
  1125.     </script>
  1126. {% endblock %}