{% extends 'frontend/frontindex/add.html.twig' %}{% block body %} <section class="doctors-area doctor-page"> <div class="container"> {% if congres.dateFin >= currentDate %} <div class="row"> <div class="col-md-12 text-center"> <a href="{{path('details_congres',{id:congres.id })}}" class="text-dark"><h1>{{'%Participation-atelier-du-congrès%'|trans}} : {% if app.request.locale =='fr' %} {{congres.label|raw}} {% elseif app.request.locale =='en' %}{{congres.labelEn|raw}} {% endif %}</h1></a> </div> </div> <div class="row"> {% for message in app.flashes('success') %} <div class="alert alert-success col-12 text-center"> {{ message }} </div> {% endfor %} {% for message in app.flashes('danger') %} <div class="alert alert-danger col-12 text-center"> {{ message }} </div> {% endfor %} </div> <form action="{{path('app_participation_atelier',{'id': congres.id})}}" method="post" enctype="multipart/form-data" id="inscriptionForm"> <div class="row mb-5 mt-5"> <div class="form-group col-md-6"> <label for="nom"><strong>{{'%nomAtelier%'|trans|capitalize}}</strong></label> <input class="form-control" type="text" placeholder="{{'%nomAtelier%'|trans}}" required name="nom"> </div> <div class="form-group col-md-6"> <label for="prenom"><strong>{{'%prenomAtelier%'|trans|capitalize}}</strong></label> <input class="form-control" type="text" placeholder="{{'%prenomAtelier%'|trans}}" required name="prenom"> </div> <div class="form-group col-md-6"> <label for="email"><strong>{{'%E-mail%'|trans|capitalize}}</strong></label> <input type="email" class="form-control" id="email" placeholder="name@example.com" name="email"> </div> <div class="form-group col-md-6"> <label for="tel"><strong>{{'%Phone%'|trans|capitalize}}</strong></label> <input type="text" class="form-control" id="tel" placeholder="+21612345678" name="tel"> </div> <div class="form-group col-md-6"> <label for="atelier"><strong>{{'%Choisissez-un-ou-plusieurs-ateliers%'|trans|capitalize}}</strong></label> {% for key, atelier in ateliers %} <div class="form-check pt-2"> <input class="form-check-input atelier" type="checkbox" value="{{atelier.id}}" id="atelier{{atelier.id}}" name="atelier{{atelier.id}}" {% if atelier.nbPlaceAtteint == atelier.place %}disabled{% endif %}> <label class="form-check-label" for="atelier{{atelier.id}}"> {{atelier.titre}} <br> <i class="fa fa-calendar"></i> {{atelier.date|date('Y-m-d')}} : <i class="fa fa-clock"></i> {{atelier.heureDeb|date('H:i')}} - {{atelier.heureFin|date('H:i')}} <br><i class="fa fa-users"></i> <strong> {{'%Animateur%'|trans}} : {{atelier.animateur}}</strong> {% if atelier.nbPlaceAtteint == atelier.place %}<strong class="text-danger"> {{'%messageLimitePlaceAtelier%'|trans|capitalize}} </strong>{% endif %} </label> </div> {% endfor %} </div> <div class="form-group col-md-6"> <label for="type"> <strong>{{'%Inscrivez-vous-en-tant-que%'|trans|capitalize}} : </strong></label> <div class="form-check"> <input class="form-check-input" type="radio" name="type" id="membre" value="membre" checked> <label class="form-check-label" for="type"> {{'%membre%'|trans}} ATU </label> </div> <div class="form-check"> <input class="form-check-input" type="radio" name="type" id="nonMembre" value="nonMembre"> <label class="form-check-label" for="type"> {{'%nonmembre%'|trans}} ATU </label> </div> <div class="form-check"> <input class="form-check-input" type="radio" name="type" id="resident" value="resident"> <label class="form-check-label" for="type"> {{'%Résident%'|trans}} </label> </div> </div> <div class="form-group col-md-8 offset-md-2 text-center"> {# <h4 class="text-danger"> <i class="fa fa-triangle-exclamation"></i> {{'%Total-à-payer%'|trans|capitalize}} : <span id="total">0 DT</span></h4> <h4 class="text-danger">{{'%to-be-paid-on-site-when-registering-for-the-congress%'|trans|capitalize}}</h4> #} <button type="submit" value="Valider" class="btn btn-outline-success btn-lg mt-3">{{'%Valider%'|trans}}</button> </div> </div> </form> {% else %} <h1 class="text-center">{{'%congres-termine%'|trans}}</h1> {% endif %} </div> </section> <script> document.addEventListener('DOMContentLoaded', function() { const ateliers = document.querySelectorAll('.atelier'); const participationRadios = document.querySelectorAll('input[name="type"]'); const totalDisplay = document.getElementById('total'); const form = document.getElementById('inscriptionForm'); const participationPrices = { membre: 40, nonMembre: 120, resident: 40 }; function calculateTotal() { let totalAteliers = 0; let participationType = ''; ateliers.forEach(atelier => { if (atelier.checked) { totalAteliers++; } }); participationRadios.forEach(radio => { if (radio.checked) { participationType = radio.value; } }); const participationFee = participationPrices[participationType]; const total = totalAteliers * participationFee; totalDisplay.textContent = total + ' DT'; } // Validation avant soumission form.addEventListener('submit', function(event) { let selectedAtelier = false; ateliers.forEach(atelier => { if (atelier.checked) { selectedAtelier = true; } }); if (!selectedAtelier) { event.preventDefault(); // Empêcher l'envoi du formulaire alert("Veuillez sélectionner au moins un atelier."); } }); ateliers.forEach(atelier => { atelier.addEventListener('change', calculateTotal); }); participationRadios.forEach(radio => { radio.addEventListener('change', calculateTotal); }); }); </script>{% endblock %}