templates/front/product/location/subform_location.html.twig line 1

Open in your IDE?
  1. <form method="post" action="{{ path('new_location', {'id': product.id}) }}" id="form_location">
  2.     {% if is_granted('ROLE_ENTERPRISE') == false %}
  3.         {% if product.company.isConfirmed %}
  4.             {% set isNbGuest = null %}
  5.             {% for subcategory in product.subCategories %}
  6.                 {% if subcategory.isNbGuest %}
  7.                     {% set isNbGuest = true %}
  8.                 {% endif %}
  9.             {% endfor %}
  10.             {# {% if isNbGuest %}
  11.                  <input id="storageGroupsOption" type="hidden" name="Options" >
  12.                 <div class="form-group" id="nb_guest_old">
  13.                     <label for="nb_guest">Nombre d’invités</label><br>
  14.                     <input type="text" name="nb_guest" class="form-control" placeholder="Nombre d’invités" required>
  15.                 </div>
  16.             {% endif %} #}
  17.             {# show nbr personne if hebergement  #}
  18.             {% if product.subCategories.toArray[0].subCategorySlug == "hebergements" %}
  19.                 <div class="d-flex justify-content-between ">
  20.                     <p>Adulte</p>
  21.                     <div id="qt_adulte" class="cont_btn_qt">
  22.                         <button type="button" disabled>-</button>
  23.                         <span>1</span>
  24.                         <input type="hidden" name="qt_adulte" value=1>
  25.                         <button type="button">+</button>
  26.                     </div>
  27.                 </div>
  28.                 <div class="d-flex justify-content-between ">
  29.                     <p>Enfant</p>
  30.                     <div id="qt_enfant" class="cont_btn_qt">
  31.                         <button type="button" disabled>-</button>
  32.                         <span>0</span>
  33.                         <input type="hidden" name="qt_enfant" value=0>
  34.                         <button type="button">+</button>
  35.                     </div>
  36.                 </div>
  37.                 <div class="d-flex justify-content-between ">
  38.                     <p>Bébé</p>
  39.                     <div id="qt_bebe" class="cont_btn_qt">
  40.                         <button type="button" disabled>-</button>
  41.                         <span>0</span>
  42.                         <input type="hidden" name="qt_bebe" value=0>
  43.                         <button type="button">+</button>
  44.                     </div>
  45.                 </div>
  46.             {% endif %}
  47.             {# Récupérer les périodes d'indisponibilité du produit #}
  48.             {% for unavailableDate in product.productAgendas %}
  49.                 <input type="hidden" class="startDayNotAvailable" value={{unavailableDate.startDayNotAvailable|date('Y-m-d')}}>
  50.                 <input type="hidden" class="endDayNotAvailable" value={{unavailableDate.endDayNotAvailable|date('Y-m-d')}}>
  51.                 <input type="hidden" class="raisonNotAvailable" value={{unavailableDate.raisonNotAvailable}}>
  52.             {% endfor %}
  53.             {# Récupérer nombre de nuit min du produit s'il y en a #}
  54.             {% if product.nightMin and product.nightMin != null %}
  55.                 <input type="hidden" class="nbrNightMin" value="{{product.nightMin}}">
  56.             {% endif %}
  57.             {# reservation date #}
  58.             {% if product.typeLocation.label == "heure" %}
  59.                 <div class="form-group mt-4 mb-2">
  60.                     <div class="form-input">
  61.                         <input id="start" name="start" autocomplete="off" type="text" style="border: 0px solid white; border-bottom: 1px solid #aaa;" placeholder="Date de début" class="form-control" required>
  62.                     </div>
  63.                 </div>
  64.                 <div class="form-group mb-5">
  65.                     <div class="form-input">
  66.                         <input id="end" name="end" autocomplete="off" type="text" style="border: 0px solid white; border-bottom: 1px solid #aaa;" placeholder="Date de fin" class="form-control" required>
  67.                     </div>
  68.                 </div>
  69.             {% else %}
  70.                 <div class="form-group mt-4 mb-2">
  71.                     <label for="">Date de réservation
  72.                         {% if product.nightMin and product.nightMin != null %}
  73.                         <small>({{ product.nightMin }} nuit(s) minimum)</small>
  74.                         {% endif %}
  75.                     </label>
  76.                     <input id="daterangePicker" type="text" name="" autocomplete="off"
  77.                         style="border: 0px solid white; border-bottom: 1px solid #aaa;" class="form-control input-md" required>
  78.                     {# <div class="venue-form-calendar">
  79.                         <i class="far fa-calendar-alt"></i>
  80.                     </div> #}
  81.                     <input type="hidden" id="start" name="start" required>
  82.                     <input type="hidden" id="end" name="end" required>
  83.                 </div>
  84.             {% endif %}
  85.             <div class="form-group mb-2">
  86.                 <div class="form-input">
  87.                     <input id="startHidden" name="start_hidden" autocomplete="off" type="hidden" style="border: 0px solid white; border-bottom: 1px solid #aaa;" placeholder="Date de début" class="form-control" required>
  88.                 </div>
  89.             </div>
  90.             <div class="form-row mb-2">
  91.                 <div class="form-input">
  92.                     <input id="endHidden" name="end_hidden" autocomplete="off" type="hidden" style="border: 0px solid white; border-bottom: 1px solid #aaa;" placeholder="Date de fin" class="form-control" required>
  93.                 </div>
  94.             </div>
  95.             {# If other options #}
  96.             {% set isClothing = null %}
  97.             {% for subcategory in product.subCategories %}
  98.                 {% if subcategory.isClothing %}
  99.                     {% set isClothing = true %}
  100.                 {% endif %}
  101.             {% endfor %}
  102.             {% if isClothing and product.sizes is not empty %}
  103.                 <div class="form-group">
  104.                     <label for="quantity_product">Tailles disponibles</label><br>
  105.                     <select class="form-control wide" id="exampleFormControlSelect1" name="size">
  106.                         {% for size in product.sizes %}
  107.                             <option>{{ size }}</option>
  108.                         {% endfor %}
  109.                     </select>
  110.                 </div>
  111.             {% endif %}
  112.             {% set isClothingRing = null %}
  113.             {% for subcategory in product.subCategories %}
  114.                 {% if subcategory.isClothingRing %}
  115.                     {% set isClothingRing = true %}
  116.                 {% endif %}
  117.             {% endfor %}
  118.             {% if isClothingRing and product.sizeRing is not empty %}
  119.                 <div class="form-group">
  120.                     <label for="sizeRing">Tailles disponibles</label><br>
  121.                     <select class="form-control wide" id="sizeRing" name="size_ring">
  122.                         {% for size in product.sizeRing %}
  123.                             <option>{{ size }}</option>
  124.                         {% endfor %}
  125.                     </select>
  126.                 </div>
  127.             {% endif %}
  128.             {% set isColor = null %}
  129.             {% for subcategory in product.subCategories %}
  130.                 {% if subcategory.isColor %}
  131.                     {% set isColor = true %}
  132.                 {% endif %}
  133.             {% endfor %}
  134.             {% if isColor and product.colors is not empty %}
  135.                 <div class="form-group">
  136.                     <label for="quantity_product">Couleurs disponibles</label><br>
  137.                     <select class="form-control wide" id="exampleFormControlSelect1" name="color">
  138.                         {% for color in product.colors %}
  139.                             <option>{{ color }}</option>
  140.                         {% endfor %}
  141.                     </select>
  142.                 </div>
  143.             {% endif %}
  144.             {# Button modal option #}    
  145.             {# If the product(location) have chambre #}            
  146.             {% if product.chambres.toArray() != [] and product.typeHebergements.slugTypeHebergm == "hotel" %}
  147.             <div class="row justify-content-center mb-2">
  148.                 <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modalOptionChambre" >
  149.                     Options sur la chambre            
  150.                 </button>
  151.             </div>
  152.             {% endif %}
  153.             {# If the product(location) have options #}
  154.             {% if product.productOptions.toArray() != [] %}
  155.             <div class="row justify-content-center mb-2">
  156.                 <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modalOptionGP" onclick="voirtoutOption('{{product.id}}','{{ app.request.getSchemeAndHttpHost() }}')">                                    
  157.                     Options disponibles
  158.                 </button>
  159.             </div>
  160.             {% endif %}
  161.             {# Recupérer les reductions entrees par le prestataire s'il y en a #}
  162.             {% if product.productReductions is not null and product.productReductions is not empty %}
  163.                 {% for reductionData in product.productReductions %}
  164.                         <input type="hidden" class="startDay" value="{{ reductionData.startDay }}">
  165.                         <input type="hidden" class="reduction" value="{{ reductionData.reduction }}">
  166.                 {% endfor %}
  167.                 <div class="row justify-content-center mt-5 mb-4">
  168.                     <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modalReduction" onclick="voirtouteReduction('{{product.id}}','{{ app.request.getSchemeAndHttpHost() }}')">
  169.                         Voir les reductions de prix
  170.                     </button>
  171.                 </div>
  172.             {% endif %}
  173.             <div class="d-none">
  174.             {% if product.productOptions %}
  175.                 <span class="font-weight-bold">Options disponibles :</span>
  176.                 <div class="row pl-3 pr-3">
  177.                     {% for option in product.productOptions %}
  178.                         {% if option.image1 %}
  179.                             <div class="d-flex col-md-12">
  180.                                 <div class="col-md-6">
  181.                                     <img src="{{ asset(constant('App\\Services\\File::IMAGE_PRODUCT_DIR') ~ option.image1) }}">
  182.                                 </div>
  183.                                 <div class="col-md-6">
  184.                                     <img src="{{ asset(constant('App\\Services\\File::IMAGE_PRODUCT_DIR') ~ option.image2) }}">
  185.                                 </div>
  186.                             </div>
  187.                         {% endif %}
  188.                         <div class="col-md-12 custom-control custom-checkbox">
  189.                             <input type="checkbox" data-price="{{ option.price }}" name="options[{{ option.id }}]" value="{{ option.price }}" class="option-product custom-control-input cheklocationclass" id="option{{ loop.index }}">
  190.                             <label class="custom-control-label" for="option{{ loop.index }}">
  191.                             {# {% set prix = value %} #}
  192.                                 <strong id="valeurOptions">{{ option.price|number_format(2, ',') }}
  193.                                     €</strong>
  194.                                 -
  195.                                 {{ option.name }}</label>
  196.                         </div>
  197.                         <hr>
  198.                     {% endfor %}
  199.                 </div>
  200.             {% endif %}
  201.             </div>
  202.             
  203.             <div class="row col-md-12 pt-4 d-flex justify-content-between">
  204.                 <h4>Total :
  205.                 </h4>
  206.                 <div>
  207.                     {% set today = "now"|date('Y-m-d') %}
  208.                     {% set customPriceFound = false %}
  209.                     {% set customPrice = 0 %}
  210.                     {% set currentPrice = 0 %}
  211.                     {% set price = 0 %}
  212.                     {% set difference = null %}
  213.                     {% set reductionPercentage = 0 %}
  214.                     {% set reductionValid = false %}
  215.                     {% if product.dayPrice is not null %}
  216.                         {% for dayPrice in product.dayPrice %}
  217.                             {% set formattedDate = dayPrice.customDate|date('Y-m-d') %}
  218.                             {% if formattedDate == today %}
  219.                                 {% set customPriceFound = true %}
  220.                                 {% set customPrice = dayPrice.customPrice|number_format(2, '.', '') %}
  221.                             {% endif %}
  222.                         {% endfor %}                        
  223.                     {% endif %}
  224.                     {# {% if customPriceFound and customPrice !=0 %}
  225.                         {% set price = customPrice %}
  226.                     {% else %}
  227.                          #}
  228.                         {% set month = "now"|date('n') %}
  229.                             {% if month >= 3 and month <= 5 %}
  230.                                 {% set springPrice = product.springPrice %}
  231.                                 {% if springPrice is not null %}
  232.                                     {% set currentPrice = product.springPrice %}
  233.                                 {% else %}
  234.                                     {% set currentPrice = 0 %}                                                                
  235.                                 {% endif %}
  236.                             {% elseif month >= 6 and month <= 8 %}
  237.                                 {% set summerPrice = product.summerPrice %}
  238.                                 {% if summerPrice is not null %}
  239.                                     {% set currentPrice = product.summerPrice %}
  240.                                 {% else %}
  241.                                     {% set currentPrice = 0 %}                                                                
  242.                                 {% endif %}
  243.                             {% elseif month >= 9 and month <= 11 %}
  244.                                 {% set autumnPrice = product.autumnPrice %}
  245.                                 {% if autumnPrice is not null %}
  246.                                     {% set currentPrice = product.autumnPrice %}
  247.                                 {% else %}
  248.                                     {% set currentPrice = 0 %}                                                                
  249.                                 {% endif %}
  250.                             {% else %}
  251.                                 {% set winterPrice = product.winterPrice %}
  252.                                 {% if winterPrice is not null %}
  253.                                     {% set currentPrice = product.winterPrice %}
  254.                                 {% else %}
  255.                                     {% set currentPrice = 0 %}                                                                
  256.                                 {% endif %}
  257.                             {% endif %}
  258.                             {% set day = "now"|date('N') %}
  259.                             {% if day == 6 or day == 7 %}
  260.                                 {% set weekEndPrice = product.weekEndPrice %}
  261.                                 {% if weekEndPrice is not null %}
  262.                                     {% set currentPrice = product.weekEndPrice %}    
  263.                                 {% else %}
  264.                                     {% set currentPrice = 0 %}                                                            
  265.                                 {% endif %}
  266.                             {% endif %}            
  267.                         {% set periodPrice = 0 %}
  268.                         {% for period in product.periodPrice.toArray() %}
  269.                             {% set startDate = period.startDate|date("Y-m-d") %}
  270.                             {% set endDate = period.endDate|date("Y-m-d") %}
  271.                             {% if today >= startDate and today <= endDate and period.price is not null %}
  272.                                 {% set periodPrice = period.price %}
  273.                             {% else %}
  274.                                 {% set currentPrice = 0 %}
  275.                             {% endif %}
  276.                         {% endfor %}
  277.                     {# {% endif %} #}
  278.                     {# {% if customPrice == 0 and currentPrice == 0 %}
  279.                         {% set price = product.price %}                        
  280.                     {% endif %} #}
  281.                     
  282.                     {% if customPriceFound and customPrice !=0 %}
  283.                         {% set price = customPrice %}
  284.                     {% elseif periodPrice != 0 %}
  285.                         {% set price = periodPrice %}                            
  286.                     {% elseif currentPrice != 0 and currentPrice is not null %}
  287.                         {% set price = currentPrice %}    
  288.                     {% elseif customPrice == 0 and currentPrice == 0 and periodPrice == 0 %}
  289.                         {% set price = product.price %}                        
  290.                     {% endif %}
  291.                                                              
  292.                     {% for autoReduce in product.productAutoReduction.toArray %}
  293.                         {% if autoReduce.createdAt is not null and autoReduce.countdown is not null and autoReduce.duration is not null  and autoReduce.reductionPercentage is not null %}
  294.                             {% set difference = date(today).diff(autoReduce.createdAt).days %}
  295.                             {% set duration = autoReduce.duration %}
  296.                             {% set countdown = autoReduce.countdown %}
  297.                             {% set reductionPercentage = autoReduce.reductionPercentage %}
  298.                             {% set durationout = duration + countdown %}
  299.                             {# {{ dump(countdown,difference,durationout,duration) }} #}
  300.                             {% set reductionValid = difference > countdown and difference <= durationout %}
  301.                         {% endif %}
  302.                     {% endfor %}
  303.                     {# {{ dump(reductionValid) }} #}
  304.                     {% if reductionValid %}
  305.                         {% set priceReduced = price - ((price * reductionPercentage) / 100) %}
  306.                         <span id="totalPricese" style="font-size:1.5em" class="prece-total-location">{{ priceReduced|number_format(2, ',') }}</span>€                                                        
  307.                     {% else %}
  308.                         <span id="totalPricese" style="font-size:1.5em" class="prece-total-location">{{ price|number_format(2, ',') }}</span>€
  309.                     {% endif %}
  310.                 </div>
  311.                 {% if product.typeHebergements is not null %}
  312.                 
  313.                     {% if product.typeHebergements.slugTypeHebergm == 'hotel' %}
  314.                         <input type="hidden" name="" id="totalPriceHidden" value=0>
  315.                     {% else %}
  316.                         {% if reductionValid %}
  317.                             <input type="hidden" name="" id="totalPriceHidden" value="{{ priceReduced }}">
  318.                         {% else %}    
  319.                             <input type="hidden" name="" id="totalPriceHidden" value="{{ price }}">
  320.                         {% endif %}        
  321.                     {% endif %}
  322.                 {% else %}
  323.                     {% if reductionValid %}
  324.                         <input type="hidden" name="" id="totalPriceHidden" value="{{ priceReduced }}">
  325.                     {% else %}    
  326.                         <input type="hidden" name="" id="totalPriceHidden" value="{{ price }}">
  327.                     {% endif %}    
  328.                 {% endif %}
  329.                 <input type="hidden" name="total_price_reduced" id="totalPriceReduced">
  330.             </div>
  331.             <div id="message_form"></div>
  332.             
  333.             {% if app.user %}
  334.                 <div class="form-group text-center">
  335.                     {% if product.company.stripeAccountId == null %}
  336.                         <div class="alert alert-info text-center mt-3" style="margin-bottom: 0;">
  337.                             <i class="fas fa-info-circle"></i><br>
  338.                             La fonctionnalité paiement en ligne du prestataire doit être configurée.
  339.                         </div>
  340.                     {% endif %}
  341.                     {% if product.company.abonnements.count() > 0 %}
  342.                         {% if product.company.abonnements.last.isActive == true %}
  343.                             <button type="submit" class="btn btn-rounded btn-primary mt-3" id="btn_add" style="height:auto;">Soumettre une demande de location</button>
  344.                         {% elseif product.company.abonnement.isActive == false and product.company.commissionActive == true %}
  345.                                 <button type="submit" class="btn btn-rounded btn-primary mt-3" id="btn_add" style="height:auto;">Soumettre une demande de location</button>
  346.                         {% else %}
  347.                             <div class="alert alert-info text-center mt-3" style="margin-bottom: 0;">
  348.                                 <i class="fas fa-info-circle"></i><br>
  349.                                 La fonctionnalité paiement en ligne du prestataire n'est pas encore accessible.
  350.                                 Vous pouvez réserver le produit et vous recevrez un email quand le paiement est disponible.
  351.                                 <br>
  352.                                 <input type="hidden" name="reservation" value="reserver">
  353.                                 <button type="submit" class="btn btn-rounded btn-primary mt-3" id="btn_add" style="height:auto;">Réserver</button>
  354.                             </div>
  355.                         {% endif %}
  356.                     {% elseif product.company.abonnements.count ==  0 and product.company.commissionActive == true %}
  357.                         <button type="submit" class="btn btn-rounded btn-primary mt-3" id="btn_add" style="height:auto;">Soumettre une demande de location</button>
  358.                     {% else %}
  359.                         <div class="alert alert-info text-center mt-3" style="margin-bottom: 0;">
  360.                             <i class="fas fa-info-circle"></i><br>
  361.                             La fonctionnalité paiement en ligne du prestataire n'est pas encore accessible.
  362.                             Vous pouvez réserver le produit et vous recevrez un email quand le paiement est disponible.
  363.                             <br>
  364.                             <input type="hidden" name="reservation" value="reserver">
  365.                             <button type="submit" class="btn btn-rounded btn-primary mt-3" id="btn_add" style="height:auto;">Réserver</button>
  366.                         </div>
  367.                     {% endif %}
  368.                 </div>
  369.             {% else %}
  370.                 <div class="alert alert-info text-center">
  371.                     <i class="fa fa-info-circle"></i><br>
  372.                     Veuillez vous connecter afin de faire une demande de location
  373.                     <br>
  374.                     {% set subCategory = product.subCategories.toArray()[0] %}
  375.                     {% set slug = "" %}
  376.                     {% if product.typeActivity is not null %}
  377.                         {% set slug = product.typeActivity.slug %}
  378.                     {% elseif product.typeHebergements is not null %}
  379.                         {% set slug = product.typeHebergements.slugTypeHebergm %}
  380.                     {% else %}
  381.                         {% set slug = subCategory.categories.toArray[0].slug %}
  382.                     {% endif %}
  383.                     
  384.                     <a id="reserverNotConnected" href="{{ path('app_login', { redirect: path('front_product_single', {
  385.                                                     'slug': slug,
  386.                                                     'subCategorySlug': subCategory.subCategorySlug,
  387.                                                     'product_id': product.id,
  388.                                                     'productSlug': product.productSlug}) }) }}" 
  389.                        class="btn btn-rounded btn-primary mt-3" style="height:auto;">
  390.                        Réserver
  391.                     </a>
  392.                
  393.                 </div>
  394.             {% endif %}
  395.         {% else %}
  396.             <p>Produit pas encore disponible à l’achat</p>
  397.         {% endif %}
  398.     {% else %}
  399.         <p>Connectez-vous en tant que client pour louer cette service</p>
  400.     {% endif %}
  401. </form>