{% extends 'front/tunnel/layout.html.twig' %}
{% block head %}
<title>Étape 1</title>
{% endblock %}
{% block body %}
<!-- Timeline -->
<section class="w-full py-10 sm:py-20">
<ol class="flex flex-row w-full">
<!--first item-->
<li class="relative flex-1">
<div class="absolute top-2 left-1/2 w-full h-1.25 bg-lavande"></div>
<div class="relative z-10 flex flex-col items-center">
<div class="size-5 rounded-full bg-bleuindigo border-4 border-bleuindigo"></div>
<p class="mt-4 sm:mt-2 text-sm sm:text-lg font-bold text-bleuindigo text-center px-2">
1. Je sélectionne la durée
</p>
</div>
</li>
<!--Second item-->
<li class="relative flex-1">
<div class="absolute top-2 left-1/2 w-full h-1.25 bg-lavande"></div>
<div class="relative z-10 flex flex-col items-center">
<div class="size-5 rounded-full bg-lavande"></div>
<p class="mt-4 text-sm font-bold text-lavande text-center px-2">
2. J'accède à mon compte
</p>
</div>
</li>
<!--Third item-->
<li class="relative flex-1">
<div class="relative z-10 flex flex-col items-center">
<div class="size-5 rounded-full bg-lavande"></div>
<p class="mt-4 text-sm font-bold text-lavande text-center px-2">
3. Je procède au paiement
</p>
</div>
</li>
</ol>
</section>
{% if mode_free %}
<section class="flex justify-center mb-8 sm:mb-16">
<div class="text-center bg-jaune text-bleuindigo font-bold py-2 px-4 rounded-full text-sm sm:text-lg">
Vous ne serez pas débité avant la fin de votre essai de 7 jours, résiliable à tout moment.
</div>
</section>
{% endif %}
<!--Offres-->
<section class="flex justify-center">
<div class="flex flex-col lg:flex-row justify-between">
<!--Colonne gauche-->
<div class="flex flex-col lg:w-6/12 xl:w-7/12">
{% if not fromDashboardParent %}
<div>
<label for="enfants" class="text-bleuindigo tracking-tight sm:tracking-normal">
Combien d’enfants souhaitez-vous inscrire ?
</label>
<div class="flex items-center mt-2">
<div>
<select id="nbr-child" name="nbr-child" class="block rounded-3xl border-lavande py-1.5 text-gris text-sm">
<option value="1">1 enfant</option>
<option value="2">2 enfants</option>
<option value="3">3 enfants</option>
<option value="4">4 enfants</option>
<option value="5">5 enfants</option>
</select>
</div>
<div class="text-xs text-framboise font-bold ml-5">
<p>-50% pour chaque enfant supplémentaire</p>
</div>
</div>
</div>
{% else %}
<input type="hidden" name="nbr-child" value="1" id="nbr-child">
{% endif %}
<div>
<p class="text-bleuindigo mt-14">Sélectionnez la durée</p>
</div>
{% for row in listOffer %}
{% set noDiscountAuto = row.discount is null or (row.discountDate is not null and row.discountDate|date('U') < "now"|date('U') ) %}
{% if not noDiscountAuto %}
{% set priceReducePercent = (((((row.price/row.monthValid) - priceMark)/priceMark) * 100)|number_format(0, ',', '.')|abs) %}
{% else %}
{% set priceReducePercent = row.percentDiscount is null?(((((row.getAmount()/row.monthValid) - priceMark)/priceMark) * 100)|number_format(0, ',', '.')|abs) : row.percentDiscount %}
{% endif %}
{% set amount = noDiscountAuto ? row.price : row.getAmount() %}
<!--Carte 24 mois-->
<div class="flex flex-col sm:flex-row lg:flex-col xl:flex-row items-start relative justify-between border-lavande border rounded-lg p-5 mt-2">
{% if loop.first %}
<div class="flex items-center absolute text-bleuindigo text-[10px] font-bold bg-jaune rounded-xl px-2 -top-[8px] right-[20px]"><span class="text-lg -my-1 pr-1">♥</span> LE CHOIX DES PARENTS</div>
{% endif %}
<div class="flex items-center gap-x-3">
<input id="p-{{ loop.index }}" name="price" type="radio" value="{{ row.slug }}" class="input-price h-4 w-4 border-lavande{% if not noDiscountAuto %} js-auto-discount{% endif %}" {% if not noDiscountAuto%}data-discount="{{ row.discount.codePromo }}" data-multi-discount="{% if row.discount.moreChildReduce is not null %}{{ row.discount.moreChildReduce.percent }}{% endif %}"{% endif%} data-id="{{ row.id }}" data-title="{{ row.title }}" data-price="{{ row.price }}" data-month="{{ row.monthValid }}" data-period="{% if row.monthValid>1 %}{{ row.monthValid }}{% endif %} mois">
<label for="p-{{ loop.index }}" class="flex flex-row items-center text-nowrap">
<span class="text-bleuindigo font-bold text-xl mr-5">{{ row.monthValid }} mois</span>
{% if row.monthValid>1 or row.percentDiscount %}
<span class="text-white bg-pervenche text-[10px] rounded-4xl py-1 px-2">{% if row.percentDiscount is not null and row.percentDiscount is not empty %}{{ row.percentDiscount }}{% else %}{{ priceReducePercent }}{% endif %}% DE RÉDUCTION</span>
{% endif%}
</label>
</div>
<div class="flex flex-col sm:items-end sm:w-full sm:size-auto lg:w-full xl:size-auto sm:text-right mt-4 sm:mt-0">
<span class="text-xl">
<span class="text-pervenche sm:text-bleuindigo font-bold">{{ (amount/row.monthValid)|round(2, 'floor')|number_format(2, ',', '.') }}€/mois</span>
</span>
{% if not noDiscountAuto %}
<span class="text-base line-through">{{ priceMark|round(2, 'floor')|number_format(2, ',', '.') }}{#{{ (row.price/row.monthValid)|round(2, 'floor')|number_format(2, ',', '.') }}#}€/mois</span>
{% endif %}
<span class="text-xs">{% if row.monthValid>1 %}Paiement unique de {{ amount|number_format(2, ',', '.') }} €{% if row.monthValid<13 %}, reconduction tacite, annulable à tout moment{% else %}.{% endif %}{% else %}Sans engagement, reconduction tacite{% endif%}</span>
{% if row.monthValid > 1 and row.displayEcoText %} <span class="text-xs text-pervenche">soit {{ (priceMark * row.monthValid - amount)|number_format(2, ',', '.') }}€ économisés</span>{% endif%}
</div>
</div>
{% endfor %}
</div>
<!--Colonne droite-->
<div class="flex flex-col lg:w-5/12 xl:w-4/12 my-16 lg:mt-0">
<!--Encadré lavande-->
<div class="flex flex-col bg-lavandeclair rounded-2xl text-sm sm:text-base gap-y-2 p-5 sm:p-10">
<div class="text-bleuindigo font-bold text-xl">
Vous avez choisi l’offre
</div>
<div class="text-pervenche font-bold text-2xl sm:text-3xl">
{{ typeOffer.title|upper }}
</div>
<div class="text-lavande text-xs font-bold">
<a href="https://www.lesbonsprofs.com/nos-offres/" class="flex items-center hover:underline"><img src="/static/img/tunnel/stylo.webp" alt="Changer d'offre" class="w-3 mr-1">Changer d'offre</a>
</div>
<div class="font-bold mt-2">
{{ typeOffer.textPaid|raw }}
</div>
<div class="flex justify-between items-center mt-4">
<span class="flex text-bleuindigo font-bold">
<span class="flex items-center bg-jaune rounded-xl px-2 mr-1"><span class="text-lg -my-1 pr-1">★</span> 4,6</span>+ 300 avis Trustpilot
</span>
<span class="text-pervenche text-xs hover:underline"><a href="https://fr.trustpilot.com/review/lesbonsprofs.com" target="_blank">Voir les avis</a></span>
</div>
{% if mode_free %}
<div class="flex justify-between text-franboise font-bold mt-4">
<span>Montant dû aujourd'hui</span>
<span>0€</span>
</div>
<hr class="border-lavande border my-2" />
<div class="flex justify-between text-bleuindigo">
<span>Montant dû au {{ "now"|date_modify("+8 day")|format_datetime(locale='fr',pattern="dd MMMM YYYY") }}</span>
<span class="font-bold" id="som-toto"></span>
</div>
{% else %}
<div class="flex justify-between text-franboise font-bold mt-4">
<span>Montant dû aujourd'hui</span>
<span id="som-toto"></span>
</div>
{% endif %}
<button type="submit" class="bg-framboise hover:bg-bleuindigo hover:cursor-pointer text-white rounded-3xl font-bold py-3 mt-4 btn-form">Démarrer l'essai gratuit</button>
<div class="flex items-center text-pervenche font-bold mt-4">
<img src="/static/img/tunnel/coupon.webp" alt="Code promo" class="w-5 mr-2">Vous avez un code promo ?
</div>
<div class="flex mt-1">
<input type="text" name="promo" id="promo" autocomplete="username" class="flex-1 py-1.5 pl-5 placeholder:text-[3.5vw] sm:placeholder:text-[16px] rounded-l-3xl border-lavande border" placeholder="Entrez votre code promo">
<button type="submit" class="bg-pervenche px-3 py-2 text-3xl font-bold text-white shadow-xs hover:bg-framboise hover:cursor-pointer rounded-r-3xl" id="button-code-promo">→</button>
</div>
<div class="" id="tr-code">
<div style="padding: 2%;" class="mt-2">
<div class="remise-appliquee font-bold"></div>
<div id="text-percent"></div>
</div>
</div>
</div>
</div>
</div>
</section>
<form class="form-next-step-2" action="{{ path('choix-formule-step') }}?offre={{ getOffer }}" method="post" id="parents_registration_first_step_{% if getOffer == "essentielle" %}essentielle{% else %}assistancevisio{% endif %}">
</form>
{% endblock %}
{% block javascripts %}
<!--footer-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
function calculPrice(){
var nbrChild = parseInt($('#nbr-child').val());
var som = 0;
if($('input[name="price"]:checked').length==1){
var period = $('input[name="price"]:checked').attr('data-period');
var month = $('input[name="price"]:checked').attr('data-month');
var price = $('input[name="price"]:checked').attr('data-price');
var realPrice = parseFloat(price);
var multiPercent = 50;
var percent = 'null';
var moreChildrenActive = {{ moreChildrenActive?1:0 }};
if($('#button-code-promo').is("[data-percent]")){
percent = $('#button-code-promo').attr('data-percent');
multiPercent = $('#button-code-promo').attr('data-multi-percent')
}
if($('input[name="price"]:checked').is('[data-multi-discount]')){
multiPercent = $('input[name="price"]:checked').attr('data-multi-discount');
}
var priceMoreChild = (realPrice - realPrice*(parseFloat(multiPercent)/100));
for(var i = 0;i<nbrChild;i++){
if(percent != 'null' && percent != 0){
if( moreChildrenActive || i>0){
som = som + priceMoreChild;
}else{
som = som + (realPrice - realPrice*(parseFloat(percent)/100));
}
}else{
if(moreChildrenActive || i>0){
som = som + priceMoreChild;
}else{
som = som + realPrice;
}
}
}
$('#som-toto').text('').text((som.toFixed(2)).replaceAll('.',',')+' €');
$('#som-toto').attr('data-som',som.toFixed(2))
$('.total-price').text(' / '+period);
}
}
$('#nbr-child').change(function(){
var val = $(this).val();
calculPrice();
if($('.form-next-step-2').find('input[name="child"]').length==0){
$('.form-next-step-2').append('<input type="hidden" name="child" value="'+val+'"/>')
}else{
$('.form-next-step-2').find('input[name="child"]').val(val);
}
})
var percent = 0;
var coupon
$('#button-code-promo').click(function(){
if ($('input[name="price"]:checked').length==1){
var priceId = $('input[name="price"]:checked').attr('data-id');
var self = $(this);
$(this).prev().removeClass('is-invalid');
coupon = $(this).prev().val();
self.parent().parent().find('.invalid-feedback').text('')
$.ajax({
url:"{{ path('valid_coupon') }}",
data:"coupon="+coupon,
success:function(elem){
var verif= true;
self.parent().find('input').val('');
if(elem.success){
if(elem.data.allowOffer.length>0 && !elem.data.allowOffer.includes(parseInt(priceId))){
verif = false;
}
if(verif){
if($('.form-next-step-2').find('input[name="discount"]').length==0){
$('.form-next-step-2').append('<input type="hidden" name="discount" value="'+elem.data.code+'"/>')
}else{
$('.form-next-step-2').find('input[name="discount"]').val(elem.data.code);
}
percent = elem.data.percent;
self.attr('data-percent',percent);
self.attr('data-multi-percent',elem.data.percentMulti);
//$('#text-percent').text('').text('reduction de '+percent+'%')
$('.remise-appliquee').text('').html('<span class="font-bold me-2">Promotion appliquée :</span>'+elem.data.description);
self.addClass('js-calculate-auto');
calculPrice();
}
}
if(!elem.success || !verif){
self.parents('.input-group').parent().find('.invalid-feedback').text('').text('Ce code promo est invalide !');
if(!self.parents('.input-group').find('input').hasClass('is-invalid')){
self.parents('.input-group').find('input').addClass('is-invalid');
}
}
}
})
}else{
alert('Veuillez choisir une durée de votre offre')
}
})
$('input[name="price"]').change(function(){
if($(this).is(':checked')){
var price = parseFloat($(this).attr('data-price'));
var period = $(this).attr('data-period');
var offer = $(this).val();
var month = $(this).attr('data-month');
if($(this).hasClass('js-auto-discount')){
var coupon = $(this).attr('data-discount');
$('.u-spinner').addClass('open')
$.ajax({
url:"{{ path('valid_coupon') }}",
data:"coupon="+coupon,
success:function(elem){
if(elem.success){
//$('#tr-code').removeClass('d-none')
if($('.form-next-step-2').find('input[name="discount"]').length==0){
$('.form-next-step-2').append('<input type="hidden" name="discount" value="'+elem.data.code+'"/>')
}else{
$('.form-next-step-2').find('input[name="discount"]').val(elem.data.code);
}
percent = elem.data.percent;
$('#button-code-promo').attr('data-percent',percent);
if(!$('#button-code-promo').hasClass('js-calculate-auto')){
$('#button-code-promo').addClass('js-calculate-auto')
}
// self.attr('data-percent',percent);
//$('#text-percent').text('').text('reduction de '+percent+'%')
$('.remise-appliquee').text('').text('Promotion appliquée : '+elem.data.description);
calculPrice();
}
$('.u-spinner').removeClass('open')
}
})
}else{
if($('.form-next-step-2').find('input[name="discount"]').length==1){
$('.form-next-step-2').find('input[name="discount"]').remove()
}
//$('#text-percent').text('')
$('.remise-appliquee').text('');
calculPrice()
}
if($('.form-next-step-2').find('input[name="offer"]').length==0){
$('.form-next-step-2').append('<input type="hidden" name="offer" value="'+offer+'"/>')
}else{
$('.form-next-step-2').find('input[name="offer"]').val(offer);
}
// $('#text-toto-offer-period').removeClass('d-none').addClass('d-block')
// $('#toto-offer-period').text(period.toLowerCase())
}
})
$('input[name="price"]').change()
$('.btn-form').click(function(){
if($('.form-next-step-2').find('input[name="offer"]').length==0){
}else{
$('.form-next-step-2').submit();
}
})
{% if not getPrice %}
$('#p-1').click();
{% else %}
$('.input-price[data-id="{{ getPrice }}"]').click();
{% endif %}
})
</script>
{% endblock %}