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