diff --git a/config/config.php b/config/config.php
index b2c1b84..93f2fab 100644
--- a/config/config.php
+++ b/config/config.php
@@ -14,6 +14,8 @@ $vues['inscription']='vues/inscription.php';
$vues['profile']='vues/profile.php';
$vues['listesPrivees']='vues/listesPrivees.php';
$vues['creationListe']='vues/creationListe.php';
+$vues['infosListe']='vues/infosListe.php';
+$vues['creationTache']='vues/creationTache.php';
// Styles
$styles['commun']='vues/styles/commonStyles.css';
$styles['connection']='vues/styles/connectionStyle.css';
diff --git a/controleurs/ControleurUtilisateur.php b/controleurs/ControleurUtilisateur.php
index 1483345..fa4e665 100644
--- a/controleurs/ControleurUtilisateur.php
+++ b/controleurs/ControleurUtilisateur.php
@@ -3,7 +3,7 @@
class ControleurUtilisateur{
function __construct() {
- global $rep,$vues, $dataView;
+ global $rep,$vues, $dataView,$styles,$assets;
$arrayErrorViews= array();
$action = $_REQUEST['action']??null;
diff --git a/controleurs/ControleurVisiteur.php b/controleurs/ControleurVisiteur.php
index c07f498..a31b439 100644
--- a/controleurs/ControleurVisiteur.php
+++ b/controleurs/ControleurVisiteur.php
@@ -3,7 +3,7 @@
class ControleurVisiteur {
public function __construct() {
- global $rep,$vues,$styles,$assets;
+ global $rep,$vues,$dataView,$styles,$assets;
$arrayErrorViews= array();
try{
$action = $_REQUEST['action']??null;
@@ -11,6 +11,9 @@ class ControleurVisiteur {
case NULL:
$this->reinit();
break;
+ case "goHome":
+ $this->reinit();
+ break;
case 'accessConnectionPage':
require($rep.$vues['connection']);
break;
@@ -20,6 +23,22 @@ class ControleurVisiteur {
case "accessCreationListePage":
require($rep.$vues['creationListe']);
break;
+ case "accessCreationTachePage":
+ $dataView=$_POST['liste'];
+ require($rep.$vues['creationTache']);
+ break;
+ case "addTache":
+ $this->addTache($arrayErrorViews);
+ break;
+ case "accessListInfos":
+ $this->accessListInfos($arrayErrorViews);
+ break;
+ case "delTache":
+ $this->delTache($arrayErrorViews);
+ break;
+ case "changeCompletedTache":
+ $this->changeCompletedTache($arrayErrorViews);
+ break;
case "connection":
$this->connection($arrayErrorViews);
break;
@@ -28,17 +47,9 @@ class ControleurVisiteur {
case "creerListe":
$this->creerListe($arrayErrorViews);
break;
- case "supprListe":
- $this->supprListe($arrayErrorViews);
+ case "delListe":
+ $this->delListe($arrayErrorViews);
break;
- case "creerTache":
- $this->creerTache($arrayErrorViews);
- break;
- case "cocherTache":
- $this->cocherTache($arrayErrorViews);
- break;
- case "supprTache":
- $this->supprTache($arrayErrorViews);
default :
$arrayErrorViews[]="Erreur innatendue !!!";
require($rep.$vues['acceuil']);
@@ -58,6 +69,42 @@ class ControleurVisiteur {
}
+ public function accessListInfos($arrayErrorViews){
+ global $rep,$vues,$dataView;
+ $idListe=$_POST['liste'];
+ $model = new ListeModel();
+ $dataView = $model->pullListById($idListe);
+ require($rep.$vues['infosListe']);
+ }
+
+ public function addTache($arrayErrorViews){
+ global $rep,$vues,$dataView;
+ $nom=$_POST['name'];
+ $idListe=$_POST['liste'];
+ $model = new ListeModel();
+ $model->addTache($nom,$idListe);
+ $_REQUEST['action']="accessListInfos";
+ $this->accessListInfos($arrayErrorViews);
+ }
+
+ public function delTache($arrayErrorViews){
+ global $rep,$vues,$dataView;
+ $idTache=$_POST['tache'];
+ $model= new ListeModel();
+ $model->delTache($idTache);
+ $_REQUEST['action']="accessListInfos";
+ $this->accessListInfos($arrayErrorViews);
+ }
+
+ public function changeCompletedTache($arrayErrorViews){
+ global $rep,$vues,$dataView;
+ $idTache=$_POST['tache'];
+ $model = new ListeModel();
+ $model->changeCompletedTache($idTache);
+ $_REQUEST['action']="accessListInfos";
+ $this->accessListInfos($arrayErrorViews);
+ }
+
public function connection(array $vues_erreur){
global $rep,$vues,$dataView;
$usrname=$_POST['login'];
@@ -102,10 +149,8 @@ class ControleurVisiteur {
$nom=$_POST['name'];
$model = new ListeModel();
if(isset($_SESSION['login'])){
- foreach($_POST['private'] as $valeur){
- $private=$valeur;
- $model->creerListe($nom,$private);
- }
+ $private=$_POST['private'];
+ $model->creerListe($nom,$private);
}
else{
$model->creerListe($nom,null);
@@ -114,12 +159,13 @@ class ControleurVisiteur {
$this->reinit();
}
- public function supprListe(array $vues_erreur){
+ public function delListe(array $vues_erreur){
global $rep, $vues;
- require($rep.$vues['suppressionListe']);
-
+ $idListe=$_POST['liste'];
$model = new ListeModel();
- $model->supprListe();
+ $model->delListe($idListe);
+ $_REQUEST['action']=null;
+ $this->reinit();
}
public function creerTache(array $vues_erreur){
diff --git a/controleurs/FrontControleur.php b/controleurs/FrontControleur.php
index f0e4af6..d03e037 100644
--- a/controleurs/FrontControleur.php
+++ b/controleurs/FrontControleur.php
@@ -4,7 +4,7 @@ class FrontControleur{
public function __construct(){
$liste_actions_utilisateur = array('accessPrivateLists','accessProfilePage','deconnection','crerListePv','desinscription','changerPassword');
- $liste_actions_visiteur = array('accessCreationListePage','accessInscription','accessConnectionPage','creerListe','suprrListe','connection','inscription','creerTache','cocherTache','supprTache');
+ $liste_actions_visiteur = array('goHome','changeCompletedTache','accessCreationTachePage','addTache','delTache','accessListInfos','accessCreationListePage','accessInscription','accessConnectionPage','creerListe','delListe','connection','inscription');
global $rep,$vues,$bd,$dataView,$styles,$assets;
session_start();
try{
diff --git a/modeles/Gateways/ListeGateway.php b/modeles/Gateways/ListeGateway.php
index 30c9c11..4529a5f 100644
--- a/modeles/Gateways/ListeGateway.php
+++ b/modeles/Gateways/ListeGateway.php
@@ -87,44 +87,74 @@ class ListeGateway {
return $listes;
}
- public function creerTache(string $intitule){
- if(!empty($id) && !empty($intitutle)){
- try{
- $co = $this->co;
+ public function getById($id){
+ $taches=null;
+ $liste=null;
+ $co = $this->co;
+ $query = "SELECT * FROM Liste WHERE id=:id";
+
+ $co->executeQuery($query, array('id' => array($id, PDO::PARAM_INT)));
+
+ $results = $co->getResults();
+ foreach ($results as $row){
+ $idListe = $row['id'];
+ $queryTaches = "SELECT * FROM Tache WHERE idListe=:id";
+ $co->executeQuery($queryTaches, array(':id' => array($idListe, PDO::PARAM_INT)));
+ $resultsTaches = $co->getResults();
+
+ foreach($resultsTaches as $rowTaches){
+ if($rowTaches['complete']=="0"){
+ $taches[] = new Tache($rowTaches['id'], $rowTaches['nom'],false,$idListe);
+ }else{
+ $taches[] = new Tache($rowTaches['id'], $rowTaches['nom'],true,$idListe);
+ }
+
+ }
- $query = "INSERT INTO Tache VALUES (NULL, :intitule, 0)";
+ $liste = new Liste($row['id'], $row['nom'],$row['nomCreateur'], $taches);
+ }
+ return $liste;
+ }
- $co->executeQuery($query, array(':intitule' => array($nom, PDO::PARAM_STR)));
- }
- catch(PDOException $Exception){
- echo 'erreur';
- echo $Exception->getMessage();
- }
+ public function creerTache(string $nom, int $idListe){
+ try{
+ $co = $this->co;
+
+ $query = "INSERT INTO Tache VALUES (NULL, :intitule, 0,:idListe)";
+
+ $co->executeQuery($query, array(':intitule' => array($nom, PDO::PARAM_STR),
+ 'idListe' => array($idListe,PDO::PARAM_INT)));
+ }
+ catch(PDOException $Exception){
+ echo 'erreur';
+ echo $Exception->getMessage();
}
}
public function delTache(int $id){
- if(!empty($id)){
- try{
- $co = $this->co;
+ try{
+ $co = $this->co;
- $query = "DELETE FROM Tache WHERE id=:id";
+ $query = "DELETE FROM Tache WHERE id=:id";
- $co->executeQuery($query, array(':id' => array($id, PDO::PARAM_STR)));
- }
- catch(PDOException $Exception){
- echo 'erreur';
- echo $Exception->getMessage();
- }
+ $co->executeQuery($query, array(':id' => array($id, PDO::PARAM_STR)));
+ }
+ catch(PDOException $Exception){
+ echo 'erreur';
+ echo $Exception->getMessage();
}
}
- public function completeTache(int $id){
- if(!empty($id)){
+ public function updateTache(int $id, bool $complete){
try{
$co = $this->co;
-
- $query = "UPDATE Tache SET isCompleted=true WHERE id=:id";
+ if($complete==true){
+ $query = "UPDATE Tache SET complete=0 WHERE id=:id";
+ }
+ else{
+ $query = "UPDATE Tache SET complete=1 WHERE id=:id";
+ }
+
$co->executeQuery($query, array(':id' => array($id, PDO::PARAM_STR)));
}
@@ -132,6 +162,23 @@ class ListeGateway {
echo 'erreur';
echo $Exception->getMessage();
}
+ }
+
+ public function getTacheById(int $id){
+ $complete=null;
+ $co=$this->co;
+ $query="SELECT complete FROM Tache WHERE id=:id";
+ $co->executeQuery($query,array('id'=>array($id,PDO::PARAM_INT)));
+ $res=$co->getResults();
+ foreach($res as $row){
+ $complete=$row['complete'];
+ }
+ if($complete=="0")
+ {
+ return false;
+ }
+ else{
+ return true;
}
}
@@ -153,18 +200,16 @@ class ListeGateway {
public function delListe(int $id){
- if(!empty($id)){
- try{
- $co = $this->co;
-
- $query = "DELETE FROM Tache WHERE id=:id";
-
- $co->executeQuery($query, array(':id' => array($id, PDO::PARAM_STR)));
- }
- catch(PDOException $Exception){
- echo 'erreur';
- echo $Exception->getMessage();
- }
+ try{
+ $co = $this->co;
+ $queryDelTaches="DELETE FROM Tache WHERE idListe=:id";
+ $query = "DELETE FROM Liste WHERE id=:id";
+ $co->executeQuery($queryDelTaches, array(':id' => array($id, PDO::PARAM_STR)));
+ $co->executeQuery($query, array(':id' => array($id, PDO::PARAM_STR)));
+ }
+ catch(PDOException $Exception){
+ echo 'erreur';
+ echo $Exception->getMessage();
}
}
}
diff --git a/modeles/Modele/ListModel.php b/modeles/Modele/ListModel.php
index 0f0017b..ca5acfe 100644
--- a/modeles/Modele/ListModel.php
+++ b/modeles/Modele/ListModel.php
@@ -11,7 +11,7 @@ class ListeModel{
function creerListe(string $nom, $private){
if(isset($_SESSION['login'])){
- if($private="on"){
+ if($private!=null){
$this->listgw->creerListe($nom,$_SESSION['login']);
}else{
$this->listgw->creerListe($nom,null);
@@ -20,6 +20,27 @@ class ListeModel{
$this->listgw->creerListe($nom,null);
}
}
+
+ function pullListById(int $idListe){
+ return $this->listgw->getById($idListe);
+ }
+
+ function addTache(string $intitule, int $idListe ){
+ $this->listgw->creerTache($intitule,$idListe);
+ }
+
+ function delTache(int $idTache){
+ $this->listgw->delTache($idTache);
+ }
+
+ function changeCompletedTache(int $idTache){
+ $complete=$this->listgw->getTacheById($idTache);
+ $this->listgw->updateTache($idTache,$complete);
+ }
+
+ function delListe(int $idListe){
+ $this->listgw->delListe($idListe);
+ }
}
?>
\ No newline at end of file
diff --git a/vues/acceuil.php b/vues/acceuil.php
index 1b829ca..bdb4909 100644
--- a/vues/acceuil.php
+++ b/vues/acceuil.php
@@ -43,14 +43,15 @@
nom;
- echo '
';
- if($liste->taches != null){
- foreach($liste->taches as $tache){
- echo ' * '.$tache->nom;
- echo '
';
- }
- }
+ echo '
+