From c7b4efcf1ad0618249548a25c29eed3114f1583c Mon Sep 17 00:00:00 2001 From: Serreau Jovann Date: Tue, 27 Jan 2026 10:01:13 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(produit):=20Am=C3=A9liore=20l'?= =?UTF-8?q?affichage=20des=20prix=20et=20ajoute=20des=20options=20de=20pri?= =?UTF-8?q?x=20suppl=C3=A9mentaires.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- migrations/Version20260127085400.php | 32 +++++++++++++++++++++++++++ migrations/Version20260127085439.php | 32 +++++++++++++++++++++++++++ src/Controller/ReserverController.php | 2 +- src/Entity/Product.php | 4 ++-- src/Form/ProductType.php | 3 +-- templates/dashboard/products/add.twig | 4 +++- templates/revervation/catalogue.twig | 8 +++++-- templates/revervation/home.twig | 6 ++++- templates/revervation/produit.twig | 14 ++++++++---- 9 files changed, 92 insertions(+), 13 deletions(-) create mode 100644 migrations/Version20260127085400.php create mode 100644 migrations/Version20260127085439.php diff --git a/migrations/Version20260127085400.php b/migrations/Version20260127085400.php new file mode 100644 index 0000000..4f80623 --- /dev/null +++ b/migrations/Version20260127085400.php @@ -0,0 +1,32 @@ +addSql('ALTER TABLE product ALTER dim_w DROP NOT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE product ALTER dim_w SET NOT NULL'); + } +} diff --git a/migrations/Version20260127085439.php b/migrations/Version20260127085439.php new file mode 100644 index 0000000..a071971 --- /dev/null +++ b/migrations/Version20260127085439.php @@ -0,0 +1,32 @@ +addSql('ALTER TABLE product ALTER price_sup DROP NOT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE product ALTER price_sup SET NOT NULL'); + } +} diff --git a/src/Controller/ReserverController.php b/src/Controller/ReserverController.php index b0360c8..3945bff 100644 --- a/src/Controller/ReserverController.php +++ b/src/Controller/ReserverController.php @@ -55,7 +55,7 @@ class ReserverController extends AbstractController #[Route('/reservation', name: 'reservation')] public function revervation(ProductRepository $productRepository): Response { - $products =$productRepository->findBy([], ['updatedAt' => 'DESC']); + $products =$productRepository->findBy([], ['updatedAt' => 'DESC'],3); return $this->render('revervation/home.twig',[ 'products' => $products ]); diff --git a/src/Entity/Product.php b/src/Entity/Product.php index deb8408..1cad335 100644 --- a/src/Entity/Product.php +++ b/src/Entity/Product.php @@ -33,7 +33,7 @@ class Product #[ORM\Column] private ?float $priceDay = null; - #[ORM\Column] + #[ORM\Column(nullable: true)] private ?float $priceSup = null; #[ORM\Column] @@ -78,7 +78,7 @@ class Product #[ORM\OneToMany(targetEntity: ProductDoc::class, mappedBy: 'product')] private Collection $productDocs; - #[ORM\Column] + #[ORM\Column(nullable: true)] private ?float $dimW = null; #[ORM\Column(nullable: true)] diff --git a/src/Form/ProductType.php b/src/Form/ProductType.php index 67967a9..54ed388 100644 --- a/src/Form/ProductType.php +++ b/src/Form/ProductType.php @@ -55,8 +55,7 @@ class ProductType extends AbstractType 'html5' => true, ]) ->add('priceSup',NumberType::class,[ - 'label' => 'Prix Suplémentaire', - 'required' => true, + 'required' => false, 'html5' => true, ]) diff --git a/templates/dashboard/products/add.twig b/templates/dashboard/products/add.twig index 98e5ec9..7045e57 100644 --- a/templates/dashboard/products/add.twig +++ b/templates/dashboard/products/add.twig @@ -5,6 +5,7 @@ {% block actions %}
+ {% if product.slug != "" %} @@ -20,6 +21,7 @@ + {% endif %}
{% endblock %} {% block body %} @@ -163,7 +165,7 @@ {# PRIX LOCATION #}
- {{ form_label(form.priceDay, 'Tarif 1er Jour (€)', {'label_attr': {'class': 'text-[10px] font-black text-slate-500 uppercase tracking-widest ml-1 mb-2 block'}}) }} + {{ form_label(form.priceDay, 'Tarif 1er Jour (€) Ou Tarif weekend (si Barnums)', {'label_attr': {'class': 'text-[10px] font-black text-slate-500 uppercase tracking-widest ml-1 mb-2 block'}}) }}
{{ form_widget(form.priceDay, {'attr': {'class': 'w-full bg-slate-900/50 border-white/5 rounded-2xl text-emerald-400 font-black text-xl focus:ring-emerald-500/20 focus:border-emerald-500 transition-all py-4 px-5'}}) }} €HT diff --git a/templates/revervation/catalogue.twig b/templates/revervation/catalogue.twig index e2e9992..3c4c007 100644 --- a/templates/revervation/catalogue.twig +++ b/templates/revervation/catalogue.twig @@ -80,8 +80,12 @@ {# PRIX #}
-

- A partir de {{ product.priceDay }}€ / Jour +

+ {% if product.category == "barnums" %} + A partir de {{ product.priceDay|format_currency('EUR') }} / Week-End + {% else %} + A partir de {{ product.priceDay|format_currency('EUR') }} / Jour + {% endif %}

diff --git a/templates/revervation/home.twig b/templates/revervation/home.twig index b947e88..57f6488 100644 --- a/templates/revervation/home.twig +++ b/templates/revervation/home.twig @@ -151,7 +151,11 @@ {# Badge Prix flottant #}
-

Location / Jour

+ {% if product.category == "barnums" %} +

Week-End

+ {% else %} +

Jour

+ {% endif %}

Dès {{ product.priceDay|format_currency('EUR') }}

diff --git a/templates/revervation/produit.twig b/templates/revervation/produit.twig index b2e437c..484168c 100644 --- a/templates/revervation/produit.twig +++ b/templates/revervation/produit.twig @@ -109,18 +109,24 @@
{# Prix principal #}
- {{ product.priceDay }}€ - La première journée + {{ product.priceDay|format_currency('EUR') }} + {% if product.category == "barnums" %} + Week-End + {% else %} + La première journée + {% endif %}
{# Grille de badges Tarifs/Caution #}
+ {% if product.category != "barnums" %}
- + {{ product.priceSup }}€ + + {{ product.priceSup|format_currency('EUR') }}€ Jour supplémentaire
+ {% endif %}
- {{ product.caution }}€ + {{ product.caution|format_currency('EUR') }} LA CAUTION