diff --git a/Sources/config/config.php b/Sources/config/config.php index 4d0a0f4d..f28606cb 100755 --- a/Sources/config/config.php +++ b/Sources/config/config.php @@ -12,10 +12,10 @@ $dotenv->safeLoad(); // const DB_PASSWORD = $_ENV['DB_PASSWORD'] ?? 'achanger'; define("APP_ENV", 'development'); -const DB_SERVER = 'pgsql'; -const DB_HOST = 'localhost'; -const DB_DATABASE = 'sae_3'; -const DB_USER = 'Perederii'; +const DB_SERVER = 'mysql'; +const DB_HOST = 'localhost:3306'; +const DB_DATABASE = 'new'; +const DB_USER = 'root'; const DB_PASSWORD = ''; //const APP_ENV = 'console'; diff --git a/Sources/src/app/controller/AthleteController.php b/Sources/src/app/controller/AthleteController.php index 98428a80..0a61b7a6 100644 --- a/Sources/src/app/controller/AthleteController.php +++ b/Sources/src/app/controller/AthleteController.php @@ -91,10 +91,13 @@ class AthleteController extends BaseController } else { try { $athleteGateway = new AthleteGateway(new Connexion(DSN, DB_USER, DB_PASSWORD)); - $listSearch = $athleteGateway->getAthlete($username); + if($username==null){ + $listSearch=$athleteGateway->getAthlete(); + } else { + $listSearch = $athleteGateway->getAthleteByName($username); + } $map = new AthleteMapper(); $athleteEntity = $map->athleteSqlToEntity($listSearch); - $listUsers = []; foreach ($athleteEntity as $entity) { $user = $map->athleteEntityToModel($entity); diff --git a/Sources/src/app/controller/UserController.php b/Sources/src/app/controller/UserController.php index 6b3091af..6ce05f94 100644 --- a/Sources/src/app/controller/UserController.php +++ b/Sources/src/app/controller/UserController.php @@ -9,6 +9,8 @@ use Shared\Attributes\Route; use Twig\Environment; use Data\Core\Preferences; use Shared\Log; +use Database\Athletegateway; +use Database\Connexion; class UserController extends BaseController { @@ -43,6 +45,12 @@ class UserController extends BaseController #[Route(path: '/home', name: 'home', methods: ['GET'])] public function home(): Response { + $athleteGateway = new AthleteGateway(new Connexion(DSN, DB_USER, DB_PASSWORD)); + $activity = $athleteGateway->getListActivity('1');//$currentUser->getId() + foreach($activity as $act){ + $chart["act"] = $act["nbActivite"]; + $chart["mois"] = date('M', mktime(0, 0, 0, $act["mois"], 10)); + } return $this->render('./page/home.html.twig',[ 'css' => $this->preference->getCookie(), 'pp' => "test2", @@ -50,6 +58,7 @@ class UserController extends BaseController 'role' => "Athlète", 'friendship' => [], 'analyzes' => [], + 'chart' => $chart, 'mails' => [], 'users' => [], 'infoUser' => [], diff --git a/Sources/src/app/views/Templates/page/home.html.twig b/Sources/src/app/views/Templates/page/home.html.twig index 6ade985b..f75c376c 100755 --- a/Sources/src/app/views/Templates/page/home.html.twig +++ b/Sources/src/app/views/Templates/page/home.html.twig @@ -22,7 +22,26 @@ Stastiques globales