diff --git a/site/accesBase.php b/site/accesBase.php index 7e9577d..6d2f35a 100644 --- a/site/accesBase.php +++ b/site/accesBase.php @@ -252,6 +252,27 @@ } } + function removeRpi($ip) + { + $db = connexion(); + $query = "SELECT nom FROM capteurs WHERE raspberry = '$ip'"; + $result = pg_query($db, $query) or die("La requ te a echou : ".pg_last_error()); + $capteurs = pg_fetch_all($result); + foreach($capteurs as $capteur) + { + remove($capteur['nom']); + } + $query = "REMOVE FROM raspberry WHERE ip = '$ip'"; + $result = pg_query($db, $query) or die("La requ te a echou : ".pg_last_error()); + deconnexion($db); + if (pg_affected_rows($result)!=0){ + return True; + } + else{ + return False; + } + } + function add($nom, $type, $raspberry, $unite, $version) { $db = connexion(); @@ -263,12 +284,14 @@ $query = "SELECT * FROM capteurs WHERE nom = '$nom' OR (raspberry = '$raspberry' AND numero = '$numero')"; $result = pg_query($db, $query) or die("La requête a echoué : ".pg_last_error()); if (pg_affected_rows($result)!=0){ + deconnexion($db); return False; } else { $query = "INSERT INTO capteurs VALUES($numero, '$nom', '$raspberry', '$type', 0, '$unite', $version)"; $result = pg_query($db, $query) or die("La requête a echoué : ".pg_last_error()); + deconnexion($db); if (pg_affected_rows($result)!=0){ return True; } @@ -278,6 +301,22 @@ } } + function remove($nom) + { + $db = connexion(); + $query = "REMOVE FROM history WHERE sensor = '$nom'"; + $result = pg_query($db, $query) or die("La requ te a echou : ".pg_last_error()); + $query = "REMOVE FROM capteurs WHERE nom = '$nom'"; + $result = pg_query($db, $query) or die("La requ te a echou : ".pg_last_error()); + deconnexion($db); + if (pg_affected_rows($result)!=0){ + return True; + } + else{ + return False; + } + } + function makeArray($tab, $column) { foreach($tab as $element) diff --git a/site/add.php b/site/add.php index ad513bc..ce1c00a 100644 --- a/site/add.php +++ b/site/add.php @@ -18,7 +18,7 @@ session_start();

-

Historique

+

Ajout d'un capteur

Echec lors de l'ajout. Vérifiez vos informations !
- + diff --git a/site/addRpi.php b/site/addRpi.php index bc6fec6..4c6bb3d 100644 --- a/site/addRpi.php +++ b/site/addRpi.php @@ -18,7 +18,7 @@ session_start();

-

Historique

+

Ajout d'une Raspberry

Echec lors de l'ajout. La Raspberry existe peut-être déjà !
- + diff --git a/site/ajoutCapteur.php b/site/ajoutCapteur.php deleted file mode 100644 index a73e5ee..0000000 --- a/site/ajoutCapteur.php +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - diff --git a/site/ajoutRaspberry.php b/site/ajoutRaspberry.php index d69f026..75511e4 100644 --- a/site/ajoutRaspberry.php +++ b/site/ajoutRaspberry.php @@ -15,6 +15,7 @@ session_start(); if(isset($_SESSION['Login'], $_SESSION['Password'])) { include("addRaspberry.php"); + include("removeRaspberry.php); } else { diff --git a/site/gestionCapteur.php b/site/gestionCapteur.php new file mode 100644 index 0000000..dc9c804 --- /dev/null +++ b/site/gestionCapteur.php @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + diff --git a/site/header.php b/site/header.php index 2ed9ade..664b953 100644 --- a/site/header.php +++ b/site/header.php @@ -10,8 +10,8 @@ require_once("accesBase.php") ; $membre = getMembreByIdPwd($_SESSION['Login'], $_SESSION['Password']); ?> - Raspberry - Capteur + Raspberry + Capteur Upload Historique Graphiques diff --git a/site/remove.php b/site/remove.php new file mode 100644 index 0000000..7184507 --- /dev/null +++ b/site/remove.php @@ -0,0 +1,53 @@ + + + + + + + + + + + +
+
+
+

Suppression d'un capteur

+ + + + + + + +
+
+ + + + diff --git a/site/removeRaspberry.php b/site/removeRaspberry.php new file mode 100644 index 0000000..3b85f61 --- /dev/null +++ b/site/removeRaspberry.php @@ -0,0 +1,18 @@ +
+
+
+

Suppression d'une Raspberry

+
+ + + + + + + +
+ +
+
+
+
diff --git a/site/removeRpi.php b/site/removeRpi.php new file mode 100644 index 0000000..7a72484 --- /dev/null +++ b/site/removeRpi.php @@ -0,0 +1,52 @@ + + + + + + + + + + + +
+
+
+

Suppression d'une Raspberry

+ + + + + + +
+
+ + + + diff --git a/site/removeSensor.php b/site/removeSensor.php new file mode 100644 index 0000000..a2c84c2 --- /dev/null +++ b/site/removeSensor.php @@ -0,0 +1,18 @@ +
+
+
+

Suppression d'un capteur

+
+ + + + + + + +
+ +
+
+
+
-- libgit2 0.21.2