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') }}
É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%)