templates/persondegree/content.html.twig line 1

Open in your IDE?
  1. {% if is_granted('ROLE_ADMIN') == true  or
  2.     is_granted('ROLE_ADMIN_PAYS') == true  or
  3.     is_granted('ROLE_ADMIN_REGIONS') == true  or
  4.     is_granted('ROLE_ADMIN_VILLES') == true %}
  5.         {% set base = 'base.html.twig' %}
  6. {% elseif is_granted('ROLE_LEGISLATEUR') == true %} {% set base = 'base_legislator.html.twig' %}
  7. {% elseif is_granted('ROLE_DIRECTEUR') == true %} {% set base = 'base_legislator.html.twig' %}
  8. {% elseif is_granted('ROLE_ETABLISSEMENT') == true %} {% set base = 'base_school.html.twig' %}
  9. {% elseif is_granted('ROLE_PRINCIPAL') == true %} {% set base = 'base_principal.html.twig' %}
  10. {% else %} {% set base = 'base_degree.html.twig' %}
  11. {% endif %}
  12. {% extends base %}
  13. {% block title %}
  14.     {{ parent() }} {{ 'degree.graduates' | trans }}
  15. {% endblock %}
  16. {% block js %}
  17.     <script async defer
  18.             src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBy9WBkxvkGzs4tQN-RilyvV6WvWnTInUM&callback"
  19.             type="text/javascript">
  20.     </script>
  21.     <script>
  22.         function getPersondegreMapAddress () {
  23.             let number = $('#appbundle_persondegree_addressNumber').val();
  24.             let road = $('#appbundle_persondegree_addressRoad').val();
  25.             let locality = $('#appbundle_persondegree_addressLocality').val();
  26.             let city = $('#appbundle_persondegree_addressCity option:selected').text();
  27.             let region = $('#appbundle_persondegree_region option:selected').text();
  28.             let country = $('#appbundle_persondegree_country option:selected').text();
  29.             // adaptation dbta, annulation de la donnée de la province
  30.             if($('#selectedRegion option').length > 0) {
  31.                 country = "";
  32.             }
  33.             return (createMapsAddress(number, road, locality, city, region, country));
  34.         }
  35.         function getPersondegreCityMapAddress () {
  36.             let city = $('#appbundle_persondegree_addressCity option:selected').text();
  37.             let country = $('#appbundle_persondegree_country option:selected').text();
  38.             return (createMapsAddress(null, null, null, city, null, country));
  39.         }
  40.         let translations = [];
  41.         getTranslation().then (function (translation) {
  42.             translations = translation;
  43.             // console.log(translations);
  44.             let selectedCountry = $('#selectedCountry').val();
  45.             let selectedRegion = $('#selectedRegion').val();
  46.             //affichage de la zone Diaspora
  47.             visibilityDiaspora();
  48.             $('#appbundle_persondegree_diaspora').on('click', function () {
  49.                 visibilityDiaspora();
  50.             });
  51.             function visibilityDiaspora() {
  52.                 if ($('#appbundle_persondegree_diaspora').is(":checked")) {
  53.                     $('.addressDiaspora ').prop("hidden", false);
  54.                     if($('#appbundle_persondegree_residenceCountry').length) {
  55.                         $('#appbundle_persondegree_residenceCountry').attr("required", true);
  56.                     }
  57.                     if($('#appbundle_persondegree_residenceRegion').length) {
  58.                         $('#appbundle_persondegree_residenceRegion').attr("required", true);
  59.                     }
  60.                     $('#appbundle_persondegree_addressDiaspora').attr("required", true);
  61.                 } else {
  62.                     $('.addressDiaspora ').prop("hidden", true);
  63.                     if($('#appbundle_persondegree_residenceCountry').length) {
  64.                         $('#appbundle_persondegree_residenceCountry').attr("required", false);
  65.                     }
  66.                     if($('#appbundle_persondegree_residenceRegion').length) {
  67.                         $('#appbundle_persondegree_residenceRegion').attr("required", false);
  68.                     }
  69.                     $('#appbundle_persondegree_addressDiaspora').attr("required", false);
  70.                     $('#appbundle_persondegree_addressDiaspora').val("");
  71.                 }
  72.             }
  73.             // suppression du selectedCountry dans la liste des pays de résidence
  74.             $('#appbundle_persondegree_residenceCountry option').each(function () {
  75.                 if(selectedCountry == $(this).val()) {
  76.                     $(this).prop('hidden', true);
  77.                 }
  78.             })
  79.             //adaptation dbta (if $_env struct_province_country_city== true)
  80.             if($('#appbundle_persondegree_residenceRegion').length) {
  81.                 $('#appbundle_persondegree_residenceRegion option').each(function () {
  82.                     if(selectedRegion == $(this).val()) {
  83.                         $(this).prop('hidden', true);
  84.                     }
  85.                 })
  86.             }
  87.             //Contrôle du bouton check de localisation pour switch manuel - automatique
  88.             $('#appbundle_persondegree_locationMode').on('click', async function () {
  89.                 if ($('#appbundle_persondegree_locationMode').is(":checked")) {
  90.                     if (!confirm(translations["js.warning_coordinates_recalculated"])) {
  91.                         $('#appbundle_persondegree_locationMode').prop("checked", false);
  92.                     }
  93.                 } else {
  94.                     alert(translations["js.manual_mode"]);
  95.                 }
  96.                 //Mise à jour des coordonnées géographique en mode auto
  97.                 if ($('#appbundle_persondegree_locationMode').is(":checked")) {
  98.                     $('#appbundle_persondegree_latitude').val("");
  99.                     $('#appbundle_persondegree_longitude').val("");
  100.                     // geocodeAddressLocation(getPersondegreMapAddress(), '#appbundle_persondegree_latitude', '#appbundle_persondegree_longitude');
  101.                     //recherche des coordonnées avec l'adresse complète
  102.                     if (await geocodeAddressLocation(getPersondegreMapAddress(), '#appbundle_persondegree_latitude', '#appbundle_persondegree_longitude') == true) {
  103.                         //recherche des coordonnées avec uniquement l'adresse de la ville
  104.                         await geocodeAddressLocation(getPersondegreCityMapAddress(), '#appbundle_persondegree_latitude', '#appbundle_persondegree_longitude')
  105.                     }
  106.                     // vérifie si les coordonnées pas déjà utilisées avec autre établissement
  107.                     let url = window.location.toString();
  108.                     if (url.indexOf('/edit')!== -1) {
  109.                         url = url.replace('/edit', '/getPersondegreesByCoordinates');
  110.                     } else if (url.indexOf('/new')!== -1) {
  111.                         $('#appbundle_persondegree_locationMode').prop("checked", false);
  112.                     }
  113.                     // console.log(url);
  114.                     //creation de la data pour json
  115.                     let current_latitude = $('#appbundle_persondegree_latitude').val();
  116.                     let current_longitude = $('#appbundle_persondegree_longitude').val();
  117.                     let gap = 0.0001;
  118.                     let data = { "latitude" : current_latitude,
  119.                         "longitude" : current_longitude,
  120.                         "gap" : gap
  121.                     };
  122.                     // appel ajax en get
  123.                     await $.get(url, data).done(function (result) {
  124.                         let current_id = result['persondegree_id'];
  125.                         let coordinates = result['coordinates'];
  126.                         // console.log('current Id = ' + current_id);
  127.                         // console.log(coordinates["latitude"] + "," + coordinates["longitude"]);
  128.                         // mise à jour des coordonnées recalculées
  129.                         $('#appbundle_persondegree_latitude').val(coordinates["latitude"]);
  130.                         $('#appbundle_persondegree_longitude').val(coordinates["longitude"]);
  131.                         $('#appbundle_persondegree_locationMode').prop("checked", false);
  132.                     });
  133.                 }
  134.             });
  135.             // Si la ville n'est pas déja sélectionnée, simule un click sur le Pays pour accéder aux Regions
  136.             if ($('#selectedRegion option').length == 0) {
  137.                 if ($('#selectedCountry').val() !== '') {
  138.                     countryEvent("#selectedCountry", "persondegree");
  139.                 }
  140.             } else {
  141.                 //adaptation DBTA pour l'environnement struct_province_country
  142.                 // (pas de sélection possible sur le country, simule un click sur la region pour accéder au city)
  143.                 regionEvent("#selectedCountry", "#selectedRegion", "persondegree");
  144.             }
  145.             // console.log("test->" + $('#appbundle_persondegree_school option').length)
  146.             // création du filtre villes unique pour les établissements
  147.             $('#citySchoolFilter').append("<option selected>" + translations["js.all_f"] + "</option>");
  148.             if ($('#appbundle_persondegree_school option').length > 0) {
  149.                 // Creation du <select> de #citySchoolFilter
  150.                 let cityUnits = [];
  151.                 $('#appbundle_persondegree_school option').each(function () {
  152.                     let $this = $(this);
  153.                     if($this.text().replaceAll('é','e') != translations['js.select'].replaceAll('é','e')) {
  154.                         // vérification d'existance
  155.                         let element_exist = false;
  156.                         for (let i = 0; i < cityUnits.length; i++) {
  157.                             let thisCity = $this.text().substring($this.text().indexOf(',') + 1).trim();
  158.                             let cityUnit = cityUnits[i].substring(cityUnits[i].indexOf(',') + 1).trim();
  159.                             if (thisCity === cityUnit) {
  160.                                 element_exist = true;
  161.                             }
  162.                         }
  163.                         // génération des options du <select> de #citySchoolFilter
  164.                         if (element_exist == false) {
  165.                             cityUnits.push($this.text());
  166.                             let cityName = $this.text().substring($this.text().indexOf(',') + 1)
  167.                             let cityNameTrans = translations[cityName];
  168.                             if (!cityNameTrans) cityNameTrans = cityName;
  169.                             $('#citySchoolFilter').append("<option value='" + $this.val() + "'> " + cityNameTrans + "</option>");
  170.                         }
  171.                     }
  172.                 })
  173.             }
  174.             // création du filtre régions unique pour les établissements
  175.             $('#regionSchoolFilter').append("<option selected>" + translations["js.all_f"] + "</option>");
  176.             if ($('#schoolRegion option').length > 0) {
  177.                 // Creation du <select> de #regionSchoolFilter
  178.                 let regionUnits = [];
  179.                 $('#schoolRegion option').each(function () {
  180.                     let $this = $(this);
  181.                     // vérification d'existance
  182.                     let element_exist = false;
  183.                     for (let i = 0; i < regionUnits.length; i++) {
  184.                         if ($this.text() === regionUnits[i]) {
  185.                             element_exist = true;
  186.                         }
  187.                     }
  188.                     // génération des options du <select> de #regionSchoolFilter
  189.                     if (element_exist == false) {
  190.                         regionUnits.push($this.text());
  191.                         $('#regionSchoolFilter').append("<option value='" + $this.val() + "'> " + translations[$this.text()] + "</option>");
  192.                     }
  193.                 })
  194.             }
  195.             // filtage des établissement par villes
  196.             $('#citySchoolFilter').on('change', function () {
  197.                 let selection = $('#citySchoolFilter option:selected').text().trim();
  198.                 // console.log("selection = " + selection);
  199.                 if (selection == translations["js.all_f"]) {
  200.                     $('#appbundle_persondegree_school option').prop("hidden", false);
  201.                 } else {
  202.                     $('#appbundle_persondegree_school option[value!=""]').prop("hidden", true);
  203.                     $('#appbundle_persondegree_school option').each(function () {
  204.                         let cityName = $(this).text().substring($(this).text().indexOf(',') +1 )
  205.                         if (selection.trim() == cityName.trim()) {
  206.                             $(this).prop("hidden", false);
  207.                         }
  208.                     })
  209.                 }
  210.             })
  211.             // filtage des établissement par région
  212.             $('#regionSchoolFilter').on('change', function () {
  213.                 let selection = $('#regionSchoolFilter option:selected').text().trim();
  214.                 console.log("selection = " + selection);
  215.                 if (selection == translations["js.all_f"]) {
  216.                     $('#appbundle_persondegree_school option').prop("hidden", false);
  217.                 } else {
  218.                     $('#appbundle_persondegree_school option[value!=""]').prop("hidden", true);
  219.                     // recherche id de school
  220.                     $('#schoolRegion option').each(function () {
  221.                         // console.log($(this).text().trim());
  222.                         let schoolName = $(this).text().trim();
  223.                         let schoolId = $(this).val().trim();
  224.                         // affichage des options school
  225.                         if (selection == schoolName) {
  226.                             $('#appbundle_persondegree_school option').each(function () {
  227.                                 let selectSchoolId = $(this).val().trim();
  228.                                 if (schoolId == selectSchoolId) {
  229.                                     $(this).prop("hidden", false);
  230.                                 }
  231.                             })
  232.                         }
  233.                     })
  234.                 }
  235.             })
  236.             // Event
  237.             // Vérifie si l'indicatif du numero de téléphone est correct
  238.             {% if is_granted('ROLE_DIPLOME') == true %}
  239.             let phoneNumber = $('#appbundle_persondegree_phoneMobile1').val();
  240.             checkPhoneNumber(phoneNumber);
  241.             $('#appbundle_persondegree_phoneMobile1').on('change', function () {
  242.                 checkPhoneNumber($(this).val());
  243.             })
  244.             $('#appbundle_persondegree_residenceCountry').on('change', function () {
  245.                 checkPhoneNumber(phoneNumber);
  246.             })
  247.             $('#appbundle_persondegree_residenceRegion').on('change', function () {
  248.                 checkPhoneNumber(phoneNumber);
  249.             })
  250.             //reset pays de résidence si appbundle_persondegree_diaspora est false
  251.             $('#appbundle_persondegree_diaspora').on('click', function () {
  252.                 if ($('#appbundle_persondegree_diaspora').not(":checked")) {
  253.                     $('#appbundle_persondegree_residenceCountry').prop('selectedIndex', 0);
  254.                     $('#appbundle_persondegree_residenceRegion').prop('selectedIndex', 0);
  255.                 }
  256.                 checkPhoneNumber(phoneNumber);
  257.             })
  258.             {% endif %}
  259.             function checkPhoneNumber(phoneNumber) {
  260.                 let res = true;
  261.                 if (phoneNumber !== undefined) {
  262.                     let usrphone = $('.logged-user-phone').html().trim();
  263.                     // verification de l'indicatif pays
  264.                     // alert(" 1-> " . $('#countryPhoneCode').val());
  265.                     let indPersonDegree = '+' + $('#countryPhoneCode').val();
  266.                     // let selectResidenceCountry = $('#appbundle_persondegree_residenceCountry').val();
  267.                     let selectResidenceCountry = $('#appbundle_persondegree_country option:selected').val();
  268.                     // adaptation dbta (if $_env struct_province_country_city== true)
  269.                     if($('#selectedRegion option').length)
  270.                         selectResidenceCountry = $('#selectedRegion option:selected').val();
  271.                     // adaptation diaspora
  272.                     if($('#appbundle_persondegree_diaspora').is(":checked")) {
  273.                         if($('#appbundle_persondegree_residenceRegion option:selected').val()) {
  274.                             selectResidenceCountry = $('#appbundle_persondegree_residenceRegion option:selected').val();
  275.                         }
  276.                     }
  277.                     // console.log("test1: indPersonDegree=" + indPersonDegree + " phoneNumber=" + phoneNumber + " selectResidenceCountry=" + selectResidenceCountry);
  278.                     if($('#appbundle_persondegree_diaspora').is(":checked")) {
  279.                         $('#countriesPhoneCode option').each(function () {
  280.                             // alert(" 2-> " . $(this).val());
  281.                             // console.log("test2: " + selectResidenceCountry + " | " + $(this).val());
  282.                             if (selectResidenceCountry == $(this).val()) {
  283.                                 indPersonDegree = '+' + $(this).text();
  284.                             }
  285.                         })
  286.                     }
  287.                     //suppression des espaces
  288.                     phoneNumber = phoneNumber.replace(/ /g,'');
  289.                     $('#appbundle_persondegree_phoneMobile1').val(phoneNumber);
  290.                     //recup de l'indicatif
  291.                     let indPhone = phoneNumber.substr(0, indPersonDegree.length);
  292.                     if (indPhone != indPersonDegree) {
  293.                          // alert(" 3-> " + indPhone + " | " + indPersonDegree);
  294.                         alert(translations["js.warning,phone_must_begin_part1"] + " " + indPersonDegree + translations["js.warning,phone_must_begin_part2"]);
  295.                         $('#appbundle_persondegree_phoneMobile1').val(usrphone);
  296.                         res = false;
  297.                     } else if (phoneNumber != usrphone) {
  298.                         let confirmPhone = confirm(translations["js.warning_phone_number_changed"] + " " + phoneNumber )
  299.                         if (confirmPhone == false) {
  300.                             $('#appbundle_persondegree_phoneMobile1').val(usrphone);
  301.                         }
  302.                     }
  303.                     //verification du nombre de digit
  304.                     let nbDigitPersonDegree = null;
  305.                     $('#countriesPhoneDigit option').each(function () {
  306.                         if (selectResidenceCountry == $(this).val()) {
  307.                             nbDigitPersonDegree = $(this).text();
  308.                             // console.log(nbDigitPersonDegree);
  309.                         }
  310.                     })
  311.                     if(nbDigitPersonDegree == null) {
  312.                         $('#countriesPhoneDigit option').each(function () {
  313.                             if ($('#selectedCountry').val() == $(this).val()) {
  314.                                 nbDigitPersonDegree = $(this).text();
  315.                                 // console.log(nbDigitPersonDegree);
  316.                             }
  317.                         })
  318.                     }
  319.                     if(nbDigitPersonDegree != null) {
  320.                         if((phoneNumber.length - indPersonDegree.length) != nbDigitPersonDegree) {
  321.                             alert(translations["js.warning_telephone_digits_part1"] + " " + nbDigitPersonDegree + " " + translations["js.warning_telephone_digits_part2"]);
  322.                             $('#appbundle_persondegree_phoneMobile1').val(usrphone);
  323.                             res = false;
  324.                         }
  325.                     }
  326.                 }
  327.             }
  328.             // Initialisation de l'année et du mois d'obstention du diplome en fonction de la situation professionnelle
  329.             professionnal_situation_change_degree_year_date('#appbundle_persondegree_type');
  330.             $('#appbundle_persondegree_type').on('change', function () {
  331.                 professionnal_situation_change_degree_year_date('#appbundle_persondegree_type');
  332.             });
  333.             function professionnal_situation_change_degree_year_date(idtype) {
  334.                 let today = new Date();
  335.                 let situationPro = "";
  336.                 if ($(idtype).val())
  337.                     situationPro = $(idtype).val().trim();
  338.                 if ((situationPro == 'TYPE_TRAINING') || (situationPro == 'TYPE_DROPOUT')) {
  339.                     $('#appbundle_persondegree_lastDegreeYear option').each(function () {
  340.                         let currentYear = $(this).text().trim();
  341.                         if (today.getFullYear() == currentYear) {
  342.                             $(this).attr('selected', true);
  343.                             $(this).prop("hidden", false);
  344.                         } else {
  345.                             $(this).attr('selected', false);
  346.                             $(this).prop("hidden", true);
  347.                         }
  348.                     })
  349.                     $('#appbundle_persondegree_lastDegreeMonth option').each(function () {
  350.                         let currentMonth = $(this).val();
  351.                         if (currentMonth == "0") {
  352.                             $(this).attr('selected', true);
  353.                             $(this).prop("hidden", false);
  354.                         } else {
  355.                             $(this).attr('selected', false);
  356.                             $(this).prop("hidden", true);
  357.                         }
  358.                     })
  359.                 } else {
  360.                     $('#appbundle_persondegree_lastDegreeYear option').each(function () {
  361.                         $(this).prop("hidden", false);
  362.                     })
  363.                     $('#appbundle_persondegree_lastDegreeMonth option').each(function () {
  364.                         let currentMonth = $(this).val();
  365.                         if (currentMonth == "0") {
  366.                             $(this).attr('selected', false);
  367.                             $(this).prop("hidden", true);
  368.                         } else {
  369.                             $(this).prop("hidden", false);
  370.                         }
  371.                     })
  372.                 }
  373.             }
  374.             //Activation/désactivation du champ registration en fonction personDegree.checkSchool
  375.             if($('#checkSchool').val() == true) {
  376.                 $('#appbundle_persondegree_registrationStudentSchool').attr("disabled", true);
  377.                 $('#appbundle_persondegree_registrationStudentSchool').css("color", "green");
  378.             } else  {
  379.                 $('#appbundle_persondegree_registrationStudentSchool').attr("disabled", false);
  380.                 $('#appbundle_persondegree_registrationStudentSchool').css("color", "red");
  381.             }
  382.             //Initialisation des champs diplômes et secteurs d'activités
  383.             changeSchoolInputs('#appbundle_persondegree_school ', '#appbundle_persondegree_degree', '#appbundle_persondegree_sectorArea', '#appbundle_persondegree_activity');
  384.             //Event sur l'établissement sélectionné
  385.             listenChangeSchoolInputs('#appbundle_persondegree_school ', '#appbundle_persondegree_degree', '#appbundle_persondegree_sectorArea', '#appbundle_persondegree_activity');
  386.             let idPrefix = '#appbundle_persondegree_';
  387.             let allActivities = getAllActivities('#allActivities');
  388.             // met toutes les options (y comprises les non sélectionnées) dans le select multiple activity
  389.             initActivities(allActivities, idPrefix, 'sectorArea', 'activity', false, function () {
  390.                 // initChampsAutre(idPrefix, "activity", "otherActivity", ".hide_block_other_activity", "Autre métier")
  391.                 initChampsAutre(idPrefix, "activity", "otherActivity", ".hide_block_other_activity", translations['js.other_job'])
  392.                 masquageChampsAutre(idPrefix, "activity", "otherActivity", ".hide_block_other_activity")
  393.             });
  394.             // initialisation des zones masquées dans le select simple
  395.             // initChampsAutre(idPrefix, "school", "otherSchool", ".hide_block_other_school", "Autre établissement");
  396.             initChampsAutre(idPrefix, "school", "otherSchool", ".hide_block_other_school", translations['js.other_establishment']);
  397.             // initChampsAutre(idPrefix, "degree", "otherDegree", ".hide_block_other_degree", "Autre diplôme");
  398.             initChampsAutre(idPrefix, "degree", "otherDegree", ".hide_block_other_degree", translations['js.other_degree']);
  399.             // Event
  400.             // masquage, affichage des chapitres dans le select simple
  401.             masquageChampsAutre(idPrefix, "school", "otherSchool", ".hide_block_other_school");
  402.             masquageChampsAutre(idPrefix, "degree", "otherDegree", ".hide_block_other_degree");
  403.             // Event
  404.             // SectorArea -> Activity
  405.             listenChangeSectorArea(allActivities, idPrefix, 'sectorArea', 'activity', 'otherActivity', ".hide_block_other_activity");
  406.             // Event
  407.             // Country -> Region -> City
  408.             if(! $('#appbundle_persondegree_prefecture').length) {
  409.                 listenChangeCountryRegion('#appbundle_persondegree_country', '#appbundle_persondegree_region', 'country', 'region', 'addressCity');
  410.             }
  411.             // Event
  412.             // Region -> Prefecture -> City
  413.             else {
  414.                 listenChangeRegionPrefecture('#appbundle_persondegree_country', '#appbundle_persondegree_region', '#appbundle_persondegree_prefecture', '#appbundle_persondegree_addressCity');
  415.             }
  416.             // Event
  417.             //Modification test of submit button for RGPD
  418.             if ($('#role').val() == "ROLE_DIPLOME") {
  419.                 //désactive le boutton Valider tant que l'utilisateur n'a pas pris connaissance du RGPD
  420.                 if ($("#buttonPersonDegree").html().replace(/ /g, "") == translations["js.validate"]) {
  421.                     if ($('#appbundle_persondegree_agreeRgpd').prop('checked')) {
  422.                         $('#buttonPersonDegree').attr("disabled", false);
  423.                         $("#buttonPersonDegree").text(translations["js.validate"]);
  424.                     } else {
  425.                         $('#buttonPersonDegree').attr("disabled", true);
  426.                         $("#buttonPersonDegree").text(translations["js.accept_PDP_notice_for_valid"]);
  427.                     }
  428.                 }
  429.                 $('#appbundle_persondegree_agreeRgpd').on('change', function () {
  430.                     // si acceptation RGPD
  431.                     if ($('#appbundle_persondegree_agreeRgpd').prop('checked')) {
  432.                         $('#buttonPersonDegree').removeAttr("disabled");
  433.                         $("#buttonPersonDegree").text(translations["js.validate"]);
  434.                         $("#buttonPersonDegree").css("background-color", "#2177e0");
  435.                         $("#buttonPersonDegree").css("border-color", "#2177e0");
  436.                         // si refus RGPD
  437.                     } else {
  438.                         // formulaire Valid, suppression du compte
  439.                         if ($("#form_person_degree").valid()) {
  440.                             $("#buttonPersonDegree").text(translations["js.delete_my_account"]);
  441.                             $("#buttonPersonDegree").css("background-color", "red");
  442.                             $("#buttonPersonDegree").css("border-color", "red");
  443.                             // alert("Attention, vous êtes sur le point de supprimer toutes vos données personnelles")
  444.                             alert(translations["js.warning_delete_all_personal_data"])
  445.                             // formulaire non rempli, retour situation initiale
  446.                         } else {
  447.                             $('#buttonPersonDegree').attr("disabled", true);
  448.                             $("#buttonPersonDegree").text(translations["js.accept_PDP_notice_for_valid"]);
  449.                         }
  450.                     }
  451.                 });
  452.             }
  453.         }) ;
  454.         async function preventDefaultSubmit() {
  455.             // mise à jour mapAdresse et calcul des lat et longitude
  456.             // -----------------------------------------------------
  457.             if ($('#appbundle_persondegree_locationMode').not(":checked")) {
  458.                 if (($('#appbundle_persondegree_latitude').val() == null) ||
  459.                     ($('#appbundle_persondegree_latitude').val() == 0) ||
  460.                     ($('#appbundle_persondegree_longitude').val() == null) ||
  461.                     ($('#appbundle_persondegree_longitude').val() == 0)) {
  462.                     $('#appbundle_persondegree_locationMode').prop('checked', true)
  463.                 }
  464.             }
  465.             if ($('#appbundle_persondegree_locationMode').is(":checked")) {
  466.                 let mapAdresse = getPersondegreMapAddress();
  467.                 // alert($('#appbundle_persondegree_mapsAddress').val() + "  " + $('#appbundle_persondegree_latitude').val() + "  " + $('#appbundle_persondegree_longitude').val() + "  " + $('#appbundle_persondegree_longitude').val() );
  468.                 if (($('#appbundle_persondegree_mapsAddress').val() != mapAdresse) ||
  469.                     ($('#appbundle_persondegree_latitude').val() == null) ||
  470.                     ($('#appbundle_persondegree_latitude').val() == 0) ||
  471.                     ($('#appbundle_persondegree_longitude').val() == null) ||
  472.                     ($('#appbundle_persondegree_longitude').val() == 0)) {
  473.                     $('#appbundle_persondegree_mapsAddress').val(mapAdresse);
  474.                     //recherche des coordonnées avec l'adresse complète
  475.                     if (await geocodeAddressLocation(getPersondegreMapAddress(), '#appbundle_persondegree_latitude', '#appbundle_persondegree_longitude') == true) {
  476.                         //recherche des coordonnées avec uniquement l'adresse de la ville
  477.                         await geocodeAddressLocation(getPersondegreCityMapAddress(), '#appbundle_persondegree_latitude', '#appbundle_persondegree_longitude')
  478.                     }
  479.                     setTimeout(function () { //attente 1 seconde pour réponse google Maps geocoder avant le submit
  480.                         console.log('Coordonnees map recupérées ....');
  481.                         $('#appbundle_persondegree_registrationStudentSchool').removeAttr('disabled');
  482.                         $('#submitPersonDegree').trigger('click');
  483.                     }, 2000)
  484.                 } else {
  485.                     // alert($('#appbundle_persondegree_latitude').val() + "  " + $('#appbundle_persondegree_longitude').val());
  486.                     $('#appbundle_persondegree_registrationStudentSchool').removeAttr('disabled');
  487.                     $('#submitPersonDegree').trigger('click');
  488.                 }
  489.             } else {
  490.                 // alert($('#appbundle_persondegree_latitude').val() + "  " + $('#appbundle_persondegree_longitude').val());
  491.                 $('#appbundle_persondegree_registrationStudentSchool').removeAttr('disabled');
  492.                 $('#submitPersonDegree').trigger('click');
  493.             }
  494.         }
  495.     </script>
  496. {% endblock %}