diff --git a/config/packages/vich_uploader.yaml b/config/packages/vich_uploader.yaml index 881dab4..1afe6b4 100644 --- a/config/packages/vich_uploader.yaml +++ b/config/packages/vich_uploader.yaml @@ -1,6 +1,10 @@ vich_uploader: db_driver: orm mappings: + image_formules: + uri_prefix: /images/image_formules + upload_destination: '%kernel.project_dir%/public/images/image_formules' + namer: Vich\UploaderBundle\Naming\SmartUniqueNamer image_product: uri_prefix: /images/image_product upload_destination: '%kernel.project_dir%/public/images/image_product' diff --git a/migrations/Version20260128075215.php b/migrations/Version20260128075215.php new file mode 100644 index 0000000..2534434 --- /dev/null +++ b/migrations/Version20260128075215.php @@ -0,0 +1,42 @@ +addSql('CREATE TABLE formules (id SERIAL NOT NULL, name VARCHAR(255) NOT NULL, image_name VARCHAR(255) DEFAULT NULL, image_size INT DEFAULT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, type VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('COMMENT ON COLUMN formules.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('CREATE TABLE formules_product_inclus (id SERIAL NOT NULL, formules_id INT DEFAULT NULL, product_id INT DEFAULT NULL, config TEXT NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_BD36A828168F3793 ON formules_product_inclus (formules_id)'); + $this->addSql('CREATE INDEX IDX_BD36A8284584665A ON formules_product_inclus (product_id)'); + $this->addSql('COMMENT ON COLUMN formules_product_inclus.config IS \'(DC2Type:array)\''); + $this->addSql('ALTER TABLE formules_product_inclus ADD CONSTRAINT FK_BD36A828168F3793 FOREIGN KEY (formules_id) REFERENCES formules (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE formules_product_inclus ADD CONSTRAINT FK_BD36A8284584665A FOREIGN KEY (product_id) REFERENCES product (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + 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 formules_product_inclus DROP CONSTRAINT FK_BD36A828168F3793'); + $this->addSql('ALTER TABLE formules_product_inclus DROP CONSTRAINT FK_BD36A8284584665A'); + $this->addSql('DROP TABLE formules'); + $this->addSql('DROP TABLE formules_product_inclus'); + } +} diff --git a/src/Controller/Dashboard/FormulesController.php b/src/Controller/Dashboard/FormulesController.php new file mode 100644 index 0000000..9f293b1 --- /dev/null +++ b/src/Controller/Dashboard/FormulesController.php @@ -0,0 +1,40 @@ +record('VIEW', 'Consultation des formules'); + + return $this->render('dashboard/formules.twig', [ + 'formules' => $paginator->paginate($formulesRepository->findBy([],['id'=>'asc']), $request->query->getInt('page', 1), 10), + ]); + } + +} diff --git a/src/Entity/Formules.php b/src/Entity/Formules.php new file mode 100644 index 0000000..7801004 --- /dev/null +++ b/src/Entity/Formules.php @@ -0,0 +1,174 @@ + + */ + #[ORM\OneToMany(targetEntity: FormulesProductInclus::class, mappedBy: 'formules')] + private Collection $formulesProductIncluses; + + public function __construct() + { + $this->formulesProductIncluses = new ArrayCollection(); + } + + + public function getId(): ?int + { + return $this->id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + /** + * @return \DateTimeImmutable|null + */ + public function getUpdatedAt(): ?\DateTimeImmutable + { + return $this->updatedAt; + } + + /** + * @return File|null + */ + public function getImageFile(): ?File + { + return $this->imageFile; + } + + /** + * @return string|null + */ + public function getImageName(): ?string + { + return $this->imageName; + } + + /** + * @return int|null + */ + public function getImageSize(): ?int + { + return $this->imageSize; + } + + /** + * @param \DateTimeImmutable|null $updatedAt + */ + public function setUpdatedAt(?\DateTimeImmutable $updatedAt): void + { + $this->updatedAt = $updatedAt; + } + + /** + * @param File|null $imageFile + */ + public function setImageFile(?File $imageFile): void + { + $this->imageFile = $imageFile; + } + + /** + * @param string|null $imageName + */ + public function setImageName(?string $imageName): void + { + $this->imageName = $imageName; + } + + /** + * @param int|null $imageSize + */ + public function setImageSize(?int $imageSize): void + { + $this->imageSize = $imageSize; + } + + public function getType(): ?string + { + return $this->type; + } + + public function setType(string $type): static + { + $this->type = $type; + + return $this; + } + + /** + * @return Collection + */ + public function getFormulesProductIncluses(): Collection + { + return $this->formulesProductIncluses; + } + + public function addFormulesProductInclus(FormulesProductInclus $formulesProductInclus): static + { + if (!$this->formulesProductIncluses->contains($formulesProductInclus)) { + $this->formulesProductIncluses->add($formulesProductInclus); + $formulesProductInclus->setFormules($this); + } + + return $this; + } + + public function removeFormulesProductInclus(FormulesProductInclus $formulesProductInclus): static + { + if ($this->formulesProductIncluses->removeElement($formulesProductInclus)) { + // set the owning side to null (unless already changed) + if ($formulesProductInclus->getFormules() === $this) { + $formulesProductInclus->setFormules(null); + } + } + + return $this; + } +} diff --git a/src/Entity/FormulesProductInclus.php b/src/Entity/FormulesProductInclus.php new file mode 100644 index 0000000..2fde587 --- /dev/null +++ b/src/Entity/FormulesProductInclus.php @@ -0,0 +1,66 @@ +id; + } + + public function getFormules(): ?Formules + { + return $this->formules; + } + + public function setFormules(?Formules $formules): static + { + $this->formules = $formules; + + return $this; + } + + public function getPRODUCT(): ?Product + { + return $this->PRODUCT; + } + + public function setPRODUCT(?Product $PRODUCT): static + { + $this->PRODUCT = $PRODUCT; + + return $this; + } + + public function getConfig(): array + { + return $this->config; + } + + public function setConfig(array $config): static + { + $this->config = $config; + + return $this; + } +} diff --git a/src/Entity/Product.php b/src/Entity/Product.php index 244fc6c..25d708b 100644 --- a/src/Entity/Product.php +++ b/src/Entity/Product.php @@ -81,10 +81,17 @@ class Product #[ORM\Column(nullable: true)] private ?float $dimP = null; + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: FormulesProductInclus::class, mappedBy: 'PRODUCT')] + private Collection $formulesProductIncluses; + public function __construct() { $this->productReserves = new ArrayCollection(); $this->productDocs = new ArrayCollection(); + $this->formulesProductIncluses = new ArrayCollection(); } public function slug() { @@ -363,4 +370,34 @@ class Product return $this; } + + /** + * @return Collection + */ + public function getFormulesProductIncluses(): Collection + { + return $this->formulesProductIncluses; + } + + public function addFormulesProductInclus(FormulesProductInclus $formulesProductInclus): static + { + if (!$this->formulesProductIncluses->contains($formulesProductInclus)) { + $this->formulesProductIncluses->add($formulesProductInclus); + $formulesProductInclus->setPRODUCT($this); + } + + return $this; + } + + public function removeFormulesProductInclus(FormulesProductInclus $formulesProductInclus): static + { + if ($this->formulesProductIncluses->removeElement($formulesProductInclus)) { + // set the owning side to null (unless already changed) + if ($formulesProductInclus->getPRODUCT() === $this) { + $formulesProductInclus->setPRODUCT(null); + } + } + + return $this; + } } diff --git a/src/Repository/FormulesProductInclusRepository.php b/src/Repository/FormulesProductInclusRepository.php new file mode 100644 index 0000000..3f8bd2d --- /dev/null +++ b/src/Repository/FormulesProductInclusRepository.php @@ -0,0 +1,43 @@ + + */ +class FormulesProductInclusRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, FormulesProductInclus::class); + } + + // /** + // * @return FormulesProductInclus[] Returns an array of FormulesProductInclus objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('f') + // ->andWhere('f.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('f.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?FormulesProductInclus + // { + // return $this->createQueryBuilder('f') + // ->andWhere('f.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/src/Repository/FormulesRepository.php b/src/Repository/FormulesRepository.php new file mode 100644 index 0000000..9f9ec11 --- /dev/null +++ b/src/Repository/FormulesRepository.php @@ -0,0 +1,43 @@ + + */ +class FormulesRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Formules::class); + } + + // /** + // * @return Formules[] Returns an array of Formules objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('f') + // ->andWhere('f.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('f.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Formules + // { + // return $this->createQueryBuilder('f') + // ->andWhere('f.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/templates/dashboard/base.twig b/templates/dashboard/base.twig index 158b42d..64b5c93 100644 --- a/templates/dashboard/base.twig +++ b/templates/dashboard/base.twig @@ -42,6 +42,7 @@ {{ menu.nav_link(path('app_crm'), 'Dashboard', '', 'app_crm') }} {{ menu.nav_link(path('app_crm_product'), 'Produits', '', 'app_clients') }} + {{ menu.nav_link(path('app_crm_formules'), 'Formules', '', 'app_clients') }} {# {{ menu.nav_link(path('app_crm_contrats'), 'Contrat de location', '', 'app_clients') }}#} {# {{ menu.nav_link(path('app_crm_facture'), 'Facture', '', 'app_clients') }}#} {# {{ menu.nav_link(path('app_crm_devis'), 'Devis', '', 'app_clients') }}#} diff --git a/templates/dashboard/formules.twig b/templates/dashboard/formules.twig new file mode 100644 index 0000000..6fdfc8c --- /dev/null +++ b/templates/dashboard/formules.twig @@ -0,0 +1,66 @@ +{% extends 'dashboard/base.twig' %} + +{% block title %}Catalogue Formules{% endblock %} +{% block title_header %}Gestion du Formules{% endblock %} + +{% block actions %} + +{% endblock %} + +{% block body %} +
+
+ + + + + + + + + + + {% for formule in formules %} + + {% else %} + + + + {% endfor %} + +
VisuelDésignationTarifActions
+

Aucune formules

+
+
+
+ + {# PAGINATION #} + {% if formules.getTotalItemCount is defined and formules.getTotalItemCount > formules.getItemNumberPerPage %} +
+ {{ knp_pagination_render(formules) }} +
+ {% endif %} + + + + +{% endblock %}