You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
3.2 KiB
91 lines
3.2 KiB
function Slider(id) {
|
|
let td = document.getElementsByClassName(id);
|
|
let is_checked;
|
|
if (td[12].querySelector('input').checked == true) {
|
|
is_checked = 1;
|
|
}
|
|
else {
|
|
is_checked = 0;
|
|
}
|
|
let xhr = new XMLHttpRequest();
|
|
xhr.onreadystatechange = function() {
|
|
if (this.readyState == 4 && this.status == 200) {
|
|
if (is_checked == 1) {
|
|
td[11].querySelector('img').src = "../img/check.png";
|
|
}
|
|
else {
|
|
td[11].querySelector('img').src = "../img/excla.png";
|
|
}
|
|
}
|
|
};
|
|
xhr.open('POST', 'cible/slider.php', true);
|
|
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
|
xhr.send("is_checked=" + encodeURI(is_checked) + "&id=" + encodeURI(td[0].textContent));
|
|
}
|
|
|
|
function Edit(clas) {
|
|
let obj = document.getElementsByClassName(clas);
|
|
let data = new FormData();
|
|
if (obj[13].querySelector('input').value == 'edit') {
|
|
for (let i=1; i< 11; i++) {
|
|
obj[i].innerHTML = '<input class="input" type="text" style="width: 80%;" value="' + obj[i].textContent + '">';
|
|
}
|
|
obj[13].querySelector('input').value = 'ok';
|
|
}
|
|
else {
|
|
let value = new Value(obj);
|
|
let xhr = new XMLHttpRequest();
|
|
data.append('value', JSON.stringify(value));
|
|
xhr.onreadystatechange = function() {
|
|
if (this.readyState == 4 && this.status == 200) {
|
|
for (let i=1; i<11; i++) {
|
|
obj[i].innerHTML = this.response[i];
|
|
}
|
|
obj[13].querySelector('input').value = 'edit';
|
|
}
|
|
};
|
|
xhr.open('POST', 'cible/edit.php', true);
|
|
xhr.responseType = 'json';
|
|
xhr.send(data);
|
|
}
|
|
}
|
|
|
|
function Value(list) {
|
|
this.id = list[0].textContent;
|
|
this.dates = list[1].querySelector('input').value;
|
|
this.details = list[2].querySelector('input').value;
|
|
this.lieu = list[3].querySelector('input').value;
|
|
this.salle = list[4].querySelector('input').value;
|
|
this.pos = list[5].querySelector('input').value;
|
|
this.materiel = list[6].querySelector('input').value;
|
|
this.marque = list[7].querySelector('input').value;
|
|
this.model = list[8].querySelector('input').value;
|
|
this.nserie = list[9].querySelector('input').value;
|
|
this.demandeur = list[10].querySelector('input').value;
|
|
if (list[11].querySelector('img').src == '../img/check.png') {
|
|
this.traitement = 1;
|
|
}
|
|
else {
|
|
this.traitement = 0;
|
|
}
|
|
|
|
}
|
|
|
|
function ModifPop(clas) {
|
|
const popup = document.getElementsByClassName('container-popup__popup')[0];
|
|
popup.querySelector('p').textContent = 'Voulez-vous vraiment supprimer le ticket ' + clas + ' ?';
|
|
popup.querySelector('a > input').setAttribute('onclick', 'DelTicket('+clas+')');
|
|
}
|
|
|
|
function DelTicket(clas) {
|
|
let xhr = new XMLHttpRequest();
|
|
xhr.onreadystatechange = function() {
|
|
if (this.readyState == 4 && this.status == 200) {
|
|
location.reload();
|
|
}
|
|
};
|
|
xhr.open('POST', 'cible/delete.php', true);
|
|
xhr.responseType = 'text';
|
|
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
|
xhr.send("id=" + encodeURI(clas));
|
|
}
|
|
|