2021-12-29 14:41:33 +01:00
|
|
|
{# -*- mode: jinja-html -*- #}
|
2021-12-24 10:59:02 +01:00
|
|
|
{% extends 'base.html' %}
|
|
|
|
{% import 'bootstrap/wtf.html' as wtf %}
|
|
|
|
|
|
|
|
{% block app_content %}
|
2022-04-12 00:21:25 +02:00
|
|
|
<h1>Ajout entreprise</h1>
|
2021-12-24 10:59:02 +01:00
|
|
|
<br>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-4">
|
2021-12-24 12:12:41 +01:00
|
|
|
<p>
|
2022-02-28 18:57:05 +01:00
|
|
|
Les champs s'auto complète selon le SIRET<br>
|
|
|
|
(*) champs requis
|
2021-12-24 12:12:41 +01:00
|
|
|
</p>
|
2021-12-24 10:59:02 +01:00
|
|
|
{{ wtf.quick_form(form, novalidate=True) }}
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-01-31 18:22:54 +01:00
|
|
|
|
2021-12-24 10:59:02 +01:00
|
|
|
<script>
|
2022-04-12 00:21:25 +02:00
|
|
|
document.getElementById("siret").addEventListener("keyup", autocomplete);
|
2021-12-24 10:59:02 +01:00
|
|
|
|
2022-04-12 00:21:25 +02:00
|
|
|
function autocomplete() {
|
|
|
|
var input = document.getElementById("siret").value.replaceAll(" ", "")
|
|
|
|
if(input.length >= 14) {
|
|
|
|
fetch("https://entreprise.data.gouv.fr/api/sirene/v1/siret/" + input)
|
|
|
|
.then(response => {
|
|
|
|
if(response.ok)
|
|
|
|
return response.json()
|
|
|
|
else {
|
|
|
|
emptyForm()
|
2021-12-24 10:59:02 +01:00
|
|
|
}
|
2022-04-12 00:21:25 +02:00
|
|
|
})
|
|
|
|
.then(response => fillForm(response))
|
|
|
|
.catch(err => err)
|
2021-12-24 10:59:02 +01:00
|
|
|
}
|
2022-04-12 00:21:25 +02:00
|
|
|
}
|
2021-12-24 10:59:02 +01:00
|
|
|
|
2022-04-12 00:21:25 +02:00
|
|
|
function fillForm(response) {
|
|
|
|
document.getElementById("nom_entreprise").value = response.etablissement.l1_normalisee
|
|
|
|
document.getElementById("adresse").value = response.etablissement.l4_normalisee
|
|
|
|
document.getElementById("codepostal").value = response.etablissement.code_postal
|
|
|
|
document.getElementById("ville").value = response.etablissement.libelle_commune
|
2021-12-24 10:59:02 +01:00
|
|
|
}
|
2022-02-11 19:18:01 +01:00
|
|
|
|
2022-04-12 00:21:25 +02:00
|
|
|
function emptyForm() {
|
|
|
|
document.getElementById("nom_entreprise").value = ''
|
|
|
|
document.getElementById("adresse").value = ''
|
|
|
|
document.getElementById("codepostal").value = ''
|
|
|
|
document.getElementById("ville").value = ''
|
2022-02-11 19:18:01 +01:00
|
|
|
}
|
2021-12-24 10:59:02 +01:00
|
|
|
</script>
|
|
|
|
{% endblock %}
|