{% extends 'base.html.twig' %}
{% block title %} Récapitulatif de devis : {{ service.title }} | {{ parent() }} {% endblock %}
{% block body %}
<section class="grey-blue-bg small-padding">
<div class="container">
<div class="row">
<div class="col-md-8">
{{ include('base-default/message-flash-devis.html.twig') }}
<div class="list-single-main-container pl-0">
<div class="title-devis">
<span>Devis immédiat pour {{ service.title }}</span>
</div>
<div class="etape-demande-devis fl-wrap mb-4">
<div class="flex-center-wrap">
<a href="{{ url('app_client_service', {'slug': service.slug}) }}"><span>1</span> Type de trajet</a>
<a href="{{ url('app_client_service_route_description', {'slug': service.slug}) }}"><span>2</span> Description trajet</a>
<a href="{{ url('app_client_service_login_info', {'slug': service.slug}) }}"><span>3</span> Vos informations</a>
<a href="#" class="active"><span>4</span> Récapitulatif/Validation</a>
</div>
<div class="box-widget-list text-left mt-3">
<div class="d-flex align-items-center">
<img src="{{ asset('front/images/bot-recap.png') }}" class="img-recap-devis" alt="" />
<p class="p-recap-devis">Nous allons faire un récapitulatif ensemble.</p>
</div>
</div>
<div class="box-widget-list text-left mt-1">
<p>Vous avez besoin <span class="text-theme-bleu-marine fw-bold text-uppercase">{{ service.title }}</span> pour <span class="text-theme-bleu-marine fw-bold">{{ devis.numberOfPeople }}</span> personne(s) au départ de <span class="text-theme-bleu-marine fw-bold">{{ devis.departureAddress }}</span>{% if devis.typeOfTrip == 'Séjours' %}, le <span class="text-theme-bleu-marine fw-bold">{{ devis.departureDate|date('d/m/Y') }}</span>{% endif %} à <span class="text-theme-bleu-marine fw-bold">{{ devis.departureTime|date('H\\hi') }}</span> en destination de <span class="text-theme-bleu-marine fw-bold">{{ devis.arrivalAddress }}</span>. </p>
{% if devis.distance and devis.distancePerTrip %}
<p>Vous allez parcourir une distance approximative de <span class="text-theme-bleu-marine fw-bold">{{ devis.distance }} ({{ devis.distancePerTrip }} par trajet)</span>.</p>
{% else %}
<p>Vous allez parcourir une distance approximative de <span class="text-theme-bleu-marine fw-bold">{{ devis.distance }}</span>.</p>
{% endif %}
{% if devis.needVehicleOnSite == 'Non' %}
<p>Sur place, vous n'aurez pas besoin du véhicule.</p>
{% elseif devis.needVehicleOnSite == 'Oui' %}
{% if devis.typeOfTrip == 'Séjours' %}
<p class="pb-0">Voici le détail des destinations pendant votre séjour :</p>
{% elseif devis.typeOfTrip == 'Aller-Retour' %}
<p class="pb-0">Voici le détail des destinations pendant votre trajet :</p>
{% endif %}
{% for vehicleDetail in devis.vehicleDetails %}
{% if devis.typeOfTrip == 'Séjours' %}
<p {% if vehicleDetail.infos %}class="pb-0"{% else %}{% if loop.last %}{% else %}class="pb-0"{% endif %}{% endif %}><i class="fas fa-circle font-size-04 vertical-align-middle"></i> Le <span class="text-theme-bleu-marine fw-bold">{{ vehicleDetail.day|date('d/m/Y') }}</span>, départ de <span class="text-theme-bleu-marine fw-bold">{{ vehicleDetail.departureAddress }}</span> à destination de <span class="text-theme-bleu-marine fw-bold">{{ vehicleDetail.destinationAddress }}</span>. Départ à <span class="text-theme-bleu-marine fw-bold">{{ vehicleDetail.departureTime|date('H\\hi') }}</span> et retour à <span class="text-theme-bleu-marine fw-bold">{{ vehicleDetail.returnTime|date('H\\hi') }}</span>. </p>
{% if vehicleDetail.infos %}
<p {% if loop.last %}{% else %}class="pb-0"{% endif %}>Informations supplémentaires : <span class="text-theme-bleu-marine fw-bold">{{ vehicleDetail.infos }}</span></p>
{% endif %}
{% elseif devis.typeOfTrip == 'Aller-Retour' %}
<p {% if vehicleDetail.infos %}class="pb-0"{% else %}{% if loop.last %}{% else %}class="pb-0"{% endif %}{% endif %}><i class="fas fa-circle font-size-04 vertical-align-middle"></i> Trajet Aller-Retour : départ de <span class="text-theme-bleu-marine fw-bold">{{ vehicleDetail.departureAddress }}</span> à destination de <span class="text-theme-bleu-marine fw-bold">{{ vehicleDetail.destinationAddress }}</span>. Départ à <span class="text-theme-bleu-marine fw-bold">{{ vehicleDetail.departureTime|date('H\\hi') }}</span> et retour à <span class="text-theme-bleu-marine fw-bold">{{ vehicleDetail.returnTime|date('H\\hi') }}</span>. </p>
{% if vehicleDetail.infos %}
<p {% if loop.last %}{% else %}class="pb-0"{% endif %}>Informations supplémentaires : <span class="text-theme-bleu-marine fw-bold">{{ vehicleDetail.infos }}</span></p>
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% if devis.addPdfDocument == 'Oui' %}
<p class="pb-0">Vous souhaitez envoyer le(s) document(s) suivant(s) au transporteur :</p>
{% for attachment in devis.attachments %}
<p {% if loop.last %}{% else %}class="pb-0"{% endif %}><i class="fas fa-circle font-size-04 vertical-align-middle"></i> <span class="xt-theme-bleu-marine fw-bold text-italic">{{ attachment.originalName }}</span></p>
{% endfor %}
{% endif %}
{% if devis.typeOfTrip == 'Aller-Retour' or devis.typeOfTrip == 'Séjours' %}
<p>Votre retour s'effectuera {% if devis.typeOfTrip == 'Séjours' %}le <span class="text-theme-bleu-marine fw-bold">{{ devis.returnDate|date('d/m/Y') }}</span>{% endif %} à <span class="text-theme-bleu-marine fw-bold">{{ devis.returnTime|date('H\\hi') }}</span> depuis le <span class="text-theme-bleu-marine fw-bold">{{ devis.arrivalAddress }}</span> vers <span class="text-theme-bleu-marine fw-bold">{{ devis.departureAddress }}</span>. </p>
{% endif %}
<p>Vous {% if devis.devisLuggage.name == 'Aucun bagage' %}ne{% endif %} disposerez d{% if devis.devisLuggage.name == 'Aucun bagage' %}'{% else %}e{% endif %} <span class="text-theme-bleu-marine fw-bold">{{ devis.devisLuggage.name }}</span>, et le type de déplacement sera <span class="text-theme-bleu-marine fw-bold">{{ devis.devisTravelReason.name }}</span>.</p>
{% if devis.devisEquipment and devis.devisEquipment is not empty %}
<p class="pb-0">Vous avez besoin d'équipements particuliers dans le véhicule ci-dessous :</p>
{% for equipment in devis.devisEquipment %}
<p {% if loop.last %}{% else %}class="pb-0"{% endif %}><i class="fas fa-circle font-size-04 vertical-align-middle"></i> {{ equipment.name }}</p>
{% endfor %}
{% else %}
<p>Vous n'avez pas besoin d'équipements particuliers dans le véhicule.</p>
{% endif %}
</div>
<div class="box-widget-list">
<hr class="my-2">
</div>
<div class="box-widget-list text-left mt-4 mb-1">
<h1 class="text-theme-bleu-marine text-uppercase text-center fw-bold">Option de diffusion</h1>
</div>
<div class="devis-currency-wrap">
<div class="show-currency-devis">
<span class="text-theme-orange text-uppercase fw-bold mr-1">
<img src="{{ asset('front/images/money_8366606.png') }}" class="img-crab-devis mr-2" alt=""> {{ app.user.creditBalance | number_format(2, ',', ' ') }} Crédit(s)
</span>
<span class="text-theme-gray text-uppercase fw-bold mr-1"> Restant</span>
<span class="text-uppercase btn-recharger-devis modal-open">Recharger</span>
</div>
</div>
{{ form_start(form) }}
<div class="form-diffusion-option">
<div class="mb-1">
{{ form_widget(form.miseEnAvance) }}
<img src="{{ asset('front/images/views.png') }}" class="ml-1" alt="">
<label for="sg_devis_miseEnAvance">Mise en avant de votre demande <span class="dot-mise-en-avance">:</span> <span class="ml-2">6 Crédits</span></label>
</div>
<div class="mb-1">
{{ form_widget(form.remonteEnTeteDeListe) }}
<img src="{{ asset('front/images/up_annonce.png') }}" class="ml-1" alt="">
<label for="sg_devis_remonteEnTeteDeListe">Remonter en tête de liste tout les jours : <span class="ml-2">8 Crédits</span></label>
</div>
<div class="mb-1">
{{ form_widget(form.demandeUrgente) }}
<img src="{{ asset('front/images/annonce_urgente.png') }}" class="ml-1" alt="">
<label for="sg_devis_demandeUrgente">Logo demande urgente <span class="dot-demande-urgente">:</span> <span class="ml-2">3 Crédits</span></label>
</div>
<div class="div-total-devis">
{% if form.vars.errors is not empty %}
<div class="form-error">
{% for error in form.vars.errors %}
<p class="pb-0">{{ error.message }}</p>
{% endfor %}
</div>
{% endif %}
<div class="">
<p class="text-uppercase fw-bold">Total : <span id="total-balance" class="text-theme-orange">xx</span><span class="text-theme-orange"> crédit(s)</span></p>
</div>
</div>
</div>
<div class="book-form">
<div class="width-100 d-flex justify-content-between flex-wrap mt-4">
<a href="{{ url('app_client_service_login_info', {'slug': service.slug}) }}" class="btn-prev color3-bg">
<i class="fal fa-angle-double-left"></i> Précédent
</a>
<button type="submit" class="btn-next color2-bg">
{% trans %}Validation{% endtrans %}
</button>
</div>
</div>
{{ form_end(form) }}
</div>
</div>
</div>
<div class="col-md-4">
<div class="box-widget-wrap">
<div class="box-widget-item fl-wrap">
<div class="box-widget widget-posts">
<div class="box-widget-content pb-3">
<div class="box-widget-item-header mb-3">
<h3 class="text-uppercase fw-bold text-theme-bleu-marine">Votre demande</h3>
</div>
<div class="box-widget-list">
<h4 class="text-left mb-3 step-devis-request text-theme-bleu-marine fw-bold"><span>1</span> Type de trajet</h4>
</div>
<div id="map-distance-2address" data-departure-address={{ devis.departureAddress|e('html_attr') }} data-arrival-address={{ devis.arrivalAddress|e('html_attr') }} data-start-latitude="{{ devis.startLatitude|e('html_attr') }}" data-start-longitude="{{ devis.startLongitude|e('html_attr') }}" data-end-latitude="{{ devis.endLatitude|e('html_attr') }}" data-end-longitude="{{ devis.endLongitude|e('html_attr') }}"></div>
<div class="box-widget-list">
<h4 class="text-left text-uppercase text-theme-orange fw-bold mb-1">{{ devis.typeOfTrip }}</h4>
</div>
<div class="box-widget-list">
<ul>
{% if devis.departureAddress %}
<li class="departure-address"><a href="#" class="mx-0"><i class="fal fa-map-marker-alt"></i> {{ devis.departureAddress }}</a></li>
{% endif %}
{% if devis.arrivalAddress %}
<li class="arrival-address"><a href="#" class="mx-0"><i class="fal fa-map-pin"></i> {{ devis.arrivalAddress }}</a></li>
{% endif %}
{% if devis.departureDate and devis.departureTime %}
<li class="mb-2"><span><i class="fal fa-calendar-alt"></i> Aller :</span> <a href="#">{{ devis.departureDate|date('d/m/Y') }} départ à {{ devis.departureTime|date('H\\hi') }}</a></li>
{% endif %}
{% if devis.returnDate and devis.returnTime %}
<li class="mb-2"><span><i class="fal fa-calendar-alt"></i> Retour :</span> <a href="#">{{ devis.returnDate|date('d/m/Y') }} départ à {{ devis.returnTime|date('H\\hi') }} </a></li>
{% elseif devis.returnDate is null and devis.returnTime %}
<li class="mb-2"><span><i class="fal fa-clock"></i> Retour :</span> <a href="#"> {{ devis.returnTime|date('H\\hi') }} </a></li>
{% endif %}
{% if devis.distance and devis.distancePerTrip %}
<li class="mb-2"><span><i class="fal fa-road"></i> Distance :</span> <a href="#">{{ devis.distance }} ({{ devis.distancePerTrip }} par trajet)</a></li>
{% else %}
<li class="mb-2"><span><i class="fal fa-road"></i> Distance :</span> <a href="#">{{ devis.distance }}</a></li>
{% endif %}
{% if devis.numberOfPeople %}
<li><span><i class="fal fa-users"></i> Passagers :</span> <a href="#">{{ devis.numberOfPeople }}</a></li>
{% endif %}
</ul>
</div>
</div>
<div class="box-widget-content pt-0">
<div class="box-widget-list">
<h4 class="text-left mb-1 step-devis-request text-theme-bleu-marine fw-bold"><span>2</span> Description trajet</h4>
</div>
<div class="box-widget-list">
<ul>
<li class="departure-address mb-0"><a href="#" class="mx-0 text-uppercase"><i class="fal fa-car"></i> Utilisation du véhicule : {% if devis.needVehicleOnSite == 'Oui' %}<strong>Oui</strong>{% else %}<strong>Non</strong>{% endif %}</a></li>
{% if devis.vehicleDetails and devis.vehicleDetails is not empty %}
{% for vehicleDetail in devis.vehicleDetails %}
{% if vehicleDetail.day %}
<li class="departure-address py-0"><a href="#" class="mx-0 text-transform-none">- {{ vehicleDetail.day|date('d/m/Y') }} :</a></li>
{% endif %}
{% if vehicleDetail.departureAddress %}
<li class="departure-address py-0"><a href="#" class="mx-0 text-transform-none">{{ vehicleDetail.departureAddress }},</a></li>
{% endif %}
{% if vehicleDetail.destinationAddress %}
<li class="departure-address py-0"><a href="#" class="mx-0 text-transform-none">{{ vehicleDetail.destinationAddress }}</a></li>
{% endif %}
{% if vehicleDetail.departureTime and vehicleDetail.returnTime %}
<li class="departure-address {% if vehicleDetail.infos %}py-0{% else %}pt-0{% endif %}"><a href="#" class="mx-0 text-transform-none">Départ {{ vehicleDetail.departureTime|date('H\\hi') }} - Retour {{ vehicleDetail.returnTime|date('H\\hi') }}</a></li>
{% endif %}
{% if vehicleDetail.infos %}
<li class="departure-address pt-0"><a href="#" class="mx-0 text-transform-none">{{ vehicleDetail.infos|raw }}</a></li>
{% endif %}
{% endfor %}
{% endif %}
<li class="departure-address pt-1 mb-0"><a href="#" class="mx-0 text-uppercase"><i class="fal fa-paperclip"></i> Documents complémentaires : {% if devis.addPdfDocument == 'Oui' %}<strong>Oui</strong>{% else %}<strong>Non</strong>{% endif %}</a></li>
{% if devis.attachments and devis.attachments is not empty %}
{% for attachment in devis.attachments %}
{% if attachment.originalName %}
<li class="departure-address {% if loop.last %}pt-0{% else %}py-0{% endif %}"><a href="#" class="mx-0 text-transform-none text-italic fw-bold text-theme-bleu-marine">{{ attachment.originalName }}</a></li>
{% endif %}
{% endfor %}
{% endif %}
{% if devis.devisTravelReason %}
<li class="mb-2"><span><i class="fal fa-road"></i> Motif du déplacement :</span> <a href="#">{{ devis.devisTravelReason.name }}</a></li>
{% endif %}
{% if devis.devisLuggage %}
<li class="mb-2"><span><i class="fal fa-suitcase"></i> Bagages :</span> <a href="#">{{ devis.devisLuggage.name }}</a></li>
{% endif %}
{% if devis.infos %}
<li class="mb-2"><span><i class="fal fa-info-circle"></i> Informations complémentaires :</span></li>
<li class="departure-address py-0"><a href="#" class="mx-0 text-transform-none">{{ devis.infos|raw }}</a></li>
{% endif %}
{% if devis.devisEquipment %}
<li class="mb-2"><span><i class="fal fa-screwdriver"></i> Equipement indispensable :</span></li>
{% for equipment in devis.devisEquipment %}
<li class="departure-address py-0"><a href="#" class="mx-0 text-transform-none">- {{ equipment.name }}</a></li>
{% endfor %}
{% endif %}
{% if devis.devisBudget %}
<li class="mb-0"><span><i class="fal fa-money-bill-wave"></i> Budget :</span> <a href="#">{{ devis.devisBudget.name }}</a></li>
{% endif %}
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script>
const stripe = Stripe('{{ stripe_public_key }}');
const elements = stripe.elements();
const cardNumber = elements.create('cardNumber', { placeholder: '1234 1234 1234 1234' });
cardNumber.mount('#sg_credit_reload_card_number');
const expDate = elements.create('cardExpiry');
expDate.mount('#sg_credit_reload_expiry');
const cvc = elements.create('cardCvc', { placeholder: 'CVV' });
cvc.mount('#sg_credit_reload_cvv');
cardNumber.addEventListener("change", (event) => {
const displayError = document.getElementById("sg_credit_reload_card_errors")
displayError.textContent = event.error ? event.error.message : "";
})
expDate.addEventListener("change", (event) => {
const displayError = document.getElementById("sg_credit_reload_expiry_errors")
displayError.textContent = event.error ? event.error.message : "";
})
cvc.addEventListener("change", (event) => {
const displayError = document.getElementById("sg_credit_reload_cvv_errors")
displayError.textContent = event.error ? event.error.message : "";
})
const form = document.getElementById('paymentFormRecap');
form.addEventListener('submit', async (event) => {
event.preventDefault();
const cardHolderName = document.getElementById("sg_credit_reload_card_holder_name").value;
const montant = document.getElementById("sg_credit_reload_amount").value * 100;
const payButton = document.getElementById("card-button");
payButton.disabled = true;
try {
const response = await fetch("{{ path('app_client_credit_reload_modal') }}", {
method: 'POST',
body: new FormData(form),
headers: {
'X-Requested-With': 'XMLHttpRequest',
}
});
if (!response.ok) {
throw new Error("Erreur de communication avec le serveur.");
}
const data = await response.json();
if (!data.client_secret) {
throw new Error("Erreur lors de la création du paiement.");
}
const clientSecret = data.client_secret;
const paymentResult = await stripe.confirmCardPayment(clientSecret, {
payment_method: {
card: cardNumber,
billing_details: {
name: cardHolderName,
},
},
});
if (paymentResult.error) {
document.getElementById("errors").innerText = paymentResult.error.message;
payButton.disabled = false;
} else if (paymentResult.paymentIntent && paymentResult.paymentIntent.status === 'succeeded') {
const completeResponse = await fetch("{{ path('app_client_complete_payment_modal') }}", {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest',
},
body: JSON.stringify({
payment_intent_id: paymentResult.paymentIntent.id,
amount: montant,
status: paymentResult.paymentIntent.status
})
});
const completeData = await completeResponse.json();
if (completeData.success) {
window.scrollTo(0, 0);
window.location.reload(true);
} else {
document.getElementById("errors").innerText = completeData.message || "Erreur lors de la finalisation du paiement.";
}
} else {
document.getElementById("errors").innerText = "Le paiement a échoué.";
payButton.disabled = false;
}
} catch (error) {
document.getElementById("errors").innerText = error.message;
payButton.disabled = false;
}
});
</script>
{% endblock %}