ADD: tout ce qui est demander

master
Lucie Bedouret 2 years ago
parent 58510209ba
commit a4f871e5d7

@ -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';

@ -3,7 +3,7 @@
class ControleurUtilisateur{
function __construct() {
global $rep,$vues, $dataView;
global $rep,$vues, $dataView,$styles,$assets;
$arrayErrorViews= array();
$action = $_REQUEST['action']??null;

@ -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);
break;
case "creerTache":
$this->creerTache($arrayErrorViews);
case "delListe":
$this->delListe($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){

@ -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{

@ -87,44 +87,74 @@ class ListeGateway {
return $listes;
}
public function creerTache(string $intitule){
if(!empty($id) && !empty($intitutle)){
try{
$co = $this->co;
$query = "INSERT INTO Tache VALUES (NULL, :intitule, 0)";
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);
}
$co->executeQuery($query, array(':intitule' => array($nom, PDO::PARAM_STR)));
}
catch(PDOException $Exception){
echo 'erreur';
echo $Exception->getMessage();
}
$liste = new Liste($row['id'], $row['nom'],$row['nomCreateur'], $taches);
}
return $liste;
}
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;
if($complete==true){
$query = "UPDATE Tache SET complete=0 WHERE id=:id";
}
else{
$query = "UPDATE Tache SET complete=1 WHERE id=:id";
}
$query = "UPDATE Tache SET isCompleted=true 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();
}
}
}

@ -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);
}
}
?>

@ -43,14 +43,15 @@
<?php
if(isset($dataView)) {
foreach ($dataView as $liste){
echo $liste->nom;
echo '<br/>';
if($liste->taches != null){
foreach($liste->taches as $tache){
echo ' * '.$tache->nom;
echo '<br/>';
}
}
echo '
<div>
<form method="post" name="accessList" id="accessList">
<p>• '.$liste->nom.'
<input type="submit" value="View List"/></p>
<input type="hidden" name="action" value="accessListInfos"/>
<input type="hidden" name="liste" value="'.$liste->id.'"/>
</form>
</div>';
}
}
?>

@ -7,6 +7,10 @@
<body>
<header>
<h1>You are back ?!</h1>
<form method="POST" name="goBackHome" id="Go Home">
<input type="submit" value="Home Page"/>
<input type="hidden" name="action" value="goHome"/>
</form>
</header>
<div>
<form method="POST" name="connectionForm" id="connectionForm">

@ -4,11 +4,11 @@
<div>
<h3>Create a new list</h3>
<form method="POST" name="creaListe" id="creaListe">
<p>Name of the liste
<p>Name of the list
<input type="text" name="name" id="name" required/></p>
<?php
if(isset($_SESSION['login'])){
echo '<input type="checkbox" id="private" name="private[]">
echo '<input type="checkbox" id="private" name="private">
<label for="private">Private List?</label>';
}
?>

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<body>
<div>
<h3>Create a new list</h3>
<form method="POST" name="creaListe" id="creaListe">
<p>Name of the task
<input type="text" name="name" id="name" required/></p>
<input class="button" type="submit" value="Create Tache"/>
<input type="hidden" name="action" value="addTache"/>
<input type="hidden" name="liste" value="<?=$dataView?>"/>
</form>
</div>
</body>
</html>

@ -0,0 +1,64 @@
<!DOCTYPE html>
<html>
<header>
<h2><?=$dataView->nom?></h2>
<form method="POST" name="goBackHome" id="Go Home">
<input type="submit" value="Home Page"/>
<input type="hidden" name="action" value="goHome"/>
</form>
</header>
<body>
<div>
<?php
if (isset($dataView)) {
if($dataView->taches != null){
foreach($dataView->taches as $tache){
if($tache->isCompleted == true){
echo '
<input type="checkbox" id="tache'.$tache->id.'" name="tache'.$tache->id.'" value="'.$tache->id.'" disabled checked>
<label for="tache'.$tache->id.'">'.$tache->nom.'</label>
<form method="POST" id="check'.$tache->id.'" name="check'.$tache->id.'">
<input type="submit" value="Undo"/>
<input type="hidden" name="action" value="changeCompletedTache"/>
<input type="hidden" name="tache" value="'.$tache->id.'"/>
<input type="hidden" name="liste" value="'.$dataView->id.'"/>
</form>
';
}
else{
echo '
<input type="checkbox" id="tache'.$tache->id.'" name="tache'.$tache->id.'" value="'.$tache->id.'" disabled>
<label for="tache'.$tache->id.'">'.$tache->nom.'</label>
<form method="POST" id="uncheck'.$tache->id.'" name="uncheck'.$tache->id.'">
<input type="submit" value="Done"/>
<input type="hidden" name="action" value="changeCompletedTache"/>
<input type="hidden" name="tache" value="'.$tache->id.'"/>
<input type="hidden" name="liste" value="'.$dataView->id.'"/>
</form>
';
}
echo '
<form method="POST" id="delTache'.$tache->id.'" name="delTache'.$tache->id.'">
<input type="submit" value="Delete"/>
<input type="hidden" name="action" value="delTache"/>
<input type="hidden" name="tache" value="'.$tache->id.'"/>
<input type="hidden" name="liste" value="'.$dataView->id.'"/>
</form>';
echo '<br/>';
}
}
}
?>
<form method="POST" id="addTache" name="addTache">
<input type="submit" value="Add a Task"/></p>
<input type="hidden" name="action" value="accessCreationTachePage"/>
<input type="hidden" name="liste" value="<?=$dataView->id?>"/>
</form>
<form method="POST" id="delListe" name="delListe">
<input type="submit" value="Delete the list"/></p>
<input type="hidden" name="action" value="delListe"/>
<input type="hidden" name="liste" value="<?=$dataView->id?>"/>
</form>
</div>
</body>
</html>

@ -1,19 +1,27 @@
<!DOCTYPE html>
<html>
<header>
<h2>Private Lists</h2>
<form method="POST" name="goBackHome" id="Go Home">
<input type="submit" value="Home Page"/>
<input type="hidden" name="action" value="goHome"/>
</form>
</header>
<body>
<div>
<h2>Private Lists</h2>
<?php
if (isset($dataView)) {
if(isset($dataView)) {
foreach ($dataView as $liste){
echo $liste->nom;
echo '<br/>';
if($liste->taches != null){
foreach($liste->taches as $tache){
echo ' * '.$tache->nom;
echo '<br/>';
}
}
echo '
<div>
<form method="post" name="accessList" id="accessList">
<p>• '.$liste->nom.'
<input type="submit" value="View List"/></p>
<input type="hidden" name="action" value="accessListInfos"/>
<input type="hidden" name="liste" value="'.$liste->id.'"/>
</form>
</div>';
}
}
?>

@ -1,19 +1,19 @@
<!DOCTYPE html>
<html>
<header>
<h2>What you wanna do young padawan?</h2>
<form method="POST" name="goBackHome" id="Go Home">
<input type="submit" value="Home Page"/>
<input type="hidden" name="action" value="goHome"/>
</form>
</header>
<body>
<h2>What you wanna young padawan?</h2>
<div>
<form method="POST" name="deconnection">
<input class="button" type="submit" value="Déconnection"/>
<input type="hidden" name="action" value="deconnection"/>
</form>
</div>
<div>
<form method="POST" name="desincription">
<input class="button" type="submit" value="Desinscription"/>
<input type="hidden" name="action" value="desinscription"/>
</form>
</div>
</body>
</html>
Loading…
Cancel
Save