From 5be56cf4ba57809b131d6b6230ca387a9073678b Mon Sep 17 00:00:00 2001 From: Maxime Date: Wed, 6 Aug 2025 16:03:32 +0200 Subject: [PATCH] feat: invoice estimate list --- app/config/config.yml | 10 ++- app/config/routing/admin.yml | 4 + sources/AppBundle/Cash/Model/AfupInvoice.php | 15 ++++ .../Repository/AfupInvoiceRepository.php | 81 +++++++++++++++++++ .../Admin/Cash/Estimate/ListAction.php | 30 +++++++ templates/admin/cash/estimate/list.html.twig | 69 ++++++++++++++++ 6 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 sources/AppBundle/Cash/Model/AfupInvoice.php create mode 100644 sources/AppBundle/Cash/Model/Repository/AfupInvoiceRepository.php create mode 100644 sources/AppBundle/Controller/Admin/Cash/Estimate/ListAction.php create mode 100644 templates/admin/cash/estimate/list.html.twig diff --git a/app/config/config.yml b/app/config/config.yml index 3935ccc36..0d65ef453 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -200,9 +200,10 @@ parameters: niveau: 'ROLE_ADMIN' icon: "money bill alternate" elements: - compta_devis: + admin_cash_estimate_list: nom: 'Devis' niveau: 'ROLE_ADMIN' + url: '/admin/cash/estimate/list' compta_facture: nom: 'Factures' niveau: 'ROLE_ADMIN' @@ -375,6 +376,13 @@ ting: default: connection: main database: '%database_name%' + cash: + namespace : AppBundle\Cash\Model\Repository + directory : "@AppBundle/Cash/Model/Repository" + options: + default: + connection: main + database: '%database_name%' site: namespace : AppBundle\Site\Model\Repository directory : "@AppBundle/Site/Model/Repository" diff --git a/app/config/routing/admin.yml b/app/config/routing/admin.yml index 39848e5e8..f295c2180 100644 --- a/app/config/routing/admin.yml +++ b/app/config/routing/admin.yml @@ -108,3 +108,7 @@ admin_github_user_routes: admin_healthcheck: path: /healthcheck defaults: {_controller: AppBundle\Controller\Admin\HealthcheckController} + +admin_cash_estimate_list: + path: /cash/estimate/list + defaults: {_controller: AppBundle\Controller\Admin\Cash\Estimate\ListAction} diff --git a/sources/AppBundle/Cash/Model/AfupInvoice.php b/sources/AppBundle/Cash/Model/AfupInvoice.php new file mode 100644 index 000000000..26a8876e1 --- /dev/null +++ b/sources/AppBundle/Cash/Model/AfupInvoice.php @@ -0,0 +1,15 @@ + + */ +class AfupInvoiceRepository extends Repository implements MetadataInitializer +{ + /** + * @return list + */ + public function getList(): array + { + $sql = <<getQuery($sql); + + $results = $query->query($this->getCollection(new HydratorArray())); + $data = []; + + foreach ($results as $result) { + $data[] = $result; + } + + return $data; + } + + /** + * + * @return Metadata + * + * @throws Exception + */ + public static function initMetadata(SerializerFactoryInterface $serializerFactory, array $options = []) + { + $metadata = new Metadata($serializerFactory); + $metadata->setEntity(AfupInvoice::class); + $metadata->setConnectionName('main'); + $metadata->setDatabase($options['database']); + $metadata->setTable('afup_compta_facture'); + + $metadata + ->addField([ + 'columnName' => 'id', + 'fieldName' => 'id', + 'primary' => true, + 'autoincrement' => true, + 'type' => 'int', + ]) + ->addField([ + 'columnName' => 'date_devis', + 'fieldName' => 'dateEstimate', + 'type' => 'date', + ]) + ->addField([ + 'columnName' => 'societe', + 'fieldName' => 'enterprise', + 'type' => 'string', + ]) + ; + + return $metadata; + } +} diff --git a/sources/AppBundle/Controller/Admin/Cash/Estimate/ListAction.php b/sources/AppBundle/Controller/Admin/Cash/Estimate/ListAction.php new file mode 100644 index 000000000..3484804f2 --- /dev/null +++ b/sources/AppBundle/Controller/Admin/Cash/Estimate/ListAction.php @@ -0,0 +1,30 @@ +addFlash('notice', $_SESSION['flash']['message']); + } + if (isset($_SESSION['flash']['erreur'])) { + $this->addFlash('error', $_SESSION['flash']['erreur']); + } + unset($_SESSION['flash']); + $list = $this->afupInvoiceRepository->getList(); + return $this->render('admin/cash/estimate/list.html.twig', [ + 'estimates' => $list, + ]); + } +} diff --git a/templates/admin/cash/estimate/list.html.twig b/templates/admin/cash/estimate/list.html.twig new file mode 100644 index 000000000..7011d4979 --- /dev/null +++ b/templates/admin/cash/estimate/list.html.twig @@ -0,0 +1,69 @@ +{% extends 'admin/base_with_header.html.twig' %} + +{% block content %} +

Liste des devis

+ + + + + + + + + + + + + + + + + + + {% for estimate in estimates %} + + + + + + + + + + + + {% endfor %} + +
IdDateClientsVilleref ClientNuméro devisPrixFacturé?Actions
{{ estimate.id }}{{ estimate.date_devis }}{{ estimate.societe }}{{ estimate.ville }}{{ estimate.ref_clt1 }}{{ estimate.numero_devis }}{{ estimate.prix_total_devis|number_format(2, ',', ' ') }}{% if estimate.date_facture == null %}Non{% else %}Oui{% endif %} + {% if estimate.date_facture == null %} + + {% else %} + + {% endif %} + + {% if estimate.date_facture == null %} + + {% endif %} +
+ + +{% endblock %} + +