Compare commits
107 Commits
After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 2.0 MiB |
@ -0,0 +1,17 @@
|
||||
FROM php:8.2-fpm
|
||||
# Installation de dépendances nécessaires pour Composer
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
unzip
|
||||
|
||||
# Installation de Composer
|
||||
# TODO : should use a image with composer install
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
|
||||
RUN docker-php-ext-install pdo pdo_mysql
|
||||
|
||||
COPY . /var/www/
|
||||
|
||||
WORKDIR /var/www/
|
||||
|
||||
RUN composer install
|
@ -1,19 +1,28 @@
|
||||
server {
|
||||
listen 80;
|
||||
index index.php index.html index.htm;
|
||||
root /usr/share/nginx/html;
|
||||
index index.php;
|
||||
root /var/www/public;
|
||||
error_page 404 /index.php;
|
||||
|
||||
location ~ ^/(images|javascript|js|css|flash|media|static)/ {
|
||||
root /var/www/public;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass web:9000; # service name defined in docker-compose.yml file like web
|
||||
fastcgi_param REQUEST_METHOD $request_method;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
}
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
try_files $uri /index.php;
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace Database;
|
||||
|
||||
class AthleteEntity {
|
||||
private $idAthlete;
|
||||
private $nom;
|
||||
private $prenom;
|
||||
private $email;
|
||||
private $sexe;
|
||||
private $taille;
|
||||
private $poids;
|
||||
private $motDePasse;
|
||||
private $dateNaissance;
|
||||
|
||||
// Getters
|
||||
public function getIdAthlete() {
|
||||
return $this->idAthlete;
|
||||
}
|
||||
|
||||
public function getNom() {
|
||||
return $this->nom;
|
||||
}
|
||||
|
||||
public function getPrenom() {
|
||||
return $this->prenom;
|
||||
}
|
||||
|
||||
public function getEmail() {
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function getSexe() {
|
||||
return $this->sexe;
|
||||
}
|
||||
|
||||
public function getTaille() {
|
||||
return $this->taille;
|
||||
}
|
||||
|
||||
public function getPoids() {
|
||||
return $this->poids;
|
||||
}
|
||||
|
||||
public function getMotDePasse() {
|
||||
return $this->motDePasse;
|
||||
}
|
||||
|
||||
public function getDateNaissance() {
|
||||
return $this->dateNaissance;
|
||||
}
|
||||
|
||||
// Setters
|
||||
public function setIdAthlete($idAthlete) {
|
||||
$this->idAthlete = $idAthlete;
|
||||
}
|
||||
|
||||
public function setNom($nom) {
|
||||
$this->nom = $nom;
|
||||
}
|
||||
|
||||
public function setPrenom($prenom) {
|
||||
$this->prenom = $prenom;
|
||||
}
|
||||
|
||||
public function setEmail($email) {
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
public function setSexe($sexe) {
|
||||
$this->sexe = $sexe;
|
||||
}
|
||||
|
||||
public function setTaille($taille) {
|
||||
$this->taille = $taille;
|
||||
}
|
||||
|
||||
public function setPoids($poids) {
|
||||
$this->poids = $poids;
|
||||
}
|
||||
|
||||
public function setMotDePasse($motDePasse) {
|
||||
$this->motDePasse = $motDePasse;
|
||||
}
|
||||
|
||||
public function setDateNaissance($dateNaissance) {
|
||||
$this->dateNaissance = $dateNaissance;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace Database;
|
||||
use \PDO;
|
||||
|
||||
class AthleteGateway {
|
||||
private $connection;
|
||||
|
||||
public function __construct(Connexion $connection) {
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
public function getAthlete() {
|
||||
$query = "SELECT * FROM Athlete";
|
||||
return $this->connection->executeWithErrorHandling($query);
|
||||
}
|
||||
|
||||
public function getAthleteById(int $userId) {
|
||||
$query = "SELECT * FROM Athlete WHERE idAthlete = :id";
|
||||
$params = [':id' => [$userId, PDO::PARAM_INT]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getAthleteByName(string $name) {
|
||||
$query = "SELECT * FROM Athlete WHERE nom = :name";
|
||||
$params = [':name' => [$name, PDO::PARAM_STR]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getAthleteByFirstName(string $firstName) {
|
||||
$query = "SELECT * FROM Athlete WHERE prenom = :firstName";
|
||||
$params = [':firstName' => [$firstName, PDO::PARAM_STR]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getAthleteByEmail(string $email) {
|
||||
$query = "SELECT * FROM Athlete WHERE email = :email";
|
||||
$params = [':email' => [$email, PDO::PARAM_STR]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getAthleteByGender(string $gender) {
|
||||
$query = "SELECT * FROM Athlete WHERE sexe = :gender";
|
||||
$params = [':gender' => [$gender, PDO::PARAM_STR]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getAthleteByHeight(int $height) {
|
||||
$query = "SELECT * FROM Athlete WHERE taille = :height";
|
||||
$params = [':height' => [$height, PDO::PARAM_INT]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getAthleteByWeight(int $weight) {
|
||||
$query = "SELECT * FROM Athlete WHERE poids = :weight";
|
||||
$params = [':weight' => [$weight, PDO::PARAM_INT]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getAthleteByBirthDate(string $birthdate) {
|
||||
$query = "SELECT * FROM Athlete WHERE dateNaissance = :birthdate";
|
||||
$params = [':birthdate' => [$birthdate, PDO::PARAM_STR]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function addAthlete(AthleteEntity $athlete) {
|
||||
$query = "INSERT INTO Athlete (nom, prenom, email, sexe, taille, poids, motDePasse, dateNaissance)
|
||||
VALUES (:nom, :prenom, :email, :sexe, :taille, :poids, :motDePasse, :dateNaissance)";
|
||||
|
||||
$params = [
|
||||
':nom' => $athlete->getNom(),
|
||||
':prenom' => $athlete->getPrenom(),
|
||||
':email' => $athlete->getEmail(),
|
||||
':sexe' => $athlete->getSexe(),
|
||||
':taille' => $athlete->getTaille(),
|
||||
':poids' => $athlete->getPoids(),
|
||||
':motDePasse' => $athlete->getMotDePasse(),
|
||||
':dateNaissance' => $athlete->getDateNaissance(),
|
||||
];
|
||||
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function updateAthlete(AthleteEntity $oldAthlete, AthleteEntity $newAthlete) {
|
||||
$query = "UPDATE Athlete
|
||||
SET nom = :nom, prenom = :prenom, email = :email, sexe = :sexe,
|
||||
taille = :taille, poids = :poids, motDePasse = :motDePasse, dateNaissance = :dateNaissance
|
||||
WHERE idAthlete = :idAthlete";
|
||||
|
||||
$params = [
|
||||
':idAthlete' => $oldAthlete->getIdAthlete(),
|
||||
':nom' => $newAthlete->getNom(),
|
||||
':prenom' => $newAthlete->getPrenom(),
|
||||
':email' => $newAthlete->getEmail(),
|
||||
':sexe' => $newAthlete->getSexe(),
|
||||
':taille' => $newAthlete->getTaille(),
|
||||
':poids' => $newAthlete->getPoids(),
|
||||
':motDePasse' => $newAthlete->getMotDePasse(),
|
||||
':dateNaissance' => $newAthlete->getDateNaissance(),
|
||||
];
|
||||
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function deleteAthlete(int $idAthlete) {
|
||||
$query = "DELETE FROM Athlete WHERE idAthlete = :idAthlete";
|
||||
|
||||
$params = [
|
||||
':idAthlete' => $idAthlete,
|
||||
];
|
||||
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Exemple d'utilisation
|
||||
//$dsn = "pgsql:host=localhost;port=5432;dbname=mydatabase;user=myuser;password=mypassword";
|
||||
//$connection = new Connection($dsn);
|
||||
//$gateway = new AthleteGateway($connection);
|
||||
|
||||
//$allAth = $gateway->getAthlete();
|
||||
//print_r($allAth);
|
||||
|
||||
//$singleAth = $gateway->getAthleteById(1);
|
||||
//print_r($singleAth);
|
||||
|
||||
?>
|
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace Database;
|
||||
use Model\User;
|
||||
use \PDO;
|
||||
use \DateTime;
|
||||
use Model\Role;
|
||||
use Model\Athlete;
|
||||
|
||||
class AthleteMapper {
|
||||
public function fromSqlToEntity(array $data): array {
|
||||
$athleteEntities = [];
|
||||
|
||||
foreach ($data as $athleteData) {
|
||||
$athlete = new AthleteEntity();
|
||||
|
||||
if (isset($athleteData['idAthlete'])) {
|
||||
$athlete->setIdAthlete($athleteData['idAthlete']);
|
||||
}
|
||||
|
||||
if (isset($athleteData['nom'])) {
|
||||
$athlete->setNom($athleteData['nom']);
|
||||
}
|
||||
|
||||
if (isset($athleteData['prenom'])) {
|
||||
$athlete->setPrenom($athleteData['prenom']);
|
||||
}
|
||||
|
||||
if (isset($athleteData['email'])) {
|
||||
$athlete->setEmail($athleteData['email']);
|
||||
}
|
||||
|
||||
if (isset($athleteData['sexe'])) {
|
||||
$athlete->setSexe($athleteData['sexe']);
|
||||
}
|
||||
|
||||
if (isset($athleteData['taille'])) {
|
||||
$athlete->setTaille($athleteData['taille']);
|
||||
}
|
||||
|
||||
if (isset($athleteData['poids'])) {
|
||||
$athlete->setPoids($athleteData['poids']);
|
||||
}
|
||||
|
||||
if (isset($athleteData['motDePasse'])) {
|
||||
$athlete->setMotDePasse($athleteData['motDePasse']);
|
||||
}
|
||||
|
||||
if (isset($athleteData['dateNaissance'])) {
|
||||
$athlete->setDateNaissance($athleteData['dateNaissance']);
|
||||
}
|
||||
|
||||
$athleteEntities[] = $athlete;
|
||||
}
|
||||
|
||||
return $athleteEntities;
|
||||
}
|
||||
|
||||
public function athleteEntityToModel(AthleteEntity $athleteEntity): User {
|
||||
$role = new Athlete(); // Utilisez la classe Athlete
|
||||
|
||||
$dateSpecifique = $athleteEntity->getDateNaissance();
|
||||
$date = new DateTime($dateSpecifique);
|
||||
|
||||
$user = new User(
|
||||
$athleteEntity->getIdAthlete(),
|
||||
$athleteEntity->getNom(),
|
||||
$athleteEntity->getPrenom(),
|
||||
$athleteEntity->getEmail(),
|
||||
$athleteEntity->getMotDePasse(),
|
||||
$athleteEntity->getSexe(),
|
||||
$athleteEntity->getTaille(),
|
||||
$athleteEntity->getPoids(),
|
||||
$date,
|
||||
$role
|
||||
);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function athleteToEntity(User $user):AthleteEntity{
|
||||
|
||||
$ath = new AthleteEntity();
|
||||
$ath->setIdAthlete($user->getId());
|
||||
$ath->setNom($user->getNom());
|
||||
$ath->setPrenom($user->getPrenom());
|
||||
$ath->setEmail($user->getEmail());
|
||||
$ath->setSexe($user->getSexe());
|
||||
$ath->setTaille($user->getTaille());
|
||||
$ath->setPoids($user->getPoids());
|
||||
$ath->setMotDePasse($user->getMotDePasse());
|
||||
$ath->setDateNaissance($user->getDateNaissance());
|
||||
|
||||
return $ath;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace Database;
|
||||
|
||||
class CoachEntity {
|
||||
private $idCoach;
|
||||
private $nom;
|
||||
private $prenom;
|
||||
private $email;
|
||||
private $sexe;
|
||||
private $taille;
|
||||
private $poids;
|
||||
private $motDePasse;
|
||||
private $dateNaissance;
|
||||
|
||||
// Getters
|
||||
public function getIdCoach() {
|
||||
return $this->idCoach;
|
||||
}
|
||||
|
||||
public function getNom() {
|
||||
return $this->nom;
|
||||
}
|
||||
|
||||
public function getPrenom() {
|
||||
return $this->prenom;
|
||||
}
|
||||
|
||||
public function getEmail() {
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function getSexe() {
|
||||
return $this->sexe;
|
||||
}
|
||||
|
||||
public function getTaille() {
|
||||
return $this->taille;
|
||||
}
|
||||
|
||||
public function getPoids() {
|
||||
return $this->poids;
|
||||
}
|
||||
|
||||
public function getMotDePasse() {
|
||||
return $this->motDePasse;
|
||||
}
|
||||
|
||||
public function getDateNaissance() {
|
||||
return $this->dateNaissance;
|
||||
}
|
||||
|
||||
// Setters
|
||||
public function setIdCoach($idCoach) {
|
||||
$this->idCoach = $idCoach;
|
||||
}
|
||||
|
||||
public function setNom($nom) {
|
||||
$this->nom = $nom;
|
||||
}
|
||||
|
||||
public function setPrenom($prenom) {
|
||||
$this->prenom = $prenom;
|
||||
}
|
||||
|
||||
public function setEmail($email) {
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
public function setSexe($sexe) {
|
||||
$this->sexe = $sexe;
|
||||
}
|
||||
|
||||
public function setTaille($taille) {
|
||||
$this->taille = $taille;
|
||||
}
|
||||
|
||||
public function setPoids($poids) {
|
||||
$this->poids = $poids;
|
||||
}
|
||||
|
||||
public function setMotDePasse($motDePasse) {
|
||||
$this->motDePasse = $motDePasse;
|
||||
}
|
||||
|
||||
public function setDateNaissance($dateNaissance) {
|
||||
$this->dateNaissance = $dateNaissance;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace Database;
|
||||
use \PDO;
|
||||
|
||||
class CoachGateway {
|
||||
private $connection;
|
||||
|
||||
public function __construct(Connexion $connection) {
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
public function getCoach() {
|
||||
$query = "SELECT * FROM Athlete WHERE isCoach = TRUE;";
|
||||
return $this->connection->executeWithErrorHandling($query);
|
||||
}
|
||||
|
||||
public function getCoachById(int $userId) {
|
||||
$query = "SELECT * FROM Athlete WHERE idAthlete = :id AND isCoach = TRUE";
|
||||
$params = [':id' => [$userId, PDO::PARAM_INT]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getCoachByName(string $name) {
|
||||
$query = "SELECT * FROM Athlete WHERE nom = :name AND isCoach = TRUE";
|
||||
$params = [':name' => [$name, PDO::PARAM_STR]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getCoachByFirstName(string $firstName) {
|
||||
$query = "SELECT * FROM Athlete WHERE prenom = :firstName AND isCoach = TRUE";
|
||||
$params = [':firstName' => [$firstName, PDO::PARAM_STR]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getCoachByEmail(string $email) {
|
||||
$query = "SELECT * FROM Athlete WHERE email = :email AND isCoach = TRUE";
|
||||
$params = [':email' => [$email, PDO::PARAM_STR]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getCoachByGender(string $gender) {
|
||||
$query = "SELECT * FROM Athlete WHERE sexe = :gender AND isCoach = TRUE";
|
||||
$params = [':gender' => [$gender, PDO::PARAM_STR]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getCoachByHeight(int $height) {
|
||||
$query = "SELECT * FROM Athlete WHERE taille = :height AND isCoach = TRUE";
|
||||
$params = [':height' => [$height, PDO::PARAM_INT]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getCoachByBirthDate(string $birthdate) {
|
||||
$query = "SELECT * FROM Athlete WHERE dateNaissance = :birthdate AND isCoach = TRUE";
|
||||
$params = [':birthdate' => [$birthdate, PDO::PARAM_STR]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function addCoach(CoachEntity $coach) {
|
||||
$query = "INSERT INTO Athlete (nom, prenom, email, sexe, taille, poids, motDePasse, dateNaissance, isCoach)
|
||||
VALUES (:nom, :prenom, :email, :sexe, :taille, :poids, :motDePasse, :dateNaissance, TRUE)";
|
||||
|
||||
$params = [
|
||||
':nom' => $coach->getNom(),
|
||||
':prenom' => $coach->getPrenom(),
|
||||
':email' => $coach->getEmail(),
|
||||
':sexe' => $coach->getSexe(),
|
||||
':taille' => $coach->getTaille(),
|
||||
':poids' => $coach->getPoids(),
|
||||
':motDePasse' => $coach->getMotDePasse(),
|
||||
':dateNaissance' => $coach->getDateNaissance(),
|
||||
];
|
||||
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function updateCoach(CoachEntity $oldCoach, CoachEntity $newCoach) {
|
||||
$query = "UPDATE Athlete
|
||||
SET nom = :nom, prenom = :prenom, email = :email, sexe = :sexe,
|
||||
taille = :taille, poids = :poids, motDePasse = :motDePasse, dateNaissance = :dateNaissance, isCoach = TRUE
|
||||
WHERE idCoach = :idCoach";
|
||||
|
||||
$params = [
|
||||
':idAthlete' => $oldCoach->getIdCoach(),
|
||||
':nom' => $newCoach->getNom(),
|
||||
':prenom' => $newCoach->getPrenom(),
|
||||
':email' => $newCoach->getEmail(),
|
||||
':sexe' => $newCoach->getSexe(),
|
||||
':taille' => $newCoach->getTaille(),
|
||||
':poids' => $newCoach->getPoids(),
|
||||
':motDePasse' => $newCoach->getMotDePasse(),
|
||||
':dateNaissance' => $newCoach->getDateNaissance(),
|
||||
];
|
||||
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function deleteCoach(int $idCoach) {
|
||||
$query = "DELETE FROM Athlete WHERE idAthlete = :idCoach";
|
||||
|
||||
$params = [
|
||||
':idCoach' => $idCoach,
|
||||
];
|
||||
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Database;
|
||||
use Model\User;
|
||||
use \PDO;
|
||||
use \DateTime;
|
||||
use Model\Role;
|
||||
use Model\Coach;
|
||||
|
||||
class CoachMapper {
|
||||
public function map(array $data) {
|
||||
$coach = new CoachEntity();
|
||||
$coach->setIdCoach($data['idCoach']);
|
||||
$coach->setNom($data['nom']);
|
||||
$coach->setPrenom($data['prenom']);
|
||||
$coach->setEmail($data['email']);
|
||||
$coach->setSexe($data['sexe']);
|
||||
$coach->setTaille($data['taille']);
|
||||
$coach->setPoids($data['poids']);
|
||||
$coach->setMotDePasse($data['motDePasse']);
|
||||
$coach->setDateNaissance($data['dateNaissance']);
|
||||
|
||||
return $coach;
|
||||
}
|
||||
|
||||
public function CoachEntityToModel(CoachEntity $coachEntity):User{
|
||||
$role = "Coach";
|
||||
|
||||
$user = new User(
|
||||
$coachEntity->getIdCoach(),
|
||||
$coachEntity->getNom(),
|
||||
$coachEntity->getPrenom(),
|
||||
$coachEntity->getEmail(),
|
||||
$coachEntity->getMotDePasse(),
|
||||
$coachEntity->getSexe(),
|
||||
$coachEntity->getTaille(),
|
||||
$coachEntity->getPoids(),
|
||||
$coachEntity->getDateNaissance(),
|
||||
$role
|
||||
);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function CoachToEntity(User $user):CoachEntity{
|
||||
|
||||
$coach = new CoachEntity();
|
||||
$coach->setIdCoach($user->getId());
|
||||
$coach->setNom($user->getNom());
|
||||
$coach->setPrenom($user->getPrenom());
|
||||
$coach->setEmail($user->getEmail());
|
||||
$coach->setSexe($user->getSexe());
|
||||
$coach->setTaille($user->getTaille());
|
||||
$coach->setPoids($user->getPoids());
|
||||
$coach->setMotDePasse($user->getMotDePasse());
|
||||
$coach->setDateNaissance($user->getDateNaissance());
|
||||
|
||||
return $coach;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Database;
|
||||
|
||||
class Connexion extends \PDO {
|
||||
private $stmt;
|
||||
|
||||
public function __construct(string $dsn,string $username, string $password) {
|
||||
try {
|
||||
parent::__construct($dsn,$username,$password);
|
||||
$this->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
|
||||
} catch (\PDOException $e) {
|
||||
// Log error or handle it as needed
|
||||
throw new \PDOException("Error connecting to the database: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function executeQuery(string $query, array $parameters = []): bool {
|
||||
$this->stmt = $this->prepare($query);
|
||||
//foreach ($parameters as $name => $value) {
|
||||
// $this->stmt->bindValue($name, $value[0], $value[1]);
|
||||
//}
|
||||
foreach ($parameters as $name => $value) {
|
||||
$bindValueResult = $this->stmt->bindValue($name, $value, \PDO::PARAM_STR);
|
||||
if (!$bindValueResult) {
|
||||
// Gérez l'erreur, par exemple, en lançant une exception.
|
||||
throw new \PDOException('Failed to bind value for parameter ' . $name);
|
||||
}
|
||||
}
|
||||
return $this->stmt->execute();
|
||||
}
|
||||
|
||||
public function executeWithErrorHandling(string $query, array $params = []): array {
|
||||
try {
|
||||
$this->beginTransaction();
|
||||
$this->executeQuery($query, $params);
|
||||
$this->commit();
|
||||
return $this->getResults();
|
||||
} catch (\PDOException $e) {
|
||||
$this->rollBack();
|
||||
throw new \PDOException('Unexpected error on database client: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getResults(): array {
|
||||
return $this->stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
}
|
||||
}
|
||||
?>
|
@ -0,0 +1,133 @@
|
||||
DROP TABLE IF EXISTS Athlete, Friendship, Notification, Statistique, Entrainement, Participe, SourceDonnee, Activite, FrequenceCardiaque CASCADE;
|
||||
|
||||
CREATE TABLE Athlete (
|
||||
idAthlete INT PRIMARY KEY,
|
||||
nom VARCHAR(255),
|
||||
prenom VARCHAR(255),
|
||||
email VARCHAR(255) UNIQUE,
|
||||
sexe CHAR(1),
|
||||
taille DECIMAL,
|
||||
poids DECIMAL,
|
||||
motDePasse VARCHAR(255),
|
||||
dateNaissance DATE,
|
||||
isCoach BOOLEAN
|
||||
);
|
||||
|
||||
CREATE TABLE Friendship (
|
||||
idAthlete1 INT,
|
||||
idAthlete2 INT,
|
||||
debut DATE,
|
||||
PRIMARY KEY (idAthlete1, idAthlete2),
|
||||
FOREIGN KEY (idAthlete1) REFERENCES Athlete(idAthlete),
|
||||
FOREIGN KEY (idAthlete2) REFERENCES Athlete(idAthlete)
|
||||
);
|
||||
|
||||
CREATE TABLE Notification (
|
||||
idNotif INT PRIMARY KEY,
|
||||
message TEXT,
|
||||
date DATE,
|
||||
statut BOOLEAN,
|
||||
urgence INT,
|
||||
athleteId INT,
|
||||
FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete)
|
||||
);
|
||||
|
||||
CREATE TABLE Statistique (
|
||||
idStatistique INT PRIMARY KEY,
|
||||
poids DECIMAL,
|
||||
fcMoyenne DECIMAL,
|
||||
fcMax DECIMAL,
|
||||
caloriesBruleesMoy DECIMAL,
|
||||
date DATE,
|
||||
athleteId INT,
|
||||
FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete)
|
||||
);
|
||||
|
||||
CREATE TABLE Entrainement (
|
||||
idEntrainement INT PRIMARY KEY,
|
||||
date DATE,
|
||||
description TEXT,
|
||||
latitude DECIMAL,
|
||||
longitude DECIMAL,
|
||||
feedback TEXT,
|
||||
athleteId INT,
|
||||
FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete)
|
||||
);
|
||||
|
||||
CREATE TABLE Participe (
|
||||
athleteId INT,
|
||||
entrainementId INT,
|
||||
PRIMARY KEY (athleteId, entrainementId),
|
||||
FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete),
|
||||
FOREIGN KEY (entrainementId) REFERENCES Entrainement(idEntrainement)
|
||||
);
|
||||
|
||||
CREATE TABLE SourceDonnee (
|
||||
idSource INT PRIMARY KEY,
|
||||
type VARCHAR(255),
|
||||
modele VARCHAR(255),
|
||||
precision2 DECIMAL,
|
||||
athleteId INT,
|
||||
FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete)
|
||||
);
|
||||
|
||||
CREATE TABLE Activite (
|
||||
idActivite INT PRIMARY KEY,
|
||||
type VARCHAR(255),
|
||||
date DATE,
|
||||
heureDeDebut TIME,
|
||||
heureDeFin TIME,
|
||||
effortRessent DECIMAL,
|
||||
variabilite DECIMAL,
|
||||
variance DECIMAL,
|
||||
ecartType DECIMAL,
|
||||
moyenne DECIMAL,
|
||||
maximum DECIMAL,
|
||||
minimum DECIMAL,
|
||||
temperatureMoyenne DECIMAL,
|
||||
athleteId INT,
|
||||
sourceId INT,
|
||||
FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete),
|
||||
FOREIGN KEY (sourceId) REFERENCES SourceDonnee(idSource)
|
||||
);
|
||||
|
||||
CREATE TABLE FrequenceCardiaque (
|
||||
idFc INT PRIMARY KEY,
|
||||
altitude DECIMAL,
|
||||
temps TIME,
|
||||
temperature DECIMAL,
|
||||
bpm INT,
|
||||
longitude DECIMAL,
|
||||
latitude DECIMAL,
|
||||
activiteId INT,
|
||||
FOREIGN KEY (activiteId) REFERENCES Activite(idActivite)
|
||||
);
|
||||
|
||||
INSERT INTO Athlete (idAthlete, nom, prenom, email, sexe, taille, poids, motDePasse, dateNaissance, isCoach) VALUES
|
||||
(1, 'Doe', 'John', 'john.doe@example.com', 'M', 1.80, 70, 'password123', '1990-01-01', FALSE),
|
||||
(2, 'Smith', 'Jane', 'jane.smith@example.com', 'F', 1.65, 60, 'password456', '1992-02-02', TRUE);
|
||||
|
||||
INSERT INTO Friendship (idAthlete1, idAthlete2, debut) VALUES
|
||||
(1, 2, '2023-01-01');
|
||||
|
||||
INSERT INTO Notification (idNotif, message, date, statut, urgence, athleteId) VALUES
|
||||
(1, 'Training session at 10 AM', '2023-03-10', TRUE, 1, 1);
|
||||
|
||||
INSERT INTO Statistique (idStatistique, poids, fcMoyenne, fcMax, caloriesBruleesMoy, date, athleteId) VALUES
|
||||
(1, 70, 80, 150, 500, '2023-03-10', 1);
|
||||
|
||||
INSERT INTO Entrainement (idEntrainement, date, description, latitude, longitude, feedback, athleteId) VALUES
|
||||
(1, '2023-03-12', 'Long run in the park', 40.7128, -74.0060, 'Good effort', 1);
|
||||
|
||||
INSERT INTO Participe (athleteId, entrainementId) VALUES
|
||||
(1, 1);
|
||||
|
||||
INSERT INTO SourceDonnee (idSource, type, modele, precision2, athleteId) VALUES
|
||||
(1, 'Heart Rate Monitor', 'HRM-Pro', 98.5, 1);
|
||||
|
||||
INSERT INTO Activite (idActivite, type, date, heureDeDebut, heureDeFin, effortRessent, variabilite, variance, ecartType, moyenne, maximum, minimum, temperatureMoyenne, athleteId, sourceId) VALUES
|
||||
(1, 'Running', '2023-03-10', '08:00:00', '09:00:00', 7, 0.5, 1, 0.1, 140, 160, 120, 20, 1, 1);
|
||||
|
||||
INSERT INTO FrequenceCardiaque (idFc, altitude, temps, temperature, bpm, longitude, latitude, activiteId) VALUES
|
||||
(1, 100, '08:15:00', 15, 130, -74.0060, 40.7128, 1);
|
||||
|
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 98 KiB |
Before Width: | Height: | Size: 586 B After Width: | Height: | Size: 692 B |
@ -0,0 +1,34 @@
|
||||
/*!
|
||||
* Start Bootstrap - New Age v6.0.7 (https://startbootstrap.com/theme/new-age)
|
||||
* Copyright 2013-2023 Start Bootstrap
|
||||
* Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-new-age/blob/master/LICENSE)
|
||||
*/
|
||||
//
|
||||
// Scripts
|
||||
//
|
||||
|
||||
window.addEventListener('DOMContentLoaded', event => {
|
||||
|
||||
// Activate Bootstrap scrollspy on the main nav element
|
||||
const mainNav = document.body.querySelector('#mainNav');
|
||||
if (mainNav) {
|
||||
new bootstrap.ScrollSpy(document.body, {
|
||||
target: '#mainNav',
|
||||
offset: 74,
|
||||
});
|
||||
};
|
||||
|
||||
// Collapse responsive navbar when toggler is visible
|
||||
const navbarToggler = document.body.querySelector('.navbar-toggler');
|
||||
const responsiveNavItems = [].slice.call(
|
||||
document.querySelectorAll('#navbarResponsive .nav-link')
|
||||
);
|
||||
responsiveNavItems.map(function (responsiveNavItem) {
|
||||
responsiveNavItem.addEventListener('click', () => {
|
||||
if (window.getComputedStyle(navbarToggler).display !== 'none') {
|
||||
navbarToggler.click();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@ -0,0 +1,34 @@
|
||||
/*!
|
||||
* Start Bootstrap - New Age v6.0.7 (https://startbootstrap.com/theme/new-age)
|
||||
* Copyright 2013-2023 Start Bootstrap
|
||||
* Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-new-age/blob/master/LICENSE)
|
||||
*/
|
||||
//
|
||||
// Scripts
|
||||
//
|
||||
|
||||
window.addEventListener('DOMContentLoaded', event => {
|
||||
|
||||
// Activate Bootstrap scrollspy on the main nav element
|
||||
const mainNav = document.body.querySelector('#mainNav');
|
||||
if (mainNav) {
|
||||
new bootstrap.ScrollSpy(document.body, {
|
||||
target: '#mainNav',
|
||||
offset: 74,
|
||||
});
|
||||
};
|
||||
|
||||
// Collapse responsive navbar when toggler is visible
|
||||
const navbarToggler = document.body.querySelector('.navbar-toggler');
|
||||
const responsiveNavItems = [].slice.call(
|
||||
document.querySelectorAll('#navbarResponsive .nav-link')
|
||||
);
|
||||
responsiveNavItems.map(function (responsiveNavItem) {
|
||||
responsiveNavItem.addEventListener('click', () => {
|
||||
if (window.getComputedStyle(navbarToggler).display !== 'none') {
|
||||
navbarToggler.click();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Router\Request\IRequest;
|
||||
use App\Router\Response\Response;
|
||||
use Database\ActivityGateway;
|
||||
use Database\ActivityMapper;
|
||||
use Database\Connexion;
|
||||
use Json\JsonSerializer;
|
||||
use Manager\UserManager;
|
||||
use Shared\Attributes\Route;
|
||||
use Shared\Log;
|
||||
|
||||
class ApiController extends BaseController
|
||||
{
|
||||
private UserManager $userMgr;
|
||||
public function __construct(UserManager $manager){
|
||||
parent::__construct();
|
||||
$this->userMgr = $manager;
|
||||
}
|
||||
#[Route(path: '/api/activities', name: 'api-activities', methods: ['GET'])]
|
||||
public function apiActivities(IRequest $request)
|
||||
{
|
||||
$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()), 'type' => $activity->getType(),
|
||||
'date' => $activity->getDate()->format("Y-m-d"), 'heureDebut' => $activity->getHeureDebut()->format("Y-m-d"), 'heureFin' => $activity->getHeureFin()->format("Y-m-d"),
|
||||
'effortRessenti' => $activity->getEffortRessenti(), 'variabilite' => $activity->getVariability(), 'variance' => $activity->getVariance(),
|
||||
'ecartType' => $activity->getStandardDeviation(), 'moyenne' => $activity->getAverage(),
|
||||
'max' => $activity->getMaximum(), 'min' => $activity->getMinimum(), 'temperature' => $activity->getAvrTemperature()];
|
||||
}
|
||||
|
||||
$jsonSerializer = new JsonSerializer();
|
||||
$jsonData = $jsonSerializer::serialize($listActivity);
|
||||
|
||||
$response = new Response();
|
||||
$response->setContent($jsonData);
|
||||
$response->setHeader('Content-Type', 'application/json');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
// cela ne trouve pas la methode avec la route '/api/activities/1'
|
||||
#[Route(path: '/api/activities/{id}', name: 'api-activities-by-id', methods: ['GET'])]
|
||||
public function apiActivityById(IRequest $request, int $id)
|
||||
{
|
||||
$activityGateway = new ActivityGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
|
||||
$listSearch = $activityGateway->getActivityById($id);
|
||||
Log::dd($listSearch);
|
||||
$map = new ActivityMapper();
|
||||
$activityGateway = $map->activitySqlToEntity($listSearch);
|
||||
$listActivity = [];
|
||||
foreach ($activityGateway as $entity) {
|
||||
$activity = $map->activityEntityToModel($entity);
|
||||
$listActivity[] = ['idactivity' => number_format($activity->getIdActivity()), 'type' => $activity->getType(),
|
||||
'date' => $activity->getDate()->format("Y-m-d"), 'heureDebut' => $activity->getHeureDebut()->format("Y-m-d"), 'heureFin' => $activity->getHeureFin()->format("Y-m-d"),
|
||||
'effortRessenti' => $activity->getEffortRessenti(), 'variabilite' => $activity->getVariability(), 'variance' => $activity->getVariance(),
|
||||
'ecartType' => $activity->getStandardDeviation(), 'moyenne' => $activity->getAverage(),
|
||||
'max' => $activity->getMaximum(), 'min' => $activity->getMinimum(), 'temperature' => $activity->getAvrTemperature()];
|
||||
}
|
||||
|
||||
$jsonSerializer = new JsonSerializer();
|
||||
$jsonData = $jsonSerializer::serialize($listActivity);
|
||||
|
||||
$response = new Response();
|
||||
$response->setContent($jsonData);
|
||||
$response->setHeader('Content-Type', 'application/json');
|
||||
// pour delete renvoyer 204 pour dire ok et supprimer
|
||||
// update 200
|
||||
|
||||
|
||||
return $response;
|
||||
}
|
||||
//
|
||||
// #[Route(path: '/api/activities', name: 'api-activities-post', methods: ['POST'])]
|
||||
// public function apiAddActivity(IRequest $request)
|
||||
// {
|
||||
// $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()), 'type' => $activity->getType(),
|
||||
// 'date' => $activity->getDate()->format("Y-m-d"), 'heureDebut' => $activity->getHeureDebut()->format("Y-m-d"), 'heureFin' => $activity->getHeureFin()->format("Y-m-d"),
|
||||
// 'effortRessenti' => $activity->getEffortRessenti(), 'variabilite' => $activity->getVariability(), 'variance' => $activity->getVariance(),
|
||||
// 'ecartType' => $activity->getStandardDeviation(), 'moyenne' => $activity->getAverage(),
|
||||
// 'max' => $activity->getMaximum(), 'min' => $activity->getMinimum(), 'temperature' => $activity->getAvrTemperature()];
|
||||
// }
|
||||
//
|
||||
// $jsonSerializer = new JsonSerializer();
|
||||
// $jsonData = $jsonSerializer::serialize($listActivity);
|
||||
//
|
||||
// $response = new Response();
|
||||
// $response->setContent($jsonData);
|
||||
// $response->setHeader('Content-Type', 'application/json');
|
||||
//
|
||||
// return $response;
|
||||
// }
|
||||
// #[Route(path: '/api/activities/{id}', name: 'api-activities-post', methods: ['DELETE'])]
|
||||
// public function apiDeleteActivity(IRequest $request, int $id)
|
||||
// {
|
||||
// $activityGateway = new ActivityGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
|
||||
// $listSearch = $activityGateway->removeActivityById($id);
|
||||
//
|
||||
// $response = new Response();
|
||||
// $response->setContent($jsonData);
|
||||
// $response->setHeader('Content-Type', 'application/json');
|
||||
//
|
||||
// return $response;
|
||||
// }
|
||||
// #[Route(path: '/api/activities/{id}', name: 'api-activities-post', methods: ['PUT'])]
|
||||
// public function apiUpdateActivity(IRequest $request, int $id)
|
||||
// {
|
||||
// $activityGateway = new ActivityGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
|
||||
// $listSearch = $activityGateway->updateActivity($id);
|
||||
//
|
||||
// $response = new Response();
|
||||
// $response->setContent($jsonData);
|
||||
// $response->setHeader('Content-Type', 'application/json');
|
||||
//
|
||||
// return $response;
|
||||
// }
|
||||
}
|
@ -1,36 +1,94 @@
|
||||
<?php
|
||||
|
||||
// namespace App\Controller;
|
||||
|
||||
// use App\Container;
|
||||
// use App\Router\Request\IRequest;
|
||||
// use App\Router\Response\Response;
|
||||
// use Shared\Attributes\Route;
|
||||
// use Twig\Environment;
|
||||
// use Data\Core\Preferences;
|
||||
// use Shared\Log;
|
||||
|
||||
// class HeartRateController extends BaseController
|
||||
// {
|
||||
|
||||
|
||||
// #[Route(path: '/import', name: 'import', methods: ['GET'])]
|
||||
// public function import(): Response
|
||||
// {
|
||||
// return $this->render('./page/import.html.twig',[
|
||||
// 'css' => $this->preference->getCookie(),
|
||||
// 'pp' => "test2",
|
||||
// 'user' => "Doe",
|
||||
// 'role' => "Athlète",
|
||||
// 'friendship' => [],
|
||||
// 'analyzes' => [],
|
||||
// 'mails' => [],
|
||||
// 'users' => [],
|
||||
// 'infoUser' => [],
|
||||
// 'exos' => [],
|
||||
// 'member' => []
|
||||
// ]);
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Container;
|
||||
use App\Router\Request\IRequest;
|
||||
use App\Router\Response\IResponse;
|
||||
use App\Router\Response\RedirectResponse;
|
||||
use App\Router\Response\Response;
|
||||
use Manager\ActivityManager;
|
||||
use Shared\Attributes\Route;
|
||||
use Twig\Environment;
|
||||
use Data\Core\Preferences;
|
||||
use Shared\Log;
|
||||
|
||||
class HeartRateController extends BaseController
|
||||
{
|
||||
private ActivityManager $activityMgr;
|
||||
|
||||
public function __construct(ActivityManager $manager)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->activityMgr = $manager;
|
||||
}
|
||||
|
||||
#[Route(path: '/import', name: 'import', methods: ['GET'])]
|
||||
public function import(): Response
|
||||
{
|
||||
return $this->render('./page/import.html.twig', [
|
||||
'css' => $this->preference->getCookie(),
|
||||
'pp' => "test2",
|
||||
'user' => "Doe",
|
||||
'role' => "Athlète",
|
||||
'friendship' => [],
|
||||
'analyzes' => [],
|
||||
'mails' => [],
|
||||
'users' => [],
|
||||
'infoUser' => [],
|
||||
'exos' => [],
|
||||
'member' => []
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route(path: '/upload', name: 'upload', methods: ['POST'])]
|
||||
public function uploadFile(string $activityType, int $effort, IRequest $req): IResponse
|
||||
{
|
||||
$error = $this->validateRequest($effort);
|
||||
if (!empty($error)) {
|
||||
return $this->renderError($error);
|
||||
}
|
||||
|
||||
$tmp_file = $_FILES['uploaded_file']['tmp_name'];
|
||||
if (!$this->isValidFile($tmp_file)) {
|
||||
return $this->renderError(['Failed to get file be sure that you provide the file']);
|
||||
}
|
||||
|
||||
$content = file_get_contents($tmp_file);
|
||||
try {
|
||||
|
||||
if ($this->activityMgr->uploadFile($activityType, 5, $content)) {
|
||||
return new RedirectResponse('/home');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->renderError([$e->getMessage()]);
|
||||
}
|
||||
|
||||
return $this->renderError(['Failed to save activity.']);
|
||||
}
|
||||
|
||||
private function validateRequest(int $effort): array
|
||||
{
|
||||
$error = [];
|
||||
if ($effort < 0 || $effort > 5) {
|
||||
$error[] = 'Invalid effort level.';
|
||||
}
|
||||
$fileExtension = pathinfo($_FILES['uploaded_file']['name'], PATHINFO_EXTENSION);
|
||||
if ($fileExtension !== 'fit') {
|
||||
$error[] = 'Invalid file type. Only .fit files are allowed.';
|
||||
}
|
||||
return $error;
|
||||
}
|
||||
|
||||
private function isValidFile(string $tmp_file): bool
|
||||
{
|
||||
return file_exists($tmp_file) && is_uploaded_file($tmp_file);
|
||||
}
|
||||
|
||||
private function renderError(array $error): Response
|
||||
{
|
||||
// Consolidez la logique de rendu ici
|
||||
return $this->render('./error/error.html.twig', ['title'=> "Failed" , "code" => 400, "name" => "error import", "descr" => $error[0] ], new Response('$error', 400));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,66 @@
|
||||
<?php
|
||||
|
||||
// namespace App\Controller;
|
||||
namespace App\Controller;
|
||||
|
||||
// use App\Container;
|
||||
// use App\Router\Request\IRequest;
|
||||
// use App\Router\Response\Response;
|
||||
// use App\Router\Response\IResponse;
|
||||
use App\Container;
|
||||
use App\Router\Request\IRequest;
|
||||
use App\Router\Response\Response;
|
||||
use Database\AthleteGateway;
|
||||
use Database\AthleteMapper;
|
||||
use Database\Connexion;
|
||||
use Database\NotificationGateway;
|
||||
use Database\NotificationMapper;
|
||||
use Shared\Attributes\Route;
|
||||
use Twig\Environment;
|
||||
use Data\Core\Preferences;
|
||||
use Shared\Log;
|
||||
|
||||
// use Shared\Attributes\Route;
|
||||
// use Twig\Environment;
|
||||
// use Data\Core\Preferences;
|
||||
// use Shared\Log;
|
||||
class SocialController extends BaseController
|
||||
{
|
||||
protected Preferences $preference;
|
||||
|
||||
public function __construct(){
|
||||
$this->preference = new Preferences();
|
||||
}
|
||||
|
||||
#[Route(path: '/notification', name: 'notification', methods: ['GET'])]
|
||||
public function mail(): Response
|
||||
{
|
||||
try {
|
||||
$notificationGateway = new NotificationGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
|
||||
$listSearch = $notificationGateway->getNotifications();
|
||||
$map = new NotificationMapper();
|
||||
$notificationEntity = $map->notificationSqlToEntity($listSearch);
|
||||
|
||||
// #[Route(path: '/coach', name: 'coach')]
|
||||
// class CoachController extends BaseController
|
||||
// {
|
||||
$listUsers = [];
|
||||
|
||||
foreach ($notificationEntity as $entity) {
|
||||
$notification = $map->notificationEntityToModel($entity);
|
||||
$listUsers[] = ['idnotif' => $notification->getId(), 'message' => $notification->getMessage(),
|
||||
'date' => $notification->getDate()->format("D j F Y"),'statut' => $notification->getStatut(), 'urgence' => $notification->getUrgence(),
|
||||
'idathlete' => $notification->getToUserId()];
|
||||
}
|
||||
|
||||
$response = $this->render('./page/notification.html.twig',[
|
||||
'css' => $this->preference->getCookie(),
|
||||
'pp' => "test2",
|
||||
'user' => "Doe",
|
||||
'role' => "Athlète",
|
||||
'friendship' => [],
|
||||
'analyzes' => [],
|
||||
'mails' => $listUsers,
|
||||
'users' => [],
|
||||
'infoUser' => [],
|
||||
'exos' => [],
|
||||
'member' => []
|
||||
]);
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
throw $th;
|
||||
return $this->render("notification.html.twig", ['tabError' => $taberror]);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1 +1,338 @@
|
||||
<a href="/log">Se connecter</button>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
||||
<meta name="description" content="index page du site web" />
|
||||
<meta name="author" content="PINAGOT Antoine" />
|
||||
<title>HeartTrack - Getting Started</title>
|
||||
<link rel="icon" type="image/x-icon" href="assets/favicon.ico" />
|
||||
<!-- Bootstrap icons-->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css" rel="stylesheet" />
|
||||
<!-- Google fonts-->
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||
<link href="https://fonts.googleapis.com/css2?family=Newsreader:ital,wght@0,600;1,600&display=swap"
|
||||
rel="stylesheet" />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Mulish:ital,wght@0,300;0,500;0,600;0,700;1,300;1,500;1,600;1,700&display=swap"
|
||||
rel="stylesheet" />
|
||||
<link href="https://fonts.googleapis.com/css2?family=Kanit:ital,wght@0,400;1,400&display=swap"
|
||||
rel="stylesheet" />
|
||||
<!-- Core theme CSS (includes Bootstrap)-->
|
||||
<link href="css/styles2.css" rel="stylesheet" />
|
||||
</head>
|
||||
|
||||
<body id="page-top">
|
||||
<!-- Navigation-->
|
||||
<nav class="navbar navbar-expand-lg navbar-light fixed-top shadow-sm" id="mainNav">
|
||||
<div class="container px-5">
|
||||
<a class="navbar-brand fw-bold" href="/">HeartTrack</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive"
|
||||
aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
|
||||
Menu
|
||||
<i class="bi-list"></i>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarResponsive">
|
||||
<ul class="navbar-nav ms-auto me-4 my-3 my-lg-0">
|
||||
<li class="nav-item"><a class="nav-link me-lg-3" href="/login">Se connecter</a></li>
|
||||
<li class="nav-item"><a class="nav-link me-lg-3" href="/register">S'inscire</a></li>
|
||||
</ul>
|
||||
<button class="btn btn-primary rounded-pill px-3 mb-2 mb-lg-0" data-bs-toggle="modal"
|
||||
data-bs-target="#feedbackModal">
|
||||
<span class="d-flex align-items-center">
|
||||
<i class="bi-chat-text-fill me-2"></i>
|
||||
<span class="small">Donnez votre avis</span>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<!-- Mashead header-->
|
||||
<header class="masthead">
|
||||
<div class="container px-5">
|
||||
<div class="row gx-5 align-items-center">
|
||||
<div class="col-lg-6">
|
||||
<!-- Mashead text and app badges-->
|
||||
<div class="mb-5 mb-lg-0 text-center text-lg-start">
|
||||
<h1 class="display-1 lh-1 mb-3">HeartTrack pour mobile !</h1>
|
||||
<p class="lead fw-normal text-muted mb-5">Une application pour suivre vos analyses en direct,
|
||||
est en cours de développement.</p>
|
||||
<!-- <div class="d-flex flex-column flex-lg-row align-items-center">
|
||||
<a class="me-lg-3 mb-4 mb-lg-0" href="#!"><img class="app-badge" src="assets/img/google-play-badge.svg" alt="..." /></a>
|
||||
<a href="#!"><img class="app-badge" src="assets/img/app-store-badge.svg" alt="..." /></a>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<!-- Masthead device mockup feature-->
|
||||
<div class="masthead-device-mockup">
|
||||
<svg class="circle" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<linearGradient id="circleGradient" gradientTransform="rotate(45)">
|
||||
<stop class="gradient-start-color" offset="0%"></stop>
|
||||
<stop class="gradient-end-color" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<circle cx="50" cy="50" r="50"></circle>
|
||||
</svg><svg class="shape-1 d-none d-sm-block" viewBox="0 0 240.83 240.83"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="-32.54" y="78.39" width="305.92" height="84.05" rx="42.03"
|
||||
transform="translate(120.42 -49.88) rotate(45)"></rect>
|
||||
<rect x="-32.54" y="78.39" width="305.92" height="84.05" rx="42.03"
|
||||
transform="translate(-49.88 120.42) rotate(-45)"></rect>
|
||||
</svg><svg class="shape-2 d-none d-sm-block" viewBox="0 0 100 100"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="50" cy="50" r="50"></circle>
|
||||
</svg>
|
||||
<div class="device-wrapper">
|
||||
<div class="device" data-device="iPhoneX" data-orientation="portrait" data-color="black">
|
||||
<div class="screen bg-black">
|
||||
<!-- PUT CONTENTS HERE:-->
|
||||
<!-- * * This can be a video, image, or just about anything else.-->
|
||||
<!-- * * Set the max width of your media to 100% and the height to-->
|
||||
<!-- * * 100% like the demo example below.-->
|
||||
<video muted="muted" autoplay="" loop="" style="max-width: 100%; height: 100%">
|
||||
<source src="assets/img/demo-screen.mp4" type="video/mp4" />
|
||||
</video>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<!-- Quote/testimonial aside-->
|
||||
<aside class="text-center bg-gradient-primary-to-secondary">
|
||||
<div class="container px-5">
|
||||
<div class="row gx-5 justify-content-center">
|
||||
<div class="col-xl-8">
|
||||
<div class="h2 fs-1 text-white mb-4">"Une solution gratuite pour analyser vos données de fréquences
|
||||
cardiaques !"</div>
|
||||
<img src="assets/img/tnw-logo.svg" alt="..." style="height: 3rem" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
<!-- App features section-->
|
||||
<section id="features">
|
||||
<div class="container px-5">
|
||||
<div class="row gx-5 align-items-center">
|
||||
<div class="col-lg-8 order-lg-1 mb-5 mb-lg-0">
|
||||
<div class="container-fluid px-5">
|
||||
<div class="row gx-5">
|
||||
<div class="col-md-6 mb-5">
|
||||
<!-- Feature item-->
|
||||
<div class="text-center">
|
||||
<i class="bi-phone icon-feature text-gradient d-block mb-3"></i>
|
||||
<h3 class="font-alt">Web/Mobile</h3>
|
||||
<p class="text-muted mb-0">Gardez les informations tant bien dans l'application que
|
||||
sur le site web avec la synchronisation des données !</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 mb-5">
|
||||
<!-- Feature item-->
|
||||
<div class="text-center">
|
||||
<i class="bi-cast icon-feature text-gradient d-block mb-3"></i>
|
||||
<h3 class="font-alt">Importez vos données</h3>
|
||||
<p class="text-muted mb-0">Importez vos données directement depuis un fichier .FIT !
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-5 mb-md-0">
|
||||
<!-- Feature item-->
|
||||
<div class="text-center">
|
||||
<i class="bi-gift icon-feature text-gradient d-block mb-3"></i>
|
||||
<h3 class="font-alt">Gratuit</h3>
|
||||
<p class="text-muted mb-0">Ce site et cette application sont entièrement gratuites !
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<!-- Feature item-->
|
||||
<div class="text-center">
|
||||
<i class="bi-patch-check icon-feature text-gradient d-block mb-3"></i>
|
||||
<h3 class="font-alt">Open Source</h3>
|
||||
<p class="text-muted mb-0">Ce projet est fait en Open Source, tout le monde peut y
|
||||
accéder !</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4 order-lg-0">
|
||||
<!-- Features section device mockup-->
|
||||
<div class="features-device-mockup">
|
||||
<svg class="circle" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<linearGradient id="circleGradient" gradientTransform="rotate(45)">
|
||||
<stop class="gradient-start-color" offset="0%"></stop>
|
||||
<stop class="gradient-end-color" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<circle cx="50" cy="50" r="50"></circle>
|
||||
</svg><svg class="shape-1 d-none d-sm-block" viewBox="0 0 240.83 240.83"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="-32.54" y="78.39" width="305.92" height="84.05" rx="42.03"
|
||||
transform="translate(120.42 -49.88) rotate(45)"></rect>
|
||||
<rect x="-32.54" y="78.39" width="305.92" height="84.05" rx="42.03"
|
||||
transform="translate(-49.88 120.42) rotate(-45)"></rect>
|
||||
</svg><svg class="shape-2 d-none d-sm-block" viewBox="0 0 100 100"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="50" cy="50" r="50"></circle>
|
||||
</svg>
|
||||
<div class="device-wrapper">
|
||||
<div class="device" data-device="iPhoneX" data-orientation="portrait" data-color="black">
|
||||
<div class="screen bg-black">
|
||||
<!-- PUT CONTENTS HERE:-->
|
||||
<!-- * * This can be a video, image, or just about anything else.-->
|
||||
<!-- * * Set the max width of your media to 100% and the height to-->
|
||||
<!-- * * 100% like the demo example below.-->
|
||||
<video muted="muted" autoplay="" loop="" style="max-width: 100%; height: 100%">
|
||||
<source src="assets/img/demo-screen.mp4" type="video/mp4" />
|
||||
</video>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<!-- Basic features section-->
|
||||
<section class="bg-light">
|
||||
<div class="container px-5">
|
||||
<div class="row gx-5 align-items-center justify-content-center justify-content-lg-between">
|
||||
<div class="col-12 col-lg-5">
|
||||
<h2 class="display-4 lh-1 mb-4">Fonctionnalité supplémentaire de notre application</h2>
|
||||
<p class="lead fw-normal text-muted mb-5 mb-lg-0">Notre application propose un service de coaching
|
||||
personnalisé en fonction du besoin que vous avez en tant qu'athelète. Vous pouvez aussi fournir
|
||||
un service de coaching aux autres utilisateurs en vous inscrivant en tant que coach sportif.</p>
|
||||
</div>
|
||||
<div class="col-sm-8 col-md-6">
|
||||
<div class="px-5 px-sm-0"><img class="img-fluid rounded-circle" src="./assets/img/bg1.png"
|
||||
alt="..." /></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<!-- Call to action section-->
|
||||
<section class="cta">
|
||||
<div class="cta-content">
|
||||
<div class="container px-5">
|
||||
<h2 class="text-white display-1 lh-1 mb-4">
|
||||
Arrêtez d'attendre...
|
||||
<br />
|
||||
Inscrivez-vous !
|
||||
</h2>
|
||||
<!-- <a class="btn btn-outline-light py-3 px-4 rounded-pill" href="#" target="_blank">Download for free</a> -->
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<!-- App badge section-->
|
||||
<section class="bg-gradient-primary-to-secondary" id="download">
|
||||
<div class="container px-5">
|
||||
<h2 class="text-center text-white font-alt mb-4">Application bientôt disponible !</h2>
|
||||
<!-- <div class="d-flex flex-column flex-lg-row align-items-center justify-content-center">
|
||||
<a class="me-lg-3 mb-4 mb-lg-0" href="#!"><img class="app-badge" src="assets/img/google-play-badge.svg" alt="..." /></a>
|
||||
<a href="#!"><img class="app-badge" src="assets/img/app-store-badge.svg" alt="..." /></a>
|
||||
</div> -->
|
||||
</div>
|
||||
</section>
|
||||
<!-- Footer-->
|
||||
<footer class="bg-black text-center py-5">
|
||||
<div class="container px-5">
|
||||
<div class="text-white-50 small">
|
||||
<div class="mb-2">© HeartTrack 2023. Tous droits réservé.</div>
|
||||
<a href="#!">Politique de confidentialité</a>
|
||||
<span class="mx-1">·</span>
|
||||
<a href="#!">Termes & Conditions d'utilisation</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
<!-- Feedback Modal-->
|
||||
<div class="modal fade" id="feedbackModal" tabindex="-1" aria-labelledby="feedbackModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header bg-gradient-primary-to-secondary p-4">
|
||||
<h5 class="modal-title font-alt text-white" id="feedbackModalLabel">Envoyez votre avis</h5>
|
||||
<button class="btn-close btn-close-white" type="button" data-bs-dismiss="modal"
|
||||
aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body border-0 p-4">
|
||||
<!-- * * * * * * * * * * * * * * *-->
|
||||
<!-- * * SB Forms Contact Form * *-->
|
||||
<!-- * * * * * * * * * * * * * * *-->
|
||||
<!-- This form is pre-integrated with SB Forms.-->
|
||||
<!-- To make this form functional, sign up at-->
|
||||
<!-- https://startbootstrap.com/solution/contact-forms-->
|
||||
<!-- to get an API token!-->
|
||||
<form id="contactForm" data-sb-form-api-token="API_TOKEN">
|
||||
<!-- Name input-->
|
||||
<div class="form-floating mb-3">
|
||||
<input class="form-control" id="name" type="text" placeholder="Entrez votre nom complet..."
|
||||
data-sb-validations="required" />
|
||||
<label for="name">Nom complet</label>
|
||||
<div class="invalid-feedback" data-sb-feedback="name:required">Un nom est requis.</div>
|
||||
</div>
|
||||
<!-- Email address input-->
|
||||
<div class="form-floating mb-3">
|
||||
<input class="form-control" id="email" type="email" placeholder="nom@exemple.com"
|
||||
data-sb-validations="required,email" />
|
||||
<label for="email">Adresse email</label>
|
||||
<div class="invalid-feedback" data-sb-feedback="email:required">Adresse email requis.</div>
|
||||
<div class="invalid-feedback" data-sb-feedback="email:email">L'adresse email n'est pas
|
||||
valide.</div>
|
||||
</div>
|
||||
<!-- Phone number input-->
|
||||
<div class="form-floating mb-3">
|
||||
<input class="form-control" id="phone" type="tel" placeholder="06 12 34 56 78"
|
||||
data-sb-validations="required" />
|
||||
<label for="phone">Numéro de téléphone</label>
|
||||
<div class="invalid-feedback" data-sb-feedback="phone:required">Numéro de téléphone requis.
|
||||
</div>
|
||||
</div>
|
||||
<!-- Message input-->
|
||||
<div class="form-floating mb-3">
|
||||
<textarea class="form-control" id="message" type="text"
|
||||
placeholder="Entrez votre message..." style="height: 10rem"
|
||||
data-sb-validations="required"></textarea>
|
||||
<label for="message">Message</label>
|
||||
<div class="invalid-feedback" data-sb-feedback="message:required">Un message est requis.
|
||||
</div>
|
||||
</div>
|
||||
<!-- Submit success message-->
|
||||
<!---->
|
||||
<!-- This is what your users will see when the form-->
|
||||
<!-- has successfully submitted-->
|
||||
<div class="d-none" id="submitSuccessMessage">
|
||||
<div class="text-center mb-3">
|
||||
<div class="fw-bolder">Avis envoyé !</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Submit error message-->
|
||||
<!---->
|
||||
<!-- This is what your users will see when there is-->
|
||||
<!-- an error submitting the form-->
|
||||
<div class="d-none" id="submitErrorMessage">
|
||||
<div class="text-center text-danger mb-3">Erreur du formulaire !</div>
|
||||
</div>
|
||||
<!-- Submit Button-->
|
||||
<div class="d-grid"><button class="btn btn-primary rounded-pill btn-lg disabled"
|
||||
id="submitButton" type="submit">Envoyer</button></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Bootstrap core JS-->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<!-- Core theme JS-->
|
||||
<script src="js/scripts2.js"></script>
|
||||
<script src="https://cdn.startbootstrap.com/sb-forms-latest.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace Database;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class ActivityEntity {
|
||||
private $idActivity;
|
||||
private $type;
|
||||
private DateTime $date;
|
||||
private DateTime $heureDebut;
|
||||
private DateTime $heureFin;
|
||||
private $effortRessenti;
|
||||
private $variabilite;
|
||||
private $variance;
|
||||
private $ecartType;
|
||||
private $moyenne;
|
||||
private $maximum;
|
||||
private $minimum;
|
||||
private $temperatureMoyenne;
|
||||
|
||||
// Getters
|
||||
public function getIdActivity() {
|
||||
return $this->idActivity;
|
||||
}
|
||||
|
||||
public function getType() {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function getDate() {
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function getHeureDebut() {
|
||||
return $this->heureDebut;
|
||||
}
|
||||
|
||||
public function getHeureFin() {
|
||||
return $this->heureFin;
|
||||
}
|
||||
|
||||
public function getEffortRessenti() {
|
||||
return $this->effortRessenti;
|
||||
}
|
||||
|
||||
public function getVariability() {
|
||||
return $this->variabilite;
|
||||
}
|
||||
|
||||
public function getVariance() {
|
||||
return $this->variance;
|
||||
}
|
||||
|
||||
public function getEcartType() {
|
||||
return $this->ecartType;
|
||||
}
|
||||
|
||||
public function getMoyenne() {
|
||||
return $this->moyenne;
|
||||
}
|
||||
|
||||
public function getMaximum() {
|
||||
return $this->maximum;
|
||||
}
|
||||
|
||||
public function getMinimum() {
|
||||
return $this->minimum;
|
||||
}
|
||||
|
||||
public function getTemperatureMoyenne() {
|
||||
return $this->temperatureMoyenne;
|
||||
}
|
||||
|
||||
// Setters
|
||||
public function setIdActivity($idActivity) {
|
||||
$this->idActivity = $idActivity;
|
||||
}
|
||||
|
||||
public function setType($type) {
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function setDate($date) {
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
public function setHeureDebut($heureDebut) {
|
||||
$this->heureDebut = $heureDebut;
|
||||
}
|
||||
|
||||
public function setHeureFin($heureFin) {
|
||||
$this->heureFin = $heureFin;
|
||||
}
|
||||
|
||||
public function setEffortRessenti($effortRessenti) {
|
||||
$this->effortRessenti = $effortRessenti;
|
||||
}
|
||||
|
||||
public function setVariabilite($variabilite) {
|
||||
$this->variabilite = $variabilite;
|
||||
}
|
||||
|
||||
public function setVariance($variance) {
|
||||
$this->variance = $variance;
|
||||
}
|
||||
|
||||
public function setEcartType($ecartType) {
|
||||
$this->ecartType = $ecartType;
|
||||
}
|
||||
|
||||
public function setMoyenne($moyenne) {
|
||||
$this->moyenne = $moyenne;
|
||||
}
|
||||
|
||||
public function setMaximum($maximum) {
|
||||
$this->maximum = $maximum;
|
||||
}
|
||||
|
||||
public function setMinimum($minimum) {
|
||||
$this->minimum = $minimum;
|
||||
}
|
||||
|
||||
public function setTemperatureMoyenne($temperatureMoyenne) {
|
||||
$this->temperatureMoyenne = $temperatureMoyenne;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace Database;
|
||||
use \PDO;
|
||||
use Shared\Log;
|
||||
|
||||
class ActivityGateway {
|
||||
private Connexion $connection;
|
||||
|
||||
public function __construct(Connexion $connection) {
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
public function getActivity() {
|
||||
$query = "SELECT * FROM Activite";
|
||||
return $this->connection->executeWithErrorHandling($query);
|
||||
}
|
||||
|
||||
public function getActivityById(int $activityId) {
|
||||
$query = "SELECT * FROM Activite WHERE idActivite = :id";
|
||||
$params = [':id' => $activityId];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getActivityByType(string $type) {
|
||||
$query = "SELECT * FROM Activite WHERE type = :type";
|
||||
$params = [':type' => [$type, PDO::PARAM_STR]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getActivityByDate(string $date) {
|
||||
$query = "SELECT * FROM Activite WHERE date = :date";
|
||||
$params = [':date' => [$date, PDO::PARAM_STR]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getActivityByTimeRange(string $startTime, string $endTime) {
|
||||
$query = "SELECT * FROM Activite WHERE heureDebut >= :startTime AND heureFin <= :endTime";
|
||||
$params = [
|
||||
':startTime' => [$startTime, PDO::PARAM_STR],
|
||||
':endTime' => [$endTime, PDO::PARAM_STR]
|
||||
];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getActivityByEffort(int $effortRessenti) {
|
||||
$query = "SELECT * FROM Activite WHERE effortRessenti = :effort";
|
||||
$params = [':effort' => [$effortRessenti, PDO::PARAM_INT]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getActivityByVariability(int $variabilite) {
|
||||
$query = "SELECT * FROM Activite WHERE variabilite = :variability";
|
||||
$params = [':variability' => [$variabilite, PDO::PARAM_INT]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function getActivityByTemperature(int $temperatureMoyenne) {
|
||||
$query = "SELECT * FROM Activite WHERE temperatureMoyenne = :temperature";
|
||||
$params = [':temperature' => [$temperatureMoyenne, PDO::PARAM_INT]];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function addActivity(ActivityEntity $activity) {
|
||||
$query = "INSERT INTO Activite (idactivite, type, date, heurededebut, heuredefin, effortressent, variabilite, variance, ecarttype, moyenne, maximum, minimum, temperaturemoyenne, athleteid, sourceid)
|
||||
VALUES (:idactivite, :type, :date, :heureDebut, :heureDeFin, :effortRessenti, :variabilite, :variance, :ecartType, :moyenne, :maximum, :minimum, :temperatureMoyenne, :athleteid, :sourceid)";
|
||||
$params = [
|
||||
':idactivite' => $activity->getIdActivity(),
|
||||
':type' => $activity->getType(),
|
||||
':date' => $activity->getDate()->format('Y-m-d'), // Format date pour SQL
|
||||
':heureDebut' => $activity->getHeureDebut()->format('H:i:s'), // Format heure pour SQL
|
||||
':heureDeFin' => $activity->getHeureFin()->format('H:i:s'), // Format heure pour SQL
|
||||
':effortRessenti' => $activity->getEffortRessenti(),
|
||||
':variabilite' => $activity->getVariability(),
|
||||
':variance' => $activity->getVariance(),
|
||||
':ecartType' => $activity->getEcartType(),
|
||||
':moyenne' => $activity->getMoyenne(),
|
||||
':maximum' => $activity->getMaximum(),
|
||||
':minimum' => $activity->getMinimum(),
|
||||
':temperatureMoyenne' => $activity->getTemperatureMoyenne(),
|
||||
':athleteid' => 1,
|
||||
':sourceid' => 1,
|
||||
];
|
||||
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function updateActivity(ActivityEntity $oldActivity, ActivityEntity $newActivity) {
|
||||
$query = "UPDATE Activite
|
||||
SET type = :type, date = :date, heureDebut = :heureDebut, heureDeFin = :heureDeFin,
|
||||
effortRessenti = :effortRessenti, variabilite = :variabilite, variance = :variance, ecartType = :ecartType, moyenne = :moyenne, maximum = :maximum, minimum = :minimum, temperatureMoyenne = :temperatureMoyenne
|
||||
WHERE idActivite = :idActivite";
|
||||
|
||||
$params = [
|
||||
':idActivite' => $oldActivity->getIdActivity(),
|
||||
':type' => $newActivity->getType(),
|
||||
':date' => $newActivity->getDate()->format('Y-m-d'), // Format date pour SQL
|
||||
':heureDebut' => $newActivity->getHeureDebut()->format('H:i:s'), // Format heure pour SQL
|
||||
':heureDeFin' => $newActivity->getHeureFin()->format('H:i:s'), // Format heure pour SQL
|
||||
':effortRessenti' => $newActivity->getEffortRessenti(),
|
||||
':variabilite' => $newActivity->getVariabilite(),
|
||||
':variance' => $newActivity->getVariance(),
|
||||
':ecartType' => $newActivity->getEcartType(),
|
||||
':moyenne' => $newActivity->getMoyenne(),
|
||||
':maximum' => $newActivity->getMaximum(),
|
||||
':minimum' => $newActivity->getMinimum(),
|
||||
':temperatureMoyenne' => $newActivity->getTemperatureMoyenne(),
|
||||
];
|
||||
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
public function deleteActivity(int $idActivity) {
|
||||
$query = "DELETE FROM Activite WHERE idActivite = :idActivity";
|
||||
|
||||
$params = [
|
||||
':idActivity' => $idActivity,
|
||||
];
|
||||
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace Database;
|
||||
use DateTime;
|
||||
use Model\Activity;
|
||||
use Shared\Log;
|
||||
|
||||
class ActivityMapper {
|
||||
public function activitySqlToEntity(array $data):array
|
||||
{
|
||||
$activityEntities = [];
|
||||
|
||||
foreach ($data as $activityData) {
|
||||
$activity = new ActivityEntity();
|
||||
|
||||
if (isset($activityData['idActivite'])) {
|
||||
$activity->setIdActivity($activityData['idActivite']);
|
||||
}
|
||||
|
||||
if (isset($activityData['type'])) {
|
||||
$activity->setType($activityData['type']);
|
||||
}
|
||||
|
||||
if (isset($activityData['date'])) {
|
||||
$activity->setDate(new DateTime($activityData['date']));
|
||||
}
|
||||
|
||||
if (isset($activityData['heureDeDebut'])) {
|
||||
$activity->setHeureDebut(new DateTime($activityData['heureDeDebut']));
|
||||
}
|
||||
|
||||
if (isset($activityData['heureDeFin'])) {
|
||||
$activity->setHeureFin(new DateTime($activityData['heureDeFin']));
|
||||
}
|
||||
|
||||
if (isset($activityData['effortRessent'])) {
|
||||
$activity->setEffortRessenti($activityData['effortRessent']);
|
||||
}
|
||||
|
||||
if (isset($activityData['variabilite'])) {
|
||||
$activity->setVariabilite($activityData['variabilite']);
|
||||
}
|
||||
|
||||
if (isset($activityData['variance'])) {
|
||||
$activity->setVariance($activityData['variance']);
|
||||
}
|
||||
|
||||
if (isset($activityData['ecartType'])) {
|
||||
$activity->setEcartType($activityData['ecartType']);
|
||||
}
|
||||
|
||||
if (isset($activityData['moyenne'])) {
|
||||
$activity->setMoyenne($activityData['moyenne']);
|
||||
}
|
||||
|
||||
if (isset($activityData['maximum'])) {
|
||||
$activity->setMaximum($activityData['maximum']);
|
||||
}
|
||||
|
||||
if (isset($activityData['minimum'])) {
|
||||
$activity->setMinimum($activityData['minimum']);
|
||||
}
|
||||
|
||||
if (isset($activityData['temperatureMoyenne'])) {
|
||||
$activity->setTemperatureMoyenne($activityData['temperatureMoyenne']);
|
||||
}
|
||||
|
||||
$activityEntities[] = $activity;
|
||||
}
|
||||
|
||||
return $activityEntities;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function ActivityEntityToModel(ActivityEntity $activiteEntity):Activity {
|
||||
$date = new DateTime($activiteEntity->getDate()->format('Y-m-d'));
|
||||
$heureDebut = new \DateTime($activiteEntity->getHeureDebut()->format('H:i:s'));
|
||||
$heureFin = new \DateTime($activiteEntity->getHeureFin()->format('H:i:s'));
|
||||
$effortRessenti = intval($activiteEntity->getEffortRessenti());
|
||||
$variability = floatval($activiteEntity->getVariability());
|
||||
$variance = floatval($activiteEntity->getVariance());
|
||||
$ecartType = floatval($activiteEntity->getEcartType());
|
||||
|
||||
$act = new Activity(
|
||||
$activiteEntity->getType(),
|
||||
$date,
|
||||
$heureDebut,
|
||||
$heureFin,
|
||||
$effortRessenti,
|
||||
$variability,
|
||||
$variance,
|
||||
$ecartType,
|
||||
$activiteEntity->getMoyenne(),
|
||||
$activiteEntity->getMaximum(),
|
||||
$activiteEntity->getMinimum(),
|
||||
$activiteEntity->getTemperatureMoyenne(),
|
||||
'false'
|
||||
);
|
||||
|
||||
return $act;
|
||||
}
|
||||
//public function ActivityToEntity(Activity model): ActivityEntity;
|
||||
|
||||
public function activityToEntity(Activity $act):ActivityEntity{
|
||||
$actEntity = new ActivityEntity();
|
||||
$actEntity->setIdActivity($act->getIdActivity());
|
||||
$actEntity->setType($act->getType());
|
||||
$actEntity->setDate($act->getDate());
|
||||
$actEntity->setHeureDebut($act->getHeureDebut());
|
||||
$actEntity->setHeureFin($act->getHeureFin());
|
||||
$actEntity->setEffortRessenti($act->getEffortRessenti());
|
||||
$actEntity->setVariabilite($act->getVariability());
|
||||
$actEntity->setVariance($act->getVariance());
|
||||
$actEntity->setEcartType($act->getStandardDeviation());
|
||||
$actEntity->setMoyenne($act->getAverage());
|
||||
$actEntity->setMaximum($act->getMaximum());
|
||||
$actEntity->setMinimum($act->getMinimum());
|
||||
$actEntity->setTemperatureMoyenne($act->getAvrTemperature());
|
||||
|
||||
return $actEntity;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace Database;
|
||||
|
||||
class AnalyzeEntity
|
||||
{
|
||||
private $idFc;
|
||||
private $altitude;
|
||||
private $time;
|
||||
private $temperature;
|
||||
private $bpm;
|
||||
private $longitude;
|
||||
private $latitude;
|
||||
private $idactivity;
|
||||
public function getIdFC()
|
||||
{
|
||||
return $this->idFc;
|
||||
}
|
||||
public function getAltitude()
|
||||
{
|
||||
return $this->altitude;
|
||||
}
|
||||
public function getTime()
|
||||
{
|
||||
return $this->temps;
|
||||
}
|
||||
public function getTemperature()
|
||||
{
|
||||
return $this->temperature;
|
||||
}
|
||||
public function getBpm()
|
||||
{
|
||||
return $this->bpm;
|
||||
}
|
||||
public function getLongitude()
|
||||
{
|
||||
return $this->longitude;
|
||||
}
|
||||
public function getLatitude()
|
||||
{
|
||||
return $this->latitude;
|
||||
}
|
||||
public function getIdActivity()
|
||||
{
|
||||
return $this->idactivity;
|
||||
}
|
||||
public function setIdFC($idFc)
|
||||
{
|
||||
$this->idFc = $idFc;
|
||||
}
|
||||
public function setAltitude($altitude)
|
||||
{
|
||||
$this->altitude = $altitude;
|
||||
}
|
||||
public function setTime($time)
|
||||
{
|
||||
$this->time = $time;
|
||||
}
|
||||
public function setTemperature($temperature)
|
||||
{
|
||||
$this->temperature = $temperature;
|
||||
}
|
||||
public function setBpm($bpm)
|
||||
{
|
||||
$this->bpm = $bpm;
|
||||
}
|
||||
public function setLongitude($longitude)
|
||||
{
|
||||
$this->longitude = $longitude;
|
||||
}
|
||||
public function setLatitude($latitude)
|
||||
{
|
||||
$this->latitude = $latitude;
|
||||
}
|
||||
public function setIdActivity($idactivity)
|
||||
{
|
||||
$this->idactivity = $idactivity;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database;
|
||||
|
||||
class AnalyzeGateway
|
||||
{
|
||||
private Connexion $connection;
|
||||
|
||||
public function __construct(Connexion $connection) {
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
public function getFrequenceCardiaque() {
|
||||
$query = "SELECT * FROM FrequenceCardiaque";
|
||||
return $this->connection->executeWithErrorHandling($query);
|
||||
}
|
||||
public function getFrequenceCardiaqueByIdActivity(int $activityId)
|
||||
{
|
||||
$query = "SELECT * FROM FrequenceCardiaque WHERE activiteid = :id";
|
||||
$params = [':id' => $activityId];
|
||||
return $this->connection->executeWithErrorHandling($query, $params);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace Database;
|
||||
|
||||
use Shared\Log;
|
||||
|
||||
class AnalyzeMapper
|
||||
{
|
||||
public function analyzeSqlToEntity(array $data):array
|
||||
{
|
||||
$analyzeEntities = [];
|
||||
|
||||
foreach ($data as $analyzeData) {
|
||||
$analyze = new ActivityEntity();
|
||||
|
||||
if (isset($analyzeData['idactivite'])) {
|
||||
$analyze->setIdActivity($analyzeData['idactivite']);
|
||||
}
|
||||
|
||||
if (isset($analyzeData['type'])) {
|
||||
$analyze->setType($analyzeData['type']);
|
||||
}
|
||||
|
||||
if (isset($analyzeData['date'])) {
|
||||
$analyze->setDate($analyzeData['date']);
|
||||
}
|
||||
|
||||
if (isset($analyzeData['heurededebut'])) {
|
||||
$analyze->setHeureDebut($analyzeData['heurededebut']);
|
||||
}
|
||||
|
||||
if (isset($analyzeData['heuredefin'])) {
|
||||
$analyze->setHeureFin($analyzeData['heuredefin']);
|
||||
}
|
||||
|
||||
if (isset($analyzeData['effortressent'])) {
|
||||
$analyze->setEffortRessenti($analyzeData['effortressent']);
|
||||
}
|
||||
|
||||
if (isset($analyzeData['variabilite'])) {
|
||||
$analyze->setVariabilite($analyzeData['variabilite']);
|
||||
}
|
||||
|
||||
if (isset($analyzeData['variance'])) {
|
||||
$analyze->setVariance($analyzeData['variance']);
|
||||
}
|
||||
|
||||
if (isset($analyzeData['ecarttype'])) {
|
||||
$analyze->setEcartType($analyzeData['ecarttype']);
|
||||
}
|
||||
|
||||
if (isset($analyzeData['moyenne'])) {
|
||||
$analyze->setMoyenne($analyzeData['moyenne']);
|
||||
}
|
||||
|
||||
if (isset($analyzeData['maximum'])) {
|
||||
$analyze->setMaximum($analyzeData['maximum']);
|
||||
}
|
||||
|
||||
if (isset($analyzeData['minimum'])) {
|
||||
$analyze->setMinimum($analyzeData['minimum']);
|
||||
}
|
||||
|
||||
if (isset($analyzeData['temperaturemoyenne'])) {
|
||||
$analyze->setTemperatureMoyenne($analyzeData['temperaturemoyenne']);
|
||||
}
|
||||
|
||||
$analyzeEntities[] = $analyze;
|
||||
}
|
||||
return $analyzeEntities;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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(),
|
||||
// $date,
|
||||
// $heureDebut,
|
||||
// $heureFin,
|
||||
// $effortRessenti,
|
||||
// $variability,
|
||||
// $variance,
|
||||
// $ecartType,
|
||||
// $activiteEntity->getMoyenne(),
|
||||
// $activiteEntity->getMaximum(),
|
||||
// $activiteEntity->getMinimum(),
|
||||
// $activiteEntity->getTemperatureMoyenne(),
|
||||
// 'false'
|
||||
// );
|
||||
//
|
||||
// return $act;
|
||||
// }
|
||||
//public function ActivityToEntity(Activity model): ActivityEntity;
|
||||
|
||||
// public function activityToEntity( $act):ActivityEntity{
|
||||
//
|
||||
// $act = new ActivityEntity();
|
||||
// $act->setIdActivity($act->getIdActivity()());
|
||||
// $act->setType($act->getType());
|
||||
// $act->setDate($act->getDate());
|
||||
// $act->setHeureDebut($act->getHeureDebut());
|
||||
// $act->setHeureFin($act->getHeureFin());
|
||||
// $act->setEffortRessenti($act->getEffortRessenti());
|
||||
// $act->setVariabilite($act->getVariability());
|
||||
// $act->setVariance($act->getVariance());
|
||||
// $act->setEcartType($act->getEcartType());
|
||||
// $act->setMoyenne($act->getMoyenne());
|
||||
// $act->setMaximum($act->getMaximum());
|
||||
// $act->setMinimum($act->getMinimum());
|
||||
// $act->setTemperatureMoyenne($act->getTemperatureMoyenne());
|
||||
//
|
||||
// return $act;
|
||||
// }
|
||||
}
|