Browse Source

Enfin un site qui marche (à peu près)

master
BARRAUX Arthur 3 years ago
parent
commit
7cf69e2a05
  1. 21
      referant/cible/edit.php
  2. 9
      referant/cible/index.php
  3. 19
      referant/cible/script.js
  4. 12
      referant/cible/search.php
  5. 23
      referant/include/line.php
  6. 10
      referant/include/menu.php
  7. 2
      referant/include/nav.php
  8. 47
      referant/index.php
  9. 68
      referant/js/index.js
  10. 95
      referant/js/search.js
  11. 45
      referant/liste.php
  12. 37
      referant/search.php
  13. 110
      referant/stylepage.css

21
referant/cible/edit.php

@ -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()));
?>

9
referant/cible/index.php

@ -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;
?>

19
referant/cible/script.js

@ -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);
});

12
referant/cible/search.php

@ -1,7 +1,15 @@
<?php <?php
$bdd = new PDO('mysql:host=localhost;dbname=ticket;charset:utf8', 'root', ''); $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;
}
?> ?>

23
referant/include/line.php

@ -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>';
?>

10
referant/include/menu.php

@ -1,6 +1,4 @@
<head> <meta charset="utf-8">
<meta charset="utf-8"> <title>Admin ticket</title>
<title>Admin ticket</title> <link href="stylepage.css" rel="stylesheet">
<link href="stylepage.css" rel="stylesheet"> <img class="logo" src="../img/logo_PC.png" alt="logo_PC" width="200px">
<img class="logo" src="../img/logo_PC.png" alt="logo_PC" width="200px">
</head>

2
referant/include/nav.php

@ -3,7 +3,7 @@
<ul> <ul>
<li class="menu"><a href="index.php">Accueil</a></li> <li class="menu"><a href="index.php">Accueil</a></li>
<li class="menu"><a href="search.php">Recherche</a></li> <li class="menu"><a href="search.php">Recherche</a></li>
<li class="menu"><a href="actus.html">Actus</a></li> <li class="menu"><a href="liste.php">Liste</a></li>
<li class="menu"><a href="liens.html">Liens</a></li> <li class="menu"><a href="liens.html">Liens</a></li>
</ul> </ul>
</nav> </nav>

47
referant/index.php

@ -1,8 +1,51 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="fr"> <html lang="fr">
<?php include 'include/menu.php'; ?> <head>
<?php include 'include/menu.php'; ?>
</head>
<body> <body>
<a href="../prof/index.php">client</a> <a id="lien-client" href="../prof/index.php">client</a>
<?php include 'include/nav.php'; ?> <?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> </body>
</html> </html>

68
referant/js/index.js

@ -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;
}

95
referant/js/search.js

@ -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;
}

45
referant/liste.php

@ -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>

37
referant/search.php

@ -1,9 +1,13 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="fr"> <html lang="fr">
<?php include 'include/menu.php'; ?> <head>
<?php include 'include/menu.php'; ?>
<script type="text/javascript" src="js/search.js" defer></script>
</head>
<body id='corps'> <body id='corps'>
<?php include 'include/nav.php'; ?> <?php include 'include/nav.php'; ?>
<form id="form" action="cible/search.php" method="POST"> <form id="form" action="js/search.php" method="POST">
<div class="champ"> <div class="champ">
<input type="input" name="id"> <input type="input" name="id">
</div> </div>
@ -11,6 +15,33 @@
<input id="submit" class="entry" type="submit"> <input id="submit" class="entry" type="submit">
</div> </div>
</form> </form>
<script type="text/javascript" src="cible/script.js" defer></script> <table id='table-search'>
<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
$class = 'ticket';
include 'include/line.php';
?>
</tbody>
</table>
</body> </body>
</html> </html>

110
referant/stylepage.css

@ -5,6 +5,24 @@ body{
text-align: center; text-align: center;
} }
#lien-client{
text-decoration: none;
display: block;
width: 10%;
color: #454444;
margin: 10px auto;
border: 4px solid #4e4d4d;
padding: 10px 10px;
border-radius: 30px;
transition: 0.25s;
}
#lien-client:hover{
width: 20%;
border-color: #ac2a8d;
background-color: #dddddd;
}
nav{ nav{
width: 80%; width: 80%;
margin-left: 10%; margin-left: 10%;
@ -48,8 +66,41 @@ nav a{
text-decoration: none; text-decoration: none;
} }
#table-search{
display: none;
}
.table-title td{
color: #ac2a8d;
font-weight: bold;
}
table{
width: 80%;
border-radius: 5px;
margin-left: 10%;
background-color: #84878C;
color: #fff;
border: 1px solid #84878C;
}
td {
border: 1px solid #84878C;
background-color: #e5e5e5;
border-radius: 5px;
color: #84878C;
width: 7%;
}
th{
width: 100%;
}
.menu:hover{ .menu:hover{
background-color: #59184E; background-color: #59184E;
transition: .5s;
border-radius: 10px; border-radius: 10px;
} }
@ -70,8 +121,8 @@ nav a{
display: block; display: block;
margin: 10px auto; margin: 10px auto;
border: 4px solid #4e4d4d; border: 4px solid #4e4d4d;
padding: 40px 40px; padding: 20px 40px;
width: 60%; width: 40%;
border-radius: 80px; border-radius: 80px;
transition: 0.25s; transition: 0.25s;
} }
@ -110,3 +161,58 @@ nav a{
background-color: #82E6AC; background-color: #82E6AC;
border-color: #2ecc71; border-color: #2ecc71;
} }
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
/* Hide default HTML checkbox */
.switch input {
opacity: 0;
width: 0;
height: 0;
}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: crimson;
border-radius: 34px;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
border-radius: 50%;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color:#2ecc71;
}
input:focus + .slider {
box-shadow: 0 0 1px #2ecc71;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
Loading…
Cancel
Save