<?php
namespace App\Entity;
use App\MDS\VenuesBundle\Entity\Reservation;
use App\Repository\DocContractRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=DocContractRepository::class)
*/
class DocContract
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\OneToMany(targetEntity=DocContractHistory::class, mappedBy="docContract", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"versionNumber" = "DESC"})
*/
private Collection $histories;
public function __construct()
{
$this->histories = new ArrayCollection();
}
/**
* @ORM\Column(type="text", nullable=true)
*/
private $contractualDocument;
/**
* Reemplazamos el integer $modelId por la relación con la entidad.
*
* @ORM\ManyToOne(targetEntity=DocContractModel::class)
* @ORM\JoinColumn(name="model_id", referencedColumnName="id", nullable=true)
*/
private ?DocContractModel $model = null;
/**
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime", nullable=true)
*/
private $createdAt;
/**
* @var int
*
* @ORM\Column(name="created_id", type="integer", nullable=true)
*/
private $createdId;
/**
* @var \DateTime
*
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @var int
*
* @ORM\Column(name="updated_id", type="integer", nullable=true)
*/
private $updatedId;
/**
* @var \DateTime
*
* @ORM\Column(name="date_at", type="datetime", nullable=true)
* Fecha del contrato
*/
private $dateAt;
/**
* @ORM\Column(name="booking_data", type="text", nullable=true)
* Especificaciones para la reserva, depósito y monto
*/
private $bookingData;
/**
* @ORM\Column(name="client_proxy", type="string", length=255, nullable=true)
* Representante del cliente de cara al contrato.
*/
private $clientProxy;
/**
* @ORM\Column(name="client_job", type="string", length=255, nullable=true)
* Línea de negocio del cliente
*/
private $clientJob;
/**
* @ORM\ManyToOne(targetEntity=Reservation::class, inversedBy="docContracts")
* @ORM\JoinColumn(nullable=false)
*/
private $reservation;
/**
* @ORM\Column(name="sign_token", type="string", length=64, nullable=true, unique=true)
*/
private ?string $signToken = null;
/**
* @ORM\Column(name="signed_at", type="datetime", nullable=true)
*/
private ?\DateTimeInterface $signedAt = null;
/**
* @ORM\Column(name="client_signature", type="string", length=255, nullable=true)
*/
private ?string $clientSignature = null;
/**
* @ORM\Column(name="signed_by_name", type="string", length=255, nullable=true)
*/
private ?string $signedByName = null;
/**
* @ORM\Column(name="signed_by_job", type="string", length=255, nullable=true)
*/
private ?string $signedByJob = null;
/**
* @ORM\Column(name="signed_ip", type="string", length=45, nullable=true)
*/
private ?string $signedIp = null;
/**
* @ORM\Column(name="company_signer_id", type="integer", nullable=true)
*/
private ?int $companySignerId = null;
/**
* @ORM\Column(name="sent_to_emails", type="text", nullable=true)
*/
private ?string $sentToEmails = null;
public function getId(): ?int
{
return $this->id;
}
public function getContractualDocument(): ?string
{
return $this->contractualDocument;
}
public function setContractualDocument(string $contractualDocument): self
{
$this->contractualDocument = $contractualDocument;
return $this;
}
public function getModel(): ?DocContractModel
{
return $this->model;
}
public function setModel(?DocContractModel $model): self
{
$this->model = $model;
return $this;
}
/**
* Set createdAt
*
* @param \Datetime $createdAt
*
* @return DocContract
*/
public function setCreatedAt(\Datetime $createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \Datetime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set createdId
*
* @param integer $createdId
*
* @return DocContract
*/
public function setCreatedId($createdId)
{
$this->createdId = $createdId;
return $this;
}
/**
* Get createdId
*
* @return int
*/
public function getCreatedId()
{
return $this->createdId;
}
/**
* Set updatedAt
*
* @param \Datetime $updatedAt
*
* @return DocContract
*/
public function setUpdatedAt(\Datetime $updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get updatedAt
*
* @return \Datetime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set updatedId
*
* @param integer $updatedId
*
* @return DocContract
*/
public function setUpdatedId($updatedId)
{
$this->updatedId = $updatedId;
return $this;
}
/**
* Get updatedId
*
* @return int
*/
public function getUpdatedId()
{
return $this->updatedId;
}
/**
* Set dateAt
*
* @param \Datetime $dateAt
*
* @return DocContract
*/
public function setDateAt(\Datetime $dateAt)
{
$this->dateAt = $dateAt;
return $this;
}
/**
* Get dateAt
*
* @return \Datetime
*/
public function getDateAt()
{
return $this->dateAt;
}
/**
* Set bookingData
*
* @param string $bookingData
*
* @return DocContract
*/
public function setBookingData($bookingData)
{
$this->bookingData = $bookingData;
return $this;
}
/**
* Get bookingData
*
* @return string
*/
public function getBookingData()
{
return $this->bookingData;
}
public function getClientProxy(): ?string
{
return $this->clientProxy;
}
public function setClientProxy(string $clientProxy): self
{
$this->clientProxy = $clientProxy;
return $this;
}
public function getClientJob(): ?string
{
return $this->clientJob;
}
public function setClientJob(string $clientJob): self
{
$this->clientJob = $clientJob;
return $this;
}
public function getReservation(): ?Reservation
{
return $this->reservation;
}
public function setReservation(Reservation $reservation): self
{
$this->reservation = $reservation;
return $this;
}
public function getSignToken(): ?string
{
return $this->signToken;
}
public function setSignToken(?string $signToken): self
{
$this->signToken = $signToken;
return $this;
}
public function getSignedAt(): ?\DateTimeInterface
{
return $this->signedAt;
}
public function setSignedAt(?\DateTimeInterface $signedAt): self
{
$this->signedAt = $signedAt;
return $this;
}
public function isSigned(): bool
{
return $this->signedAt !== null;
}
public function getClientSignature(): ?string
{
return $this->clientSignature;
}
public function setClientSignature(?string $clientSignature): self
{
$this->clientSignature = $clientSignature;
return $this;
}
public function getSignedByName(): ?string
{
return $this->signedByName;
}
public function setSignedByName(?string $signedByName): self
{
$this->signedByName = $signedByName;
return $this;
}
public function getSignedByJob(): ?string
{
return $this->signedByJob;
}
public function setSignedByJob(?string $signedByJob): self
{
$this->signedByJob = $signedByJob;
return $this;
}
public function getSignedIp(): ?string
{
return $this->signedIp;
}
public function setSignedIp(?string $signedIp): self
{
$this->signedIp = $signedIp;
return $this;
}
public function getCompanySignerId(): ?int
{
return $this->companySignerId;
}
public function setCompanySignerId(?int $companySignerId): self
{
$this->companySignerId = $companySignerId;
return $this;
}
public function getSentToEmails(): ?string
{
return $this->sentToEmails;
}
public function setSentToEmails(?string $sentToEmails): self
{
$this->sentToEmails = $sentToEmails;
return $this;
}
/**
* @return string[]
*/
public function getSentToEmailsArray(): array
{
if (empty($this->sentToEmails)) {
return [];
}
$decoded = json_decode($this->sentToEmails, true);
if (is_array($decoded)) {
return $decoded;
}
return array_filter(array_map('trim', explode(',', $this->sentToEmails)));
}
/**
* @param string[] $emails
*/
public function setSentToEmailsArray(array $emails): self
{
$this->sentToEmails = json_encode(array_values(array_unique(array_filter($emails))));
return $this;
}
/**
* @return Collection<int, DocContractHistory>
*/
public function getHistories(): Collection
{
return $this->histories;
}
public function addHistory(DocContractHistory $history): self
{
if (!$this->histories->contains($history)) {
$this->histories[] = $history;
$history->setDocContract($this);
}
return $this;
}
public function removeHistory(DocContractHistory $history): self
{
if ($this->histories->removeElement($history)) {
if ($history->getDocContract() === $this) {
$history->setDocContract(null);
}
}
return $this;
}
}