Browse Source

V1.5 (export CSV)

master V1.5
BARRAUX Arthur 3 years ago
parent
commit
b9437ea5a2
  1. 2
      login/index.php
  2. 2
      referant/admin.php
  3. 16
      referant/cible/export.php
  4. 0
      referant/cible/slider.php
  5. 0
      referant/cible/ticket.sql
  6. 49
      referant/export.php
  7. 5
      referant/export/ticket.csv
  8. 42
      referant/include/line.php
  9. 0
      referant/include/menu.html
  10. 4
      referant/index.php
  11. 28
      referant/js/edit.js
  12. 80
      referant/js/search.js
  13. 4
      referant/liste.php
  14. 3
      referant/search.php
  15. 1
      stylepage.css

2
login/index.php

@ -22,7 +22,7 @@
</div>
</div>
<div class="container-champ">
<div class="champ">
<div class="submit">
<input class="entry" type="submit" value="conexion">
</div>
</div>

2
referant/admin.php

@ -11,7 +11,7 @@
<html>
<head>
<?php include 'include/menu.php'; ?>
<?php include 'include/menu.html'; ?>
<script type="text/javascript" src="js/admin.js" defer></script>
</head>
<body>

16
referant/cible/export.php

@ -0,0 +1,16 @@
<?php
$connect = mysqli_connect("localhost", "root", "", "ticket");
$query = "SELECT * FROM `" .$_POST['bdd'] ."`";
$title = array_keys(mysqli_fetch_assoc(mysqli_query($connect, $query)));
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=' .$_POST['bdd'] .'.csv');
$output = fopen("php://output", "w");
fputcsv($output, $title);
$result = mysqli_query($connect, $query);
while($row = mysqli_fetch_assoc($result)) {
fputcsv($output, $row);
}
fclose($output);
?>

0
referant/cible/index.php → referant/cible/slider.php

0
referant/cible/ticket.sql

49
referant/export.php

@ -1,18 +1,39 @@
<?php
include '../session_restraintes.php';
?>
$bdd = new PDO('mysql:host=localhost;dbname=ticket;charset:utf8', 'root', '');
$reponse = $bdd->query("SELECT DISTINCT * FROM `pannes`");
$stream = fopen('export/ticket.csv', 'w');
<!DOCTYPE html>
<html lang="fr">
<head>
<?php include 'include/menu.html'; ?>
</head>
while($line = $reponse->fetch()) {
print_r($line);
echo '<br>';
fputcsv(
$stream, // file
$line, // arr
);
}
$reponse->closeCursor();
fclose($stream);
?>
<body>
<?php include 'include/nav.php'?>
<form id='form' action="cible/export.php" method="post">
<div class="container-champ">
<p>Type:</p>
<div class="champ">
<select class="entry" name="type">
<option value="csv">CSV</option>
<!-- <option value="sql">SQL</option> -->
</select>
</div>
</div>
<div class="container-champ">
<p>Base:</p>
<div class="champ">
<select class="entry" name="bdd">
<option value="pannes">pannes</option>
<option value="logins">logins</option>
</select>
</div>
</div>
<div class="container-champ">
<div class="submit">
<input class="entry" type="submit" value="Download">
</div>
</div>
</form>
</body>
</html>

5
referant/export/ticket.csv

