From 4bde5312ef4634ef8adbddecd0cd2482eab156a6 Mon Sep 17 00:00:00 2001 From: "Chuck.D.Norris" Date: Mon, 16 Dec 2024 20:49:36 +0100 Subject: [PATCH] . --- .../Controllers/Admin/ContractController.php | 1 + .../Admin/EstadistiquesController.php | 46 ++++--------------- app/src/app/Models/Estadistiques.php | 37 --------------- app/src/app/Views/Admin/Grafics.php | 6 ++- 4 files changed, 14 insertions(+), 76 deletions(-) delete mode 100644 app/src/app/Models/Estadistiques.php diff --git a/app/src/app/Controllers/Admin/ContractController.php b/app/src/app/Controllers/Admin/ContractController.php index 5a9a77a..a628367 100644 --- a/app/src/app/Controllers/Admin/ContractController.php +++ b/app/src/app/Controllers/Admin/ContractController.php @@ -10,6 +10,7 @@ class ContractController public function index($queryParams) { $contracts = Contract::findAll(); + View::render([ 'view' => 'Admin/Contracts', 'title' => 'Contracts', diff --git a/app/src/app/Controllers/Admin/EstadistiquesController.php b/app/src/app/Controllers/Admin/EstadistiquesController.php index 37511a4..09fc1c4 100644 --- a/app/src/app/Controllers/Admin/EstadistiquesController.php +++ b/app/src/app/Controllers/Admin/EstadistiquesController.php @@ -3,56 +3,28 @@ namespace App\Controllers\Admin; use App\Core\View; -use App\Models\Estadistiques; +use App\Models\Contract; +use App\Models\TreeType; class EstadistiquesController { public function index($queryParams = []) { // Obtenim les dades del model correcte - $grafiques = Estadistiques::findAll(); - + $totalContractes = Contract::count(); + $totalTreeTypes = TreeType::count(); // Comprova si $grafiques és null i assegura't que sigui un array - $contracts = $contracts = Estadistiques::findAll(); + + + $contracts = Contract::findAll(); + // Renderitzem la vista amb les dades View::render([ 'view' => 'Admin/Grafics', 'title' => 'Grafiques', 'layout' => 'Admin/AdminLayout', - 'contracts' => $contracts, - 'data' => ['grafics' => $grafiques], + 'data' => ['totalContractes' => $totalContractes, 'totalTreeTypes' => $totalTreeTypes], ]); } } -namespace App\Models; - -class BaseModel -{ - public static function findAll($filters = [], $includeDeleted = false) - { - // Simulació d'una consulta a la base de dades - $result = static::queryDatabase($filters, $includeDeleted); - - // Evita que $result sigui null abans de passar-ho a array_map - if (!is_array($result)) { - $result = []; // Inicialitza com a array buit si cal - } - - return array_map(function ($item) { - return static::mapToModel($item); - }, $result); - } - - private static function queryDatabase($filters, $includeDeleted) - { - // Aquí aniria la lògica per consultar la base de dades - return null; // Simulació d'un resultat null - } - - private static function mapToModel($item) - { - // Lògica per mapejar una fila de la base de dades al model - return $item; - } -} \ No newline at end of file diff --git a/app/src/app/Models/Estadistiques.php b/app/src/app/Models/Estadistiques.php deleted file mode 100644 index eb98bbc..0000000 --- a/app/src/app/Models/Estadistiques.php +++ /dev/null @@ -1,37 +0,0 @@ - litres = $data['litres']; - $estadistiques-> hours = $data['hours']; - $estadistiques-> pending = $data["pending"]; - $estadistiques-> filled = $data["filled"]; - - - - return $estadistiques; - } - - -} \ No newline at end of file diff --git a/app/src/app/Views/Admin/Grafics.php b/app/src/app/Views/Admin/Grafics.php index 6becdc9..0b5551f 100644 --- a/app/src/app/Views/Admin/Grafics.php +++ b/app/src/app/Views/Admin/Grafics.php @@ -31,8 +31,10 @@ - - + +
+

Contractes:

+

Tipus: