From 0c075f3baf031992f962562c2cf2495207ad0b58 Mon Sep 17 00:00:00 2001 From: thchazot1 Date: Fri, 23 Dec 2022 14:21:49 +0100 Subject: [PATCH] SEULEMENT 2H POUR CA --- Vues/seeList.php | 6 ++---- controllers/FrontController.php | 2 +- gateway/ListeGateway.php | 18 ++++++++++-------- gateway/TacheGateway.php | 1 - modeles/MdlListe.php | 2 +- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Vues/seeList.php b/Vues/seeList.php index dfe6a61..f135c29 100644 --- a/Vues/seeList.php +++ b/Vues/seeList.php @@ -64,7 +64,6 @@ else{ if (isset($dataView)): ?> -
    @@ -99,8 +98,8 @@ else{ } ?> - - + + @@ -181,6 +180,5 @@ else{ -
diff --git a/controllers/FrontController.php b/controllers/FrontController.php index 5bdadbb..db7101a 100644 --- a/controllers/FrontController.php +++ b/controllers/FrontController.php @@ -11,7 +11,7 @@ class FrontController { session_start(); try{ $user=$_SESSION??null; - $action = $_REQUEST['action']; + $action = $_REQUEST['action']??null; if (in_array($action,$liste_actions_utilisateur)){ if($user == null){ diff --git a/gateway/ListeGateway.php b/gateway/ListeGateway.php index 7f36217..3e21044 100644 --- a/gateway/ListeGateway.php +++ b/gateway/ListeGateway.php @@ -26,10 +26,13 @@ class ListeGateway } public function delete(int $id): void{ - $results=findById($id); + $results=$this->findById($id); $tacheGateway=new TacheGateway($this->con); - foreach($results[0]->getTaches() as $taches){ - $tacheGateway->delete($taches); + foreach ($results as $row ) { + $taches=$tacheGateway->getTacheFromIdList($row['id']); + foreach($taches as $tata){ + $tacheGateway->delete($tata); + } } $query = "DELETE FROM Liste where id=:id"; $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT))); @@ -60,15 +63,14 @@ class ListeGateway return $results; } - public function findById(string $id): array{ + public function findById(int $id): Array{ $results=[]; + $taches = array(); if (!empty($id)){ $query = "SELECT * FROM Liste WHERE id=:id"; $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_STR))); - - $results=$this->con->getResults(); - return $results; - } + $results = $this->con->getResults(); + } return $results; } diff --git a/gateway/TacheGateway.php b/gateway/TacheGateway.php index 7b290b3..6af5bf1 100644 --- a/gateway/TacheGateway.php +++ b/gateway/TacheGateway.php @@ -30,7 +30,6 @@ class TacheGateway $query = "SELECT * FROM Tache t where idListe=:id"; $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT))); $results=$this->con->getResults(); - return $results; foreach ($results as $row) { $tabTaches[]=new Tache($row['id'], $row['name'], $row['content'], $row['completed']); } diff --git a/modeles/MdlListe.php b/modeles/MdlListe.php index 37d9c70..716c64b 100644 --- a/modeles/MdlListe.php +++ b/modeles/MdlListe.php @@ -64,7 +64,7 @@ class MdlListe{ $tabTache=[]; $taches=$gateTache->getTacheFromIdList($row['id']); foreach($taches as $tata){ - $tabTache[]=new Tache($tata['id'], $tata['name'], $tata['content'], $tata['completed']); + $tabTache[]=$tata; } $tabListe[]=new Liste($row['id'], $row['name'], $row['private'], null, $tabTache); }