@ -1,5 +0,0 @@
1,1,2021-10-22,2021-10-22,"Bonjour de Bretagne","Bonjour de Bretagne","Bâtiment A","Bâtiment A",42,42,"au fond a gauche","au fond a gauche",pc,pc,alienware,alienware,"lattitude E6410","lattitude E6410",sefv-45-gd1,sefv-45-gd1,barraux,barraux,0,0
4,4,2021-10-23,2021-10-23,sq@,sq@,FE,FE,ds,ds,QDGFDQ,QDGFDQ,UC,UC,QGDF,QGDF,FQG,FQG,QGZet,QGZet,qgqre,qgqre,0,0
5,5,2021-10-23,2021-10-23,sq@,sq@,FE,FE,ds,ds,QDGFDQ,QDGFDQ,UC,UC,QGDF,QGDF,FQG,FQG,sgf,sgf,sef,sef,0,0
6,6,2021-10-25,2021-10-25,"manque la dernière carte graphique","manque la dernière carte graphique",Locquirec,Locquirec,"Ma chambre","Ma chambre","Sur le lit","Sur le lit",UC,UC,Dell,Dell,"LATITTUDE E6410","LATITTUDE E6410","chai pas","chai pas",BARRAUX,BARRAUX,0,0
7,7,2021-10-28,2021-10-28,"pas d'inspi","pas d'inspi",Locquirec,Locquirec,"chambre 6","chambre 6","pas bougé","pas bougé",UC,UC,Dell,Dell,flemme,flemme,"je sais pas","je sais pas","Le Cocotier des mers","Le Cocotier des mers",0,0
1 1 1 2021-10-22 2021-10-22 Bonjour de Bretagne Bonjour de Bretagne Bâtiment A Bâtiment A 42 42 au fond a gauche au fond a gauche pc pc alienware alienware lattitude E6410 lattitude E6410 sefv-45-gd1 sefv-45-gd1 barraux barraux 0 0
2 4 4 2021-10-23 2021-10-23 sq@ sq@ FE FE ds ds QDGFDQ QDGFDQ UC UC QGDF QGDF FQG FQG QGZet QGZet qgqre qgqre 0 0
3 5 5 2021-10-23 2021-10-23 sq@ sq@ FE FE ds ds QDGFDQ QDGFDQ UC UC QGDF QGDF FQG FQG sgf sgf sef sef 0 0
4 6 6 2021-10-25 2021-10-25 manque la dernière carte graphique manque la dernière carte graphique Locquirec Locquirec Ma chambre Ma chambre Sur le lit Sur le lit UC UC Dell Dell LATITTUDE E6410 LATITTUDE E6410 chai pas chai pas BARRAUX BARRAUX 0 0
5 7 7 2021-10-28 2021-10-28 pas d'inspi pas d'inspi Locquirec Locquirec chambre 6 chambre 6 pas bougé pas bougé UC UC Dell Dell flemme flemme je sais pas je sais pas Le Cocotier des mers Le Cocotier des mers 0 0

42
referant/include/line.php

@ -1,5 +1,6 @@
<?php
echo '<tr>
if (isset($line)) {
echo '<tr>
<td class=', $class , ' style="font-weight: bold;" >',$class,'</td>
<td class=', $class , '>',$line[1],'</td>
<td class=', $class , '>',$line[2],'</td>
@ -10,8 +11,40 @@ echo '<tr>
<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 , '>',$line[10],'</td>';
if ($line[11] == 1) {
echo '<td class=', $class , '><img src="../img/check.png" width="50%"></td>';
}
else {
echo '<td class=', $class , '><img src="../img/excla.png" width="50%"></td>';
}
echo ' <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>';
}
else {
echo '<tr>
<td class=', $class , ' style="font-weight: bold;" ></td>
<td class=', $class , '></td>
<td class=', $class , '></td>
<td class=', $class , '></td>
<td class=', $class , '></td>
<td class=', $class , '></td>
<td class=', $class , '></td>
<td class=', $class , '></td>
<td class=', $class , '></td>
<td class=', $class , '></td>
<td class=', $class , '></td>
<td class=', $class , '><img src="../img/check.png" width="50%"></td>
<td class=', $class , '>
<label class="switch">
<input class="checkbox" type="checkbox" onchange="Slider(\'',$class,'\')">
@ -19,5 +52,6 @@ echo '<tr>
</label>
</td>
<td class=',$class,'><input class="edit" type="button" value="edit" onclick="Edit(\'',$class,'\')"></td>
</tr>';
</tr>';
}
?>

