{% extends "layout.html.twig" %}
{% block content %}
<div class="page-collect-centre-inscription-form apk-page-inscription">
<div class="uk-container uk-margin-large-top">
<h2 class="h-big-lowcase-grey">{{ "Prendre un rendez-vous dans un centre de prélèvement"|trans }}</h2>
<div class="uk-grid" uk-grid>
<div class="uk-width-2-3@s">
<div class="uk-text-uppercase uk-width-1-1" style="border-bottom: 1px solid grey;">{{ 'Votre Centre'|trans }}</div>
<div class="adresse uk-margin-top">
<ul class="fa-ul">
<li>
<img uk-svg width="14" height="14" src="/static/img/pictos/position.svg" />
<strong>{{ centre.site.name }}</strong><br>
{{ centre.site.address }}<br>
{{ centre.site.zip }} {{ centre.site.city }}
</li>
</ul>
</div>
<div>
<ul class="fa-ul telephone">
<li>
<img uk-svg width="14" height="14" src="/static/img/pictos/phone.svg" />
<a href="tel:{{ centre.site.phone}}"
target="_blank">{{ centre.site.phone}}</a>
</li>
</ul>
</div>
<div class="horaires">
<ul class="fa-ul">
<li>
<img uk-svg width="14" height="14" src="/static/img/pictos/horaires.svg" />
{# <strong>{{ 'Horaires'|trans }} {{ 'du'|trans }} {{ date['weekStartDate'] }} {{'au'|trans}} {{ date['weekEndDate'] }}</strong><br/> #}
{% for jour,horaire in centre.days %}
{% if horaire %}
{{ jour|trans }} : {{ horaire }}
<br/>
{% else %}
{{ jour|trans }} : {{ "Fermé"|trans }}
<br/>
{% endif %}
{% endfor %}
</li>
</ul>
</div>
{% if centre.site.informations %}
<div class="apk-special-container">
{{ centre.site.informations|raw }}
</div>
{% endif %}
<div>
</div>
</div>
<div class="uk-width-1-3@s">
{% if centre.site.picture %}
<figure class="uk-margin-top">
<img src="{{ centre.site.picture }}" alt="{{ centre.site.name }}" />
{% if centre.site.copyright %}
<figcaption>{{ centre.site.copyright }}</figcaption>
{% endif %}
</figure>
{% else %}
<img src="/static/img/logos/logo-crb.svg" alt="Croix-Rouge de Belgique"/>
{% endif %}
</div>
</div>
</div>
<div class="uk-container uk-margin-medium-top">
<form class="uk-form" role="form" name="form-validation" id="form-validation" method="POST">
<div class="uk-text-uppercase uk-width-1-1" style="border-bottom: 1px solid grey;">{{ "A quelle date souhaitez-vous vous inscrire ?"|trans }}</div>
<div uk-slider>
<div class="uk-position-relative">
<div class="uk-slider-container uk-padding">
<ul class="uk-slider-items uk-grid-small" uk-grid>
{% for i in 0..5 %}
<li class=" uk-width-1-4@m">
<div class="apk-calendar">
{{ calendriers[i]|raw }}
</div>
</li>
{% endfor %}
</ul>
</div>
<div class="uk-visible@s">
<a class="uk-position-center-left-out uk-position-small" href="#" uk-slidenav-previous uk-slider-item="previous"></a>
<a class="uk-position-center-right-out uk-position-small" href="#" uk-slidenav-next uk-slider-item="next"></a>
</div>
</div>
<ul class="uk-slider-nav uk-dotnav uk-margin-bottom uk-margin-left"></ul>
</div>
<div class="uk-grid-small" uk-grid>
<div class="uk-width-1-1">
<div class="uk-text-uppercase" style="border-bottom: 1px solid grey;">
<label class="control-label">
{{ "A quelle heure souhaitez-vous prendre rendez-vous le"|trans }} <span id="dateSelect" name="dateSelect" class="date-selected">...</span> ?
</label>
</div>
<div class="uk-width-1-1@m" id="resultats">
<div class="resultats-placeholder">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" data-svg="info"><path fill="currentColor" d="M12.13,11.59 C11.97,12.84 10.35,14.12 9.1,14.16 C6.17,14.2 9.89,9.46 8.74,8.37 C9.3,8.16 10.62,7.83 10.62,8.81 C10.62,9.63 10.12,10.55 9.88,11.32 C8.66,15.16 12.13,11.15 12.14,11.18 C12.16,11.21 12.16,11.35 12.13,11.59 C12.08,11.95 12.16,11.35 12.13,11.59 L12.13,11.59 Z M11.56,5.67 C11.56,6.67 9.36,7.15 9.36,6.03 C9.36,5 11.56,4.54 11.56,5.67 L11.56,5.67 Z"></path><circle fill="none" stroke="currentColor" stroke-width="1.1" cx="10" cy="10" r="9"></circle></svg>
{{ "Veuillez sélectionner d'abord une date dans le calendrier au-dessus"|trans }}
</div>
</div>
</div>
</div>
<div class="uk-grid">
<div class="uk-width-1-1">
<div class="uk-text-uppercase" style="border-bottom: 1px solid grey;">
{{ "Avant de terminer votre inscription,"|trans }}<br/>
{{ "Nous avons besoin de ces quelques informations"|trans }}
</div>
</div>
</div>
<div class="uk-grid">
{% if errorMessage or errorMessage != "" %}
<div class="uk-width-1-1">
<div class="uk-margin-bottom uk-alert uk-alert-warning" id="error-msg" uk-alert>{% if errorMessage %}{{ errorMessage|trans }}{% endif %}</div>
</div>
{% endif %}
<input type="hidden" name="akimedia-centre" value="{{ centre.site.id }}">
<div class="uk-grid-medium" uk-grid>
<div class="uk-width-1-2@s ">
<label class="control-label required" for="collecte_centre_form_lastname">{{ 'Nom'|trans }}</label><br/>
<input type="text" id="collecte_centre_form_lastname" name="lastname" required="required" class="uk-input">
</div>
<div class="uk-width-1-2@s">
<label class="control-label required" for="collecte_centre_form_firstname">{{ 'Prénom'|trans }}</label><br/>
<input type="text" id="collecte_centre_form_firstname" name="firstname" required="required" class="uk-input">
</div>
<div class="uk-width-1-2@s">
<label class="control-label required" for="collecte_centre_form_email">{{ 'Adresse mail'|trans }}</label><br/>
<input type="email" id="collecte_centre_form_email" name="email" required="required" class="uk-input">
</div>
<div class="uk-width-1-2@s">
<label class="control-label required" for="collecte_centre_form_email2">{{ 'Confirmez votre adresse mail'|trans }}</label><br/>
<input type="email" id="collecte_centre_form_email2" name="email2" required="required" class="uk-input">
</div>
<div class="uk-width-1-2@s">
<label class="control-label required" for="collecte_centre_form_phone">{{ 'Téléphone'|trans }}</label>
<input type="text" id="collecte_centre_form_phone" name="phone" required="required" class="uk-input">
</div>
<div class="uk-width-1-2@s">
<label class="control-label required" for="dtenaissance">{{ 'Date de naissance jj/mm/aaaa'|trans }}</label>
<input class="uk-input" type="date" name="dtenaissance" id ="dtenaissance"
data-min="{{yearAllowed.min|date('Y-m-d')}}" data-max="{{yearAllowed.max|date('Y-m-d')}}"
value="" autocomplete="false" maxlength="10" required>
</div>
<div class="uk-width-1-1 apk-choix uk-margin-top uk-grid-margin uk-first-column">
<div class="uk-grid uk-grid-small uk-child-width-1-2@s" uk-grid>
<div>
<div class="apk-sang">
<div class="uk-margin-top uk-position-relative">
<div>
<label class="required">{{ 'Déjà donné du sang'|trans }}</label>
<div id="inscription_form_plasma">
<input type="radio" id="collecte_centre_form_alreadyBlood_0" name="alreadyBlood" required="required" value="OUI">
<label for="collecte_centre_form_alreadyBlood_0" class="required apk-label-is-linked-to-field">{{ "Oui"|trans }}</label>
<input type="radio" id="collecte_centre_form_alreadyBlood_1" name="alreadyBlood" required="required" value="non" checked="checked" class="apk-field-is-checked">
<label for="collecte_centre_form_alreadyBlood_1" class="required apk-label-is-linked-to-field">{{ "Non"|trans }}</label>
</div>
</div>
</div>
</div>
</div>
<div>
<div class="apk-plasma">
<div class="uk-margin-top uk-position-relative">
<div>
<label class="required">{{ 'Déjà donné du plasma'|trans }}</label>
<div id="inscription_form_plasma">
<input type="radio" id="collecte_centre_form_alreadyPlasma_0" name="alreadyPlasma" required="required" value="OUI">
<label for="collecte_centre_form_alreadyPlasma_0" class="required apk-label-is-linked-to-field">{{ "Oui"|trans }}</label>
<input type="radio" id="collecte_centre_form_alreadyPlasma_1" name="alreadyPlasma" required="required" value="non" checked="checked" class="apk-field-is-checked">
<label for="collecte_centre_form_alreadyPlasma_1" class="required apk-label-is-linked-to-field">{{ "Non"|trans }}</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="uk-width-1-1">
<label class="gdpr-label">
<input type="checkbox" id="collecte_centre_form_gdpr" name="gdpr" required="required" class="uk-checkbox uk-margin-small-right" value="1">{{ 'En cochant cette case, vous acceptez la manière dont vos données sont traitées.'|trans }} *</label>
</div>
<div class="uk-width-1-1">
<div class="uk-display-inline-block">
<button type="submit" id="collecte_centre_form_submit" class="uk-button">{{"Envoyer"|trans}}</button>
</div>
</div>
</div>
</div>
<input id="collecte_centre_form_centre" name="centre" type="hidden" value="{{ centre.site.id }}">
<input id="collecte_centre_form_date" name="date" type="hidden" value="">
<input id="collecte_centre_form_horaire" name="horaire" type="hidden" value="">
<input id="collecte_centre_form_heure" name="heure" type="hidden" value="">
</form>
</div>
</div>
{% endblock %}
{% block inlinescripts %}
<link href="https://cdn.jsdelivr.net/npm/flatpickr@4.6.13/dist/flatpickr.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/flatpickr@4.6.13/dist/flatpickr.min.js"></script>
<script src="https://npmcdn.com/flatpickr@4.6.13/dist/l10n/{{app.request.locale}}.js"></script>
{% if not editmode %}
<script>
var borne = [];
{% set now = "now"|date("Y-m-d") %}
{% for date in dates %}
{% set d = date|date("Y-m-d") %}
{% if d >= now %}
borne.push('{{ d }}');
{% endif %}
{% endfor %}
$( document ).ready(function() {
//gestion de la birthDate
newMaxDate = false;
const BirthMaxOri = new Date($('#dtenaissance').attr('data-max'));
const BirthMinOri = new Date($('#dtenaissance').attr('data-min'));
let inputBirthDate = $("#dtenaissance").flatpickr({
locale : "{{app.request.locale}}",
dateFormat : "d/m/Y",
minDate : BirthMinOri,
maxDate : BirthMaxOri,
allowInput: true,
});
function setDateMax () {
let BirthMax = BirthMaxOri;
let BirthMin = BirthMinOri;
let newMaxDate = null;
let radioSelected = null;
let found = false;
$('.schedule-item').each(function(el){
if($(this).is('.is-selected')) {
found = true;
radioSelected = $(this).find('input:checked');
}
});
if(found) {
newMaxDate = radioSelected.attr('data-id');
BirthMax18 = new Date(newMaxDate);
newBirthMax = new Date(BirthMax18.setFullYear(BirthMax18.getFullYear() - parseFloat({{yearAllowed.year}})));
inputBirthDate.set('maxDate', newBirthMax);
} else {
inputBirthDate.set('maxDate', BirthMaxOri);
}
inputBirthDate.clear();
}
setDateMax();
$("form").on("submit", function() {
if($("#collecte_centre_form_email").val() != $("#collecte_centre_form_email2").val()){
$("#error-msg").text("{{ 'Les adresses e-mails sont différentes, veuillez corriger'|trans }}");
$("#error-msg").addClass("uk-padding-small uk-margin-bottom");
console.log('in');
return false;
}
if($("#collecte_centre_form_horaire").val() == 'zzzzz'){
$("#error-msg").text("{{ 'Veuillez choisir une date et une heure.'|trans }}");
return false;
}
// Ajout du test de validiter de l'horaire pour eviter les doublon
var horaire = $("#collecte_centre_form_horaire").val()+'|'+$("#collecte_centre_form_heure").val();
var codeCentre = $("#collecte_centre_form_centre").val();
});
$("form").on("submit", function() {
});
$('.day').each(function () {
console.log ($(this).attr('data-date'));
if(borne.includes($(this).attr('data-date'))){
$(this).addClass('date_actif');
}
else {
$(this).addClass('not-active');
}
});
$('.day.date_actif').on("click", function () {
$('.day.is-selected').removeClass('is-selected');
$(this).addClass('is-selected');
var date = $(this).attr('data-date');
var centreid = $(this).attr('data-centre-id');
$("#dateSelect").html($(this).attr('data-date-format'));
$("#collecte_centre_form_date").val(date);
var lang = '{{ app.request.locale }}';
$.ajax({
dataType: "json",
type: "GET",
url: "{{ path('getHoraireCentreAkimedia') }}",
data: {'date': date ,'centreid':centreid, 'lang':lang},
success: function (data) {
$('#resultats').html(data["msg"]);
$("input[name='inscription']").on("click", function(){
$("#collecte_centre_form_heure").val($(this).val());
$("#collecte_centre_form_horaire").val($(this).attr("data-id"));
});
console.log(data);
inputBirthDate.clear();
$('.schedule-item').on("click", function () {
var $radioSelected = $(this).find('.uk-radio');
if($radioSelected.attr("data-id")){
$('.schedule-item').removeClass('is-selected');
$(this).addClass('is-selected');
$radioSelected.prop('checked', true);
setDateMax();
$("#collecte_centre_form_heure").val($radioSelected.val());
$("#collecte_centre_form_horaire").val($radioSelected.attr("data-id"));
}
else{
$('.schedule-item').removeClass('is-selected');
}
});
},
error: function (xhr, textStatus, errorThrown) {
UIkit.notification('{{ "Oops! Une erreur s'est produite. Veuillez réessayer."|trans }}', {status: 'danger'});
console.log(xhr, textStatus, errorThrown);
}
});
})
});
</script>
{% endif %}
{% endblock inlinescripts %}