✨ feat(artemis/dashboard): Affiche les factures du client connecté.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Controller\Artemis;
|
||||
|
||||
use App\Repository\CustomerOrderRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
@@ -11,9 +12,29 @@ use Symfony\Component\Routing\Attribute\Route;
|
||||
class DashboardController extends AbstractController
|
||||
{
|
||||
#[Route('/artemis', name: 'artemis_dashboard', methods: ['GET', 'POST'])]
|
||||
public function artemis(Request $request): Response
|
||||
public function artemis(Request $request,CustomerOrderRepository $customerOrderRepository): Response
|
||||
{
|
||||
$invoiceList = [];
|
||||
$remaining_amount = 0;
|
||||
if(in_array("ROLE_CUSTOMER",$this->getUser()->getRoles())) {
|
||||
$customer = $this->getUser()->getCustomers()[0];
|
||||
foreach ($customerOrderRepository->findBy(['customer'=>$customer]) as $order) {
|
||||
$amount = 0;
|
||||
foreach ($order->getCustomerOrderLines() as $customerOrderLine) {
|
||||
$amount += (1.*20*$customerOrderLine->getPriceHt());
|
||||
}
|
||||
$invoiceList[] = [
|
||||
'reference' => $order->getNumOrder(),
|
||||
'date' => $order->getCreateAt()->format('Y-m-d'),
|
||||
'amount' => $amount,
|
||||
'status' => $order->getState(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('artemis/dashboard.twig',[
|
||||
'invoiceList' => $invoiceList,
|
||||
'remaining_amount' => $remaining_amount,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,6 @@
|
||||
{% if is_granted('ROLE_CUSTOMER') %}
|
||||
|
||||
{# Données Statiques simulant les informations de l'API/BDD #}
|
||||
{% set remaining_amount = 450.75 %}
|
||||
|
||||
{% set static_invoices = [
|
||||
{'reference': 'F-2024-0012', 'date': '2024-09-15', 'amount': 150.00, 'status': 'En attente', 'id': 12},
|
||||
{'reference': 'F-2024-0011', 'date': '2024-08-20', 'amount': 300.75, 'status': 'En attente', 'id': 11},
|
||||
{'reference': 'F-2024-0010', 'date': '2024-07-25', 'amount': 55.00, 'status': 'Payé', 'id': 10},
|
||||
] %}
|
||||
|
||||
{% set static_notices = [
|
||||
{'reference': 'AP-2024-0005', 'date': '2024-09-25', 'amount': 300.75, 'status': 'Validé', 'id': 5},
|
||||
@@ -166,7 +159,7 @@
|
||||
|
||||
<a id="invoices-tab" data-target="#invoices" role="tab" aria-controls="invoices" aria-selected="true"
|
||||
class="{{ tab_class }}">
|
||||
Factures ({{ static_invoices|length }})
|
||||
Factures ({{ invoiceList|length }})
|
||||
</a>
|
||||
<a id="notices-tab" data-target="#notices" role="tab" aria-controls="notices" aria-selected="false"
|
||||
class="{{ tab_class }}">
|
||||
@@ -183,7 +176,7 @@
|
||||
|
||||
{# Inclusions du fichier artemis/dashboard/customer_doc_list.twig #}
|
||||
<div id="invoices" role="tabpanel" aria-labelledby="invoices-tab" class="tab-pane-tailwind block">
|
||||
{% include 'artemis/dashboard/customer_doc_list.twig' with {'documents': static_invoices, 'type': 'facture'} %}
|
||||
{% include 'artemis/dashboard/customer_doc_list.twig' with {'documents': invoiceList, 'type': 'facture'} %}
|
||||
</div>
|
||||
|
||||
<div id="notices" role="tabpanel" aria-labelledby="notices-tab" class="tab-pane-tailwind hidden">
|
||||
|
||||
Reference in New Issue
Block a user