update vues with database

merging_APE
Antoine PEREDERII 1 year ago
parent 6e935ce864
commit 0093f21b81

@ -24,6 +24,13 @@ class AppCreator
return $this;
}
public function registerSingleton(string $serviceId, $service): self
{
$this->container->set($serviceId, $service, Container::SINGLETON);
$this->services[] = $serviceId;
return $this;
}
/**
* Create an instance or perform actions based on the current application environment.
*
@ -71,7 +78,7 @@ class AppCreator
if ($reflectionClass->isSubclassOf(BaseController::class)) {
// Register in DI container
$this->container->set($fullClassName, function () use ($fullClassName) {
$controllerInstance = new $fullClassName();
$controllerInstance = $this->container->resolve($fullClassName);
$controllerInstance->setContainer($this->container);
return $controllerInstance;
});
@ -81,7 +88,6 @@ class AppCreator
return $this;
}
public function getServiceRegistered(): array
{
return $this->services;

@ -2,10 +2,17 @@
namespace App\Controller;
use Database\ActivityGateway;
use Database\ActivityMapper;
use Database\AthleteEntity;
use Database\AthleteMapper;
use Database\EntrainementGateway;
use Database\EntrainementMapper;
use Database\NotificationEntity;
use Database\NotificationGateway;
use Database\NotificationMapper;
use DateTime;
use Model\Notification;
use Shared\Validation;
use App\Container;
use App\Router\Request\IRequest;
@ -23,11 +30,12 @@ class AthleteController extends BaseController
private Environment $twig;
protected Preferences $preference;
// private UserManager $userMgr;
public function __construct()
{
//session_start();
$this->preference = new Preferences();
// $this->userMgr = $manager;
}
// #[Route(path: '/search-user', name: 'search-user', methods: ['GET'])]
@ -87,21 +95,19 @@ class AthleteController extends BaseController
$athleteEntity = $map->athleteSqlToEntity($listSearch);
$listUsers = [];
$i = 0;
foreach ($athleteEntity as $entity) {
$user = $map->athleteEntityToModel($entity);
$listUsers[$i] = ['idathlete' => number_format($user->getId(), 1), 'nom' => $user->getNom(),
$listUsers[] = ['idathlete' => number_format($user->getId(), 1), 'nom' => $user->getNom(),
'prenom' => $user->getPrenom(),'email' => $user->getEmail(), 'sexe' => $user->getSexe(),
'taille' => $user->getTaille(), 'poids' => $user->getPoids(), 'motdepasse' => $user->getMotDePasse(),
'datenaissance' => $user->getDateNaissance(), 'iscoach' => $user->getRole(), 'img' => 'test',
'username' => $user->getUsername()];
$i++;
}
$response = $this->render('./page/addfriend.html.twig',[
'css' => $_COOKIE['preferences'],
'pp' => 'test',
'user' => 'johndoe',//$currentUser->getUsername(),
'user' => 'John',//$currentUser->getUsername(),
'role' => 'Athlete',//$currentUser->getRole(),
'users' => $listUsers
]);
@ -117,39 +123,78 @@ class AthleteController extends BaseController
#[Route(path: '/analyses', name: 'analyses', methods: ['GET'])]
public function analyses(): Response
{
return $this->render('./page/analyze.html.twig',[
try {
$activityGateway = new ActivityGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
$listSearch = $activityGateway->getActivity();
$map = new ActivityMapper();
$activityGateway = $map->activitySqlToEntity($listSearch);
$listActivity = [];
foreach ($activityGateway as $entity) {
$activity = $map->activityEntityToModel($entity);
$listActivity[] = ['idactivity' => number_format($activity->getIdActivity(), 1), 'type' => $activity->getType(),
'date' => $activity->getDate()->format("D j F Y"), 'heureDebut' => $activity->getHeureDebut()->format("H\h i"), 'heureFin' => $activity->getHeureFin()->format("H\h i"),
'effortRessenti' => $activity->getEffortRessenti(), 'variabilite' => $activity->getVariability(), 'variance' => $activity->getVariance(),
'ecartType' => $activity->getStandardDeviation(), 'moyenne' => $activity->getAverage(),
'max' => $activity->getMaximum(), 'min' => $activity->getMinimum(), 'temperature' =>$activity->getAvrTemperature()];
}
$response = $this->render('./page/analyze.html.twig',[
'css' => $this->preference->getCookie(),
'pp' => "test2",
'user' => 'johndoe',//$currentUser->getUsername(),
'role' => 'Athlete',//$currentUser->getRole(),
'friendship' => [],
'analyzes' => [],
'analyzes' => $listActivity,
'mails' => [],
'users' => [],
'infoUser' => [],
'exos' => [],
'member' => []
]);
} catch (\Throwable $th) {
throw $th;
return $this->render("./page/analyze.html.twig", ['tabError' => $taberror]);
}
return $response;
}
#[Route(path: '/activity', name: 'activity', methods: ['GET'])]
public function activity(): Response
{
return $this->render('./page/activity.html.twig',[
try {
$activityGateway = new ActivityGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
$listSearch = $activityGateway->getActivity();
$map = new ActivityMapper();
$activityGateway = $map->activitySqlToEntity($listSearch);
$listActivity = [];
foreach ($activityGateway as $entity) {
$activity = $map->activityEntityToModel($entity);
$listActivity[] = ['idactivity' => number_format($activity->getIdActivity(), 1), 'type' => $activity->getType(),
'date' => $activity->getDate()->format("D j F Y"), 'heureDebut' => $activity->getHeureDebut()->format("H\h i"), 'heureFin' => $activity->getHeureFin()->format("H\h i"),
'effortRessenti' => $activity->getEffortRessenti(), 'variabilite' => $activity->getVariability(), 'variance' => $activity->getVariance(),
'ecartType' => $activity->getStandardDeviation(), 'moyenne' => $activity->getAverage(),
'max' => $activity->getMaximum(), 'min' => $activity->getMinimum(), 'temperature' => $activity->getAvrTemperature()];
}
$response = $this->render('./page/activity.html.twig', [
'css' => $this->preference->getCookie(),
'pp' => "test",
'pp' => "test2",
'user' => 'johndoe',//$currentUser->getUsername(),
'role' => 'Athlete',//$currentUser->getRole(),
'friendship' => [],
'analyzes' => [],
'analyzes' => $listActivity,
'mails' => [],
'users' => [],
'infoUser' => [],
'exos' => [],
'member' => []
]);
} catch (\Throwable $th) {
throw $th;
return $this->render("./page/analyze.html.twig", ['tabError' => $taberror]);
}
return $response;
}
#[Route(path: '/exercice', name: 'exercice', methods: ['GET'])] // 8
public function exercice(): Response
@ -161,13 +206,11 @@ class AthleteController extends BaseController
$entrainementEntity = $map->entrainementSqlToEntity($listSearch);
$listUsers = [];
$i = 0;
foreach ($entrainementEntity as $entity) {
$training = $map->entrainementEntityToModel($entity);
$listUsers[$i] = ['idTraining' => number_format($training->getId(), 1), 'date' => $training->getDate()->format("D j F Y"),
$listUsers[] = ['idTraining' => number_format($training->getId(), 1), 'date' => $training->getDate()->format("D j F Y"),
'location' => $training->getLocation(), 'description' => $training->getDescription(),
'feedback' => $training->getFeedback()];
$i++;
}
$response = $this->render('./page/exercice.html.twig',[
@ -220,23 +263,58 @@ class AthleteController extends BaseController
#[Route(path: '/add-friend', name: 'add-friend', methods: ['POST'])]
public function addFriend(string $username, IRequest $req): Response
{
try {
try {/*
$athleteGateway = new AthleteGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
$map=new AthleteMapper();
$userSearched=$athleteGateway->getAthleteByFirstName($username);
$currentUser=$map->athleteEntityToModel(new AthleteEntity($athleteGateway->getAthleteById(1)));
foreach($userSearched as $user) {
$listUser[] = $map->athleteEntityToModel(new AthleteEntity($user));
}
if ($listUser!=null) {
foreach ($userSearched as $user) {
$currentUser->addFriend($user);
$users = ['nom' => $user->getNom(), 'prenom' => $user->getPrenom(), 'img' => 'test', 'username' => $user->getUsername()];
$friendEntity = $athleteGateway->getListIdFriends(1);
foreach($friendEntity as $users) {
if ($users['idathlete1']==1){
$user=(int)$users['idathlete2'];
} else {
$user=(int)$users['idathlete1'];
}
$listUserEntity[] = $map->athleteSqlToEntity($athleteGateway->getAthleteById(1));
}
else{
foreach ($listUserEntity as $user) {
$friendList[] = ['nom' => $user[0]->getNom(), 'prenom' => $user[0]->getPrenom(), 'img' => 'test', 'username' => 'test'];
}*/
// $entrainementGateway = new EntrainementGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
// $listSearch = $entrainementGateway->getEntrainements();
// $map = new EntrainementMapper();
// $entrainementEntity = $map->entrainementSqlToEntity($listSearch);
//
// $listUsers = [];
// foreach ($entrainementEntity as $entity) {
// $training = $map->entrainementEntityToModel($entity);
// $listUsers[] = ['idTraining' => number_format($training->getId(), 1), 'date' => $training->getDate()->format("D j F Y"),
// 'location' => $training->getLocation(), 'description' => $training->getDescription(),
// 'feedback' => $training->getFeedback()];
// }
$athleteGateway = new AthleteGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
$map = new AthleteMapper();
$userSearched = $athleteGateway->getAthleteByFirstName("Bryan");
$athleteEntity = $map->athleteSqlToEntity($userSearched);
// $user = $athleteGateway->getAthleteById(1);
// $currentUser = $map->athleteToEntity($user);
// Log::dd($currentUser);
// foreach($userSearched as $user) {
// $listUser[] = $map->athleteToEntity($user);
// }
$users=[];
foreach ($athleteEntity as $user) {
// $this->userMgr->getCurrentUser()->addFriend($user);
// $currentUser->addFriend($user);
$users = ['nom' => $user->getNom(), 'prenom' => $user->getPrenom(), 'img' => 'test', 'username' => $user->getUsername()];
}
$notif = new NotificationGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
$mapper = new NotificationMapper();
$date = new DateTime();
// DateTime::createFromFormat('d/m/Y', date('d/m/Y'));
// Log::dd($date);
$myNotif = new Notification(20, "Demande d'ami de la part de " . $users['nom'], $date, true, 7, 1);
$notif->addNotification($mapper->notificationToEntity($myNotif));
return $this->render('./page/addfriend.html.twig',[
'css' => $this->preference->getCookie(),
'pp' => "test2",
@ -311,10 +389,12 @@ class AthleteController extends BaseController
try {
$athleteGateway = new AthleteGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
$map=new AthleteMapper();
$friendEntity = $athleteGateway->getListIdFriends(1/*currentUser->getId()*/);
$friendEntity = $athleteGateway->getListIdFriends(1/*$currentUser->getId()*/);
$friendList = [];
$listUserEntity = [];
foreach($friendEntity as $users) {
if ($users['idathlete1']==1/*currentUser->getId()*/){
if ($users['idathlete1']==1/*$currentUser->getId()*/){
$user=(int)$users['idathlete2'];
} else {
$user=(int)$users['idathlete1'];
@ -331,12 +411,6 @@ class AthleteController extends BaseController
'user' => "Doe",
'role' => "Athlète",
'friendship' => $friendList,
'analyzes' => [],
'mails' => [],
'users' => $users,
'infoUser' => [],
'exos' => [],
'member' => [],
]);
} catch (\Throwable $th) {

@ -18,6 +18,19 @@ class AuthController extends BaseController
public function __construct(){
$this->preference = new Preferences();
}
// ! private UserManager $userMgr;
// public function __construct(UserManager $manager){
// parent::__construct();
// $this->userMgr = $manager;
// }
#[Route('/login', name: 'login')]
public function login(?string $username, ?string $password ,IRequest $request): Response {

@ -17,17 +17,12 @@ use Shared\Log;
class SocialController extends BaseController
{
private Environment $twig;
protected Preferences $preference;
public function __construct()
{
session_start();
public function __construct(){
$this->preference = new Preferences();
}
#[Route(path: '/notification', name: 'notification', methods: ['GET'])]
public function mail(): Response
{
@ -42,7 +37,7 @@ class SocialController extends BaseController
foreach ($notificationEntity as $entity) {
$notification = $map->notificationEntityToModel($entity);
$listUsers[] = ['idnotif' => $notification->getId(), 'message' => $notification->getMessage(),
'date' => $notification->getDate(),'statut' => $notification->getStatut(), 'urgence' => $notification->getUrgence(),
'date' => $notification->getDate()->format("D j F Y"),'statut' => $notification->getStatut(), 'urgence' => $notification->getUrgence(),
'idathlete' => $notification->getToUserId()];
}
@ -62,7 +57,7 @@ class SocialController extends BaseController
} catch (\Throwable $th) {
throw $th;
return $this->render("addfriend.html.twig", ['tabError' => $taberror]);
return $this->render("notification.html.twig", ['tabError' => $taberror]);
}
return $response;
}

@ -18,7 +18,6 @@ class UserController extends BaseController
public function __construct()
{
session_start();
$this->preference = new Preferences();
}

@ -10,6 +10,7 @@
<link href="https://cdn.jsdelivr.net/npm/simple-datatables@7.1.2/dist/style.min.css" rel="stylesheet" />
<link href="/css/{% block css %}styles{% endblock %}.css" rel="stylesheet" />
<script src="https://use.fontawesome.com/releases/v6.3.0/js/all.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />
</head>
<body class="sb-nav-fixed">
<nav class="sb-topnav navbar navbar-expand navbar-dark bg-dark">
@ -55,7 +56,7 @@
<div class="sb-nav-link-icon"><img src="/assets/img/sprinter.png"></div>
Exercices
</a>
<a class="nav-link" href="/analyses">
<a class="nav-link" href="/activity">
<div class="sb-nav-link-icon"><i class="fas fa-chart-area"></i></div>
Analyses
</a>

@ -21,7 +21,7 @@
<h1 class="display-1">{% block nb %}{% endblock %}</h1>
<p class="lead">{% block name %}{% endblock %}</p>
<p>{% block descr %}{% endblock %}</p>
<a href="/">
<a href="/home">
<i class="fas fa-arrow-left me-1"></i>
Retour à l'accueil
</a>

@ -4,30 +4,85 @@
{% block css %}{{css}}{% endblock %}
{% block title %}Exercices - HearthTrack{% endblock %}
{% block title %}Analyses - HearthTrack{% endblock %}
{% block user %}{{user}} - {{role}}{% endblock %}
{% block body %}
<div class="container-fluid px-4">
<h1 class="mt-4">Exercices</h1>
<h1 class="mt-4">Analyses</h1>
<ol class="breadcrumb mb-4">
<li class="breadcrumb-item"><a href="/">Accueil</a></li>
<li class="breadcrumb-item active">Exercices</li>
<li class="breadcrumb-item"><a href="/home">Accueil</a></li>
<li class="breadcrumb-item active">Analyses</li>
</ol>
<div class="card-body">
<div class="datatable-container">
<form method="post" action="/exercices">
Type : <input type="text" name="type"/>
Intensité : <input type="text" name="intensite"/>
Date : <input type="text" name="date"/>
<button class="btn btn-primary btn-mrg" id="btnNavbarSearch" type="submit">Ajouter l'exercice</button>
</form>
<table id="datatablesSimple" class="datatable-table">
<thead>
<tr>
<th>Date</th>
<th>Heure de début</th>
<th>Heure de fin</th>
<th>Type</th>
<th>effort ressenti</th>
<th>Variabilité</th>
<th>Variance</th>
<th>Ecart type</th>
<th>Moyenne</th>
<th>Maximum</th>
<th>Minimum</th>
<th>Temperature moyenne</th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th>Date</th>
<th>Heure de début</th>
<th>Heure de fin</th>
<th>Type</th>
<th>effort ressenti</th>
<th>Variabilité</th>
<th>Variance</th>
<th>Ecart type</th>
<th>Moyenne</th>
<th>Maximum</th>
<th>Minimum</th>
<th>Temperature moyenne</th>
</tr><tr></tr>
</tfoot>
<tbody>
{% for analyze in analyzes %}
<tr>
<td>{{analyze.date}}</td>
<td>{{analyze.heureDebut}}</td>
<td>{{analyze.heureFin}}</td>
<td>{{analyze.type}}</td>
<td>{{analyze.effortRessenti}}</td>
<td>{{analyze.variabilite}}</td>
<td>{{analyze.variance}}</td>
<td>{{analyze.ecartType}}</td>
<td>{{analyze.moyenne}} Bpm</td>
<td>{{analyze.max}} Bpm</td>
<td>{{analyze.min}} Bpm</td>
<td>{{analyze.temperature}} °C</td>
{# <td><a href="{{ path('analyze_details', {'id': analyze.id}) }}">En savoir plus</a></td>#}
<td><a href="/analyses">En savoir plus</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<h1>{{responce}}</h1>
{% endblock %}
{% block script %}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
<script src="js/scripts.js"></script>
<script src="https://cdn.jsdelivr.net/npm/simple-datatables@7.1.2/dist/umd/simple-datatables.min.js" crossorigin="anonymous"></script>
<script src="js/datatables-simple-demo.js"></script>
{% endblock %}

@ -12,7 +12,7 @@
<div class="container-fluid px-4">
<h1 class="mt-4">Liste d'ami</h1>
<ol class="breadcrumb mb-4">
<li class="breadcrumb-item"><a href="/">Accueil</a></li>
<li class="breadcrumb-item"><a href="/home">Accueil</a></li>
<li class="breadcrumb-item active">Ami</li>
</ol>

@ -12,7 +12,7 @@
<div class="container-fluid px-4">
<h1 class="mt-4">Coaching</h1>
<ol class="breadcrumb mb-4">
<li class="breadcrumb-item"><a href="/">Accueil</a></li>
<li class="breadcrumb-item"><a href="/home">Accueil</a></li>
<li class="breadcrumb-item active">Coaching</li>
</ol>

@ -4,63 +4,47 @@
{% block css %}{{css}}{% endblock %}
{% block title %}Analyses - HearthTrack{% endblock %}
{% block title %}Exercices - HearthTrack{% endblock %}
{% block user %}{{user}} - {{role}}{% endblock %}
{% block body %}
<div class="container-fluid px-4">
<h1 class="mt-4">Analyses</h1>
<h1 class="mt-4">Exercices</h1>
<ol class="breadcrumb mb-4">
<li class="breadcrumb-item"><a href="/">Accueil</a></li>
<li class="breadcrumb-item active">Analyses</li>
<li class="breadcrumb-item"><a href="/home">Accueil</a></li>
<li class="breadcrumb-item active">Exercices</li>
</ol>
<div class="card-body">
<div class="datatable-container">
<table id="datatablesSimple" class="datatable-table">
<thead>
<tr>
<th>Date</th>
<th>Type</th>
<th>BMP</th>
<th>KM/H</th>
<th>Distance</th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th>Date</th>
<th>Type</th>
<th>BPM</th>
<th>KM/H</th>
<th>Distance</th>
</tr><tr></tr>
</tfoot>
<tbody>
<form method="post" action="/exercices">
Type : <input type="text" name="type"/>
Intensité : <input type="text" name="intensite"/>
Date : <input type="text" name="date"/>
<button class="btn btn-primary btn-mrg" id="btnNavbarSearch" type="submit">Ajouter l'exercice</button>
</form>
</div>
{% for analyze in analyzes %}
<tr>
<td>{{analyze.date}}</td>
<td>{{analyze.heureDebut}}</td>
<td>{{analyze.heureFin}}</td>
<td>{{analyze.type}}</td>
<td>{{analyze.bpm}}</td>
<td>{{analyze.kmh}} Km/H</td>
<td>{{analyze.distance}} Km</td>
<td><a href="#about">En savoir plus</a></td>
<td>{{analyze.effortRessenti}}</td>
<td>{{analyze.variabilite}}</td>
<td>{{analyze.variance}}</td>
<td>{{analyze.ecartType}}</td>
<td>{{analyze.moyenne}} Bpm</td>
<td>{{analyze.max}} Bpm</td>
<td>{{analyze.min}} Bpm</td>
<td>{{analyze.temperature}} °C</td>
<td><a href="/analyses">En savoir plus</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block script %}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
<script src="js/scripts.js"></script>
<script src="https://cdn.jsdelivr.net/npm/simple-datatables@7.1.2/dist/umd/simple-datatables.min.js" crossorigin="anonymous"></script>
<script src="js/datatables-simple-demo.js"></script>
<h1>{{responce}}</h1>
{% endblock %}

@ -13,7 +13,7 @@
<div class="container-fluid px-4">
<h1 class="mt-4">Coaching</h1>
<ol class="breadcrumb mb-4">
<li class="breadcrumb-item"><a href="/">Accueil</a></li>
<li class="breadcrumb-item"><a href="/home">Accueil</a></li>
<li class="breadcrumb-item active">Coaching</li>
</ol>
<style>.btn-mrg{margin:15px; margin-left:83%}</style>

@ -9,10 +9,11 @@
{% block user %}{{user}} - {{role}}{% endblock %}
{% block body %}
<div class="container-fluid px-4">
<h1 class="mt-4">Exercices</h1>
<ol class="breadcrumb mb-4">
<li class="breadcrumb-item"><a href="/">Accueil</a></li>
<li class="breadcrumb-item"><a href="/home">Accueil</a></li>
<li class="breadcrumb-item active">Exercices</li>
</ol>
<style>.btn-mrg{margin:15px; margin-left:85%}</style>
@ -31,11 +32,32 @@
</tr>
</thead>
<tbody>
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
{% for exo in exos %}
<tr>
<td>{{ exo.date }}</td>
<td>{{ exo.description }}</td>
<td>{{exo.location}}</td>
<td>
<div id="map-{{ loop.index }}"
data-lat=45.758285982369415
data-lng=3.110223414416445
style="height: 300px; width: 650px;"></div>
<script>
document.addEventListener("DOMContentLoaded", function() {
var map{{ loop.index }} = L.map('map-{{ loop.index }}').setView([45.75771709151474, 3.113484980409329], 14);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map{{ loop.index }});
var marker{{ loop.index }} = L.marker([45.75771709151474, 3.113484980409329]).addTo(map{{ loop.index }});
marker{{ loop.index }}.bindPopup(`
<strong>Date:</strong> {{ exo.date }}<br>
<strong>Description:</strong> {{ exo.description }}<br>
<strong>Feedback:</strong> {{ exo.feedback }}
`);
});
</script>
</td>
<td>{{ exo.feedback }}</td>
</tr>
{% endfor %}

@ -12,7 +12,7 @@
<div class="container-fluid px-4">
<h1 class="mt-4">Liste d'ami</h1>
<ol class="breadcrumb mb-4">
<li class="breadcrumb-item"><a href="/">Accueil</a></li>
<li class="breadcrumb-item"><a href="/home">Accueil</a></li>
<li class="breadcrumb-item active">Ami</li>
</ol>
<style>.btn-mrg{margin:15px; margin-left:87%}</style>

@ -23,14 +23,16 @@
<th>Lu</th>
<th>De:</th>
<th>Description</th>
<th>Date</th>
</tr>
</thead>
<tbody>
{% for mail in mails %}
<tr>
<td><img src="/assets/img/verif/{{mail.idnotif}}.png" width="25px" height="25px"></td>
<td>{{mail.urgence}} {{mail.statut}}</td>
<td>{{mail.idathlete}}</td>
<td><a href="#">{{mail.message}}</a></td>
<td>{{ mail.date }}</td>
</tr>
{% endfor %}
</tbody>

@ -12,7 +12,7 @@
<div class="container-fluid px-4">
<h1 class="mt-4">Profile</h1>
<ol class="breadcrumb mb-4">
<li class="breadcrumb-item"><a href="/">Accueil</a></li>
<li class="breadcrumb-item"><a href="/home">Accueil</a></li>
<li class="breadcrumb-item active">Profile</li>
</ol>
<div class="row">

@ -12,7 +12,7 @@
<div class="container-fluid px-4">
<h1 class="mt-4">Paramètres</h1>
<ol class="breadcrumb mb-4">
<li class="breadcrumb-item"><a href="/">Accueil</a></li>
<li class="breadcrumb-item"><a href="/home">Accueil</a></li>
<li class="breadcrumb-item active">Paramètres</li>
</ol>
<div class="row">

@ -42,7 +42,7 @@ class ActivityEntity {
return $this->effortRessenti;
}
public function getVariabilite() {
public function getVariability() {
return $this->variabilite;
}

@ -1,7 +1,9 @@
<?php
namespace Database;
use DateTime;
use Model\Activity;
use Shared\Log;
class ActivityMapper {
public function activitySqlToEntity(array $data):array
@ -11,61 +13,60 @@ class ActivityMapper {
foreach ($data as $activityData) {
$activity = new ActivityEntity();
if (isset($activityData['idActivity'])) {
$activity->setIdActivity($data['idActivity']);
if (isset($activityData['idactivite'])) {
$activity->setIdActivity($activityData['idactivite']);
}
if (isset($activityData['type'])) {
$activity->setType($data['type']);
$activity->setType($activityData['type']);
}
if (isset($activityData['date'])) {
$activity->setDate($data['date']);
$activity->setDate($activityData['date']);
}
if (isset($activityData['heureDebut'])) {
$activity->setHeureDebut($data['heureDebut']);
if (isset($activityData['heurededebut'])) {
$activity->setHeureDebut($activityData['heurededebut']);
}
if (isset($activityData['heureFin'])) {
$activity->setHeureFin($data['heureFin']);
if (isset($activityData['heuredefin'])) {
$activity->setHeureFin($activityData['heuredefin']);
}
if (isset($activityData['effortRessenti'])) {
$activity->setEffortRessenti($data['effortRessenti']);
if (isset($activityData['effortressent'])) {
$activity->setEffortRessenti($activityData['effortressent']);
}
if (isset($activityData['variabilite'])) {
$activity->setVariabilite($data['variabilite']);
$activity->setVariabilite($activityData['variabilite']);
}
if (isset($activityData['variance'])) {
$activity->setVariance($data['variance']);
$activity->setVariance($activityData['variance']);
}
if (isset($activityData['ecartType'])) {
$activity->setEcartType($data['ecartType']);
if (isset($activityData['ecarttype'])) {
$activity->setEcartType($activityData['ecarttype']);
}
if (isset($activityData['moyenne'])) {
$activity->setMoyenne($data['moyenne']);
$activity->setMoyenne($activityData['moyenne']);
}
if (isset($activityData['maximum'])) {
$activity->setMaximum($data['maximum']);
$activity->setMaximum($activityData['maximum']);
}
if (isset($activityData['minimum'])) {
$activity->setMinimum($data['minimum']);
$activity->setMinimum($activityData['minimum']);
}
if (isset($activityData['temperatureMoyenne'])) {
$activity->setTemperatureMoyenne($data['temperatureMoyenne']);
if (isset($activityData['temperaturemoyenne'])) {
$activity->setTemperatureMoyenne($activityData['temperaturemoyenne']);
}
$activityEntities[] = $activity;
}
return $activityEntities;
}
@ -73,21 +74,29 @@ class ActivityMapper {
* @throws \Exception
*/
public function ActivityEntityToModel(ActivityEntity $activiteEntity):Activity {
$date = new DateTime($activiteEntity->getDate());
$heureDebut = new \DateTime($activiteEntity->getHeureDebut());
$heureFin = new \DateTime($activiteEntity->getHeureFin());
$effortRessenti = intval($activiteEntity->getEffortRessenti());
$variability = floatval($activiteEntity->getVariability());
$variance = floatval($activiteEntity->getVariance());
$ecartType = floatval($activiteEntity->getEcartType());
$act = new Activity(
$activiteEntity->getIdActivity(),
$activiteEntity->getType(),
$activiteEntity->getDate(),
$activiteEntity->getHeureDebut(),
$activiteEntity->getHeureFin(),
$activiteEntity->getEffortRessenti(),
$activiteEntity->getVariabilite(),
$activiteEntity->getVariance(),
$activiteEntity->getEcartType(),
$date,
$heureDebut,
$heureFin,
$effortRessenti,
$variability,
$variance,
$ecartType,
$activiteEntity->getMoyenne(),
$activiteEntity->getMaximum(),
$activiteEntity->getMinimum(),
$activiteEntity->getTemperatureMoyenne()
$activiteEntity->getTemperatureMoyenne(),
'false'
);
return $act;
@ -103,7 +112,7 @@ class ActivityMapper {
$act->setHeureDebut($act->getHeureDebut());
$act->setHeureFin($act->getHeureFin());
$act->setEffortRessenti($act->getEffortRessenti());
$act->setVariabilite($act->getVariabilite());
$act->setVariabilite($act->getVariability());
$act->setVariance($act->getVariance());
$act->setEcartType($act->getEcartType());
$act->setMoyenne($act->getMoyenne());

@ -6,6 +6,7 @@ class AthleteEntity {
private $idAthlete;
private $nom;
private $prenom;
private $username;
private $email;
private $sexe;
private $taille;
@ -27,6 +28,10 @@ class AthleteEntity {
return $this->prenom;
}
public function getUsername(){
return $this->username;
}
public function getEmail() {
return $this->email;
}
@ -55,6 +60,7 @@ class AthleteEntity {
return $this->isCoach;
}
// Setters
public function setIdAthlete($idAthlete) {
$this->idAthlete = $idAthlete;
@ -68,6 +74,10 @@ class AthleteEntity {
$this->prenom = $prenom;
}
public function setUsername($username){
$this->username = $username;
}
public function setEmail($email) {
$this->email = $email;
}

@ -37,21 +37,21 @@ class AthleteGateway {
public function getAthleteByFirstName(string $firstName): array
{
$query = "SELECT * FROM Athlete WHERE prenom = :firstName AND isCoach=FALSE";
$params = [':firstName' => [$firstName, PDO::PARAM_STR]];
$params = [':firstName' => $firstName];
return $this->connection->executeWithErrorHandling($query, $params);
}
public function getAthleteByEmail(string $email): array
{
$query = "SELECT * FROM Athlete WHERE email = :email AND isCoach=FALSE";
$params = [':email' => [$email, PDO::PARAM_STR]];
$params = [':email' => $email];
return $this->connection->executeWithErrorHandling($query, $params);
}
public function getAthleteByGender(string $gender): array
{
$query = "SELECT * FROM Athlete WHERE sexe = :gender AND isCoach=FALSE";
$params = [':gender' => [$gender, PDO::PARAM_STR]];
$params = [':gender' => $gender];
return $this->connection->executeWithErrorHandling($query, $params);
}

@ -26,6 +26,10 @@ class AthleteMapper {
$athlete->setPrenom($athleteData['prenom']);
}
if (isset($athleteData['username'])) {
$athlete->setUsername($athleteData['username']);
}
if (isset($athleteData['email'])) {
$athlete->setEmail($athleteData['email']);
}
@ -63,16 +67,19 @@ class AthleteMapper {
public function athleteEntityToModel(AthleteEntity $athleteEntity): User {
$role = new Athlete(); // Utilisez la classe Athlete
$date = new DateTime($athleteEntity->getDateNaissance());
$poids = floatval($athleteEntity->getPoids());
$taille = floatval($athleteEntity->getTaille());
$user = new User(
$athleteEntity->getIdAthlete(),
$athleteEntity->getNom(),
$athleteEntity->getPrenom(),
"myUsername",
$athleteEntity->getUsername(),
$athleteEntity->getEmail(),
$athleteEntity->getMotDePasse(),
$athleteEntity->getSexe(),
$athleteEntity->getTaille(),
$athleteEntity->getPoids(),
$taille,
$poids,
$date,
$role
);
@ -86,6 +93,7 @@ class AthleteMapper {
$ath->setIdAthlete($user->getId());
$ath->setNom($user->getNom());
$ath->setPrenom($user->getPrenom());
$ath->setUsername($user->getUsername());
$ath->setEmail($user->getEmail());
$ath->setSexe($user->getSexe());
$ath->setTaille($user->getTaille());

@ -44,26 +44,7 @@ class Connexion extends \PDO {
}
public function getResults(): array {
$results = $this->stmt->fetchAll(\PDO::FETCH_ASSOC);
// Convertissez les colonnes "taille" et "poids" en nombres
foreach ($results as &$row) {
if($row['identrainement']) {
$row['identrainement'] = floatval(($row['identrainement']));
}
if($row['latitude']) {
$row['latitude'] = floatval(($row['latitude']));
}
if($row['longitude']) {
$row['longitude'] = floatval(($row['longitude']));
}
if($row['taille']) {
$row['taille'] = floatval($row['taille']);
}
if($row['poids']) {
$row['poids'] = floatval($row['poids']);
}
}
return $results;
return $this->stmt->fetchAll(\PDO::FETCH_ASSOC);
}
}
?>

@ -52,11 +52,15 @@ class EntrainementMapper
public function entrainementEntityToModel(EntrainementEntity $entrainementEntity): Training {
$date = new DateTime($entrainementEntity->getDate());
$idTraining = intval($entrainementEntity->getIdEntrainement());
$latitude = floatval($entrainementEntity->getLatitude());
$longitude = floatval($entrainementEntity->getLongitude());
return new Training(
$entrainementEntity->getIdEntrainement(),
$idTraining,
$date,
$entrainementEntity->getLatitude(),
$entrainementEntity->getLongitude(),
$latitude,
$longitude,
$entrainementEntity->getDescription(),
$entrainementEntity->getFeedback()
);

@ -12,6 +12,7 @@ class NotificationEntity
private $statut;
private $urgence;
private $idAthlete;
public function getIdNotif(): int
{
return $this->idNotif;

@ -2,6 +2,8 @@
namespace Database;
use Shared\Log;
class NotificationGateway
{
private Connexion $connection;
@ -16,4 +18,10 @@ class NotificationGateway
$res = $this->connection->executeWithErrorHandling($query);
return $res;
}
public function addNotification(NotificationEntity $notif){
$query = "INSERT INTO Notification (idnotif, message, date, statut, urgence, athleteid) VALUES (:idNotif, :message, :date, :statut, :urgence, :idAthlete)";
$params = [':idNotif'=>$notif->getIdNotif(), ':message'=>$notif->getMessage(), ':date'=>$notif->getDate(), ':statut'=>$notif->getStatut(), ':urgence'=>$notif->getUrgence(), ':idAthlete'=>$notif->getIdAthlete()];
return $this->connection->executeWithErrorHandling($query, $params);
}
}

@ -64,7 +64,7 @@ class NotificationMapper
$notif = new NotificationEntity();
$notif->setIdNotif($notification->getId());
$notif->setMessage($notification->getMessage());
$notif->setDate($notification->getDate());
$notif->setDate($notification->getDate()->format('Y-m-d H:i:s'));
$notif->setStatut($notification->getStatut());
$notif->setUrgence($notification->getUrgence());
$notif->setIdAthlete($notification->getToUserId());

@ -53,6 +53,7 @@ class Activity
* @throws \Exception Si l'effort ressenti n'est pas compris entre 0 et 5.
*/
public function __construct(
int $idActivity,
String $type,
\DateTime $date,
\DateTime $heureDebut,
@ -67,7 +68,7 @@ class Activity
float $avrTemperature,
bool $hasPause
) {
$this->idActivity = self::generateId();
$this->idActivity = $idActivity;
$this->type = $type;
$this->date = $date;
$this->heureDebut = $heureDebut;

@ -9,7 +9,7 @@ class Notification
private int $idNotif;
private string $message;
private \DateTime $date;
private string $statut;
private bool $statut;
private string $urgence;
private int $toUserId;
/**

@ -2,6 +2,7 @@
namespace Stub;
use DateTime;
use Repository\INotificationRepository;
use Model\Notification;
@ -10,13 +11,13 @@ class NotificationRepository implements INotificationRepository
private $notifications = []; // Array to store notifications
public function __construct()
{
$date = DateTime::createFromFormat('d/m/Y', date('d/m/Y'));
// Initialize with some sample notifications for user IDs 1, 2, and 3
$this->notifications[] = new Notification(1, 'info', 'Welcome to our service!');
$this->notifications[] = new Notification(2, 'alert', 'Your subscription is about to expire.');
$this->notifications[] = new Notification(3, 'info', 'New features available.');
$this->notifications[] = new Notification(1, 'reminder', 'Dont forget your upcoming appointment.');
$this->notifications[] = new Notification(2, 'update', 'Service update completed.');
// Add more notifications as needed
$this->notifications[] = new Notification(1, 'info', $date,'Welcome to our service!', '1', 1);
$this->notifications[] = new Notification(2, 'info', $date,'Welcome to our service!', '1', 1);
$this->notifications[] = new Notification(3, 'info', $date,'Welcome to our service!', '1', 1);
$this->notifications[] = new Notification(1, 'info', $date,'Welcome to our service!', '1', 1);
$this->notifications[] = new Notification(2, 'info', $date,'Welcome to our service!', '1', 1);
}
public function getItemById(int $id)
{

Loading…
Cancel
Save