<?php

namespace App\Entity;

use App\Repository\EtatLieuxRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Attribute\Uploadable;
use Vich\UploaderBundle\Mapping\Attribute\UploadableField;

#[ORM\Entity(repositoryClass: EtatLieuxRepository::class)]
#[Uploadable]
class EtatLieux
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\OneToOne(inversedBy: 'etatLieux', cascade: ['persist', 'remove'])]
    private ?Contrats $contrat = null;

    #[ORM\ManyToOne(inversedBy: 'etatLieuxes')]
    private ?Prestaire $prestataire = null;

    #[ORM\ManyToOne(inversedBy: 'etatLieuxes')]
    private ?Account $account = null;

    #[ORM\Column(length: 50, options: ['default' => 'delivery_ready'])]
    private string $status = 'delivery_ready';

    /**
     * @var Collection<int, EtatLieuxFile>
     */
    #[ORM\OneToMany(targetEntity: EtatLieuxFile::class, mappedBy: 'etatLieux', cascade: ['persist', 'remove'])]
    private Collection $files;

    /**
     * @var Collection<int, EtatReturnLieuxFile>
     */
    #[ORM\OneToMany(targetEntity: EtatReturnLieuxFile::class, mappedBy: 'etatLieux', cascade: ['persist', 'remove'])]
    private Collection $filesReturn;

    /**
     * @var Collection<int, EtatLieuxComment>
     */
    #[ORM\OneToMany(targetEntity: EtatLieuxComment::class, mappedBy: 'etatLieux', cascade: ['persist', 'remove'])]
    private Collection $comments;

    #[ORM\OneToMany(targetEntity: EtatLieuxReturnComment::class, mappedBy: 'etatLieux', cascade: ['persist', 'remove'])]
    private Collection $commentsReturns;

    /**
     * @var Collection<int, EtatLieuxPointControl>
     */
    #[ORM\OneToMany(targetEntity: EtatLieuxPointControl::class, mappedBy: 'etatLieux', cascade: ['persist', 'remove'])]
    private Collection $pointControls;
    /**
     * @var Collection<int, EtatLieuxPointControl>
     */
    #[ORM\OneToMany(targetEntity: EtatLieuxReturnPointControl::class, mappedBy: 'etatLieux', cascade: ['persist', 'remove'])]
    private Collection $pointControlsReturn;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $signIdDelivery = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $signIdCustomer = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $signIdReturn = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $signIdCustomerReturn = null;

    // --- FILES DELIVERY ---

    #[UploadableField(mapping: 'etat_lieux_unsign', fileNameProperty: 'etatLieuxUnsignFileName', size: 'etatLieuxUnsignFileSize')]
    private ?File $etatLieuxUnsignFile = null;

    #[ORM\Column(nullable: true)]
    private ?string $etatLieuxUnsignFileName = null;

    #[ORM\Column(nullable: true)]
    private ?int $etatLieuxUnsignFileSize = null;

    #[UploadableField(mapping: 'etat_lieux_sign', fileNameProperty: 'etatLieuxSignFileName', size: 'etatLieuxSignFileSize')]
    private ?File $etatLieuxSignFile = null;

    #[ORM\Column(nullable: true)]
    private ?string $etatLieuxSignFileName = null;

    #[ORM\Column(nullable: true)]
    private ?int $etatLieuxSignFileSize = null;

    #[UploadableField(mapping: 'etat_lieux_audit', fileNameProperty: 'etatLieuxAuditFileName', size: 'etatLieuxAuditFileSize')]
    private ?File $etatLieuxAuditFile = null;

    #[ORM\Column(nullable: true)]
    private ?string $etatLieuxAuditFileName = null;

    #[ORM\Column(nullable: true)]
    private ?int $etatLieuxAuditFileSize = null;

    // --- FILES RETURN ---

    #[UploadableField(mapping: 'etat_lieux_unsign_return', fileNameProperty: 'etatLieuxUnsignReturnFileName', size: 'etatLieuxUnsignReturnFileSize')]
    private ?File $etatLieuxUnsignReturnFile = null;

    #[ORM\Column(nullable: true)]
    private ?string $etatLieuxUnsignReturnFileName = null;

    #[ORM\Column(nullable: true)]
    private ?int $etatLieuxUnsignReturnFileSize = null;

    #[UploadableField(mapping: 'etat_lieux_sign_return', fileNameProperty: 'etatLieuxSignReturnFileName', size: 'etatLieuxSignReturnFileSize')]
    private ?File $etatLieuxSignReturnFile = null;

    #[ORM\Column(nullable: true)]
    private ?string $etatLieuxSignReturnFileName = null;

    #[ORM\Column(nullable: true)]
    private ?int $etatLieuxSignReturnFileSize = null;

    #[UploadableField(mapping: 'etat_lieux_audit_return', fileNameProperty: 'etatLieuxAuditReturnFileName', size: 'etatLieuxAuditReturnFileSize')]
    private ?File $etatLieuxAuditReturnFile = null;

    #[ORM\Column(nullable: true)]
    private ?string $etatLieuxAuditReturnFileName = null;

    #[ORM\Column(nullable: true)]
    private ?int $etatLieuxAuditReturnFileSize = null;

    #[ORM\Column(nullable: true)]
    private ?\DateTimeImmutable $updatedAt = null;

    #[ORM\Column(type: Types::TEXT, nullable: true)]
    private ?string $raisonRefused = null;

    public function __construct()
    {
        $this->files = new ArrayCollection();
        $this->filesReturn = new ArrayCollection();
        $this->comments = new ArrayCollection();
        $this->commentsReturns = new ArrayCollection();
        $this->pointControls = new ArrayCollection();
        $this->pointControlsReturn = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    /**
     * @return Collection<int, EtatLieuxFile>
     */
    public function getFiles(): Collection
    {
        return $this->files;
    }

    public function addFile(EtatLieuxFile $file): static
    {
        if (!$this->files->contains($file)) {
            $this->files->add($file);
            $file->setEtatLieux($this);
        }

        return $this;
    }

    public function removeFile(EtatLieuxFile $file): static
    {
        if ($this->files->removeElement($file)) {
            // set the owning side to null (unless already changed)
            if ($file->getEtatLieux() === $this) {
                $file->setEtatLieux(null);
            }
        }

        return $this;
    }


    /**
     * @return Collection<int, EtatLieuxFile>
     */
    public function getFileReturn(): Collection
    {
        return $this->filesReturn;
    }

    public function addFileReturn(EtatReturnLieuxFile $file): static
    {
        if (!$this->filesReturn->contains($file)) {
            $this->filesReturn->add($file);
            $file->setEtatLieux($this);
        }

        return $this;
    }

    public function removeFileReturn(EtatReturnLieuxFile $file): static
    {
        if ($this->filesReturn->removeElement($file)) {
            // set the owning side to null (unless already changed)
            if ($file->getEtatLieux() === $this) {
                $file->setEtatLieux(null);
            }
        }

        return $this;
    }

    public function getStatus(): string
    {
        return $this->status;
    }

    public function setStatus(string $status): static
    {
        $this->status = $status;

        return $this;
    }

    public function getAccount(): ?Account
    {
        return $this->account;
    }

    public function setAccount(?Account $account): static
    {
        $this->account = $account;

        return $this;
    }

    public function getContrat(): ?Contrats
    {
        return $this->contrat;
    }

    public function setContrat(?Contrats $contrat): static
    {
        $this->contrat = $contrat;

        return $this;
    }

    public function getPrestataire(): ?Prestaire
    {
        return $this->prestataire;
    }

    public function setPrestataire(?Prestaire $prestataire): static
    {
        $this->prestataire = $prestataire;

        return $this;
    }

    /**
     * @return Collection<int, EtatLieuxComment>
     */
    public function getComments(): Collection
    {
        return $this->comments;
    }

    public function addComment(EtatLieuxComment $comment): static
    {
        if (!$this->comments->contains($comment)) {
            $this->comments->add($comment);
            $comment->setEtatLieux($this);
        }

        return $this;
    }

    public function removeComment(EtatLieuxComment $comment): static
    {
        if ($this->comments->removeElement($comment)) {
            if ($comment->getEtatLieux() === $this) {
                $comment->setEtatLieux(null);
            }
        }

        return $this;
    }

    /*
    * @return Collection<int, EtatReturnLieuxFile>
    */
    public function getEtatReturnLieuxFile(): Collection
    {
        return $this->filesReturn;
    }

    public function addEtatReturnLieuxFile(EtatReturnLieuxFile $comment): static
    {
        if (!$this->filesReturn->contains($comment)) {
            $this->filesReturn->add($comment);
            $comment->setEtatLieux($this);
        }

        return $this;
    }

    public function removeEtatReturnLieuxFile(EtatReturnLieuxFile $comment): static
    {
        if ($this->filesReturn->removeElement($comment)) {
            if ($comment->getEtatLieux() === $this) {
                $comment->setEtatLieux(null);
            }
        }

        return $this;
    }

    /*
   * @return Collection<int, EtatLieuxReturnPointControl>
   */
    public function getPointControlsReturn(): Collection
    {
        return $this->pointControlsReturn;
    }

    public function addPointControlsReturn(EtatLieuxReturnPointControl $comment): static
    {
        if (!$this->pointControlsReturn->contains($comment)) {
            $this->pointControlsReturn->add($comment);
            $comment->setEtatLieux($this);
        }

        return $this;
    }

    public function removeEtatLieuxReturnPointControl(EtatLieuxReturnPointControl $comment): static
    {
        if ($this->pointControlsReturn->removeElement($comment)) {
            if ($comment->getEtatLieux() === $this) {
                $comment->setEtatLieux(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, EtatLieuxReturnComment>
     */
    public function getCommentsReturn(): Collection
    {
        return $this->commentsReturns;
    }

    public function addCommentReturn(EtatLieuxReturnComment $comment): static
    {
        if (!$this->commentsReturns->contains($comment)) {
            $this->commentsReturns->add($comment);
            $comment->setEtatLieux($this);
        }

        return $this;
    }

    public function removeCommentReturn(EtatLieuxReturnComment $comment): static
    {
        if ($this->commentsReturns->removeElement($comment)) {
            if ($comment->getEtatLieux() === $this) {
                $comment->setEtatLieux(null);
            }
        }

        return $this;
    }

    public function getSignIdDelivery(): ?string
    {
        return $this->signIdDelivery;
    }

    public function setSignIdDelivery(?string $signIdDelivery): static
    {
        $this->signIdDelivery = $signIdDelivery;

        return $this;
    }

    public function getSignIdCustomer(): ?string
    {
        return $this->signIdCustomer;
    }

    public function setSignIdCustomer(?string $signIdCustomer): static
    {
        $this->signIdCustomer = $signIdCustomer;

        return $this;
    }

    public function getEtatLieuxUnsignFile(): ?File
    {
        return $this->etatLieuxUnsignFile;
    }

    public function setEtatLieuxUnsignFile(?File $etatLieuxUnsignFile): void
    {
        $this->etatLieuxUnsignFile = $etatLieuxUnsignFile;
        if (null !== $etatLieuxUnsignFile) {
            $this->updatedAt = new \DateTimeImmutable();
        }
    }

    public function getEtatLieuxUnsignFileName(): ?string
    {
        return $this->etatLieuxUnsignFileName;
    }

    public function setEtatLieuxUnsignFileName(?string $etatLieuxUnsignFileName): void
    {
        $this->etatLieuxUnsignFileName = $etatLieuxUnsignFileName;
    }

    public function getEtatLieuxUnsignFileSize(): ?int
    {
        return $this->etatLieuxUnsignFileSize;
    }

    public function setEtatLieuxUnsignFileSize(?int $etatLieuxUnsignFileSize): void
    {
        $this->etatLieuxUnsignFileSize = $etatLieuxUnsignFileSize;
    }

    public function getEtatLieuxSignFile(): ?File
    {
        return $this->etatLieuxSignFile;
    }

    public function setEtatLieuxSignFile(?File $etatLieuxSignFile): void
    {
        $this->etatLieuxSignFile = $etatLieuxSignFile;
        if (null !== $etatLieuxSignFile) {
            $this->updatedAt = new \DateTimeImmutable();
        }
    }

    public function getEtatLieuxSignFileName(): ?string
    {
        return $this->etatLieuxSignFileName;
    }

    public function setEtatLieuxSignFileName(?string $etatLieuxSignFileName): void
    {
        $this->etatLieuxSignFileName = $etatLieuxSignFileName;
    }

    public function getEtatLieuxSignFileSize(): ?int
    {
        return $this->etatLieuxSignFileSize;
    }

    public function setEtatLieuxSignFileSize(?int $etatLieuxSignFileSize): void
    {
        $this->etatLieuxSignFileSize = $etatLieuxSignFileSize;
    }

    public function getEtatLieuxAuditFile(): ?File
    {
        return $this->etatLieuxAuditFile;
    }

    public function setEtatLieuxAuditFile(?File $etatLieuxAuditFile): void
    {
        $this->etatLieuxAuditFile = $etatLieuxAuditFile;
        if (null !== $etatLieuxAuditFile) {
            $this->updatedAt = new \DateTimeImmutable();
        }
    }

    public function getEtatLieuxAuditFileName(): ?string
    {
        return $this->etatLieuxAuditFileName;
    }

    public function setEtatLieuxAuditFileName(?string $etatLieuxAuditFileName): void
    {
        $this->etatLieuxAuditFileName = $etatLieuxAuditFileName;
    }

    public function getEtatLieuxAuditFileSize(): ?int
    {
        return $this->etatLieuxAuditFileSize;
    }

    public function setEtatLieuxAuditFileSize(?int $etatLieuxAuditFileSize): void
    {
        $this->etatLieuxAuditFileSize = $etatLieuxAuditFileSize;
    }

    public function getUpdatedAt(): ?\DateTimeImmutable
    {
        return $this->updatedAt;
    }

    public function setUpdatedAt(?\DateTimeImmutable $updatedAt): static
    {
        $this->updatedAt = $updatedAt;

        return $this;
    }

    public function getSignIdReturn(): ?string
    {
        return $this->signIdReturn;
    }

    public function setSignIdReturn(?string $signIdReturn): static
    {
        $this->signIdReturn = $signIdReturn;

        return $this;
    }

    public function getSignIdCustomerReturn(): ?string
    {
        return $this->signIdCustomerReturn;
    }

    public function setSignIdCustomerReturn(?string $signIdCustomerReturn): static
    {
        $this->signIdCustomerReturn = $signIdCustomerReturn;

        return $this;
    }

    public function getEtatLieuxUnsignReturnFile(): ?File
    {
        return $this->etatLieuxUnsignReturnFile;
    }

    public function setEtatLieuxUnsignReturnFile(?File $etatLieuxUnsignReturnFile): void
    {
        $this->etatLieuxUnsignReturnFile = $etatLieuxUnsignReturnFile;
        if (null !== $etatLieuxUnsignReturnFile) {
            $this->updatedAt = new \DateTimeImmutable();
        }
    }

    public function getEtatLieuxUnsignReturnFileName(): ?string
    {
        return $this->etatLieuxUnsignReturnFileName;
    }

    public function setEtatLieuxUnsignReturnFileName(?string $etatLieuxUnsignReturnFileName): void
    {
        $this->etatLieuxUnsignReturnFileName = $etatLieuxUnsignReturnFileName;
    }

    public function getEtatLieuxUnsignReturnFileSize(): ?int
    {
        return $this->etatLieuxUnsignReturnFileSize;
    }

    public function setEtatLieuxUnsignReturnFileSize(?int $etatLieuxUnsignReturnFileSize): void
    {
        $this->etatLieuxUnsignReturnFileSize = $etatLieuxUnsignReturnFileSize;
    }

    public function getEtatLieuxSignReturnFile(): ?File
    {
        return $this->etatLieuxSignReturnFile;
    }

    public function setEtatLieuxSignReturnFile(?File $etatLieuxSignReturnFile): void
    {
        $this->etatLieuxSignReturnFile = $etatLieuxSignReturnFile;
        if (null !== $etatLieuxSignReturnFile) {
            $this->updatedAt = new \DateTimeImmutable();
        }
    }

    public function getEtatLieuxSignReturnFileName(): ?string
    {
        return $this->etatLieuxSignReturnFileName;
    }

    public function setEtatLieuxSignReturnFileName(?string $etatLieuxSignReturnFileName): void
    {
        $this->etatLieuxSignReturnFileName = $etatLieuxSignReturnFileName;
    }

    public function getEtatLieuxSignReturnFileSize(): ?int
    {
        return $this->etatLieuxSignReturnFileSize;
    }

    public function setEtatLieuxSignReturnFileSize(?int $etatLieuxSignReturnFileSize): void
    {
        $this->etatLieuxSignReturnFileSize = $etatLieuxSignReturnFileSize;
    }

    public function getEtatLieuxAuditReturnFile(): ?File
    {
        return $this->etatLieuxAuditReturnFile;
    }

    public function setEtatLieuxAuditReturnFile(?File $etatLieuxAuditReturnFile): void
    {
        $this->etatLieuxAuditReturnFile = $etatLieuxAuditReturnFile;
        if (null !== $etatLieuxAuditReturnFile) {
            $this->updatedAt = new \DateTimeImmutable();
        }
    }

    public function getEtatLieuxAuditReturnFileName(): ?string
    {
        return $this->etatLieuxAuditReturnFileName;
    }

    public function setEtatLieuxAuditReturnFileName(?string $etatLieuxAuditReturnFileName): void
    {
        $this->etatLieuxAuditReturnFileName = $etatLieuxAuditReturnFileName;
    }

    public function getEtatLieuxAuditReturnFileSize(): ?int
    {
        return $this->etatLieuxAuditReturnFileSize;
    }

    public function setEtatLieuxAuditReturnFileSize(?int $etatLieuxAuditReturnFileSize): void
    {
        $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;
    }

    public function getRaisonRefused(): ?string
    {
        return $this->raisonRefused;
    }

    public function setRaisonRefused(?string $raisonRefused): static
    {
        $this->raisonRefused = $raisonRefused;

        return $this;
    }
}
