From b9437ea5a2a8029d16a2ec9ad00883d841474162 Mon Sep 17 00:00:00 2001 From: "barraux.a" Date: Tue, 2 Nov 2021 22:06:58 +0100 Subject: [PATCH] V1.5 (export CSV) --- login/index.php | 2 +- referant/admin.php | 2 +- referant/cible/export.php | 16 +++++ referant/cible/{index.php => slider.php} | 0 referant/cible/ticket.sql | 0 referant/export.php | 49 ++++++++++----- referant/export/ticket.csv | 5 -- referant/include/line.php | 78 ++++++++++++++++------- referant/include/{menu.php => menu.html} | 0 referant/index.php | 6 +- referant/js/{index.js => edit.js} | 30 +++++---- referant/js/search.js | 80 +++--------------------- referant/liste.php | 10 +-- referant/search.php | 7 ++- stylepage.css | 11 ++-- 15 files changed, 155 insertions(+), 141 deletions(-) create mode 100644 referant/cible/export.php rename referant/cible/{index.php => slider.php} (100%) create mode 100644 referant/cible/ticket.sql delete mode 100755 referant/export/ticket.csv rename referant/include/{menu.php => menu.html} (100%) rename referant/js/{index.js => edit.js} (79%) mode change 100755 => 100644 diff --git a/login/index.php b/login/index.php index 0986465..abdf4a1 100755 --- a/login/index.php +++ b/login/index.php @@ -22,7 +22,7 @@
-
+
diff --git a/referant/admin.php b/referant/admin.php index 2ebd032..82253ba 100755 --- a/referant/admin.php +++ b/referant/admin.php @@ -11,7 +11,7 @@ - + diff --git a/referant/cible/export.php b/referant/cible/export.php new file mode 100644 index 0000000..9a7aa6c --- /dev/null +++ b/referant/cible/export.php @@ -0,0 +1,16 @@ + diff --git a/referant/cible/index.php b/referant/cible/slider.php similarity index 100% rename from referant/cible/index.php rename to referant/cible/slider.php diff --git a/referant/cible/ticket.sql b/referant/cible/ticket.sql new file mode 100644 index 0000000..e69de29 diff --git a/referant/export.php b/referant/export.php index dd25e12..71dc337 100755 --- a/referant/export.php +++ b/referant/export.php @@ -1,18 +1,39 @@ -$bdd = new PDO('mysql:host=localhost;dbname=ticket;charset:utf8', 'root', ''); -$reponse = $bdd->query("SELECT DISTINCT * FROM `pannes`"); -$stream = fopen('export/ticket.csv', 'w'); + + + + + -while($line = $reponse->fetch()) { - print_r($line); - echo '
'; - fputcsv( - $stream, // file - $line, // arr - ); -} -$reponse->closeCursor(); -fclose($stream); -?> \ No newline at end of file + + +
+
+

Type:

+
+ +
+
+
+

Base:

+
+ +
+
+
+
+ +
+
+
+ + diff --git a/referant/export/ticket.csv b/referant/export/ticket.csv deleted file mode 100755 index 1f8dcc0..0000000 --- a/referant/export/ticket.csv +++ /dev/null @@ -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 diff --git a/referant/include/line.php b/referant/include/line.php index 5fd759d..1ab5cb4 100755 --- a/referant/include/line.php +++ b/referant/include/line.php @@ -1,23 +1,57 @@ - ',$class,' - ',$line[1],' - ',$line[2],' - ',$line[3],' - ',$line[4],' - ',$line[5],' - ',$line[6],' - ',$line[7],' - ',$line[8],' - ',$line[9],' - ',$line[10],' - ',$line[11],' - - - - -'; -?> \ No newline at end of file +if (isset($line)) { + echo ' + ',$class,' + ',$line[1],' + ',$line[2],' + ',$line[3],' + ',$line[4],' + ',$line[5],' + ',$line[6],' + ',$line[7],' + ',$line[8],' + ',$line[9],' + ',$line[10],''; + + if ($line[11] == 1) { + echo ''; + } + else { + echo ''; + } + + + + echo ' + + + + '; +} +else { + echo ' + + + + + + + + + + + + + + + + + '; +} +?> diff --git a/referant/include/menu.php b/referant/include/menu.html similarity index 100% rename from referant/include/menu.php rename to referant/include/menu.html diff --git a/referant/index.php b/referant/index.php index 0bac5c7..e7d90f5 100755 --- a/referant/index.php +++ b/referant/index.php @@ -5,13 +5,13 @@ include '../session_restraintes.php'; - + - + client - + diff --git a/referant/js/index.js b/referant/js/edit.js old mode 100755 new mode 100644 similarity index 79% rename from referant/js/index.js rename to referant/js/edit.js index 22da26f..a6deffc --- a/referant/js/index.js +++ b/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 = ''; } 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; -} \ No newline at end of file + if (list[11].querySelector('img').src == '../img/check.png') { + this.traitement = 1; + } + else { + this.traitement = 0; + } + +} diff --git a/referant/js/search.js b/referant/js/search.js index 96c2071..6e71bdd 100755 --- a/referant/js/search.js +++ b/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 = ''; - } - 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; -} \ No newline at end of file diff --git a/referant/liste.php b/referant/liste.php index b9b4919..cedd46c 100755 --- a/referant/liste.php +++ b/referant/liste.php @@ -5,8 +5,8 @@ include '../session_restraintes.php'; - - + + @@ -32,11 +32,11 @@ include '../session_restraintes.php'; - query("SELECT * FROM pannes ORDER BY ID"); - + while ($line = $reponse->fetch()) { $class = $line[0]; include 'include/line.php'; @@ -46,4 +46,4 @@ include '../session_restraintes.php';
traitement valider
- \ No newline at end of file + diff --git a/referant/search.php b/referant/search.php index ea95e73..45ae788 100755 --- a/referant/search.php +++ b/referant/search.php @@ -5,10 +5,11 @@ include '../session_restraintes.php'; - + + - +
@@ -41,7 +42,7 @@ include '../session_restraintes.php'; traitement valider - diff --git a/stylepage.css b/stylepage.css index 7226b1d..1ad9bba 100755 --- a/stylepage.css +++ b/stylepage.css @@ -60,7 +60,7 @@ form{ border-radius: 30px; width: 200px; - + transition: 0.25s; } @@ -98,14 +98,14 @@ form{ text-align: center; color: #454444; - + margin: 10px auto; border: 4px solid #4e4d4d; padding: 10px 10px; border-radius: 30px; width: 200px; - + transition: 0.25s; } @@ -130,7 +130,7 @@ form{ padding: 15px; margin: 0; background-color: #dddddd; - + } .help * { @@ -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; @@ -294,4 +295,4 @@ input:checked + .slider:before { -webkit-transform: translateX(26px); -ms-transform: translateX(26px); transform: translateX(26px); -} \ No newline at end of file +}