diff --git a/Project/php/controller/FrontController.php b/Project/php/controller/FrontController.php index 7dba54d..4f6e544 100755 --- a/Project/php/controller/FrontController.php +++ b/Project/php/controller/FrontController.php @@ -14,8 +14,8 @@ class FrontController session_start(); - var_dump($_SESSION['login']); - var_dump($_SESSION['roles']); + //var_dump($_SESSION['login']); + //var_dump($_SESSION['roles']); try { $router = new \AltoRouter(); diff --git a/Project/php/controller/TeacherController.php b/Project/php/controller/TeacherController.php index 28958ad..da42c5e 100755 --- a/Project/php/controller/TeacherController.php +++ b/Project/php/controller/TeacherController.php @@ -35,11 +35,12 @@ class TeacherController } - public function DelById($id):void{ + public function DelById():void{ global $twig; $mdl = new MdlTeacher(); + $id = Validation::filter_int($_GET['vocabID'] ?? null); $vocab = $mdl->removeVocById($id); - echo $twig->render('usersView.html', ['users' => $vocab]); + echo $twig->render('manageVocabListView.html', [ 'vocabularies' => $vocab]); } public function showVocabListForm(): void { diff --git a/Project/php/gateway/VocabularyListGateway.php b/Project/php/gateway/VocabularyListGateway.php index 4cc07b2..e4cdcef 100755 --- a/Project/php/gateway/VocabularyListGateway.php +++ b/Project/php/gateway/VocabularyListGateway.php @@ -30,16 +30,21 @@ class VocabularyListGateway extends AbsGateway public function remove(int $id): void { try{ + + $query = "DELETE FROM Translate WHERE listVoc=:id"; + $args = array(':id'=>array($id,PDO::PARAM_INT)); + $this->con->ExecuteQuery($query,$args); + $query = "DELETE FROM Practice WHERE vocabID=:id"; $args = array(':id'=>array($id,PDO::PARAM_INT)); $this->con->ExecuteQuery($query,$args); - $query = "DELETE FROM VocabularyList v WHERE v.id=:id "; + $query = "DELETE FROM VocabularyList WHERE id=:id "; $args = array(':id'=>array($id,PDO::PARAM_INT)); $this->con->ExecuteQuery($query,$args); } catch (PDOException $e){ - throw new Exception('problème pour supprimer les vocabulaires avec leur Id'); + throw new Exception('problème pour supprimer les vocabulaires avec leur Id'. $e->getMessage()); } } diff --git a/Project/php/templates/manageVocabListView.html b/Project/php/templates/manageVocabListView.html index f2ca5fb..f5d5689 100755 --- a/Project/php/templates/manageVocabListView.html +++ b/Project/php/templates/manageVocabListView.html @@ -23,7 +23,7 @@

Unassigned vocab

- {% include 'vocabularyContainer.twig' with {'vocabularies' : vocabularies , 'actions' : 'getVocabByName'} %} + {% include 'vocabularyContainer.twig' with {'vocabularies' : vocabularies , 'actions' : 'delById'} %}
diff --git a/Project/php/templates/vocabularyContainer.twig b/Project/php/templates/vocabularyContainer.twig index b95ade3..85ae52d 100755 --- a/Project/php/templates/vocabularyContainer.twig +++ b/Project/php/templates/vocabularyContainer.twig @@ -18,11 +18,14 @@ {% if actions == 'affAllVocab' %} - + {% elseif actions == 'getByName' %} - + + {% elseif actions == 'delById' %} + + {% endif %}