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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
$(document).ready(function () {
applyDatatable();
$.ajax({
url: 'Api/ApiParamHabilitation.asmx/ChargerParamIdentifiants',
type: 'POST',
contentType: "application/json",
dataType: 'json',
success: function (response) {
var jsonD = jQuery.parseJSON(response.d);
var items = jsonD.DonneesSortie;
var t = $('#maTable').DataTable();
$.each(items, function (i, item) {
t.row.add([
'' + item.IdentifiantEU,
'' + item.IdentifiantBDRM,
'<button type=\"button\" class=\"data-popup-open btn btn-secondary\" data-popup-open=\"popup-1\">Edit</button>',
'<button type=\"button\" class=\"data-popup-openD btn btn-delete\" style=\"background-color:blue;\" data-popup-open=\"popup-2\">Delete</button>',
]).node().IdentifiantEU = item.DonneesSortieModif;
t.draw();
});
console.log('Statut Chargement:' + jsonD.Statut);
},
error: function (response) {
var jsonD = jQuery.parseJSON(response.d);
console.log('Statut Chargement:' + jsonD.Statut);
}
});
//}
function applyDatatable() {
$('#maTable').DataTable({
language: {
processing: "Traitement en cours...",
search: "Rechercher :",
lengthMenu: "Afficher _MENU_ éléments",
info: "Affichage de l'élement _START_ à _END_ sur _TOTAL_ éléments",
infoEmpty: "Affichage de l'élement 0 à 0 sur 0 éléments",
infoFiltered: "(filtré de _MAX_ éléments au total)",
infoPostFix: "",
loadingRecords: "Chargement en cours...",
zeroRecords: "Aucun élément à afficher",
emptyTable: "Aucune donnée disponible dans le tableau",
paginate: {
first: "Premier",
previous: "Précédent",
next: "Suivant",
last: "Dernier"
},
aria: {
sortAscending: ": activer pour trier la colonne par ordre croissant",
sortDescending: ": activer pour trier la colonne par ordre décroissant"
}
}
});
}
var idEvalActuelle = "";
var table = $('#maTable').DataTable();
$('#maTable ').on('click', 'data-popup-open btn', function () {
var targeted_popup_class = $(this).attr('data-popup-open'), id_tr = $(this).closest('tr').attr('id');
var data = table.row($(this).closest('tr')).data();
idEvalActuelle = data[0];
$('#popup_')
.attr({ "data-popup": targeted_popup_class, "data-id-tr": id_tr })
.find('#nomH2')
.text(targeted_popup_class == "popup-1"?"Modifier un Identifiant" : "Supprimer un identifiant")//modification du titre selon l'action
.next()
.find("#Login").val("teste " + data[0])
.parent()
.next()
.find('#MotDePasse').val(data[1])
.closest('.popup-inner')
.find('#ButtonAnnuler,.popup-close')
.attr('data-popup-close', targeted_popup_class)//attribuer targeted_popup_class à 2 éléments, le <bouton> et le <a class="popup-close">
.closest('#popup_')
.fadeIn(350);
console.log('data-popup :' + targeted_popup_class + ', id tr clicked :' + id_tr + ', button clicked :' + targeted_popup_class, ' data[0] :', data[0]);
});
function confirmerModification() {
var donneesLg = $("#Login").val();
var donneesPwd = $("#MotDePasse").val();
var data_id_tr=$("#popup_").attr('data-id-tr');
console.log('le id tr est :',data_id_tr);
$.ajax({
url: 'Api/ApiParamIdentifiant.asmx/ModifierUnLogin',
type: 'POST',
contentType: "application/json",
dataType: 'json',
data: JSON.stringify({
donneesEntree: idEvalActuelle + "," + donneesLg + "," + donneesPwd + "," + data_id_tr,
}),
success: function (response) {
var jsonD = response.d;
messageModification = jsonD.DonneesSortieModif;
console.log(messageModification);
},
error: function (response) {
fail(response);
}
});
function fail(reponse) {
var jsonD = response.d;
console.log("Statut Modification identifiant :" + jsonD.Statut);
}
}
//fonction de suppression
function confirmerSuppression() {
var donneesEu = $("#IdentifiantEU").val();
var donneesBdrm = $("#IdentifiantBDRM").val();
$.ajax({
url: 'Api/ApiParamHabilitation.asmx/SupprimerUnLogin',
type: 'POST',
contentType: "application/json",
dataType: 'json',
data: JSON.stringify({
donneesEntree: idEvalActuelle + "," + donneesBdrm + "," + donneesEu,
}),
success: function (response) {
var jsonD = jQuery.parseJSON(response.d);
messageSuppression = jsonD.donneesEntree;
alert(messageSuppression);
location.reload(true);
},
error: function (response) {
fail(response);
}
});
function fail(reponse) {
var jsonD = jQuery.parseJSON(response.d);
console.log("Statut Suppression habilitation:" + jsonD.Statut);
}
}
$('#Buttonvalider').click(function () {
$('.popup-inner').hide();
confirmerModification();
});
// Le curseur au niveau du menu
var elt = $('#Identifiant');
$('#Acceuil').removeClass("active");
$('#Parametres').removeClass("active");
$('#Deconnexion').removeClass("active");
}); |