From fd5e60800a770c28fb6560a212aad602596a1b7c Mon Sep 17 00:00:00 2001 From: Serreau Jovann Date: Thu, 13 Nov 2025 15:23:54 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(Dashboard):=20Affiche=20le=20C?= =?UTF-8?q?A=20actuel,=20le=20CA=20pr=C3=A9vu=20et=20l'=C3=A9cart=20sur=20?= =?UTF-8?q?le=20tableau=20de=20bord.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Artemis/DashboardController.php | 22 ++++++++++++++++++- .../CustomerAdvertPaymentRepository.php | 14 ++++++++++++ src/Repository/CustomerOrderRepository.php | 13 +++++++++++ templates/artemis/dashboard.twig | 10 ++++----- 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/Controller/Artemis/DashboardController.php b/src/Controller/Artemis/DashboardController.php index 06be0f2..d44a42f 100644 --- a/src/Controller/Artemis/DashboardController.php +++ b/src/Controller/Artemis/DashboardController.php @@ -5,6 +5,7 @@ namespace App\Controller\Artemis; use App\Controller\Artemis\Intranet\FaultController; use App\Entity\Customer; use App\Entity\CustomerAdvertPayment; +use App\Entity\CustomerOrder; use App\Repository\ComputeRepository; use App\Repository\CustomerAdvertPaymentRepository; use App\Repository\CustomerDevisRepository; @@ -127,7 +128,23 @@ class DashboardController extends AbstractController } $faults = $faults + $sub; } - + $totalCaPrevu = 0; + foreach ($customerAdvertPaymentRepository->currentMonth() as $payment) { + $sub = 0; + foreach ($payment->getCustomerAdvertPaymentLines() as $line) { + $sub = $sub + $line->getPriceHt()*1.20; + } + $totalCaPrevu = $totalCaPrevu + $sub; + } + $totalCaCurrent= 0; + /** @var CustomerOrder $payment */ + foreach ($customerOrderRepository->currentMonth() as $payment) { + $sub = 0; + foreach ($payment->getCustomerOrderLines() as $line) { + $sub = $sub + $line->getPriceHt()*1.20; + } + $totalCaCurrent = $totalCaCurrent + $sub; + } return $this->render('artemis/dashboard.twig',[ 'invoiceList' => $invoiceList, 'advertList' => $advertList, @@ -136,6 +153,9 @@ class DashboardController extends AbstractController 'remaining_amount' => $remaining_amount, 'servers' => $servers, 'dns' => $dns, + 'totalCaPrevu' => $totalCaPrevu, + 'totalCaCurrent' => $totalCaCurrent, + 'diffCa' => $totalCaPrevu - $totalCaCurrent, 'faults' => $faults, ]); } diff --git a/src/Repository/CustomerAdvertPaymentRepository.php b/src/Repository/CustomerAdvertPaymentRepository.php index 1cfb1cd..196e7a4 100644 --- a/src/Repository/CustomerAdvertPaymentRepository.php +++ b/src/Repository/CustomerAdvertPaymentRepository.php @@ -40,4 +40,18 @@ class CustomerAdvertPaymentRepository extends ServiceEntityRepository // ->getOneOrNullResult() // ; // } + public function currentMonth() + { + $t = new \DateTime(); + $t->setDate($t->format('Y'), $t->format('m'),1); + $tV = new \DateTime(); + $tV->setDate($t->format('Y'), $t->format('m'),31); + return $this->createQueryBuilder('cp') + ->andWhere('cp.createAt BETWEEN :start AND :end') + ->setParameter('start',$t) + ->setParameter('end', $tV) + ->getQuery() + ->getResult(); + + } } diff --git a/src/Repository/CustomerOrderRepository.php b/src/Repository/CustomerOrderRepository.php index 3f8145b..f31d162 100644 --- a/src/Repository/CustomerOrderRepository.php +++ b/src/Repository/CustomerOrderRepository.php @@ -40,4 +40,17 @@ class CustomerOrderRepository extends ServiceEntityRepository // ->getOneOrNullResult() // ; // } + public function currentMonth() + { + $t = new \DateTime(); + $t->setDate($t->format('Y'), $t->format('m'),1); + $tV = new \DateTime(); + $tV->setDate($t->format('Y'), $t->format('m'),31); + return $this->createQueryBuilder('cp') + ->andWhere('cp.createAt BETWEEN :start AND :end') + ->setParameter('start',$t) + ->setParameter('end', $tV) + ->getQuery() + ->getResult(); + } } diff --git a/templates/artemis/dashboard.twig b/templates/artemis/dashboard.twig index b4fff59..37e72c8 100644 --- a/templates/artemis/dashboard.twig +++ b/templates/artemis/dashboard.twig @@ -160,12 +160,12 @@

CA En Cours

-

0 €

+

{{ totalCaCurrent|format_currency('EUR') }}

CA Prévu

-

0 €

+

{{ totalCaPrevu|format_currency('EUR') }}

@@ -176,7 +176,7 @@

Écart / Objectif Prévu

- 0 € + {{ diffCa|format_currency('EUR') }}

(Reste à atteindre ce mois) @@ -294,11 +294,11 @@

Total Coûts / CA :

-

63.5%

+

0%

- (Coût Infra 28.5% + Coût Salarial 35.0%) + (Coût Infra 0% + Coût Salarial 0%)