diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 8b0ba08..9f88259 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -48,6 +48,7 @@ security: # Note: Only the *first* matching rule is applied access_control: + - { path: ^/uploads/devis, roles: ROLE_USER } - { path: ^/2fa, role: IS_AUTHENTICATED_2FA_IN_PROGRESS } - { path: ^/admin, roles: ROLE_EMPLOYE } - { path: ^/espace-client, roles: ROLE_CUSTOMER } diff --git a/config/packages/vich_uploader.yaml b/config/packages/vich_uploader.yaml index 0ca283a..efa05dd 100644 --- a/config/packages/vich_uploader.yaml +++ b/config/packages/vich_uploader.yaml @@ -6,3 +6,7 @@ vich_uploader: uri_prefix: /uploads/avatars upload_destination: '%kernel.project_dir%/public/uploads/avatars' namer: Vich\UploaderBundle\Naming\SmartUniqueNamer + devis_pdf: + uri_prefix: /uploads/devis + upload_destination: '%kernel.project_dir%/public/uploads/devis' + namer: Vich\UploaderBundle\Naming\SmartUniqueNamer diff --git a/migrations/Version20260402203334.php b/migrations/Version20260402203334.php new file mode 100644 index 0000000..9be74f4 --- /dev/null +++ b/migrations/Version20260402203334.php @@ -0,0 +1,41 @@ +addSql('ALTER TABLE devis ADD submitter_siteconseil_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE devis ADD submitter_customer_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE devis ADD unsigned_pdf VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE devis ADD signed_pdf VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE devis ADD audit_pdf VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE devis ADD updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE devis DROP submitter_siteconseil_id'); + $this->addSql('ALTER TABLE devis DROP submitter_customer_id'); + $this->addSql('ALTER TABLE devis DROP unsigned_pdf'); + $this->addSql('ALTER TABLE devis DROP signed_pdf'); + $this->addSql('ALTER TABLE devis DROP audit_pdf'); + $this->addSql('ALTER TABLE devis DROP updated_at'); + } +} diff --git a/src/Entity/Devis.php b/src/Entity/Devis.php index 94ddcf3..56ba2bf 100644 --- a/src/Entity/Devis.php +++ b/src/Entity/Devis.php @@ -6,8 +6,11 @@ use App\Repository\DevisRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\HttpFoundation\File\File; +use Vich\UploaderBundle\Mapping\Annotation as Vich; #[ORM\Entity(repositoryClass: DevisRepository::class)] +#[Vich\Uploadable] class Devis { #[ORM\Id] @@ -22,9 +25,36 @@ class Devis #[ORM\Column(length: 128)] private string $hmac; + #[ORM\Column(nullable: true)] + private ?int $submitterSiteconseilId = null; + + #[ORM\Column(nullable: true)] + private ?int $submitterCustomerId = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $unsignedPdf = null; + + #[Vich\UploadableField(mapping: 'devis_pdf', fileNameProperty: 'unsignedPdf')] + private ?File $unsignedPdfFile = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $signedPdf = null; + + #[Vich\UploadableField(mapping: 'devis_pdf', fileNameProperty: 'signedPdf')] + private ?File $signedPdfFile = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $auditPdf = null; + + #[Vich\UploadableField(mapping: 'devis_pdf', fileNameProperty: 'auditPdf')] + private ?File $auditPdfFile = null; + #[ORM\Column] private \DateTimeImmutable $createdAt; + #[ORM\Column(nullable: true)] + private ?\DateTimeImmutable $updatedAt = null; + /** @var Collection */ #[ORM\OneToMany(targetEntity: Advert::class, mappedBy: 'devis')] private Collection $adverts; @@ -52,11 +82,105 @@ class Devis return $this->hmac; } + public function getSubmitterSiteconseilId(): ?int + { + return $this->submitterSiteconseilId; + } + + public function setSubmitterSiteconseilId(?int $submitterSiteconseilId): void + { + $this->submitterSiteconseilId = $submitterSiteconseilId; + } + + public function getSubmitterCustomerId(): ?int + { + return $this->submitterCustomerId; + } + + public function setSubmitterCustomerId(?int $submitterCustomerId): void + { + $this->submitterCustomerId = $submitterCustomerId; + } + + public function getUnsignedPdf(): ?string + { + return $this->unsignedPdf; + } + + public function setUnsignedPdf(?string $unsignedPdf): void + { + $this->unsignedPdf = $unsignedPdf; + } + + public function getUnsignedPdfFile(): ?File + { + return $this->unsignedPdfFile; + } + + public function setUnsignedPdfFile(?File $unsignedPdfFile): void + { + $this->unsignedPdfFile = $unsignedPdfFile; + if (null !== $unsignedPdfFile) { + $this->updatedAt = new \DateTimeImmutable(); + } + } + + public function getSignedPdf(): ?string + { + return $this->signedPdf; + } + + public function setSignedPdf(?string $signedPdf): void + { + $this->signedPdf = $signedPdf; + } + + public function getSignedPdfFile(): ?File + { + return $this->signedPdfFile; + } + + public function setSignedPdfFile(?File $signedPdfFile): void + { + $this->signedPdfFile = $signedPdfFile; + if (null !== $signedPdfFile) { + $this->updatedAt = new \DateTimeImmutable(); + } + } + + public function getAuditPdf(): ?string + { + return $this->auditPdf; + } + + public function setAuditPdf(?string $auditPdf): void + { + $this->auditPdf = $auditPdf; + } + + public function getAuditPdfFile(): ?File + { + return $this->auditPdfFile; + } + + public function setAuditPdfFile(?File $auditPdfFile): void + { + $this->auditPdfFile = $auditPdfFile; + if (null !== $auditPdfFile) { + $this->updatedAt = new \DateTimeImmutable(); + } + } + public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; } + public function getUpdatedAt(): ?\DateTimeImmutable + { + return $this->updatedAt; + } + /** @return Collection */ public function getAdverts(): Collection {