<form method="post" action="{{ path('new_location', {'id': product.id}) }}" id="form_location">
{% if is_granted('ROLE_ENTERPRISE') == false %}
{% if product.company.isConfirmed %}
{% set isNbGuest = null %}
{% for subcategory in product.subCategories %}
{% if subcategory.isNbGuest %}
{% set isNbGuest = true %}
{% endif %}
{% endfor %}
{# {% if isNbGuest %}
<input id="storageGroupsOption" type="hidden" name="Options" >
<div class="form-group" id="nb_guest_old">
<label for="nb_guest">Nombre d’invités</label><br>
<input type="text" name="nb_guest" class="form-control" placeholder="Nombre d’invités" required>
</div>
{% endif %} #}
{# show nbr personne if hebergement #}
{% if product.subCategories.toArray[0].subCategorySlug == "hebergements" %}
<div class="d-flex justify-content-between ">
<p>Adulte</p>
<div id="qt_adulte" class="cont_btn_qt">
<button type="button" disabled>-</button>
<span>1</span>
<input type="hidden" name="qt_adulte" value=1>
<button type="button">+</button>
</div>
</div>
<div class="d-flex justify-content-between ">
<p>Enfant</p>
<div id="qt_enfant" class="cont_btn_qt">
<button type="button" disabled>-</button>
<span>0</span>
<input type="hidden" name="qt_enfant" value=0>
<button type="button">+</button>
</div>
</div>
<div class="d-flex justify-content-between ">
<p>Bébé</p>
<div id="qt_bebe" class="cont_btn_qt">
<button type="button" disabled>-</button>
<span>0</span>
<input type="hidden" name="qt_bebe" value=0>
<button type="button">+</button>
</div>
</div>
{% endif %}
{# Récupérer les périodes d'indisponibilité du produit #}
{% for unavailableDate in product.productAgendas %}
<input type="hidden" class="startDayNotAvailable" value={{unavailableDate.startDayNotAvailable|date('Y-m-d')}}>
<input type="hidden" class="endDayNotAvailable" value={{unavailableDate.endDayNotAvailable|date('Y-m-d')}}>
<input type="hidden" class="raisonNotAvailable" value={{unavailableDate.raisonNotAvailable}}>
{% endfor %}
{# Récupérer nombre de nuit min du produit s'il y en a #}
{% if product.nightMin and product.nightMin != null %}
<input type="hidden" class="nbrNightMin" value="{{product.nightMin}}">
{% endif %}
{# reservation date #}
{% if product.typeLocation.label == "heure" %}
<div class="form-group mt-4 mb-2">
<div class="form-input">
<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>
</div>
</div>
<div class="form-group mb-5">
<div class="form-input">
<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>
</div>
</div>
{% else %}
<div class="form-group mt-4 mb-2">
<label for="">Date de réservation
{% if product.nightMin and product.nightMin != null %}
<small>({{ product.nightMin }} nuit(s) minimum)</small>
{% endif %}
</label>
<input id="daterangePicker" type="text" name="" autocomplete="off"
style="border: 0px solid white; border-bottom: 1px solid #aaa;" class="form-control input-md" required>
{# <div class="venue-form-calendar">
<i class="far fa-calendar-alt"></i>
</div> #}
<input type="hidden" id="start" name="start" required>
<input type="hidden" id="end" name="end" required>
</div>
{% endif %}
<div class="form-group mb-2">
<div class="form-input">
<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>
</div>
</div>
<div class="form-row mb-2">
<div class="form-input">
<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>
</div>
</div>
{# If other options #}
{% set isClothing = null %}
{% for subcategory in product.subCategories %}
{% if subcategory.isClothing %}
{% set isClothing = true %}
{% endif %}
{% endfor %}
{% if isClothing and product.sizes is not empty %}
<div class="form-group">
<label for="quantity_product">Tailles disponibles</label><br>
<select class="form-control wide" id="exampleFormControlSelect1" name="size">
{% for size in product.sizes %}
<option>{{ size }}</option>
{% endfor %}
</select>
</div>
{% endif %}
{% set isClothingRing = null %}
{% for subcategory in product.subCategories %}
{% if subcategory.isClothingRing %}
{% set isClothingRing = true %}
{% endif %}
{% endfor %}
{% if isClothingRing and product.sizeRing is not empty %}
<div class="form-group">
<label for="sizeRing">Tailles disponibles</label><br>
<select class="form-control wide" id="sizeRing" name="size_ring">
{% for size in product.sizeRing %}
<option>{{ size }}</option>
{% endfor %}
</select>
</div>
{% endif %}
{% set isColor = null %}
{% for subcategory in product.subCategories %}
{% if subcategory.isColor %}
{% set isColor = true %}
{% endif %}
{% endfor %}
{% if isColor and product.colors is not empty %}
<div class="form-group">
<label for="quantity_product">Couleurs disponibles</label><br>
<select class="form-control wide" id="exampleFormControlSelect1" name="color">
{% for color in product.colors %}
<option>{{ color }}</option>
{% endfor %}
</select>
</div>
{% endif %}
{# Button modal option #}
{# If the product(location) have chambre #}
{% if product.chambres.toArray() != [] and product.typeHebergements.slugTypeHebergm == "hotel" %}
<div class="row justify-content-center mb-2">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modalOptionChambre" >
Options sur la chambre
</button>
</div>
{% endif %}
{# If the product(location) have options #}
{% if product.productOptions.toArray() != [] %}
<div class="row justify-content-center mb-2">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modalOptionGP" onclick="voirtoutOption('{{product.id}}','{{ app.request.getSchemeAndHttpHost() }}')">
Options disponibles
</button>
</div>
{% endif %}
{# Recupérer les reductions entrees par le prestataire s'il y en a #}
{% if product.productReductions is not null and product.productReductions is not empty %}
{% for reductionData in product.productReductions %}
<input type="hidden" class="startDay" value="{{ reductionData.startDay }}">
<input type="hidden" class="reduction" value="{{ reductionData.reduction }}">
{% endfor %}
<div class="row justify-content-center mt-5 mb-4">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modalReduction" onclick="voirtouteReduction('{{product.id}}','{{ app.request.getSchemeAndHttpHost() }}')">
Voir les reductions de prix
</button>
</div>
{% endif %}
<div class="d-none">
{% if product.productOptions %}
<span class="font-weight-bold">Options disponibles :</span>
<div class="row pl-3 pr-3">
{% for option in product.productOptions %}
{% if option.image1 %}
<div class="d-flex col-md-12">
<div class="col-md-6">
<img src="{{ asset(constant('App\\Services\\File::IMAGE_PRODUCT_DIR') ~ option.image1) }}">
</div>
<div class="col-md-6">
<img src="{{ asset(constant('App\\Services\\File::IMAGE_PRODUCT_DIR') ~ option.image2) }}">
</div>
</div>
{% endif %}
<div class="col-md-12 custom-control custom-checkbox">
<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 }}">
<label class="custom-control-label" for="option{{ loop.index }}">
{# {% set prix = value %} #}
<strong id="valeurOptions">{{ option.price|number_format(2, ',') }}
€</strong>
-
{{ option.name }}</label>
</div>
<hr>
{% endfor %}
</div>
{% endif %}
</div>
<div class="row col-md-12 pt-4 d-flex justify-content-between">
<h4>Total :
</h4>
<div>
{% set today = "now"|date('Y-m-d') %}
{% set customPriceFound = false %}
{% set customPrice = 0 %}
{% set currentPrice = 0 %}
{% set price = 0 %}
{% set difference = null %}
{% set reductionPercentage = 0 %}
{% set reductionValid = false %}
{% if product.dayPrice is not null %}
{% for dayPrice in product.dayPrice %}
{% set formattedDate = dayPrice.customDate|date('Y-m-d') %}
{% if formattedDate == today %}
{% set customPriceFound = true %}
{% set customPrice = dayPrice.customPrice|number_format(2, '.', '') %}
{% endif %}
{% endfor %}
{% endif %}
{# {% if customPriceFound and customPrice !=0 %}
{% set price = customPrice %}
{% else %}
#}
{% set month = "now"|date('n') %}
{% if month >= 3 and month <= 5 %}
{% set springPrice = product.springPrice %}
{% if springPrice is not null %}
{% set currentPrice = product.springPrice %}
{% else %}
{% set currentPrice = 0 %}
{% endif %}
{% elseif month >= 6 and month <= 8 %}
{% set summerPrice = product.summerPrice %}
{% if summerPrice is not null %}
{% set currentPrice = product.summerPrice %}
{% else %}
{% set currentPrice = 0 %}
{% endif %}
{% elseif month >= 9 and month <= 11 %}
{% set autumnPrice = product.autumnPrice %}
{% if autumnPrice is not null %}
{% set currentPrice = product.autumnPrice %}
{% else %}
{% set currentPrice = 0 %}
{% endif %}
{% else %}
{% set winterPrice = product.winterPrice %}
{% if winterPrice is not null %}
{% set currentPrice = product.winterPrice %}
{% else %}
{% set currentPrice = 0 %}
{% endif %}
{% endif %}
{% set day = "now"|date('N') %}
{% if day == 6 or day == 7 %}
{% set weekEndPrice = product.weekEndPrice %}
{% if weekEndPrice is not null %}
{% set currentPrice = product.weekEndPrice %}
{% else %}
{% set currentPrice = 0 %}
{% endif %}
{% endif %}
{% set periodPrice = 0 %}
{% for period in product.periodPrice.toArray() %}
{% set startDate = period.startDate|date("Y-m-d") %}
{% set endDate = period.endDate|date("Y-m-d") %}
{% if today >= startDate and today <= endDate and period.price is not null %}
{% set periodPrice = period.price %}
{% else %}
{% set currentPrice = 0 %}
{% endif %}
{% endfor %}
{# {% endif %} #}
{# {% if customPrice == 0 and currentPrice == 0 %}
{% set price = product.price %}
{% endif %} #}
{% if customPriceFound and customPrice !=0 %}
{% set price = customPrice %}
{% elseif periodPrice != 0 %}
{% set price = periodPrice %}
{% elseif currentPrice != 0 and currentPrice is not null %}
{% set price = currentPrice %}
{% elseif customPrice == 0 and currentPrice == 0 and periodPrice == 0 %}
{% set price = product.price %}
{% endif %}
{% for autoReduce in product.productAutoReduction.toArray %}
{% if autoReduce.createdAt is not null and autoReduce.countdown is not null and autoReduce.duration is not null and autoReduce.reductionPercentage is not null %}
{% set difference = date(today).diff(autoReduce.createdAt).days %}
{% set duration = autoReduce.duration %}
{% set countdown = autoReduce.countdown %}
{% set reductionPercentage = autoReduce.reductionPercentage %}
{% set durationout = duration + countdown %}
{# {{ dump(countdown,difference,durationout,duration) }} #}
{% set reductionValid = difference > countdown and difference <= durationout %}
{% endif %}
{% endfor %}
{# {{ dump(reductionValid) }} #}
{% if reductionValid %}
{% set priceReduced = price - ((price * reductionPercentage) / 100) %}
<span id="totalPricese" style="font-size:1.5em" class="prece-total-location">{{ priceReduced|number_format(2, ',') }}</span>€
{% else %}
<span id="totalPricese" style="font-size:1.5em" class="prece-total-location">{{ price|number_format(2, ',') }}</span>€
{% endif %}
</div>
{% if product.typeHebergements is not null %}
{% if product.typeHebergements.slugTypeHebergm == 'hotel' %}
<input type="hidden" name="" id="totalPriceHidden" value=0>
{% else %}
{% if reductionValid %}
<input type="hidden" name="" id="totalPriceHidden" value="{{ priceReduced }}">
{% else %}
<input type="hidden" name="" id="totalPriceHidden" value="{{ price }}">
{% endif %}
{% endif %}
{% else %}
{% if reductionValid %}
<input type="hidden" name="" id="totalPriceHidden" value="{{ priceReduced }}">
{% else %}
<input type="hidden" name="" id="totalPriceHidden" value="{{ price }}">
{% endif %}
{% endif %}
<input type="hidden" name="total_price_reduced" id="totalPriceReduced">
</div>
<div id="message_form"></div>
{% if app.user %}
<div class="form-group text-center">
{% if product.company.stripeAccountId == null %}
<div class="alert alert-info text-center mt-3" style="margin-bottom: 0;">
<i class="fas fa-info-circle"></i><br>
La fonctionnalité paiement en ligne du prestataire doit être configurée.
</div>
{% endif %}
{% if product.company.abonnements.count() > 0 %}
{% if product.company.abonnements.last.isActive == true %}
<button type="submit" class="btn btn-rounded btn-primary mt-3" id="btn_add" style="height:auto;">Soumettre une demande de location</button>
{% elseif product.company.abonnement.isActive == false and product.company.commissionActive == true %}
<button type="submit" class="btn btn-rounded btn-primary mt-3" id="btn_add" style="height:auto;">Soumettre une demande de location</button>
{% else %}
<div class="alert alert-info text-center mt-3" style="margin-bottom: 0;">
<i class="fas fa-info-circle"></i><br>
La fonctionnalité paiement en ligne du prestataire n'est pas encore accessible.
Vous pouvez réserver le produit et vous recevrez un email quand le paiement est disponible.
<br>
<input type="hidden" name="reservation" value="reserver">
<button type="submit" class="btn btn-rounded btn-primary mt-3" id="btn_add" style="height:auto;">Réserver</button>
</div>
{% endif %}
{% elseif product.company.abonnements.count == 0 and product.company.commissionActive == true %}
<button type="submit" class="btn btn-rounded btn-primary mt-3" id="btn_add" style="height:auto;">Soumettre une demande de location</button>
{% else %}
<div class="alert alert-info text-center mt-3" style="margin-bottom: 0;">
<i class="fas fa-info-circle"></i><br>
La fonctionnalité paiement en ligne du prestataire n'est pas encore accessible.
Vous pouvez réserver le produit et vous recevrez un email quand le paiement est disponible.
<br>
<input type="hidden" name="reservation" value="reserver">
<button type="submit" class="btn btn-rounded btn-primary mt-3" id="btn_add" style="height:auto;">Réserver</button>
</div>
{% endif %}
</div>
{% else %}
<div class="alert alert-info text-center">
<i class="fa fa-info-circle"></i><br>
Veuillez vous connecter afin de faire une demande de location
<br>
{% set subCategory = product.subCategories.toArray()[0] %}
{% set slug = "" %}
{% if product.typeActivity is not null %}
{% set slug = product.typeActivity.slug %}
{% elseif product.typeHebergements is not null %}
{% set slug = product.typeHebergements.slugTypeHebergm %}
{% else %}
{% set slug = subCategory.categories.toArray[0].slug %}
{% endif %}
<a id="reserverNotConnected" href="{{ path('app_login', { redirect: path('front_product_single', {
'slug': slug,
'subCategorySlug': subCategory.subCategorySlug,
'product_id': product.id,
'productSlug': product.productSlug}) }) }}"
class="btn btn-rounded btn-primary mt-3" style="height:auto;">
Réserver
</a>
</div>
{% endif %}
{% else %}
<p>Produit pas encore disponible à l’achat</p>
{% endif %}
{% else %}
<p>Connectez-vous en tant que client pour louer cette service</p>
{% endif %}
</form>