diff --git a/database/ticket_panne.db b/database/ticket_panne.db new file mode 100755 index 0000000..f93fba3 Binary files /dev/null and b/database/ticket_panne.db differ diff --git a/login/cible.php b/login/cible.php index b13f4c5..038b5df 100755 --- a/login/cible.php +++ b/login/cible.php @@ -1,10 +1,10 @@ query("SELECT * FROM logins"); - while ($line = $reponse->fetch()) { + while ($line = $reponse->fetchArray()) { if ($line[0] == $_POST['login'] && $line[1] == $_POST['pwd']) { session_start(); $_SESSION['login'] = $_POST['login']; @@ -12,9 +12,8 @@ if (isset($_POST['login']) && isset($_POST['pwd'])) { header('location: ../prof/index.php'); } } - $reponse->closeCursor(); } echo ''; -?> \ No newline at end of file +?> diff --git a/prof/cible/index.php b/prof/cible/index.php index 86d2c29..5479093 100755 --- a/prof/cible/index.php +++ b/prof/cible/index.php @@ -1,22 +1,22 @@ prepare('INSERT INTO pannes(dates, details, lieu, salle, pos, materiel, marque, model, nserie, demandeur, traitement) VALUES(:dates, :details, :lieu, :salle, :pos, :materiel, :marque, :model, :nserie, :demandeur, :traitement)'); +$stmt = $bdd->prepare('INSERT INTO pannes(dates, details, lieu, salle, pos, materiel, marque, model, nserie, demandeur, traitement) VALUES(:dates, :details, :lieu, :salle, :pos, :materiel, :marque, :model, :nserie, :demandeur, :traitement)'); -$req->execute(array( - 'dates' => $_POST['dates'], - 'details' => $_POST['details'], - 'lieu' => $_POST['lieu'], - 'salle' => $_POST['salle'], - 'pos' => $_POST['pos'], - 'materiel' => $_POST['materiel'], - 'marque' => $_POST['marque'], - 'model' => $_POST['model'], - 'nserie' => $_POST['nserie'], - 'demandeur' => $_POST['demandeur'], - 'traitement' => 0 - )); +$stmt->bindValue(':dates', $_POST['dates']); +$stmt->bindValue(':details', $_POST['details']); +$stmt->bindValue(':lieu', $_POST['lieu']); +$stmt->bindValue(':salle', $_POST['salle']); +$stmt->bindValue(':pos', $_POST['pos']); +$stmt->bindValue(':materiel', $_POST['materiel']); +$stmt->bindValue(':marque', $_POST['marque']); +$stmt->bindValue(':model', $_POST['model']); +$stmt->bindValue(':nserie', $_POST['nserie']); +$stmt->bindValue(':demandeur', $_POST['demandeur']); +$stmt->bindValue(':traitement', 0); + +$stmt->execute(); echo 'Votre ticket à bien été pris en compte'; ?> diff --git a/referant/admin.php b/referant/admin.php index 1770ca7..3a420a8 100755 --- a/referant/admin.php +++ b/referant/admin.php @@ -1,12 +1,11 @@ query("SELECT * FROM logins"); $arr = []; - while ($line = $reponse->fetch()) { + while ($line = $reponse->fetchArray()) { $arr[$line[0]] = $line[1]; } - $reponse->closeCursor(); ?> diff --git a/referant/cible/admin.php b/referant/cible/admin.php index e067375..463ca49 100755 --- a/referant/cible/admin.php +++ b/referant/cible/admin.php @@ -1,8 +1,15 @@ -query('UPDATE `logins` SET `pwd` = "' .$decode['pwd'] .'" WHERE `login` = "' .$decode['login'] .'"'); +$bdd = new SQLite3('../../database/ticket_panne.db', SQLITE3_OPEN_READWRITE); -$traitement = $bdd->query("SELECT * FROM `logins` WHERE `login`= '" .$decode['login'] ."'"); -print_r(json_encode($traitement->fetch())); -?> \ No newline at end of file +$stmt = $bdd->prepare('UPDATE `logins` SET `pwd` = :pwd WHERE `login` = :login'); +$stmt->bindValue(':pwd', $decode['pwd']); +$stmt->bindValue(':login', $decode['login']); + +$stmt->execute(); + +$select = $bdd->prepare("SELECT * FROM `logins` WHERE `login` = :login"); +$select->bindValue(':login', $decode['login']); +$traitement = $select->execute(); +print_r(json_encode($traitement->fetchArray())); +?> diff --git a/referant/cible/edit.php b/referant/cible/edit.php index c0d3529..9e5407b 100755 --- a/referant/cible/edit.php +++ b/referant/cible/edit.php @@ -1,7 +1,7 @@ -query($request); $traitement = $bdd->query("SELECT * FROM pannes WHERE ID=" .$decode['id']); -print_r(json_encode($traitement->fetch())); -?> \ No newline at end of file +print_r(json_encode($traitement->fetchArray())); +?> diff --git a/referant/cible/export.php b/referant/cible/export.php index 9a7aa6c..38a9497 100644 --- a/referant/cible/export.php +++ b/referant/cible/export.php @@ -1,15 +1,30 @@ query("SELECT * FROM `" .$_POST['bdd'] ."`"); +$title = array_keys($response->fetchArray(SQLITE3_ASSOC)); 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)) { + +while($row = $response->fetchArray(SQLITE3_ASSOC)) { fputcsv($output, $row); } fclose($output); diff --git a/referant/cible/search.php b/referant/cible/search.php index d361c52..6c8f308 100755 --- a/referant/cible/search.php +++ b/referant/cible/search.php @@ -1,12 +1,12 @@ query("SELECT * FROM pannes WHERE `" .$_POST['champ'] ."`='" .$_POST['value'] ."'"); $reponse = $bdd->prepare("SELECT * FROM pannes WHERE `" .$_POST['champ'] ."`='" .$_POST['value'] ."'"); $reponse->execute(); $result = []; - while ($line = $reponse->fetch()) { + while ($line = $reponse->fetchArray()) { array_push($result, $line); }; diff --git a/referant/cible/slider.php b/referant/cible/slider.php index c4be944..396fa2f 100755 --- a/referant/cible/slider.php +++ b/referant/cible/slider.php @@ -1,9 +1,9 @@ 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']; +$res = $traitement->fetchArray()['traitement']; echo $res; -?> \ No newline at end of file +?> diff --git a/referant/index.php b/referant/index.php index db16e75..17d2ba6 100755 --- a/referant/index.php +++ b/referant/index.php @@ -36,12 +36,12 @@ include '../sessions/session_restraintes.php'; query("SELECT * FROM pannes ORDER BY ID DESC"); for ($j=0; $j < 3; $j++) { - $line = $reponse->fetch(); + $line = $reponse->fetchArray(); if ($line['traitement'] == 0) { $class = $line[0]; include 'include/line.php'; @@ -50,7 +50,6 @@ include '../sessions/session_restraintes.php'; $j--; } } - $reponse->closeCursor(); ?> diff --git a/referant/js/edit.js b/referant/js/edit.js index a15cc9b..88558d3 100644 --- a/referant/js/edit.js +++ b/referant/js/edit.js @@ -38,6 +38,7 @@ function Edit(clas) { data.append('value', JSON.stringify(value)); xhr.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { + console.log(this.response); for (let i=1; i<11; i++) { obj[i].innerHTML = this.response[i]; } diff --git a/referant/liste.php b/referant/liste.php index 918b971..cc71c64 100755 --- a/referant/liste.php +++ b/referant/liste.php @@ -33,15 +33,14 @@ include '../sessions/session_restraintes.php';