From 0f59ed962c7b511c2a78767c1ce052e793f861fd Mon Sep 17 00:00:00 2001 From: anperederi Date: Sun, 26 Nov 2023 23:47:28 +0100 Subject: [PATCH] updates controllers --- .../src/app/controller/CoachController.php | 274 ++++++++++++---- Sources/src/app/controller/Controller.php | 296 +++++++++--------- 2 files changed, 368 insertions(+), 202 deletions(-) diff --git a/Sources/src/app/controller/CoachController.php b/Sources/src/app/controller/CoachController.php index db95d553..669248f9 100644 --- a/Sources/src/app/controller/CoachController.php +++ b/Sources/src/app/controller/CoachController.php @@ -1,31 +1,31 @@ coachManager = $dataManager->coachMgr; -// $this->security = $security; -// } + public function __construct(DataManager $dataManager, Security $security) + { + $this->coachManager = $dataManager->coachMgr; + $this->security = $security; + } // #[Route(path: '/', name: 'home', methods: ['GET'])] // public function index(): Response @@ -44,7 +44,7 @@ // 'member' => [] // ]); // } - +// // #[Route('/global-stats', name: 'coach_global_stats', methods: ['GET'])] // public function globalStats(): Response // { @@ -52,10 +52,194 @@ // return $this->render('coach/global_stats.html.twig'); // } -// #[Route(path: '/exercice', name: 'exercice', methods: ['GET'])] // 8 -// public function exercice(): Response + #[Route(path: '/exercice', name: 'exercice', methods: ['GET'])] // 8 + public function exercice(): Response + { + return $this->render('./page/exercice.html.twig',[ + 'css' => $this->preference->getCookie(), + 'pp' => "test2", + 'user' => "Doe", + 'role' => "Athlète", + 'friendship' => [], + 'analyzes' => [], + 'mails' => [], + 'users' => [], + 'infoUser' => [], + 'exos' => [], + 'member' => [] + ]); + } + + #[Route(path: '/exercices', name: 'exercices', methods: ['POST'])] // 8 + public function exercices(String $type, String $intensite, String $date, IRequest $req): Response + { + $exercicesArray = [ + [ + 'date' => $date, + 'type' => $type, + 'intensite' => $intensite, + 'status' => 'A venur', + ] + ]; + return $this->render('./page/exercice.html.twig',[ + 'css' => $this->preference->getCookie(), + 'pp' => "test2", + 'user' => "Doe", + 'role' => "Athlète", + 'friendship' => [], + 'analyzes' => [], + 'mails' => [], + 'users' => [], + 'infoUser' => [], + 'exos' => $exercicesArray, + '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(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' => "Athlète", + 'friendship' => [], + 'analyzes' => [], + 'mails' => [], + 'users' => [], + 'infoUser' => [], + 'exos' => [], + 'member' => [] + ]); + } + + +// #[Route(path: '/coaching', name: 'coaching', methods: ['GET'])] +// public function coaching(): Response // { -// return $this->render('./page/exercice.html.twig',[ +// return $this->render('./page/coaching.html.twig',[ // 'css' => $this->preference->getCookie(), // 'pp' => "test2", // 'user' => "Doe", @@ -69,32 +253,13 @@ // 'member' => [] // ]); // } - - -// #[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' => "Athlète", -// 'friendship' => [], -// 'analyzes' => [], -// 'mails' => [], -// 'users' => [], -// '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, // ]); @@ -107,22 +272,23 @@ // '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"); -// // } + // #[Route('/remove-athlete', name: 'coach_remove_athlete', methods: ['POST'])] + // public function removeAthlete(int $athleteId, IRequest $request): IResponse + // { + + // return $this->redirectToRoute("/athletes"); + // } + - -// } \ No newline at end of file + } +?> \ No newline at end of file diff --git a/Sources/src/app/controller/Controller.php b/Sources/src/app/controller/Controller.php index 7dddd5c5..c3228d04 100644 --- a/Sources/src/app/controller/Controller.php +++ b/Sources/src/app/controller/Controller.php @@ -76,49 +76,49 @@ class Controller extends BaseController ]); } - #[Route(path: '/exercice', name: 'exercice', methods: ['GET'])] // 8 - public function exercice(): Response - { - return $this->render('./page/exercice.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [] - ]); - } - - #[Route(path: '/exercices', name: 'exercices', methods: ['POST'])] // 8 - public function exercices(String $type, String $intensite, String $date, IRequest $req): Response - { - $exercicesArray = [ - [ - 'date' => $date, - 'type' => $type, - 'intensite' => $intensite, - 'status' => 'A venur', - ] - ]; - return $this->render('./page/exercice.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => $exercicesArray, - 'member' => [] - ]); - } +// #[Route(path: '/exercice', name: 'exercice', methods: ['GET'])] // 8 +// public function exercice(): Response +// { +// return $this->render('./page/exercice.html.twig',[ +// 'css' => $this->preference->getCookie(), +// 'pp' => "test2", +// 'user' => "Doe", +// 'role' => "Athlète", +// 'friendship' => [], +// 'analyzes' => [], +// 'mails' => [], +// 'users' => [], +// 'infoUser' => [], +// 'exos' => [], +// 'member' => [] +// ]); +// } +// +// #[Route(path: '/exercices', name: 'exercices', methods: ['POST'])] // 8 +// public function exercices(String $type, String $intensite, String $date, IRequest $req): Response +// { +// $exercicesArray = [ +// [ +// 'date' => $date, +// 'type' => $type, +// 'intensite' => $intensite, +// 'status' => 'A venur', +// ] +// ]; +// return $this->render('./page/exercice.html.twig',[ +// 'css' => $this->preference->getCookie(), +// 'pp' => "test2", +// 'user' => "Doe", +// 'role' => "Athlète", +// 'friendship' => [], +// 'analyzes' => [], +// 'mails' => [], +// 'users' => [], +// 'infoUser' => [], +// 'exos' => $exercicesArray, +// 'member' => [] +// ]); +// } #[Route(path: '/search-user', name: 'search-user', methods: ['GET'])] public function searchUser(string $username, IRequest $req): Response @@ -165,94 +165,94 @@ class Controller extends BaseController } - #[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: '/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 @@ -432,23 +432,23 @@ class Controller extends BaseController ]); } - #[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' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [] - ]); - } +// #[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' => "Athlète", +// 'friendship' => [], +// 'analyzes' => [], +// 'mails' => [], +// 'users' => [], +// 'infoUser' => [], +// 'exos' => [], +// 'member' => [] +// ]); +// } #[Route(path: '/mail', name: 'mail', methods: ['GET'])] public function mail(): Response