BARRAUX Arthur
3 years ago
13 changed files with 463 additions and 35 deletions
@ -0,0 +1,21 @@ |
|||
<?php |
|||
$decode = json_decode($_POST['value'], TRUE); |
|||
$bdd = new PDO('mysql:host=localhost;dbname=ticket;charset:utf8', 'root', ''); |
|||
$request = 'UPDATE pannes SET |
|||
dates = "' .$decode["dates"] .'", |
|||
details = "' .$decode["details"] .'", |
|||
lieu = "' .$decode["lieu"] .'", |
|||
salle = "' .$decode["salle"] .'", |
|||
pos = "' .$decode["pos"] .'", |
|||
materiel = "' .$decode["materiel"] .'", |
|||
marque = "' .$decode["marque"] .'", |
|||
model = "' .$decode["model"] .'", |
|||
nserie = "' .$decode["nserie"] .'", |
|||
demandeur = "' .$decode["demandeur"] .'", |
|||
traitement = "' .$decode["traitement"] .'" |
|||
WHERE ID= "' .$decode['id'] .'"'; |
|||
$update = $bdd->query($request); |
|||
|
|||
$traitement = $bdd->query("SELECT * FROM pannes WHERE ID=" .$decode['id']); |
|||
print_r(json_encode($traitement->fetch())); |
|||
?> |
@ -0,0 +1,9 @@ |
|||
<?php |
|||
$bdd = new PDO('mysql:host=localhost;dbname=ticket;charset:utf8', 'root', ''); |
|||
|
|||
$update = $bdd->query("UPDATE pannes SET traitement = " .$_POST['is_checked'] ." WHERE ID = " .$_POST['id']); |
|||
|
|||
$traitement = $bdd->query("SELECT traitement FROM pannes WHERE ID=" .$_POST['id']); |
|||
$res = $traitement->fetch()['traitement']; |
|||
echo $res; |
|||
?> |
@ -1,19 +0,0 @@ |
|||
document.getElementById('form').addEventListener('submit', function(e) { |
|||
e.preventDefault(); |
|||
|
|||
let data = new FormData(this); |
|||
|
|||
let xhr = new XMLHttpRequest(); |
|||
xhr.onreadystatechange = function() { |
|||
console.log(this.response); |
|||
if (this.readyState == 4 && this.status == 200) { |
|||
} else if (this.readyState == 4) { |
|||
alert('uhe erreur est survenue...'); |
|||
} |
|||
}; |
|||
xhr.open('POST', 'cible/search.php', true); |
|||
xhr.send(data); |
|||
let p = document.createElement('p'); |
|||
p.textContent = 'hzllo'; |
|||
document.getElementById('corps').appendChild(p); |
|||
}); |
@ -1,7 +1,15 @@ |
|||
<?php |
|||
$bdd = new PDO('mysql:host=localhost;dbname=ticket;charset:utf8', 'root', ''); |
|||
|
|||
$reponse = $bdd->query("SELECT * FROM pannes ORDER BY ID"); |
|||
try { |
|||
$reponse = $bdd->query("SELECT * FROM pannes WHERE ID=" .$_POST['id']); |
|||
$line = $reponse -> fetch(); |
|||
|
|||
print_r($reponse -> fetch($_POST['id'])); |
|||
|
|||
$result = json_encode($line); |
|||
|
|||
print_r($result); |
|||
} catch (Exception) { |
|||
echo false; |
|||
} |
|||
?> |
|||
|
@ -0,0 +1,23 @@ |
|||
<?php |
|||
echo '<tr> |
|||
<td class=', $class , ' style="font-weight: bold;" >',$class,'</td> |
|||
<td class=', $class , '>',$line[1],'</td> |
|||
<td class=', $class , '>',$line[2],'</td> |
|||
<td class=', $class , '>',$line[3],'</td> |
|||
<td class=', $class , '>',$line[4],'</td> |
|||
<td class=', $class , '>',$line[5],'</td> |
|||
<td class=', $class , '>',$line[6],'</td> |
|||
<td class=', $class , '>',$line[7],'</td> |
|||
<td class=', $class , '>',$line[8],'</td> |
|||
<td class=', $class , '>',$line[9],'</td> |
|||
<td class=', $class , '>',$line[10],'</td> |
|||
<td class=', $class , '>',$line[11],'</td> |
|||
<td class=', $class , '> |
|||
<label class="switch"> |
|||
<input class="checkbox" type="checkbox" onchange="Slider(\'',$class,'\')"> |
|||
<span class="slider"></span> |
|||
</label> |
|||
</td> |
|||
<td class=',$class,'><input class="edit" type="button" value="edit" onclick="Edit(\'',$class,'\')"></td> |
|||
</tr>'; |
|||
?> |
@ -1,6 +1,4 @@ |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<title>Admin ticket</title> |
|||
<link href="stylepage.css" rel="stylesheet"> |
|||
<img class="logo" src="../img/logo_PC.png" alt="logo_PC" width="200px"> |
|||
</head> |
|||
<meta charset="utf-8"> |
|||
<title>Admin ticket</title> |
|||
<link href="stylepage.css" rel="stylesheet"> |
|||
<img class="logo" src="../img/logo_PC.png" alt="logo_PC" width="200px"> |
|||
|
@ -1,8 +1,51 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="fr"> |
|||
<head> |
|||
<?php include 'include/menu.php'; ?> |
|||
</head> |
|||
|
|||
<body> |
|||
<a href="../prof/index.php">client</a> |
|||
<a id="lien-client" href="../prof/index.php">client</a> |
|||
<?php include 'include/nav.php'; ?> |
|||
<script type="text/javascript" src="js/index.js" defer></script> |
|||
<table id="table"> |
|||
<thead> |
|||
<tr> |
|||
<th colspan="14">Ticket récents non traités</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr class="table-title"> |
|||
<td>ID</td> |
|||
<td>date</td> |
|||
<td>details</td> |
|||
<td>lieu</td> |
|||
<td>salle</td> |
|||
<td>pos</td> |
|||
<td>materiel</td> |
|||
<td>marque</td> |
|||
<td>model</td> |
|||
<td>nserie</td> |
|||
<td>demandeur</td> |
|||
<td>traitement</td> |
|||
<td>valider</td> |
|||
</tr> |
|||
|
|||
<?php |
|||
$bdd = new PDO('mysql:host=localhost;dbname=ticket;charset:utf8', 'root', ''); |
|||
|
|||
$reponse = $bdd->query("SELECT * FROM pannes ORDER BY ID DESC"); |
|||
|
|||
for ($j=0; $j < 3; $j++) { |
|||
$line = $reponse->fetch(); |
|||
if ($line['traitement'] == 0) { |
|||
$class = $line[0]; |
|||
include 'include/line.php'; |
|||
} |
|||
} |
|||
$reponse->closeCursor(); |
|||
?> |
|||
</tbody> |
|||
</table> |
|||
</body> |
|||
</html> |
|||
|
@ -0,0 +1,68 @@ |
|||
let checkbox = document.getElementsByClassName('checkbox'); |
|||
for (elem in checkbox) { |
|||
elem.checked = false; |
|||
} |
|||
|
|||
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) { |
|||
td[11].textContent = this.response; |
|||
} |
|||
}; |
|||
xhr.open('POST', 'cible/index.php', true); |
|||
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
|||
xhr.send("is_checked=" + encodeURI(is_checked) + "&id=" + encodeURI(id)); |
|||
} |
|||
|
|||
function Edit(clas) { |
|||
let obj = document.getElementsByClassName(clas); |
|||
let data = new FormData(); |
|||
if (obj[13].querySelector('input').value == 'edit') { |
|||
for (let i=1; i< 12; i++) { |
|||
obj[i].innerHTML = '<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)); |
|||
console.log(data); |
|||
xhr.onreadystatechange = function() { |
|||
if (this.readyState == 4 && this.status == 200) { |
|||
console.log(this.response); |
|||
for (let i=1; i<12; 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; |
|||
this.traitement = list[11].querySelector('input').value; |
|||
} |
@ -0,0 +1,95 @@ |
|||
const table_ticket = document.getElementsByClassName('ticket'); |
|||
const table_title = document.getElementsByClassName('table-title'); |
|||
var id_displayed; |
|||
|
|||
document.getElementById('form').addEventListener('submit', function(e) { |
|||
e.preventDefault(); |
|||
|
|||
let data = new FormData(this); |
|||
|
|||
let xhr = new XMLHttpRequest(); |
|||
xhr.onreadystatechange = function() { |
|||
if (this.readyState == 4 && this.status == 200) { |
|||
if (this.response != false) { |
|||
id_displayed = data.get('id'); |
|||
for (let i=0; i < 12; i++) { |
|||
table_ticket[i].textContent = this.response[i]; |
|||
} |
|||
document.getElementById('table-search').style.display = 'block'; |
|||
} |
|||
else { |
|||
alert("Ce ticket n'existe pas"); |
|||
} |
|||
} else if (this.readyState == 4) { |
|||
alert('uhe erreur est survenue...'); |
|||
} |
|||
}; |
|||
xhr.open('POST', 'cible/search.php', true); |
|||
xhr.responseType = 'json'; |
|||
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
|||
xhr.send("id=" + encodeURI(data.get('id'))); |
|||
}); |
|||
|
|||
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) { |
|||
td[11].textContent = this.response; |
|||
} |
|||
}; |
|||
xhr.open('POST', 'cible/index.php', true); |
|||
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
|||
xhr.send("is_checked=" + encodeURI(is_checked) + "&id=" + encodeURI(id_displayed)); |
|||
} |
|||
|
|||
function Edit(clas) { |
|||
let obj = document.getElementsByClassName(clas); |
|||
let data = new FormData(); |
|||
if (obj[13].querySelector('input').value == 'edit') { |
|||
for (let i=1; i< 12; i++) { |
|||
obj[i].innerHTML = '<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)); |
|||
console.log(data); |
|||
xhr.onreadystatechange = function() { |
|||
if (this.readyState == 4 && this.status == 200) { |
|||
console.log(this.response); |
|||
for (let i=1; i<12; 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; |
|||
this.traitement = list[11].querySelector('input').value; |
|||
} |
@ -0,0 +1,45 @@ |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<?php include 'include/menu.php';?> |
|||
<script type="text/javascript" src="js/index.js" defer></script> |
|||
</head> |
|||
<body id="corps"> |
|||
<?php include 'include/nav.php';?> |
|||
<table> |
|||
<thead> |
|||
<tr> |
|||
<th colspan="14">Ticket</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr class='table-title'> |
|||
<td>ID</td> |
|||
<td>date</td> |
|||
<td>details</td> |
|||
<td>lieu</td> |
|||
<td>salle</td> |
|||
<td>pos</td> |
|||
<td>materiel</td> |
|||
<td>marque</td> |
|||
<td>model</td> |
|||
<td>nserie</td> |
|||
<td>demandeur</td> |
|||
<td>traitement</td> |
|||
<td>valider</td> |
|||
</tr> |
|||
<?php |
|||
$bdd = new PDO('mysql:host=localhost;dbname=ticket;charset:utf8', 'root', ''); |
|||
|
|||
$reponse = $bdd->query("SELECT * FROM pannes ORDER BY ID"); |
|||
|
|||
while ($line = $reponse->fetch()) { |
|||
$class = $line[0]; |
|||
include 'include/line.php'; |
|||
} |
|||
$reponse->closeCursor(); |
|||
?> |
|||
</tbody> |
|||
</table> |
|||
</body> |
|||
</html> |
Loading…
Reference in new issue