src/Entity/DocContract.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\MDS\VenuesBundle\Entity\Reservation;
  4. use App\Repository\DocContractRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=DocContractRepository::class)
  10.  */
  11. class DocContract
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\OneToMany(targetEntity=DocContractHistory::class, mappedBy="docContract", cascade={"persist", "remove"}, orphanRemoval=true)
  21.      * @ORM\OrderBy({"versionNumber" = "DESC"})
  22.      */
  23.     private Collection $histories;
  24.     public function __construct()
  25.     {
  26.         $this->histories = new ArrayCollection();
  27.     }
  28.     /**
  29.      * @ORM\Column(type="text", nullable=true)
  30.      */
  31.     private $contractualDocument;
  32.     /**
  33.      * Reemplazamos el integer $modelId por la relación con la entidad.
  34.      *
  35.      * @ORM\ManyToOne(targetEntity=DocContractModel::class)
  36.      * @ORM\JoinColumn(name="model_id", referencedColumnName="id", nullable=true)
  37.      */
  38.     private ?DocContractModel $model = null;
  39.     /**
  40.      * @var \DateTime
  41.      *
  42.      * @ORM\Column(name="created_at", type="datetime", nullable=true)
  43.      */
  44.     private $createdAt;
  45.     /**
  46.      * @var int
  47.      *
  48.      * @ORM\Column(name="created_id", type="integer", nullable=true)
  49.      */
  50.     private $createdId;
  51.     /**
  52.      * @var \DateTime
  53.      *
  54.      * @ORM\Column(name="updated_at", type="datetime", nullable=true)
  55.      */
  56.     private $updatedAt;
  57.     /**
  58.      * @var int
  59.      *
  60.      * @ORM\Column(name="updated_id", type="integer", nullable=true)
  61.      */
  62.     private $updatedId;
  63.     /**
  64.      * @var \DateTime
  65.      *
  66.      * @ORM\Column(name="date_at", type="datetime", nullable=true)
  67.      * Fecha del contrato
  68.      */
  69.     private $dateAt;
  70.     /**
  71.      * @ORM\Column(name="booking_data", type="text", nullable=true)
  72.      * Especificaciones para la reserva, depósito y monto
  73.      */
  74.     private $bookingData;
  75.     /**
  76.      * @ORM\Column(name="client_proxy", type="string", length=255, nullable=true)
  77.      * Representante del cliente de cara al contrato.
  78.      */
  79.     private $clientProxy;
  80.     /**
  81.      * @ORM\Column(name="client_job", type="string", length=255, nullable=true)
  82.      * Línea de negocio del cliente
  83.      */
  84.     private $clientJob;
  85.     /**
  86.      * @ORM\ManyToOne(targetEntity=Reservation::class, inversedBy="docContracts")
  87.      * @ORM\JoinColumn(nullable=false)
  88.      */
  89.     private $reservation;
  90.     /**
  91.      * @ORM\Column(name="sign_token", type="string", length=64, nullable=true, unique=true)
  92.      */
  93.     private ?string $signToken = null;
  94.     /**
  95.      * @ORM\Column(name="signed_at", type="datetime", nullable=true)
  96.      */
  97.     private ?\DateTimeInterface $signedAt = null;
  98.     /**
  99.      * @ORM\Column(name="client_signature", type="string", length=255, nullable=true)
  100.      */
  101.     private ?string $clientSignature = null;
  102.     /**
  103.      * @ORM\Column(name="signed_by_name", type="string", length=255, nullable=true)
  104.      */
  105.     private ?string $signedByName = null;
  106.     /**
  107.      * @ORM\Column(name="signed_by_job", type="string", length=255, nullable=true)
  108.      */
  109.     private ?string $signedByJob = null;
  110.     /**
  111.      * @ORM\Column(name="signed_ip", type="string", length=45, nullable=true)
  112.      */
  113.     private ?string $signedIp = null;
  114.     /**
  115.      * @ORM\Column(name="company_signer_id", type="integer", nullable=true)
  116.      */
  117.     private ?int $companySignerId = null;
  118.     /**
  119.      * @ORM\Column(name="sent_to_emails", type="text", nullable=true)
  120.      */
  121.     private ?string $sentToEmails = null;
  122.     public function getId(): ?int
  123.     {
  124.         return $this->id;
  125.     }
  126.     public function getContractualDocument(): ?string
  127.     {
  128.         return $this->contractualDocument;
  129.     }
  130.     public function setContractualDocument(string $contractualDocument): self
  131.     {
  132.         $this->contractualDocument = $contractualDocument;
  133.         return $this;
  134.     }
  135.     public function getModel(): ?DocContractModel
  136.     {
  137.         return $this->model;
  138.     }
  139.     public function setModel(?DocContractModel $model): self
  140.     {
  141.         $this->model = $model;
  142.         return $this;
  143.     }
  144.     /**
  145.      * Set createdAt
  146.      *
  147.      * @param \Datetime $createdAt
  148.      *
  149.      * @return DocContract
  150.      */
  151.     public function setCreatedAt(\Datetime $createdAt)
  152.     {
  153.         $this->createdAt = $createdAt;
  154.         return $this;
  155.     }
  156.     /**
  157.      * Get createdAt
  158.      *
  159.      * @return \Datetime
  160.      */
  161.     public function getCreatedAt()
  162.     {
  163.         return $this->createdAt;
  164.     }
  165.     /**
  166.      * Set createdId
  167.      *
  168.      * @param integer $createdId
  169.      *
  170.      * @return DocContract
  171.      */
  172.     public function setCreatedId($createdId)
  173.     {
  174.         $this->createdId = $createdId;
  175.         return $this;
  176.     }
  177.     /**
  178.      * Get createdId
  179.      *
  180.      * @return int
  181.      */
  182.     public function getCreatedId()
  183.     {
  184.         return $this->createdId;
  185.     }
  186.     /**
  187.      * Set updatedAt
  188.      *
  189.      * @param \Datetime $updatedAt
  190.      *
  191.      * @return DocContract
  192.      */
  193.     public function setUpdatedAt(\Datetime $updatedAt)
  194.     {
  195.         $this->updatedAt = $updatedAt;
  196.         return $this;
  197.     }
  198.     /**
  199.      * Get updatedAt
  200.      *
  201.      * @return \Datetime
  202.      */
  203.     public function getUpdatedAt()
  204.     {
  205.         return $this->updatedAt;
  206.     }
  207.     /**
  208.      * Set updatedId
  209.      *
  210.      * @param integer $updatedId
  211.      *
  212.      * @return DocContract
  213.      */
  214.     public function setUpdatedId($updatedId)
  215.     {
  216.         $this->updatedId = $updatedId;
  217.         return $this;
  218.     }
  219.     /**
  220.      * Get updatedId
  221.      *
  222.      * @return int
  223.      */
  224.     public function getUpdatedId()
  225.     {
  226.         return $this->updatedId;
  227.     }
  228.     /**
  229.      * Set dateAt
  230.      *
  231.      * @param \Datetime $dateAt
  232.      *
  233.      * @return DocContract
  234.      */
  235.     public function setDateAt(\Datetime $dateAt)
  236.     {
  237.         $this->dateAt = $dateAt;
  238.         return $this;
  239.     }
  240.     /**
  241.      * Get dateAt
  242.      *
  243.      * @return \Datetime
  244.      */
  245.     public function getDateAt()
  246.     {
  247.         return $this->dateAt;
  248.     }
  249.     /**
  250.      * Set bookingData
  251.      *
  252.      * @param string $bookingData
  253.      *
  254.      * @return DocContract
  255.      */
  256.     public function setBookingData($bookingData)
  257.     {
  258.         $this->bookingData = $bookingData;
  259.         return $this;
  260.     }
  261.     /**
  262.      * Get bookingData
  263.      *
  264.      * @return string
  265.      */
  266.     public function getBookingData()
  267.     {
  268.         return $this->bookingData;
  269.     }
  270.     public function getClientProxy(): ?string
  271.     {
  272.         return $this->clientProxy;
  273.     }
  274.     public function setClientProxy(string $clientProxy): self
  275.     {
  276.         $this->clientProxy = $clientProxy;
  277.         return $this;
  278.     }
  279.     public function getClientJob(): ?string
  280.     {
  281.         return $this->clientJob;
  282.     }
  283.     public function setClientJob(string $clientJob): self
  284.     {
  285.         $this->clientJob = $clientJob;
  286.         return $this;
  287.     }
  288.     public function getReservation(): ?Reservation
  289.     {
  290.         return $this->reservation;
  291.     }
  292.     public function setReservation(Reservation $reservation): self
  293.     {
  294.         $this->reservation = $reservation;
  295.         return $this;
  296.     }
  297.     public function getSignToken(): ?string
  298.     {
  299.         return $this->signToken;
  300.     }
  301.     public function setSignToken(?string $signToken): self
  302.     {
  303.         $this->signToken = $signToken;
  304.         return $this;
  305.     }
  306.     public function getSignedAt(): ?\DateTimeInterface
  307.     {
  308.         return $this->signedAt;
  309.     }
  310.     public function setSignedAt(?\DateTimeInterface $signedAt): self
  311.     {
  312.         $this->signedAt = $signedAt;
  313.         return $this;
  314.     }
  315.     public function isSigned(): bool
  316.     {
  317.         return $this->signedAt !== null;
  318.     }
  319.     public function getClientSignature(): ?string
  320.     {
  321.         return $this->clientSignature;
  322.     }
  323.     public function setClientSignature(?string $clientSignature): self
  324.     {
  325.         $this->clientSignature = $clientSignature;
  326.         return $this;
  327.     }
  328.     public function getSignedByName(): ?string
  329.     {
  330.         return $this->signedByName;
  331.     }
  332.     public function setSignedByName(?string $signedByName): self
  333.     {
  334.         $this->signedByName = $signedByName;
  335.         return $this;
  336.     }
  337.     public function getSignedByJob(): ?string
  338.     {
  339.         return $this->signedByJob;
  340.     }
  341.     public function setSignedByJob(?string $signedByJob): self
  342.     {
  343.         $this->signedByJob = $signedByJob;
  344.         return $this;
  345.     }
  346.     public function getSignedIp(): ?string
  347.     {
  348.         return $this->signedIp;
  349.     }
  350.     public function setSignedIp(?string $signedIp): self
  351.     {
  352.         $this->signedIp = $signedIp;
  353.         return $this;
  354.     }
  355.     public function getCompanySignerId(): ?int
  356.     {
  357.         return $this->companySignerId;
  358.     }
  359.     public function setCompanySignerId(?int $companySignerId): self
  360.     {
  361.         $this->companySignerId = $companySignerId;
  362.         return $this;
  363.     }
  364.     public function getSentToEmails(): ?string
  365.     {
  366.         return $this->sentToEmails;
  367.     }
  368.     public function setSentToEmails(?string $sentToEmails): self
  369.     {
  370.         $this->sentToEmails = $sentToEmails;
  371.         return $this;
  372.     }
  373.     /**
  374.      * @return string[]
  375.      */
  376.     public function getSentToEmailsArray(): array
  377.     {
  378.         if (empty($this->sentToEmails)) {
  379.             return [];
  380.         }
  381.         $decoded = json_decode($this->sentToEmails, true);
  382.         if (is_array($decoded)) {
  383.             return $decoded;
  384.         }
  385.         return array_filter(array_map('trim', explode(',', $this->sentToEmails)));
  386.     }
  387.     /**
  388.      * @param string[] $emails
  389.      */
  390.     public function setSentToEmailsArray(array $emails): self
  391.     {
  392.         $this->sentToEmails = json_encode(array_values(array_unique(array_filter($emails))));
  393.         return $this;
  394.     }
  395.     /**
  396.      * @return Collection<int, DocContractHistory>
  397.      */
  398.     public function getHistories(): Collection
  399.     {
  400.         return $this->histories;
  401.     }
  402.     public function addHistory(DocContractHistory $history): self
  403.     {
  404.         if (!$this->histories->contains($history)) {
  405.             $this->histories[] = $history;
  406.             $history->setDocContract($this);
  407.         }
  408.         return $this;
  409.     }
  410.     public function removeHistory(DocContractHistory $history): self
  411.     {
  412.         if ($this->histories->removeElement($history)) {
  413.             if ($history->getDocContract() === $this) {
  414.                 $history->setDocContract(null);
  415.             }
  416.         }
  417.         return $this;
  418.     }
  419. }