Browse Source

save

master
BARRAUX Arthur 3 years ago
parent
commit
8b8912b50d
  1. BIN
      database/ticket_panne.db
  2. 36
      referant/cible/edit.php
  3. 7
      referant/cible/export.php

BIN
database/ticket_panne.db

Binary file not shown.

36
referant/cible/edit.php

@ -1,21 +1,25 @@
<?php <?php
$decode = json_decode($_POST['value'], TRUE); $decode = json_decode($_POST['value'], TRUE);
$bdd = new SQLite3('../../database/ticket_panne.db', SQLITE3_OPEN_READWRITE); $bdd = new SQLite3('../../database/ticket_panne.db', SQLITE3_OPEN_READWRITE);
$request = 'UPDATE pannes SET $stmt = $bdd->prepare('UPDATE pannes SET dates=:dates, details=:details, lieu=:lieu, salle=:salle, pos=:pos, materiel=:materiel, marque=:marque, model=:model, nserie=:nserie, demandeur=:demandeur, traitement=:traitement WHERE ID=:id');
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']); $stmt->bindValue(':id', $decode['id']);
print_r(json_encode($traitement->fetchArray())); $stmt->bindValue(':dates', $decode['dates']);
$stmt->bindValue(':details', $decode['details']);
$stmt->bindValue(':lieu', $decode['lieu']);
$stmt->bindValue(':salle', $decode['salle']);
$stmt->bindValue(':pos', $decode['pos']);
$stmt->bindValue(':materiel', $decode['materiel']);
$stmt->bindValue(':marque', $decode['marque']);
$stmt->bindValue(':model', $decode['model']);
$stmt->bindValue(':nserie', $decode['nserie']);
$stmt->bindValue(':demandeur', $decode['demandeur']);
$stmt->bindValue(':traitement', $decode['traitement']);
$stmt->execute();
$traitement = $bdd->prepare("SELECT * FROM pannes WHERE ID=:id");
$traitement->bindValue(':id', $decode['id']);
$res = $traitement->execute();
print_r(json_encode($res->fetchArray()));
?> ?>

7
referant/cible/export.php

@ -16,15 +16,16 @@
// //
$bdd = new SQLite3('../../database/ticket_panne.db', SQLITE3_OPEN_READWRITE); $bdd = new SQLite3('../../database/ticket_panne.db', SQLITE3_OPEN_READWRITE);
$response = $bdd->query("SELECT * FROM `" .$_POST['bdd'] ."`"); $stmt = $bdd->prepare("SELECT * FROM :base");
$title = array_keys($response->fetchArray(SQLITE3_ASSOC)); $stmt->bindValue(':base', $_POST['bdd']);
$title = array_keys($stmt->fetchArray(SQLITE3_ASSOC));
header('Content-Type: text/csv; charset=utf-8'); header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=' .$_POST['bdd'] .'.csv'); header('Content-Disposition: attachment; filename=' .$_POST['bdd'] .'.csv');
$output = fopen("php://output", "w"); $output = fopen("php://output", "w");
fputcsv($output, $title); fputcsv($output, $title);
while($row = $response->fetchArray(SQLITE3_ASSOC)) { while($row = $stmt->fetchArray(SQLITE3_ASSOC)) {
fputcsv($output, $row); fputcsv($output, $row);
} }
fclose($output); fclose($output);

Loading…
Cancel
Save