Lilian BRETON 2 years ago
commit f7c84a7c63

@ -64,7 +64,6 @@ else{
if (isset($dataView)): if (isset($dataView)):
?> ?>
<form>
<div class="container"> <div class="container">
<ul class="responsive-table"> <ul class="responsive-table">
@ -99,8 +98,8 @@ else{
} }
?> ?>
<form method="POST" id="marche" name="marche" class="col col-2"> <form method="post" id="marche" name="marche" class="col col-2">
<input value="Delete" type="submit"/> <input value="DELETE" type="submit"/>
<input type="hidden" name="action" value="delList"/> <input type="hidden" name="action" value="delList"/>
<input type="hidden" name="list" value="<?=$list->getId()?>"/> <input type="hidden" name="list" value="<?=$list->getId()?>"/>
</form> </form>
@ -181,6 +180,5 @@ else{
<?php <?php
endif; endif;
?> ?>
</form>
</div> </div>
</div> </div>

@ -11,7 +11,7 @@ class FrontController {
session_start(); session_start();
try{ try{
$user=$_SESSION??null; $user=$_SESSION??null;
$action = $_REQUEST['action']; $action = $_REQUEST['action']??null;
if (in_array($action,$liste_actions_utilisateur)){ if (in_array($action,$liste_actions_utilisateur)){
if($user == null){ if($user == null){

@ -26,10 +26,13 @@ class ListeGateway
} }
public function delete(int $id): void{ public function delete(int $id): void{
$results=findById($id); $results=$this->findById($id);
$tacheGateway=new TacheGateway($this->con); $tacheGateway=new TacheGateway($this->con);
foreach($results[0]->getTaches() as $taches){ foreach ($results as $row ) {
$tacheGateway->delete($taches); $taches=$tacheGateway->getTacheFromIdList($row['id']);
foreach($taches as $tata){
$tacheGateway->delete($tata);
}
} }
$query = "DELETE FROM Liste where id=:id"; $query = "DELETE FROM Liste where id=:id";
$this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT))); $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT)));
@ -60,15 +63,14 @@ class ListeGateway
return $results; return $results;
} }
public function findById(string $id): array{ public function findById(int $id): Array{
$results=[]; $results=[];
$taches = array();
if (!empty($id)){ if (!empty($id)){
$query = "SELECT * FROM Liste WHERE id=:id"; $query = "SELECT * FROM Liste WHERE id=:id";
$this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_STR))); $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_STR)));
$results = $this->con->getResults();
$results=$this->con->getResults(); }
return $results;
}
return $results; return $results;
} }

@ -30,7 +30,6 @@ class TacheGateway
$query = "SELECT * FROM Tache t where idListe=:id"; $query = "SELECT * FROM Tache t where idListe=:id";
$this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT))); $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT)));
$results=$this->con->getResults(); $results=$this->con->getResults();
return $results;
foreach ($results as $row) { foreach ($results as $row) {
$tabTaches[]=new Tache($row['id'], $row['name'], $row['content'], $row['completed']); $tabTaches[]=new Tache($row['id'], $row['name'], $row['content'], $row['completed']);
} }

@ -64,7 +64,7 @@ class MdlListe{
$tabTache=[]; $tabTache=[];
$taches=$gateTache->getTacheFromIdList($row['id']); $taches=$gateTache->getTacheFromIdList($row['id']);
foreach($taches as $tata){ 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); $tabListe[]=new Liste($row['id'], $row['name'], $row['private'], null, $tabTache);
} }

Loading…
Cancel
Save