feat(Dashboard): Affiche le CA actuel, le CA prévu et l'écart sur le tableau de bord.

This commit is contained in:
Serreau Jovann
2025-11-13 15:23:54 +01:00
parent ff04320200
commit fd5e60800a
4 changed files with 53 additions and 6 deletions

View File

@@ -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,
]);
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -160,12 +160,12 @@
<div class="p-6 rounded-lg shadow-xl bg-white dark:bg-gray-800">
<p class="text-sm text-gray-500 dark:text-gray-400">CA En Cours</p>
<p class="text-2xl font-bold text-green-500">0 €</p>
<p class="text-2xl font-bold text-green-500">{{ totalCaCurrent|format_currency('EUR') }}</p>
</div>
<div class="p-6 rounded-lg shadow-xl bg-white dark:bg-gray-800">
<p class="text-sm text-gray-500 dark:text-gray-400">CA Prévu</p>
<p class="text-2xl font-bold text-blue-400">0 €</p>
<p class="text-2xl font-bold text-blue-400">{{ totalCaPrevu|format_currency('EUR') }}</p>
</div>
<div class="p-6 rounded-lg shadow-xl bg-white dark:bg-gray-800">
@@ -176,7 +176,7 @@
<div class="p-6 rounded-lg shadow-xl bg-white dark:bg-gray-800 border-l-4 border-yellow-500">
<p class="text-sm font-medium text-gray-500 dark:text-gray-400">Écart / Objectif Prévu</p>
<p class="text-2xl font-bold text-yellow-500">
0 €
{{ diffCa|format_currency('EUR') }}
</p>
<p class="text-xs text-gray-400 dark:text-gray-500 mt-1">
(Reste à atteindre ce mois)
@@ -294,11 +294,11 @@
</div>
<div class="text-right">
<p class="text-sm text-gray-600 dark:text-gray-400">Total Coûts / CA :</p>
<p class="text-xl font-bold text-green-500">63.5%</p>
<p class="text-xl font-bold text-green-500">0%</p>
</div>
</div>
<p class="text-xs text-gray-400 dark:text-gray-500 mt-3">
(Coût Infra 28.5% + Coût Salarial 35.0%)
(Coût Infra 0% + Coût Salarial 0%)
</p>
</div>