1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| function litfichier(A, B, C, D, E) {
var x, V, Kkey, ligne = '', Vid;
$('.data').remove(); //RAZ tableau
$.ajax({
url: "./dossiers-recents-durbanisme.json",
type: "GET",
dataType: "json",
error: function () {
console.log('Error!')
},
success: function (data) {
for (x = 0; x < (data.length); x += 1) {
Kkey = Object.keys(data[x]);
if (Kkey[1] === "recordid") {
Vid = Object.values(data[x]);
}
if (Kkey[2] === "fields") {
V = Object.values(data[x]);
if (V[2]['type_decision'] === undefined) {
V[2]['type_decision'] = '';
}
if (V[2]['type_dossier'] === A && V[2]['commune'] === parseInt(B) && (V[2]['type_decision'] === C || V[2]['type_decision'] === '') && V[2]['etat'] === D && V[2]['circonscription'] === E) {
ligne += `<tr class="data"><td> ${V[2]['type_dossier']}</td>` +
`<td> ${V[2]['commune']}</td>` +
`<td> ${V[2]['type_decision']}</td>` +
`<td> ${V[2]['etat']}</td>` +
`<td> ${V[2]['circonscription']}</td>` +
`<td> ${Vid[1]} </td></tr>`;
}
}
}
$('table').append(ligne); // On affiche les résultats dans le tableau
}
});
}
$(function () {
(function ($) {
$('#rechecher').on('click', function () {
var optionsselect = [];// Les valeurs des selects dans un array
/*
type_dossier --> Permis de construire
type_decision --> Favorable FavorableRéservé Défavorable
circonscription --> NORD EST SUD OUEST
commune --> n° de l'arrondissement
etat --> En cours d'instruction Accordé Refusé
*/
optionsselect[0] = $('#select_un option:selected').text(); //type_dossier
optionsselect[1] = $('#select_deux option:selected').text(); // commune
optionsselect[2] = $('#select_trois option:selected').text(); //type_decision
optionsselect[3] = $('#select_quatre option:selected').text(); // etat
optionsselect[4] = $('#select_cinq option:selected').text(); // circonscription
litfichier(optionsselect[0], optionsselect[1], optionsselect[2], optionsselect[3], optionsselect[4]); // En Ajax
});
})(jQuery);
}); |
Partager