74 lines
2.3 KiB
JavaScript
74 lines
2.3 KiB
JavaScript
formulaire = $('.formulaire')
|
|
date = Date.now()
|
|
|
|
$(document).ready(function () {
|
|
|
|
// $.ajax({
|
|
// url: "/controleurs/c_interventions.php?action=infoFormulaire",
|
|
// method: "POST", // Méthode HTTP (GET, POST, etc.)
|
|
// dataType: "json", // Type de données attendu
|
|
// error: function(status, error) {
|
|
// // Gérer les erreurs de la requête AJAX
|
|
// console.error("Erreur lors de la requête AJAX :", status, error);
|
|
// },
|
|
// success: function(result) {
|
|
|
|
// }
|
|
// });
|
|
|
|
$('#caserneInter').change(function () {
|
|
console.log($(this).val());
|
|
caserne = $(this).val()
|
|
//cis
|
|
$.ajax({
|
|
url: "./../controleurs/c_interventions.php?action=listePompier&cis=" + caserne,
|
|
method: "POST", // Méthode HTTP (GET, POST, etc.)
|
|
dataType: "json", // Type de données attendu
|
|
error: function (status, error) {
|
|
// Gérer les erreurs de la requête AJAX
|
|
console.error("Erreur lors de la requête AJAX :", status, error);
|
|
},
|
|
success: function (result) {
|
|
$('#pompierDispo').html(' ');
|
|
result.forEach(element => {
|
|
var ligne = '<div id='
|
|
+ element['pId']
|
|
+ ' class="' + element['pLibelle']
|
|
+ '" style = "background-color: ' + element['pValeur'] + ';" draggable = "true" ondragstart = "dragstartHandler(event)" >'
|
|
+ element['pPrenom'] + ' ' + element['pNom']
|
|
+ ' (' + element['statut'] + ')'
|
|
+ '</div> ';
|
|
|
|
$('#pompierDispo').append(ligne)
|
|
|
|
});
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
function dragstartHandler(ev) {
|
|
// Add the target element's id to the data transfer object
|
|
ev.dataTransfer.setData("application/my-app", ev.target.id);
|
|
ev.dataTransfer.effectAllowed = "move";
|
|
}
|
|
function dragoverHandler(ev) {
|
|
ev.preventDefault();
|
|
ev.dataTransfer.dropEffect = "move";
|
|
}
|
|
function dropHandler(ev) {
|
|
ev.preventDefault();
|
|
// Get the id of the target and add the moved element to the target's DOM
|
|
const data = ev.dataTransfer.getData("application/my-app");
|
|
if (ev.target.id === "target" || ev.target.parentNode.id === "target") {
|
|
trgt = document.getElementById('target');
|
|
} else if (ev.target.id === "pompierDispo" || ev.target.parentNode.id === "pompierDispo") {
|
|
trgt = document.getElementById('pompierDispo');
|
|
}
|
|
trgt.appendChild(document.getElementById(data));
|
|
}
|
|
|
|
|