{% if is_granted('ROLE_ADMIN') == true or
is_granted('ROLE_ADMIN_PAYS') == true or
is_granted('ROLE_ADMIN_REGIONS') == true or
is_granted('ROLE_ADMIN_VILLES') == true %}
{% set base = 'base.html.twig' %}
{% elseif is_granted('ROLE_LEGISLATEUR') == true %} {% set base = 'base_legislator.html.twig' %}
{% elseif is_granted('ROLE_DIRECTEUR') == true %} {% set base = 'base_legislator.html.twig' %}
{% elseif is_granted('ROLE_ETABLISSEMENT') == true %} {% set base = 'base_school.html.twig' %}
{% elseif is_granted('ROLE_PRINCIPAL') == true %} {% set base = 'base_principal.html.twig' %}
{% else %} {% set base = 'base_degree.html.twig' %}
{% endif %}
{% extends base %}
{% block title %}
{{ parent() }} {{ 'degree.graduates' | trans }}
{% endblock %}
{% block js %}
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBy9WBkxvkGzs4tQN-RilyvV6WvWnTInUM&callback"
type="text/javascript">
</script>
<script>
function getPersondegreMapAddress () {
let number = $('#appbundle_persondegree_addressNumber').val();
let road = $('#appbundle_persondegree_addressRoad').val();
let locality = $('#appbundle_persondegree_addressLocality').val();
let city = $('#appbundle_persondegree_addressCity option:selected').text();
let region = $('#appbundle_persondegree_region option:selected').text();
let country = $('#appbundle_persondegree_country option:selected').text();
// adaptation dbta, annulation de la donnée de la province
if($('#selectedRegion option').length > 0) {
country = "";
}
return (createMapsAddress(number, road, locality, city, region, country));
}
function getPersondegreCityMapAddress () {
let city = $('#appbundle_persondegree_addressCity option:selected').text();
let country = $('#appbundle_persondegree_country option:selected').text();
return (createMapsAddress(null, null, null, city, null, country));
}
let translations = [];
getTranslation().then (function (translation) {
translations = translation;
// console.log(translations);
let selectedCountry = $('#selectedCountry').val();
let selectedRegion = $('#selectedRegion').val();
//affichage de la zone Diaspora
visibilityDiaspora();
$('#appbundle_persondegree_diaspora').on('click', function () {
visibilityDiaspora();
});
function visibilityDiaspora() {
if ($('#appbundle_persondegree_diaspora').is(":checked")) {
$('.addressDiaspora ').prop("hidden", false);
if($('#appbundle_persondegree_residenceCountry').length) {
$('#appbundle_persondegree_residenceCountry').attr("required", true);
}
if($('#appbundle_persondegree_residenceRegion').length) {
$('#appbundle_persondegree_residenceRegion').attr("required", true);
}
$('#appbundle_persondegree_addressDiaspora').attr("required", true);
} else {
$('.addressDiaspora ').prop("hidden", true);
if($('#appbundle_persondegree_residenceCountry').length) {
$('#appbundle_persondegree_residenceCountry').attr("required", false);
}
if($('#appbundle_persondegree_residenceRegion').length) {
$('#appbundle_persondegree_residenceRegion').attr("required", false);
}
$('#appbundle_persondegree_addressDiaspora').attr("required", false);
$('#appbundle_persondegree_addressDiaspora').val("");
}
}
// suppression du selectedCountry dans la liste des pays de résidence
$('#appbundle_persondegree_residenceCountry option').each(function () {
if(selectedCountry == $(this).val()) {
$(this).prop('hidden', true);
}
})
//adaptation dbta (if $_env struct_province_country_city== true)
if($('#appbundle_persondegree_residenceRegion').length) {
$('#appbundle_persondegree_residenceRegion option').each(function () {
if(selectedRegion == $(this).val()) {
$(this).prop('hidden', true);
}
})
}
//Contrôle du bouton check de localisation pour switch manuel - automatique
$('#appbundle_persondegree_locationMode').on('click', async function () {
if ($('#appbundle_persondegree_locationMode').is(":checked")) {
if (!confirm(translations["js.warning_coordinates_recalculated"])) {
$('#appbundle_persondegree_locationMode').prop("checked", false);
}
} else {
alert(translations["js.manual_mode"]);
}
//Mise à jour des coordonnées géographique en mode auto
if ($('#appbundle_persondegree_locationMode').is(":checked")) {
$('#appbundle_persondegree_latitude').val("");
$('#appbundle_persondegree_longitude').val("");
// geocodeAddressLocation(getPersondegreMapAddress(), '#appbundle_persondegree_latitude', '#appbundle_persondegree_longitude');
//recherche des coordonnées avec l'adresse complète
if (await geocodeAddressLocation(getPersondegreMapAddress(), '#appbundle_persondegree_latitude', '#appbundle_persondegree_longitude') == true) {
//recherche des coordonnées avec uniquement l'adresse de la ville
await geocodeAddressLocation(getPersondegreCityMapAddress(), '#appbundle_persondegree_latitude', '#appbundle_persondegree_longitude')
}
// vérifie si les coordonnées pas déjà utilisées avec autre établissement
let url = window.location.toString();
if (url.indexOf('/edit')!== -1) {
url = url.replace('/edit', '/getPersondegreesByCoordinates');
} else if (url.indexOf('/new')!== -1) {
$('#appbundle_persondegree_locationMode').prop("checked", false);
}
// console.log(url);
//creation de la data pour json
let current_latitude = $('#appbundle_persondegree_latitude').val();
let current_longitude = $('#appbundle_persondegree_longitude').val();
let gap = 0.0001;
let data = { "latitude" : current_latitude,
"longitude" : current_longitude,
"gap" : gap
};
// appel ajax en get
await $.get(url, data).done(function (result) {
let current_id = result['persondegree_id'];
let coordinates = result['coordinates'];
// console.log('current Id = ' + current_id);
// console.log(coordinates["latitude"] + "," + coordinates["longitude"]);
// mise à jour des coordonnées recalculées
$('#appbundle_persondegree_latitude').val(coordinates["latitude"]);
$('#appbundle_persondegree_longitude').val(coordinates["longitude"]);
$('#appbundle_persondegree_locationMode').prop("checked", false);
});
}
});
// Si la ville n'est pas déja sélectionnée, simule un click sur le Pays pour accéder aux Regions
if ($('#selectedRegion option').length == 0) {
if ($('#selectedCountry').val() !== '') {
countryEvent("#selectedCountry", "persondegree");
}
} else {
//adaptation DBTA pour l'environnement struct_province_country
// (pas de sélection possible sur le country, simule un click sur la region pour accéder au city)
regionEvent("#selectedCountry", "#selectedRegion", "persondegree");
}
// console.log("test->" + $('#appbundle_persondegree_school option').length)
// création du filtre villes unique pour les établissements
$('#citySchoolFilter').append("<option selected>" + translations["js.all_f"] + "</option>");
if ($('#appbundle_persondegree_school option').length > 0) {
// Creation du <select> de #citySchoolFilter
let cityUnits = [];
$('#appbundle_persondegree_school option').each(function () {
let $this = $(this);
if($this.text().replaceAll('é','e') != translations['js.select'].replaceAll('é','e')) {
// vérification d'existance
let element_exist = false;
for (let i = 0; i < cityUnits.length; i++) {
let thisCity = $this.text().substring($this.text().indexOf(',') + 1).trim();
let cityUnit = cityUnits[i].substring(cityUnits[i].indexOf(',') + 1).trim();
if (thisCity === cityUnit) {
element_exist = true;
}
}
// génération des options du <select> de #citySchoolFilter
if (element_exist == false) {
cityUnits.push($this.text());
let cityName = $this.text().substring($this.text().indexOf(',') + 1)
let cityNameTrans = translations[cityName];
if (!cityNameTrans) cityNameTrans = cityName;
$('#citySchoolFilter').append("<option value='" + $this.val() + "'> " + cityNameTrans + "</option>");
}
}
})
}
// création du filtre régions unique pour les établissements
$('#regionSchoolFilter').append("<option selected>" + translations["js.all_f"] + "</option>");
if ($('#schoolRegion option').length > 0) {
// Creation du <select> de #regionSchoolFilter
let regionUnits = [];
$('#schoolRegion option').each(function () {
let $this = $(this);
// vérification d'existance
let element_exist = false;
for (let i = 0; i < regionUnits.length; i++) {
if ($this.text() === regionUnits[i]) {
element_exist = true;
}
}
// génération des options du <select> de #regionSchoolFilter
if (element_exist == false) {
regionUnits.push($this.text());
$('#regionSchoolFilter').append("<option value='" + $this.val() + "'> " + translations[$this.text()] + "</option>");
}
})
}
// filtage des établissement par villes
$('#citySchoolFilter').on('change', function () {
let selection = $('#citySchoolFilter option:selected').text().trim();
// console.log("selection = " + selection);
if (selection == translations["js.all_f"]) {
$('#appbundle_persondegree_school option').prop("hidden", false);
} else {
$('#appbundle_persondegree_school option[value!=""]').prop("hidden", true);
$('#appbundle_persondegree_school option').each(function () {
let cityName = $(this).text().substring($(this).text().indexOf(',') +1 )
if (selection.trim() == cityName.trim()) {
$(this).prop("hidden", false);
}
})
}
})
// filtage des établissement par région
$('#regionSchoolFilter').on('change', function () {
let selection = $('#regionSchoolFilter option:selected').text().trim();
console.log("selection = " + selection);
if (selection == translations["js.all_f"]) {
$('#appbundle_persondegree_school option').prop("hidden", false);
} else {
$('#appbundle_persondegree_school option[value!=""]').prop("hidden", true);
// recherche id de school
$('#schoolRegion option').each(function () {
// console.log($(this).text().trim());
let schoolName = $(this).text().trim();
let schoolId = $(this).val().trim();
// affichage des options school
if (selection == schoolName) {
$('#appbundle_persondegree_school option').each(function () {
let selectSchoolId = $(this).val().trim();
if (schoolId == selectSchoolId) {
$(this).prop("hidden", false);
}
})
}
})
}
})
// Event
// Vérifie si l'indicatif du numero de téléphone est correct
{% if is_granted('ROLE_DIPLOME') == true %}
let phoneNumber = $('#appbundle_persondegree_phoneMobile1').val();
checkPhoneNumber(phoneNumber);
$('#appbundle_persondegree_phoneMobile1').on('change', function () {
checkPhoneNumber($(this).val());
})
$('#appbundle_persondegree_residenceCountry').on('change', function () {
checkPhoneNumber(phoneNumber);
})
$('#appbundle_persondegree_residenceRegion').on('change', function () {
checkPhoneNumber(phoneNumber);
})
//reset pays de résidence si appbundle_persondegree_diaspora est false
$('#appbundle_persondegree_diaspora').on('click', function () {
if ($('#appbundle_persondegree_diaspora').not(":checked")) {
$('#appbundle_persondegree_residenceCountry').prop('selectedIndex', 0);
$('#appbundle_persondegree_residenceRegion').prop('selectedIndex', 0);
}
checkPhoneNumber(phoneNumber);
})
{% endif %}
function checkPhoneNumber(phoneNumber) {
let res = true;
if (phoneNumber !== undefined) {
let usrphone = $('.logged-user-phone').html().trim();
// verification de l'indicatif pays
// alert(" 1-> " . $('#countryPhoneCode').val());
let indPersonDegree = '+' + $('#countryPhoneCode').val();
// let selectResidenceCountry = $('#appbundle_persondegree_residenceCountry').val();
let selectResidenceCountry = $('#appbundle_persondegree_country option:selected').val();
// adaptation dbta (if $_env struct_province_country_city== true)
if($('#selectedRegion option').length)
selectResidenceCountry = $('#selectedRegion option:selected').val();
// adaptation diaspora
if($('#appbundle_persondegree_diaspora').is(":checked")) {
if($('#appbundle_persondegree_residenceRegion option:selected').val()) {
selectResidenceCountry = $('#appbundle_persondegree_residenceRegion option:selected').val();
}
}
// console.log("test1: indPersonDegree=" + indPersonDegree + " phoneNumber=" + phoneNumber + " selectResidenceCountry=" + selectResidenceCountry);
if($('#appbundle_persondegree_diaspora').is(":checked")) {
$('#countriesPhoneCode option').each(function () {
// alert(" 2-> " . $(this).val());
// console.log("test2: " + selectResidenceCountry + " | " + $(this).val());
if (selectResidenceCountry == $(this).val()) {
indPersonDegree = '+' + $(this).text();
}
})
}
//suppression des espaces
phoneNumber = phoneNumber.replace(/ /g,'');
$('#appbundle_persondegree_phoneMobile1').val(phoneNumber);
//recup de l'indicatif
let indPhone = phoneNumber.substr(0, indPersonDegree.length);
if (indPhone != indPersonDegree) {
// alert(" 3-> " + indPhone + " | " + indPersonDegree);
alert(translations["js.warning,phone_must_begin_part1"] + " " + indPersonDegree + translations["js.warning,phone_must_begin_part2"]);
$('#appbundle_persondegree_phoneMobile1').val(usrphone);
res = false;
} else if (phoneNumber != usrphone) {
let confirmPhone = confirm(translations["js.warning_phone_number_changed"] + " " + phoneNumber )
if (confirmPhone == false) {
$('#appbundle_persondegree_phoneMobile1').val(usrphone);
}
}
//verification du nombre de digit
let nbDigitPersonDegree = null;
$('#countriesPhoneDigit option').each(function () {
if (selectResidenceCountry == $(this).val()) {
nbDigitPersonDegree = $(this).text();
// console.log(nbDigitPersonDegree);
}
})
if(nbDigitPersonDegree == null) {
$('#countriesPhoneDigit option').each(function () {
if ($('#selectedCountry').val() == $(this).val()) {
nbDigitPersonDegree = $(this).text();
// console.log(nbDigitPersonDegree);
}
})
}
if(nbDigitPersonDegree != null) {
if((phoneNumber.length - indPersonDegree.length) != nbDigitPersonDegree) {
alert(translations["js.warning_telephone_digits_part1"] + " " + nbDigitPersonDegree + " " + translations["js.warning_telephone_digits_part2"]);
$('#appbundle_persondegree_phoneMobile1').val(usrphone);
res = false;
}
}
}
}
// Initialisation de l'année et du mois d'obstention du diplome en fonction de la situation professionnelle
professionnal_situation_change_degree_year_date('#appbundle_persondegree_type');
$('#appbundle_persondegree_type').on('change', function () {
professionnal_situation_change_degree_year_date('#appbundle_persondegree_type');
});
function professionnal_situation_change_degree_year_date(idtype) {
let today = new Date();
let situationPro = "";
if ($(idtype).val())
situationPro = $(idtype).val().trim();
if ((situationPro == 'TYPE_TRAINING') || (situationPro == 'TYPE_DROPOUT')) {
$('#appbundle_persondegree_lastDegreeYear option').each(function () {
let currentYear = $(this).text().trim();
if (today.getFullYear() == currentYear) {
$(this).attr('selected', true);
$(this).prop("hidden", false);
} else {
$(this).attr('selected', false);
$(this).prop("hidden", true);
}
})
$('#appbundle_persondegree_lastDegreeMonth option').each(function () {
let currentMonth = $(this).val();
if (currentMonth == "0") {
$(this).attr('selected', true);
$(this).prop("hidden", false);
} else {
$(this).attr('selected', false);
$(this).prop("hidden", true);
}
})
} else {
$('#appbundle_persondegree_lastDegreeYear option').each(function () {
$(this).prop("hidden", false);
})
$('#appbundle_persondegree_lastDegreeMonth option').each(function () {
let currentMonth = $(this).val();
if (currentMonth == "0") {
$(this).attr('selected', false);
$(this).prop("hidden", true);
} else {
$(this).prop("hidden", false);
}
})
}
}
//Activation/désactivation du champ registration en fonction personDegree.checkSchool
if($('#checkSchool').val() == true) {
$('#appbundle_persondegree_registrationStudentSchool').attr("disabled", true);
$('#appbundle_persondegree_registrationStudentSchool').css("color", "green");
} else {
$('#appbundle_persondegree_registrationStudentSchool').attr("disabled", false);
$('#appbundle_persondegree_registrationStudentSchool').css("color", "red");
}
//Initialisation des champs diplômes et secteurs d'activités
changeSchoolInputs('#appbundle_persondegree_school ', '#appbundle_persondegree_degree', '#appbundle_persondegree_sectorArea', '#appbundle_persondegree_activity');
//Event sur l'établissement sélectionné
listenChangeSchoolInputs('#appbundle_persondegree_school ', '#appbundle_persondegree_degree', '#appbundle_persondegree_sectorArea', '#appbundle_persondegree_activity');
let idPrefix = '#appbundle_persondegree_';
let allActivities = getAllActivities('#allActivities');
// met toutes les options (y comprises les non sélectionnées) dans le select multiple activity
initActivities(allActivities, idPrefix, 'sectorArea', 'activity', false, function () {
// initChampsAutre(idPrefix, "activity", "otherActivity", ".hide_block_other_activity", "Autre métier")
initChampsAutre(idPrefix, "activity", "otherActivity", ".hide_block_other_activity", translations['js.other_job'])
masquageChampsAutre(idPrefix, "activity", "otherActivity", ".hide_block_other_activity")
});
// initialisation des zones masquées dans le select simple
// initChampsAutre(idPrefix, "school", "otherSchool", ".hide_block_other_school", "Autre établissement");
initChampsAutre(idPrefix, "school", "otherSchool", ".hide_block_other_school", translations['js.other_establishment']);
// initChampsAutre(idPrefix, "degree", "otherDegree", ".hide_block_other_degree", "Autre diplôme");
initChampsAutre(idPrefix, "degree", "otherDegree", ".hide_block_other_degree", translations['js.other_degree']);
// Event
// masquage, affichage des chapitres dans le select simple
masquageChampsAutre(idPrefix, "school", "otherSchool", ".hide_block_other_school");
masquageChampsAutre(idPrefix, "degree", "otherDegree", ".hide_block_other_degree");
// Event
// SectorArea -> Activity
listenChangeSectorArea(allActivities, idPrefix, 'sectorArea', 'activity', 'otherActivity', ".hide_block_other_activity");
// Event
// Country -> Region -> City
if(! $('#appbundle_persondegree_prefecture').length) {
listenChangeCountryRegion('#appbundle_persondegree_country', '#appbundle_persondegree_region', 'country', 'region', 'addressCity');
}
// Event
// Region -> Prefecture -> City
else {
listenChangeRegionPrefecture('#appbundle_persondegree_country', '#appbundle_persondegree_region', '#appbundle_persondegree_prefecture', '#appbundle_persondegree_addressCity');
}
// Event
//Modification test of submit button for RGPD
if ($('#role').val() == "ROLE_DIPLOME") {
//désactive le boutton Valider tant que l'utilisateur n'a pas pris connaissance du RGPD
if ($("#buttonPersonDegree").html().replace(/ /g, "") == translations["js.validate"]) {
if ($('#appbundle_persondegree_agreeRgpd').prop('checked')) {
$('#buttonPersonDegree').attr("disabled", false);
$("#buttonPersonDegree").text(translations["js.validate"]);
} else {
$('#buttonPersonDegree').attr("disabled", true);
$("#buttonPersonDegree").text(translations["js.accept_PDP_notice_for_valid"]);
}
}
$('#appbundle_persondegree_agreeRgpd').on('change', function () {
// si acceptation RGPD
if ($('#appbundle_persondegree_agreeRgpd').prop('checked')) {
$('#buttonPersonDegree').removeAttr("disabled");
$("#buttonPersonDegree").text(translations["js.validate"]);
$("#buttonPersonDegree").css("background-color", "#2177e0");
$("#buttonPersonDegree").css("border-color", "#2177e0");
// si refus RGPD
} else {
// formulaire Valid, suppression du compte
if ($("#form_person_degree").valid()) {
$("#buttonPersonDegree").text(translations["js.delete_my_account"]);
$("#buttonPersonDegree").css("background-color", "red");
$("#buttonPersonDegree").css("border-color", "red");
// alert("Attention, vous êtes sur le point de supprimer toutes vos données personnelles")
alert(translations["js.warning_delete_all_personal_data"])
// formulaire non rempli, retour situation initiale
} else {
$('#buttonPersonDegree').attr("disabled", true);
$("#buttonPersonDegree").text(translations["js.accept_PDP_notice_for_valid"]);
}
}
});
}
}) ;
async function preventDefaultSubmit() {
// mise à jour mapAdresse et calcul des lat et longitude
// -----------------------------------------------------
if ($('#appbundle_persondegree_locationMode').not(":checked")) {
if (($('#appbundle_persondegree_latitude').val() == null) ||
($('#appbundle_persondegree_latitude').val() == 0) ||
($('#appbundle_persondegree_longitude').val() == null) ||
($('#appbundle_persondegree_longitude').val() == 0)) {
$('#appbundle_persondegree_locationMode').prop('checked', true)
}
}
if ($('#appbundle_persondegree_locationMode').is(":checked")) {
let mapAdresse = getPersondegreMapAddress();
// alert($('#appbundle_persondegree_mapsAddress').val() + " " + $('#appbundle_persondegree_latitude').val() + " " + $('#appbundle_persondegree_longitude').val() + " " + $('#appbundle_persondegree_longitude').val() );
if (($('#appbundle_persondegree_mapsAddress').val() != mapAdresse) ||
($('#appbundle_persondegree_latitude').val() == null) ||
($('#appbundle_persondegree_latitude').val() == 0) ||
($('#appbundle_persondegree_longitude').val() == null) ||
($('#appbundle_persondegree_longitude').val() == 0)) {
$('#appbundle_persondegree_mapsAddress').val(mapAdresse);
//recherche des coordonnées avec l'adresse complète
if (await geocodeAddressLocation(getPersondegreMapAddress(), '#appbundle_persondegree_latitude', '#appbundle_persondegree_longitude') == true) {
//recherche des coordonnées avec uniquement l'adresse de la ville
await geocodeAddressLocation(getPersondegreCityMapAddress(), '#appbundle_persondegree_latitude', '#appbundle_persondegree_longitude')
}
setTimeout(function () { //attente 1 seconde pour réponse google Maps geocoder avant le submit
console.log('Coordonnees map recupérées ....');
$('#appbundle_persondegree_registrationStudentSchool').removeAttr('disabled');
$('#submitPersonDegree').trigger('click');
}, 2000)
} else {
// alert($('#appbundle_persondegree_latitude').val() + " " + $('#appbundle_persondegree_longitude').val());
$('#appbundle_persondegree_registrationStudentSchool').removeAttr('disabled');
$('#submitPersonDegree').trigger('click');
}
} else {
// alert($('#appbundle_persondegree_latitude').val() + " " + $('#appbundle_persondegree_longitude').val());
$('#appbundle_persondegree_registrationStudentSchool').removeAttr('disabled');
$('#submitPersonDegree').trigger('click');
}
}
</script>
{% endblock %}