feat(artemis/dashboard): Affiche les avis de paiement client sur le tableau de bord.

This commit is contained in:
Serreau Jovann
2025-10-10 09:25:37 +02:00
parent 38a293debb
commit d84029911e
3 changed files with 23 additions and 8 deletions

View File

@@ -2,6 +2,8 @@
namespace App\Controller\Artemis;
use App\Entity\CustomerAdvertPayment;
use App\Repository\CustomerAdvertPaymentRepository;
use App\Repository\CustomerOrderRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@@ -12,9 +14,10 @@ use Symfony\Component\Routing\Attribute\Route;
class DashboardController extends AbstractController
{
#[Route('/artemis', name: 'artemis_dashboard', methods: ['GET', 'POST'])]
public function artemis(Request $request,CustomerOrderRepository $customerOrderRepository): Response
public function artemis(Request $request,CustomerOrderRepository $customerOrderRepository,CustomerAdvertPaymentRepository $customerAdvertPaymentRepository): Response
{
$invoiceList = [];
$advertList = [];
$remaining_amount = 0;
if(in_array("ROLE_CUSTOMER",$this->getUser()->getRoles())) {
$customer = $this->getUser()->getCustomers()[0];
@@ -30,10 +33,26 @@ class DashboardController extends AbstractController
'status' => $order->getState(),
];
}
foreach ($customerAdvertPaymentRepository->findBy(['customer'=>$customer]) as $order) {
$amount = 0;
foreach ($order->getCustomerAdvertPaymentLines() as $customerOrderLine) {
$amount += (1.*20*$customerOrderLine->getPriceHt());
}
if($order->getState() != "pay") {
$remaining_amount = $remaining_amount + $amount;
}
$advertList[] = [
'reference' => $order->getNumAvis(),
'date' => $order->getCreateAt()->format('Y-m-d'),
'amount' => $amount,
'status' => $order->getState(),
];
}
}
return $this->render('artemis/dashboard.twig',[
'invoiceList' => $invoiceList,
'advertList' => $advertList,
'remaining_amount' => $remaining_amount,
]);
}

View File

@@ -10,10 +10,6 @@
{# Données Statiques simulant les informations de l'API/BDD #}
{% set static_notices = [
{'reference': 'AP-2024-0005', 'date': '2024-09-25', 'amount': 300.75, 'status': 'Validé', 'id': 5},
{'reference': 'AP-2024-0004', 'date': '2024-08-30', 'amount': 55.00, 'status': 'Traité', 'id': 4},
] %}
{% set static_quotes = [
{'reference': 'D-2024-0021', 'date': '2024-10-01', 'amount': 890.50, 'status': 'Accepté', 'id': 21},
@@ -163,7 +159,7 @@
</a>
<a id="notices-tab" data-target="#notices" role="tab" aria-controls="notices" aria-selected="false"
class="{{ tab_class }}">
Avis de Paiement ({{ static_notices|length }})
Avis de Paiement ({{ advertList|length }})
</a>
<a id="quotes-tab" data-target="#quotes" role="tab" aria-controls="quotes" aria-selected="false"
class="{{ tab_class }}">
@@ -180,7 +176,7 @@
</div>
<div id="notices" role="tabpanel" aria-labelledby="notices-tab" class="tab-pane-tailwind hidden">
{% include 'artemis/dashboard/customer_doc_list.twig' with {'documents': static_notices, 'type': 'avis de paiement'} %}
{% include 'artemis/dashboard/customer_doc_list.twig' with {'documents': advertList, 'type': 'avis de paiement'} %}
</div>
<div id="quotes" role="tabpanel" aria-labelledby="quotes-tab" class="tab-pane-tailwind hidden">

View File

@@ -29,7 +29,7 @@
{% set badge_class = 'bg-yellow-600 text-yellow-100' %}
{% endif %}
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full {{ badge_class }}">
{{ document.status }}
{{ ('dc_'~document.status)|trans }}
</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">