{% if centres | length != 0 %}
{% for centre in centres %}
<div class="card" id="{{centre.id}}" data-latitude="{{centre.latitude}}" data-longitude="{{centre.longitude}}">
<div class="row">
<div class="col-md-3 containerInfo">
<img class="imgCentre imgCentreClick " src="{{BASE_API}}centre/image/{{centre.id}}" alt="{{centre.name}}" onclick='goToCentre({{centre.id}},"{{centre.city}}","{{centre.postale}}","{{centre.slug}}")' />
<div class="note">
<span>{{centre.averageRating}}/5</span>
<span class="material-icons">star</span>
<span>({{centre.nbrReview}})</span>
</div>
</div>
<div class="col-md-9 containerCentre">
<span class="centreName centreNameClick" onclick='goToCentre({{centre.id}},"{{centre.city}}","{{centre.postale}}","{{centre.slug}}")'>{{centre.name}}</span>
<div class="row">
<div class="col-md-6 containerAudioChoice">
<select id="audioCentre{{centre.id}}" data-centre="{{centre.id}}" onchange="changeHoraireAudio(this)" class="audioCentre form-select" name="audioCentre{{centre.id}}">
{% set i = 0 %}
{% for audio in centre.audio %}
<option value="{{audio.id}}" {% if i == 0 %} selected {% endif %}>{{audio.lastname}} {{audio.name}}</option>
{% set i = i + 1 %}
{% endfor %}
</select>
</div>
<div class="col-md-6 containerAdresse">
<p class="adresse">{{centre.address}}</p>
<p class="CP">{{centre.postale}} {{centre.city}}</p>
</div>
</div>
</div>
</div>
<div class="row avaibility-row">
{% set i = 0 %}
{% for audio in centre.audio %}
<!-- Modify your motif select box -->
<select class="form-select motif-select mot{{centre.id}}" data-id="{{centre.id}}" id="motif{{audio.id}}{{centre.id}}" data-audio-id="{{audio.id}}" onchange="changeHoraire({{audio.id}}, {{centre.id}})" {% if loop.first %} {% else %}style="display: none;"{% endif %}>
<option hidden style="text-align:center;">Choisissez votre motif de consultation</option>
{% for motif in audio.motifs %}
{% if motif.isRdvonline and motif.titre != "Rendez-vous pro externe" and motif.titre != "Google Agenda" and motif.titre != "Suivie de l’essai" and motif.titre != "Confirmation de l’essai" and motif.titre != "Validation de l’appareillage" and motif.titre != "Facturation de l’appareillage" %}
<option value="{{motif.id}}-{{motif.duration}}" data-duration="">{{motif.titre}} </option>
{% endif %}
{% endfor %}
</select>
<!-- Enclose the select within a div with a common class -->
<div class="motif-container mot{{centre.id}}" id="motif-container{{audio.id}}" {% if loop.first %} {% else %}style="display: none;"{% endif %}>
<!-- Your other elements and code here -->
<div class="row avaibility-row">
<div class="choixMotif mapChoice" id="choixMotif{{audio.id}}{{centre.id}}" style="display:none">Veuillez choisir un motif de consultation</div>
<div id="avaibility{{audio.id}}{{centre.id}}" data-audio="{{audio.id}}" data-centre="{{centre.id}}" class="avaibility-container avaibility{{centre.id}} col-md-12"></div>
<div class="loading-container" id="loading{{audio.id}}{{centre.id}}" style="display:none;">
<img class="loading" src="/assets/img/recherche/loading.gif" alt="loading" />
</div>
<div id="alertDate{{audio.id}}{{centre.id}}" style="display:none" class="alertDate">Veuillez sélectionner un horaire</div>
<div class="btnMap">
<button class="prendreRDV btn btn-vert-inverse" id="rdv{{audio.id}}" onclick="encodeAndCallVerificationSelection({{audio.id}}, {{centre.id}}, '{{centre.name|replace({'\'' : '\\\''})}}','{{audio.lastname}} {{audio.name}}');">Je prends RDV</button>
</div>
</div>
</div>
{% set i = i + 1 %}
{% endfor %}
<!-- Modal confirmatio info RDV -->
</div></div>
<script>
var dateSelectionne = "";
{% set i = 0 %}
{% for audio in centre.audio %}
{% if i == 0 %}
dispo = {{audio.schedule | json_encode() | raw}};
dispoSplit = getTimeAvailable(dispo);
dispoSplit = addEmptyTime(dispoSplit);
nextHtml = getChevronNext('{{audio.id}}');
prevHtml = getChevronPrev('{{audio.id}}');
initCalendar('{{audio.id}}','{{centre.id}}', dispoSplit);
$(".precedent").css("display","none");
$(".available-time-hide").css("display","none");
{% endif %}
{% set i = i + 1 %}
{% endfor %}
var image = {
url:"./assets/img/recherche/pointer.png",
scaledSize: new google.maps.Size(33,47), // scaled size
};
lati = "{{centre.latitude}}";// On récupère la latitude
lon = "{{centre.longitude}}"; // On récupère la longitude
var pos = {
lat: lati,
lng: lon
};
point = new google.maps.LatLng(lati, lon);
optionsMarqueur = {
position: point,
icon: image,
map: map,
animation: google.maps.Animation.DROP
}
marqueur = new google.maps.Marker(optionsMarqueur);
contenue = '<a href="#{{centre.id}}" onclick="cacherMap();"><img class="imgCentre" src="{{BASE_API}}centre/image/{{centre.id}}" alt="{{centre.name}}" style="width:120px; height:120px; object-fit:contain;"/></a>';
bindInfoWindow(marqueur, contenue);
function changeHoraire(audio_id, centre_id){
$("#loading"+audio_id).css("display","flex");
$("#choixMotif"+audio_id+centre_id).css("display","none");
value = document.getElementById("motif"+audio_id).value;
id = value.split('-')[0];
motifDuration = parseInt(value.split('-')[1]);
datetime = dateFormat(new Date(), "dd/mm/yyyy").toString();
getHoraire(audio_id,centre_id, datetime);
dateSelectionne = "";
$("#loading"+audio_id+centre_id).css("display","none");
$(".alertDate").css("display","none");
}
// Add an event listener to each audio select box
$('.audioCentre').on('change', function () {
// Get the selected audio ID
var selectedAudioId = $(this).val();
var center = $(this).attr('data-centre');
console.log(center);
// Hide all motif select boxes
$('.mot'+center).hide();
// Show the motif select box corresponding to the selected audio
$('#motif' + selectedAudioId).show();
$('#motif-container' + selectedAudioId).show();
});
function encodeAndCallVerificationSelection(audio_id, centre_id, centre_name, audio_name) {
var motifFirst = $("#motif"+audio_id+centre_id+" option:selected").text();
if(motifFirst === "Choisissez votre motif de consultation"){
$("#choixMotif"+audio_id+centre_id).show();
}
else{
//alert(motifFirst);
var encodedCentreName = encodeURIComponent(centre_name);
var encodedAudioName = encodeURIComponent(audio_name);
verificationSelection(audio_id, centre_id, encodedCentreName, encodedAudioName);
}
}
function verificationSelection(audio_id, centre_id, centre_name, audio_name) {
var decodedCentreName = decodeURIComponent(centre_name);
var decodedAudioName = decodeURIComponent(audio_name);
// Now you can use the decodedCentreName as needed
if (dateSelectionne !== "") {
if (getCookie('token') === "" || getCookie('token') === null) {
rendezVousEnCours = 1;
audioIDSelectionne = audio_id;
$('#loginModal').modal('show');
// alert("sel");
} else {
$("#loadingRDV").css("display", "flex");
rendezVousEnCours = 1;
infoRdvHtmlMotif(audio_id, centre_id, decodedCentreName, decodedAudioName);
}
} else {
$("#alertDate" + audio_id + centre_id).css("display", "block");
}
$(document).on('hidden.bs.modal', '#loginModal', function () {
//alert("lgoin");
if (rendezVousEnCours == 1 && getCookie('token') != "" && getCookie('token') != null ){
$("#loadingRDV").css("display", "flex");
rendezVousEnCours = 1;
infoRdvHtmlMotif(audio_id, centre_id, decodedCentreName, decodedAudioName); }
})
}
function audioActif(id){
audios = document.getElementsByClassName('audioInfo');
for (audio of audios){
audio.classList.remove("actif");
}
audio_actif_id = id;
document.getElementById(id).classList.add("actif");
changeHoraireAudio(id);
}
</script>
<style>
.gm-style .gm-style-iw-c{
padding:0 !important;
border: 1px solid #E2E2E2 !important;
}
.gm-style-iw-d{
overflow:hidden !important;
}
button.gm-ui-hover-effect img {
display: none !important;
}
</style>
{% endfor %}
{% else %}
{% endif %}