You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
213 lines
6.6 KiB
213 lines
6.6 KiB
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Container;
|
|
use App\Router\Request\IRequest;
|
|
use App\Router\Response\Response;
|
|
use App\Router\Response\IResponse;
|
|
|
|
use Shared\Attributes\Route;
|
|
use Twig\Environment;
|
|
use Data\Core\Preferences;
|
|
use Shared\Log;
|
|
|
|
|
|
class CoachController extends BaseController
|
|
{
|
|
|
|
private ICoachManager $coachManager;
|
|
private Environment $twig;
|
|
private Preferences $preference;
|
|
|
|
public function __construct(DataManager $dataManager, Security $security)
|
|
{
|
|
session_start();
|
|
$this->coachManager = $dataManager->coachMgr;
|
|
$this->preference = new Preferences();
|
|
}
|
|
|
|
// #[Route('/global-stats', name: 'coach_global_stats', methods: ['GET'])]
|
|
// public function globalStats(): Response
|
|
// {
|
|
// // Add logic to fetch and process global stats
|
|
// return $this->render('coach/global_stats.html.twig');
|
|
// }
|
|
|
|
|
|
#[Route(path: '/coaching', name: 'coaching', methods: ['GET'])]
|
|
public function coaching(): Response
|
|
{
|
|
return $this->render('./page/coaching.html.twig',[
|
|
'css' => $this->preference->getCookie(),
|
|
'pp' => "test2",
|
|
'user' => "Doe",
|
|
'role' => "Coach",
|
|
'friendship' => [],
|
|
'analyzes' => [],
|
|
'mails' => [],
|
|
'users' => [],
|
|
'infoUser' => [],
|
|
'exos' => [],
|
|
'member' => []
|
|
]);
|
|
}
|
|
|
|
#[Route(path: '/search-member', name: 'search-member', methods: ['GET'])]
|
|
public function searchMember(string $username, IRequest $req): Response
|
|
{
|
|
$taberror = [];
|
|
// FILTER
|
|
$utiliArray = [
|
|
[
|
|
'nom' => 'John',
|
|
'prenom' => 'Doe',
|
|
'img' => 'john_doe',
|
|
'username' => 'johndoe',
|
|
],
|
|
[
|
|
'nom' => 'Alice',
|
|
'prenom' => 'Smith',
|
|
'img' => 'alice_smith',
|
|
'username' => 'alicesmith',
|
|
],
|
|
];
|
|
// if(!Validation::val_string($name)){
|
|
try {
|
|
//code...
|
|
// $model->userMgr->addFriend($name);
|
|
return $this->render('./page/addmember.html.twig',[
|
|
'css' => $this->preference->getCookie(),
|
|
'pp' => "test2",
|
|
'user' => "Doe",
|
|
'role' => "Athlète",
|
|
'friendship' => [],
|
|
'analyzes' => [],
|
|
'mails' => [],
|
|
'users' => $utiliArray,
|
|
'infoUser' => [],
|
|
'exos' => [],
|
|
'member' => [],
|
|
'responce' => "Notification d'ajout envoyée à $username"
|
|
]);
|
|
} catch (\Throwable $th) {
|
|
//throw $th;
|
|
// return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
|
|
}
|
|
// }
|
|
|
|
}
|
|
|
|
#[Route(path: '/add-member', name: 'add-member', methods: ['POST'])]
|
|
public function addmember(string $username, IRequest $req): Response
|
|
{
|
|
$taberror = [];
|
|
$utiliArray = [
|
|
[
|
|
'nom' => 'John',
|
|
'prenom' => 'Doe',
|
|
'img' => 'john_doe',
|
|
'username' => 'johndoe',
|
|
],
|
|
[
|
|
'nom' => 'Alice',
|
|
'prenom' => 'Smith',
|
|
'img' => 'alice_smith',
|
|
'username' => 'alicesmith',
|
|
],
|
|
];
|
|
// if(!Validation::val_string($name)){
|
|
try {
|
|
//code...
|
|
// $model->userMgr->addFriend($name);
|
|
return $this->render('./page/addmember.html.twig',[
|
|
'css' => $this->preference->getCookie(),
|
|
'pp' => "test2",
|
|
'user' => "Doe",
|
|
'role' => "Athlète",
|
|
'friendship' => [],
|
|
'analyzes' => [],
|
|
'mails' => [],
|
|
'users' => $utiliArray,
|
|
'infoUser' => [],
|
|
'exos' => [],
|
|
'member' => [],
|
|
'responce' => "Notification d'ajout envoyée à $username"
|
|
]);
|
|
} catch (\Throwable $th) {
|
|
//throw $th;
|
|
// return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
|
|
}
|
|
// }
|
|
|
|
}
|
|
|
|
#[Route(path: '/member', name: 'member', methods: ['GET'])]
|
|
public function member(): Response
|
|
{
|
|
$utiliArray = [
|
|
[
|
|
'nom' => 'John',
|
|
'prenom' => 'Doe',
|
|
'img' => 'john_doe',
|
|
'username' => 'johndoe',
|
|
],
|
|
[
|
|
'nom' => 'Alice',
|
|
'prenom' => 'Smith',
|
|
'img' => 'alice_smith',
|
|
'username' => 'alicesmith',
|
|
],
|
|
];
|
|
return $this->render('./page/addmember.html.twig',[
|
|
'css' => $this->preference->getCookie(),
|
|
'pp' => "test2",
|
|
'user' => "Doe",
|
|
'role' => "Athlète",
|
|
'friendship' => [],
|
|
'analyzes' => [],
|
|
'mails' => [],
|
|
'users' => $utiliArray,
|
|
'infoUser' => [],
|
|
'exos' => [],
|
|
'member' => [],
|
|
]);
|
|
}
|
|
|
|
// #[Route('/list-athletes', name: 'coach_list_athletes')]
|
|
// public function listAthletes(): Response
|
|
// {
|
|
// $coach = $this->security->getUser();
|
|
// $athletes = $this->coachManager->getAthletesForCoach($coach);
|
|
|
|
// return $this->render('coach/list_athletes.html.twig', [
|
|
// 'athletes' => $athletes,
|
|
// ]);
|
|
// }
|
|
// #[Route('/athlete-analysis/{athleteId}', name: 'coach_athlete_analysis', methods: ['GET'])]
|
|
// public function athleteAnalysis($athleteId): Response
|
|
// {
|
|
// // Fetch and process data specific to the athlete
|
|
// return $this->render('coach/athlete_analysis.html.twig', [
|
|
// 'athleteId' => $athleteId,
|
|
// ]);
|
|
// }
|
|
|
|
// #[Route('/add-athlete/{athleteId}', name: 'coach_add_athlete', methods: ['POST'])]
|
|
// public function addAthlete(IRequest $request, $athleteId): IResponse
|
|
// {
|
|
// // Implement logic to add athlete
|
|
// // ...
|
|
|
|
// return $this->redirectToRoute('coach_list_athletes');
|
|
// }
|
|
|
|
// // #[Route('/remove-athlete', name: 'coach_remove_athlete', methods: ['POST'])]
|
|
// // public function removeAthlete(int $athleteId, IRequest $request): IResponse
|
|
// // {
|
|
|
|
// // return $this->redirectToRoute("/athletes");
|
|
// // }
|
|
|
|
|
|
} |