✨ feat(email, etat-lieux): Ajoute l'attachement du PDF signé et la collection de points de contrôle.
This commit is contained in:
34
migrations/Version20260207010000.php
Normal file
34
migrations/Version20260207010000.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20260207010000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Create etat_lieux_point_control table';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->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');
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,12 @@ class EtatLieux
|
||||
#[ORM\OneToMany(targetEntity: EtatLieuxComment::class, mappedBy: 'etatLieux', cascade: ['persist', 'remove'])]
|
||||
private Collection $comments;
|
||||
|
||||
/**
|
||||
* @var Collection<int, EtatLieuxPointControl>
|
||||
*/
|
||||
#[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<int, EtatLieuxPointControl>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
82
src/Entity/EtatLieuxPointControl.php
Normal file
82
src/Entity/EtatLieuxPointControl.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\EtatLieuxPointControlRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: EtatLieuxPointControlRepository::class)]
|
||||
class EtatLieuxPointControl
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\Column(options: ['default' => 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;
|
||||
}
|
||||
}
|
||||
23
src/Repository/EtatLieuxPointControlRepository.php
Normal file
23
src/Repository/EtatLieuxPointControlRepository.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\EtatLieuxPointControl;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<EtatLieuxPointControl>
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user