diff --git a/migrations/Version20260404193257.php b/migrations/Version20260404193257.php new file mode 100644 index 0000000..b3ff459 --- /dev/null +++ b/migrations/Version20260404193257.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE customer ADD revendeur_code VARCHAR(10) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE customer DROP revendeur_code'); + } +} diff --git a/migrations/Version20260404193605.php b/migrations/Version20260404193605.php new file mode 100644 index 0000000..c6a8221 --- /dev/null +++ b/migrations/Version20260404193605.php @@ -0,0 +1,37 @@ +addSql('CREATE TABLE website_configuration (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, type VARCHAR(25) NOT NULL, value TEXT NOT NULL, website_id INT NOT NULL, PRIMARY KEY (id))'); + $this->addSql('CREATE INDEX IDX_8BC287E818F45C82 ON website_configuration (website_id)'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_8BC287E818F45C828CDE5729 ON website_configuration (website_id, type)'); + $this->addSql('ALTER TABLE website_configuration ADD CONSTRAINT FK_8BC287E818F45C82 FOREIGN KEY (website_id) REFERENCES website (id) ON DELETE CASCADE NOT DEFERRABLE'); + $this->addSql('ALTER TABLE website ADD revendeur_code VARCHAR(10) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE website_configuration DROP CONSTRAINT FK_8BC287E818F45C82'); + $this->addSql('DROP TABLE website_configuration'); + $this->addSql('ALTER TABLE website DROP revendeur_code'); + } +} diff --git a/src/Controller/Admin/ClientsController.php b/src/Controller/Admin/ClientsController.php index 22fcd8f..c700283 100644 --- a/src/Controller/Admin/ClientsController.php +++ b/src/Controller/Admin/ClientsController.php @@ -13,6 +13,7 @@ use App\Service\MailerService; use App\Service\MeilisearchService; use App\Service\OvhService; use App\Service\UserManagementService; +use App\Repository\RevendeurRepository; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; @@ -47,6 +48,7 @@ class ClientsController extends AbstractController public function create( Request $request, CustomerRepository $customerRepository, + RevendeurRepository $revendeurRepository, EntityManagerInterface $em, MeilisearchService $meilisearch, UserManagementService $userService, @@ -57,7 +59,9 @@ class ClientsController extends AbstractController #[Autowire(env: 'STRIPE_SK')] string $stripeSecretKey, ): Response { if ('POST' !== $request->getMethod()) { - return $this->render('admin/clients/create.html.twig'); + return $this->render('admin/clients/create.html.twig', [ + 'revendeurs' => $revendeurRepository->findBy(['isActive' => true], ['codeRevendeur' => 'ASC']), + ]); } try { @@ -223,6 +227,7 @@ class ClientsController extends AbstractController $customer->setZipCode(trim($request->request->getString('zipCode')) ?: null); $customer->setCity(trim($request->request->getString('city')) ?: null); $customer->setTypeCompany(trim($request->request->getString('typeCompany')) ?: null); + $customer->setRevendeurCode(trim($request->request->getString('revendeurCode')) ?: null); $customer->setGeoLat(trim($request->request->getString('geoLat')) ?: null); $customer->setGeoLong(trim($request->request->getString('geoLong')) ?: null); } diff --git a/src/Entity/Customer.php b/src/Entity/Customer.php index 56a8976..cddf5bc 100644 --- a/src/Entity/Customer.php +++ b/src/Entity/Customer.php @@ -112,6 +112,9 @@ class Customer #[ORM\Column(length: 50, unique: true, nullable: true)] private ?string $codeComptable = null; + #[ORM\Column(length: 10, nullable: true)] + private ?string $revendeurCode = null; + #[ORM\Column(nullable: true)] private ?\DateTimeImmutable $updatedAt = null; @@ -133,6 +136,18 @@ class Customer return $this; } + public function getRevendeurCode(): ?string + { + return $this->revendeurCode; + } + + public function setRevendeurCode(?string $revendeurCode): static + { + $this->revendeurCode = $revendeurCode; + + return $this; + } + public function generateCodeComptable(): string { $prefix = '411'; diff --git a/src/Entity/Website.php b/src/Entity/Website.php index 525a979..fcfa1b4 100644 --- a/src/Entity/Website.php +++ b/src/Entity/Website.php @@ -38,6 +38,9 @@ class Website #[ORM\Column(length: 20)] private string $state = self::STATE_CREATED; + #[ORM\Column(length: 10, nullable: true)] + private ?string $revendeurCode = null; + #[ORM\Column] private \DateTimeImmutable $createdAt; @@ -110,6 +113,18 @@ class Website return self::STATE_OPEN === $this->state; } + public function getRevendeurCode(): ?string + { + return $this->revendeurCode; + } + + public function setRevendeurCode(?string $revendeurCode): static + { + $this->revendeurCode = $revendeurCode; + + return $this; + } + public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; diff --git a/src/Entity/WebsiteConfiguration.php b/src/Entity/WebsiteConfiguration.php new file mode 100644 index 0000000..6d60730 --- /dev/null +++ b/src/Entity/WebsiteConfiguration.php @@ -0,0 +1,66 @@ +website = $website; + $this->type = $type; + $this->value = $value; + } + + public function getId(): ?int + { + return $this->id; + } + + public function getWebsite(): Website + { + return $this->website; + } + + public function getType(): string + { + return $this->type; + } + + public function setType(string $type): static + { + $this->type = $type; + + return $this; + } + + public function getValue(): string + { + return $this->value; + } + + public function setValue(string $value): static + { + $this->value = $value; + + return $this; + } +} diff --git a/templates/admin/clients/create.html.twig b/templates/admin/clients/create.html.twig index 5253849..bdbe511 100644 --- a/templates/admin/clients/create.html.twig +++ b/templates/admin/clients/create.html.twig @@ -68,6 +68,15 @@ +