Anthony RICHARD 1 year ago
commit 9efefc32eb

@ -8,22 +8,21 @@ use config\Connection;
class StudentController
{
public function __construct(){
public function __construct()
{
global $twig;
global $gtw;
global $con;
$con = new Connection('mysql:host=localhost;dbname=dbanrichard7','anrichard7','achanger');
$gtw = new UserGateway($con);
$actionList = ['showUsers'];
$dVueEreur= [];
session_start();
$actionList = ['showVocab', 'getByName'];
$dVueEreur = [];
try {
$action = $_REQUEST['action'] ?? null;
switch ($action) {
case NULL:
case 'allVocab':
case null:
$this->affAllVocab();
break;
case "ajouter":
ajouter($_REQUEST['']);
case 'getByName':
$this->getByName($_REQUEST['nom']);
break;
default:
@ -31,19 +30,26 @@ class StudentController
echo $twig->render('vuephp1.html', ['dVueEreur' => $dVueEreur]);
break;
}
}
catch(\PDOException $e){
} catch (\PDOException $e) {
$dataVueEreur[] = "Erreur inattendue";
$twig->render("vuephp1.html", ['dVueErreur' => $dataVueEreur]);
}
catch (Exception $e2)
{
} catch (Exception $e2) {
$dataVueEreur[] = "Erreur inattendue!!! ";
require($dataVueEreur['erreur']);
}
}
function AffAllStudent():void{
public function affAllVocab(): void
{
global $twig;
$mdl = new MdlStudent();
$student = $mdl->getAll();
echo $twig->render('usersView.html', ['users' => $student]);
}
public function affAllStudent(): void
{
global $twig;
$mdl = new MdlStudent();
$student = $mdl->getAll();
@ -51,5 +57,15 @@ class StudentController
}
public function getByName($name): void
{
global $twig;
$mdl = new MdlStudent();
$vocab = $mdl->getVocabByName($name);
echo $twig->render('usersView.html', ['users' => $vocab]);
}
}

@ -0,0 +1,89 @@
<?php
namespace controller;
use model\MdlTeacher;
use gateway\UserGateway;
use config\Connection;
class TeacherController
{
public function __construct()
{
global $twig;
session_start();
$actionList = ['getAllStudent','getAllVocab','getVocabByName','AddVocab', 'DelVocab'];
$dVueEreur = [];
try {
$action = $_REQUEST['action'] ?? null;
switch ($action) {
case null:
case 'getAllStudent':
$this->affAllStudent();
break;
case 'allVocab':
$this->affAllVocab();
break;
case 'getVocabByName':
$this->getByName($_REQUEST['name']);
break;
case 'addVocab':
break;
/* case 'delVoc':
$this->delById($_REQUEST['id']);
break;*/
default:
$dVueEreur[] = "Erreur d'appel php";
echo $twig->render('vuephp1.html', ['dVueEreur' => $dVueEreur]);
break;
}
}
catch (\PDOException $e) {
$dataVueEreur[] = "Erreur inattendue";
$twig->render("vuephp1.html", ['dVueErreur' => $dataVueEreur]);
} catch (Exception $e2) {
$dataVueEreur[] = "Erreur inattendue!!! ";
require($dataVueEreur['erreur']);
}
}
public function affAllStudent(): void
{
global $twig;
$mdl = new MdlTeacher();
$student = $mdl->getAllStudent();
echo $twig->render('usersView.html', ['users' => $student]);
}
public function affAllVocab(): void
{
global $twig;
$mdl = new MdlTeacher();
$student = $mdl->getAll();
echo $twig->render('usersView.html', ['users' => $student]);
}
public function getByName($name): void
{
global $twig;
$mdl = new MdlTeacher();
$vocab = $mdl->getVocabByName($name);
echo $twig->render('usersView.html', ['users' => $vocab]);
}
public function DelById($id):void{
global $twig;
$mdl = new MdlTeacher();
$vocab = $mdl->removeVocById($id);
echo $twig->render('usersView.html', ['users' => $vocab]);
}
}

@ -26,7 +26,7 @@ class MdlStudent extends AbsModel
else return null;
}
*/
public function getAll(){
public function getAll():array{
global $twig;
$gtw = new VocabularyGateway(new Connection('mysql:host=localhost;dbname=dbanrichard7','anrichard7','achanger'));
return $gtw->findAll();
@ -38,14 +38,16 @@ class MdlStudent extends AbsModel
*/
}
public function getById($id){
$gtw = new VocabularyGateway(new Connection());
$res = $gtw->getById($id);
public function getVocabByName($name):array{
$gtw = new VocabularyGateway(new Connection('mysql:host=localhost;dbname=dbanrichard7','anrichard7','achanger'));
$res = $gtw->findByName($name);
return $res;
}
}

@ -0,0 +1,48 @@
<?php
namespace model;
//use http\Client\Curl\User;
use model\AbsModel;
use config\Connection;
use gateway\UserGateway;
use gateway\VocabularyGateway;
class MdlTeacher extends AbsModel
{
public function __construct()
{
parent::__construct("teacher");
}
public function getAll():array{
$gtw = new VocabularyGateway(new Connection('mysql:host=localhost;dbname=dbanrichard7','anrichard7','achanger'));
return $gtw->findAll();
/*
foreach ($data as $row){
$AllStudent[] = User($row['id'],$row['password'],$row['email'],$row['name'],$row['surname'],$row['nickname'],$row['image'],$row['extraTime'],$row['group'],$row['roles']);
}
return $AllStudent;
*/
}
public function getAllStudent():array {
$gtw = new UserGateway(new Connection('mysql:host=localhost;dbname=dbanrichard7','anrichard7','achanger'));
return $gtw->findAll();
}
public function getVocabByName($name):array{
$gtw = new VocabularyGateway(new Connection('mysql:host=localhost;dbname=dbanrichard7','anrichard7','achanger'));
$res = $gtw->findByName($name);
return $res;
}
public function RemoveVocById($id):void{
$gtw = new VocabularyGateway(new Connection('mysql:host=localhost;dbname=dbanrichard7','anrichard7','achanger'));
$res = $gtw->remove($id);
}
}

@ -95,7 +95,7 @@ h6 span{
position: relative;
width: 440px;
max-width: 100%;
height: 400px;
height: 500px;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
perspective: 800px;

@ -41,18 +41,34 @@
<div class="center-wrap">
<div class="section text-center">
<h4 class="mb-4 pb-3">Sign Up</h4>
<div class="form-group">
<input type="text" name="logname" class="form-style" placeholder="Your Full Name" id="logname" autocomplete="off">
<div class="form-group mt-2">
<input type="text" name="logsurname" class="form-style" placeholder="Surname" id="logsurname" autocomplete="off">
<i class="input-icon uil uil-user"></i>
</div>
<div class="form-group mt-2" >
<input type="email" name="logemail" class="form-style" placeholder="Your Email" id="logemail" autocomplete="off">
<input type="text" name="logname" class="form-style" placeholder="Name" id="logname" autocomplete="off">
<i class="input-icon uil uil-user"></i>
</div>
<div class="form-group mt-2">
<input type="text" name="lognickname" class="form-style" placeholder="Nickname" id="lognickname" autocomplete="off">
<i class="input-icon uil uil-user"></i>
</div>
<div class="form-group mt-2">
<input type="email" name="logmail" class="form-style" placeholder="Your Email" id="logmail" autocomplete="off">
<i class="input-icon uil uil-at"></i>
</div>
<div class="form-group mt-2">
<input type="password" name="logpass" class="form-style" placeholder="Your Password" id="logpass" autocomplete="off">
<input type="password" name="logpasswd" class="form-style" placeholder="Your Password" id="logpasswd" autocomplete="off">
<i class="input-icon uil uil-lock-alt"></i>
</div>
<a href="#" class="btn mt-4">submit</a>
</div>
</div>

@ -9,6 +9,7 @@
<section>
<table>
<tr>
<td>Id</td>
<td>Nickname</td>
<td>Name</td>
<td>Surname</td>
@ -20,13 +21,14 @@
{% if users is defined %}
{% for row in users %}
<tr>
<td>{{row.id}}</td>
<td>{{row.nickname}}</td>
<td>{{row.name}}</td>
<td>{{row.surname}}</td>
<td>{{row.email}}</td>
<td>{{row.group}}</td>
<td>{{row.role}}</td>
<td>{{row.extraTime}}</td>
<td>{{row.roles|join(', ')}}</td>
<td>{{row.extraTime? 'yes' : 'no' }}</td>
<td><a href="index.php?action=removeUser&id={{row.id}}">
<input class="btn-black" type="button" value="Delete"/>
</a></td>

Loading…
Cancel
Save