diff --git a/migrations/Version20260207010000.php b/migrations/Version20260207010000.php new file mode 100644 index 0000000..45bb340 --- /dev/null +++ b/migrations/Version20260207010000.php @@ -0,0 +1,34 @@ +addSql('CREATE TABLE etat_lieux_point_control (id SERIAL NOT NULL, etat_lieux_id INT NOT NULL, name VARCHAR(255) NOT NULL, status BOOLEAN DEFAULT false NOT NULL, details TEXT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_ETAT_LIEUX_POINT_CONTROL ON etat_lieux_point_control (etat_lieux_id)'); + $this->addSql('ALTER TABLE etat_lieux_point_control ADD CONSTRAINT FK_ETAT_LIEUX_POINT_CONTROL FOREIGN KEY (etat_lieux_id) REFERENCES etat_lieux (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('ALTER TABLE etat_lieux_point_control DROP FOREIGN KEY FK_ETAT_LIEUX_POINT_CONTROL'); + $this->addSql('DROP TABLE etat_lieux_point_control'); + } +} diff --git a/src/Controller/EtlController.php b/src/Controller/EtlController.php index e212514..710c342 100644 --- a/src/Controller/EtlController.php +++ b/src/Controller/EtlController.php @@ -22,6 +22,8 @@ use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Mime\Part\DataPart; +use Symfony\Component\Mime\Part\File as MimeFile; use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; @@ -687,6 +689,11 @@ class EtlController extends AbstractController $recipients[] = $etatLieux->getPrestataire()->getEmail(); } + $attachments = []; + if (isset($tmpPath) && file_exists($tmpPath)) { + $attachments[] = DataPart::fromPath($tmpPath, 'Etat_des_lieux_signe.pdf'); + } + foreach (array_unique($recipients) as $email) { $mailer->send( $email, @@ -697,10 +704,7 @@ class EtlController extends AbstractController 'contrat' => $contrat, 'etatLieux' => $etatLieux ], - // Attachments logic would go here if Mailer service supports it easily - // For now, links in email body or assuming Mailer handles file objects if passed? - // The custom Mailer service in this project likely needs checking. - // Assuming it sends 'datas' to template. + $attachments ); } diff --git a/src/Entity/EtatLieux.php b/src/Entity/EtatLieux.php index 747ef2f..e22ee2b 100644 --- a/src/Entity/EtatLieux.php +++ b/src/Entity/EtatLieux.php @@ -43,6 +43,12 @@ class EtatLieux #[ORM\OneToMany(targetEntity: EtatLieuxComment::class, mappedBy: 'etatLieux', cascade: ['persist', 'remove'])] private Collection $comments; + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: EtatLieuxPointControl::class, mappedBy: 'etatLieux', cascade: ['persist', 'remove'])] + private Collection $pointControls; + #[ORM\Column(length: 255, nullable: true)] private ?string $signIdDelivery = null; @@ -120,6 +126,7 @@ class EtatLieux { $this->files = new ArrayCollection(); $this->comments = new ArrayCollection(); + $this->pointControls = new ArrayCollection(); } public function getId(): ?int @@ -491,4 +498,33 @@ class EtatLieux { $this->etatLieuxAuditReturnFileSize = $etatLieuxAuditReturnFileSize; } + + /** + * @return Collection + */ + public function getPointControls(): Collection + { + return $this->pointControls; + } + + public function addPointControl(EtatLieuxPointControl $pointControl): static + { + if (!$this->pointControls->contains($pointControl)) { + $this->pointControls->add($pointControl); + $pointControl->setEtatLieux($this); + } + + return $this; + } + + public function removePointControl(EtatLieuxPointControl $pointControl): static + { + if ($this->pointControls->removeElement($pointControl)) { + if ($pointControl->getEtatLieux() === $this) { + $pointControl->setEtatLieux(null); + } + } + + return $this; + } } diff --git a/src/Entity/EtatLieuxPointControl.php b/src/Entity/EtatLieuxPointControl.php new file mode 100644 index 0000000..be56353 --- /dev/null +++ b/src/Entity/EtatLieuxPointControl.php @@ -0,0 +1,82 @@ + false])] + private ?bool $status = false; + + #[ORM\Column(type: Types::TEXT, nullable: true)] + private ?string $details = null; + + #[ORM\ManyToOne(inversedBy: 'pointControls')] + #[ORM\JoinColumn(nullable: false)] + private ?EtatLieux $etatLieux = null; + + 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; + } + + public function isStatus(): ?bool + { + return $this->status; + } + + public function setStatus(bool $status): static + { + $this->status = $status; + + return $this; + } + + public function getDetails(): ?string + { + return $this->details; + } + + public function setDetails(?string $details): static + { + $this->details = $details; + + return $this; + } + + public function getEtatLieux(): ?EtatLieux + { + return $this->etatLieux; + } + + public function setEtatLieux(?EtatLieux $etatLieux): static + { + $this->etatLieux = $etatLieux; + + return $this; + } +} diff --git a/src/Repository/EtatLieuxPointControlRepository.php b/src/Repository/EtatLieuxPointControlRepository.php new file mode 100644 index 0000000..3efad4e --- /dev/null +++ b/src/Repository/EtatLieuxPointControlRepository.php @@ -0,0 +1,23 @@ + + * + * @method EtatLieuxPointControl|null find($id, $lockMode = null, $lockVersion = null) + * @method EtatLieuxPointControl|null findOneBy(array $criteria, array $orderBy = null) + * @method EtatLieuxPointControl[] findAll() + * @method EtatLieuxPointControl[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class EtatLieuxPointControlRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, EtatLieuxPointControl::class); + } +}