0
referant/include/menu.php → referant/include/menu.html

4
referant/index.php

@ -5,13 +5,13 @@ include '../session_restraintes.php';
<!DOCTYPE html>
<html lang="fr">
<head>
<?php include 'include/menu.php'; ?>
<?php include 'include/menu.html'; ?>
</head>
<body>
<a class="champ" href="../prof/index.php">client</a>
<?php include 'include/nav.php'; ?>
<script type="text/javascript" src="js/index.js" defer></script>
<script type="text/javascript" src="js/edit.js" defer></script>
<table id="table">
<thead>
<tr>

28
referant/js/index.js → referant/js/edit.js

@ -1,8 +1,3 @@
let checkbox = document.getElementsByClassName('checkbox');
for (elem in checkbox) {
elem.checked = false;
}
function Slider(id) {
let td = document.getElementsByClassName(id);
let is_checked;
@ -15,19 +10,24 @@ function Slider(id) {
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
td[11].textContent = this.response;
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/index.php', true);
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(id));
xhr.send("is_checked=" + encodeURI(is_checked) + "&id=" + encodeURI(td[1].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< 12; i++) {
for (let i=1; i< 11; i++) {
obj[i].innerHTML = '<input type="text" style="width: 80%;" value="' + obj[i].textContent + '">';
}
obj[13].querySelector('input').value = 'ok';
@ -40,7 +40,7 @@ function Edit(clas) {
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(this.response);
for (let i=1; i<12; i++) {
for (let i=1; i<11; i++) {
obj[i].innerHTML = this.response[i];
}
obj[13].querySelector('input').value = 'edit';
@ -64,5 +64,11 @@ function Value(list) {
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;
if (list[11].querySelector('img').src == '../img/check.png') {
this.traitement = 1;
}
else {
this.traitement = 0;
}
}

80
referant/js/search.js

@ -1,6 +1,4 @@
const table_ticket = document.getElementsByClassName('ticket');
const table_title = document.getElementsByClassName('table-title');
var id_displayed;
const ticket = document.getElementsByClassName('ticket');
document.getElementById('form').addEventListener('submit', function(e) {
e.preventDefault();
@ -11,9 +9,15 @@ document.getElementById('form').addEventListener('submit', function(e) {
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];
console.log(this.response);
for (let i=0; i < 11; i++) {
ticket[i].textContent = this.response[i];
}
if (this.response[11] == 1) {
ticket[11].querySelector('img').src = "../img/check.png";
}
else {
ticket[11].querySelector('img').src = "../img/excla.png";
}
document.getElementById('table-search').style.display = 'block';
}
@ -29,67 +33,3 @@ document.getElementById('form').addEventListener('submit', function(e) {
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;
}

4
referant/liste.php

@ -5,8 +5,8 @@ include '../session_restraintes.php';
<!DOCTYPE html>
<html>
<head>
<?php include 'include/menu.php';?>
<script type="text/javascript" src="js/index.js" defer></script>
<?php include 'include/menu.html';?>
<script type="text/javascript" src="js/edit.js" defer></script>
</head>
<body id="corps">
<?php include 'include/nav.php';?>

3
referant/search.php

@ -5,8 +5,9 @@ include '../session_restraintes.php';
<!DOCTYPE html>
<html lang="fr">
<head>
<?php include 'include/menu.php'; ?>
<?php include 'include/menu.html'; ?>
<script type="text/javascript" src="js/search.js" defer></script>
<script type="text/javascript" src="js/edit.js" defer></script>
</head>
<body id='corps'>

1
stylepage.css

@ -218,6 +218,7 @@ table{
width: 80%;
border-radius: 5px;
margin-left: 10%;
margin-top: 2%;
background-color: #84878C;
color: #fff;
border: 1px solid #84878C;

Loading…
Cancel
Save