src/MDS/VenuesBundle/Entity/Reservation.php line 29

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\MDS\VenuesBundle\Entity;
  4. use App\Entity\GpReminder;
  5. use App\Entity\Client;
  6. use App\Entity\HtFile;
  7. use App\MDS\AvexpressBundle\Entity\AveFiles;
  8. use App\Entity\DocContract;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  14. use Symfony\Component\Serializer\Annotation\Ignore;
  15. //use Doctrine\Common\Collections\ArrayCollection;
  16. //use Doctrine\Common\Collections\Collection;
  17. use Symfony\Component\Validator\Context\ExecutionContextInterface;
  18. /**
  19.  * Reservation
  20.  *
  21.  * @ORM\Table(name="reservation")
  22.  * @ORM\Entity(repositoryClass="App\MDS\VenuesBundle\Repository\ReservationRepository")
  23.  * @ORM\HasLifecycleCallbacks
  24.  */
  25. class Reservation
  26. {
  27.     /**
  28.      * @var int
  29.      *
  30.      * @ORM\Column(name="id", type="integer")
  31.      * @ORM\Id
  32.      * @ORM\GeneratedValue(strategy="AUTO")
  33.      */
  34.     private $id;
  35.     /**
  36.      * @var string
  37.      *
  38.      * @ORM\Column(name="title", type="string", length=255)
  39.      * @Assert\NotBlank
  40.      */
  41.     private $title;
  42.     /**
  43.      * @ORM\ManyToOne(targetEntity=Client::class)
  44.      * @ORM\JoinColumn(name="client_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
  45.      */
  46.     private ?Client $client null;
  47.     /**
  48.      * @var string
  49.      *
  50.      * @ORM\Column(name="clientContact", type="string", length=255, nullable=true )
  51.      *
  52.      */
  53.     private $clientContact;
  54.     /**
  55.      * @var string
  56.      *
  57.      * @ORM\Column(name="contactUnregistered", type="string", length=255, nullable=true )
  58.      *
  59.      */
  60.     private $contactUnregistered;
  61.     /**
  62.      * @var string
  63.      *
  64.      * @ORM\Column(name="nameContactUnregistered", type="string", length=255, nullable=true )
  65.      *
  66.      */
  67.     private $nameContactUnregistered;
  68.     /**
  69.      * @var string
  70.      *
  71.      * @ORM\Column(name="phoneContactUnregistered", type="string", length=255, nullable=true )
  72.      *
  73.      */
  74.     private $phoneContactUnregistered;
  75.     /**
  76.      * @var \DateTimeInterface|null
  77.      *
  78.      * @ORM\Column(name="days", type="datetime", nullable=true)
  79.      */
  80.     private $days;
  81.     /**
  82.      * @var \DateTime
  83.      *
  84.      * @ORM\Column(name="createdAt", type="datetime")
  85.      */
  86.     private $createdAt;
  87.     /**
  88.      * @var string
  89.      *
  90.      * @ORM\Column(name="priority", type="string", length=255)
  91.      */
  92.     private $priority;
  93.     /**
  94.      * @var string
  95.      *
  96.      * @ORM\Column(name="createdBy", type="string", length=255)
  97.      */
  98.     private $createdBy;
  99.     /**
  100.      * @var string
  101.      *
  102.      * @ORM\Column(name="supplier", type="string", length=255, nullable=true)
  103.      */
  104.     private $supplier;
  105.     /**
  106.      * @var string
  107.      *
  108.      * @ORM\Column(name="status", type="string", length=255, nullable=true)
  109.      */
  110.     private $status;
  111.     /**
  112.      * @var \DateTime
  113.      *
  114.      * @ORM\Column(name="updatedAt", type="datetime")
  115.      */
  116.     private $updatedAt;
  117.     /**
  118.      * @var string
  119.      *
  120.      * @ORM\Column(name="updatedBy", type="string", length=255)
  121.      */
  122.     private $updatedBy;
  123.     /**
  124.      * @var int
  125.      *
  126.      * @ORM\Column(name="daysBlock", type="integer", nullable=true)
  127.      */
  128.     private $daysBlock;
  129.     /**
  130.      * @var \DateTime
  131.      *
  132.      * @ORM\Column(name="dateStart", type="datetime", nullable=true)
  133.      */
  134.     private $dateStart;
  135.     /**
  136.      * @var \DateTime
  137.      *
  138.      * @ORM\Column(name="dateEnd", type="datetime", nullable=true)
  139.      */
  140.     private $dateEnd;
  141.     /**
  142.      * @var int
  143.      *
  144.      * @ORM\Column(name="pax", type="integer", nullable=true)
  145.      */
  146.     private $pax;
  147.     /**
  148.      * @var string
  149.      *
  150.      * @ORM\Column(name="access_key", type="string", length=255, nullable=true)
  151.      */
  152.     private $accessKey;
  153.     /**
  154.      * @var string
  155.      *
  156.      * @ORM\Column(name="description", type="text", nullable=true)
  157.      */
  158.     private $description;
  159.     /**
  160.      * @var string
  161.      *
  162.      * @ORM\Column(name="contract", type="text", nullable=true)
  163.      */
  164.     private $contract;
  165.     /**
  166.      * @ORM\OneToOne(targetEntity=HtFile::class, mappedBy="reservation", cascade={"persist", "remove"})
  167.      * @Ignore
  168.      */
  169.     private $htFile;
  170.     /**
  171.      * @ORM\OneToOne(targetEntity=AveFiles::class, mappedBy="reservation", cascade={"persist","remove"})
  172.      */
  173.     private ?AveFiles $aveFile null;
  174.     /**
  175.      * @var string
  176.      *
  177.      * @ORM\Column(name="token", type="text", nullable=true)
  178.      */
  179.     private $token;
  180.     /**
  181.      * @var float
  182.      *
  183.      * @ORM\Column(name="comAvGp", type="float", nullable=true)
  184.      * Comisión que la empresa de Audiovisuales debe pagar a la empresa de Audiovisuales (10% por defecto)
  185.      */
  186.     private $comAvGp 10.0;
  187.     /**
  188.      * @var float
  189.      *
  190.      * @ORM\Column(name="comHtGp", type="float", nullable=true)
  191.      * Comisión que la empresa de Catering debe pagar a la empresa de Venues (14% por defecto)
  192.      */
  193.     private $comHtGp 14.0;
  194.     /**
  195.      * @ORM\Column(type="boolean", nullable=true)
  196.      */
  197.     private $sucoe;
  198.     /**
  199.      * @ORM\OneToMany(targetEntity=DocContract::class, mappedBy="reservation", orphanRemoval=true)
  200.      */
  201.     private $docContracts;
  202.     public function __construct()
  203.     {
  204.         $this->docContracts = new ArrayCollection();
  205.     }
  206.     public function getId(): ?int
  207.     {
  208.         return $this->id;
  209.     }
  210.     public function getTitle(): ?string
  211.     {
  212.         return $this->title;
  213.     }
  214.     public function setTitle(string $title): self
  215.     {
  216.         $this->title $title;
  217.         return $this;
  218.     }
  219.     public function getClient(): ?Client
  220.     {
  221.         return $this->client;
  222.     }
  223.     public function setClient(?Client $client): self
  224.     {
  225.         $this->client $client;
  226.         return $this;
  227.     }
  228.     public function getClientContact(): ?string
  229.     {
  230.         return $this->clientContact;
  231.     }
  232.     public function setClientContact(?string $clientContact): self
  233.     {
  234.         $this->clientContact $clientContact;
  235.         return $this;
  236.     }
  237.     public function getContactUnregistered(): ?string
  238.     {
  239.         return $this->contactUnregistered;
  240.     }
  241.     public function setContactUnregistered(?string $contactUnregistered): self
  242.     {
  243.         $this->contactUnregistered $contactUnregistered;
  244.         return $this;
  245.     }
  246.     public function getNameContactUnregistered(): ?string
  247.     {
  248.         return $this->nameContactUnregistered;
  249.     }
  250.     public function setNameContactUnregistered(?string $nameContactUnregistered): self
  251.     {
  252.         $this->nameContactUnregistered $nameContactUnregistered;
  253.         return $this;
  254.     }
  255.     public function getPhoneContactUnregistered(): ?string
  256.     {
  257.         return $this->phoneContactUnregistered;
  258.     }
  259.     public function setPhoneContactUnregistered(?string $phoneContactUnregistered): self
  260.     {
  261.         $this->phoneContactUnregistered $phoneContactUnregistered;
  262.         return $this;
  263.     }
  264.     public function getDays(): ?\DateTimeInterface
  265.     {
  266.         return $this->days;
  267.     }
  268.     public function setDays(?\DateTimeInterface $days): self
  269.     {
  270.         $this->days $days;
  271.         return $this;
  272.     }
  273.     public function getCreatedAt(): ?\DateTimeInterface
  274.     {
  275.         return $this->createdAt;
  276.     }
  277.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  278.     {
  279.         $this->createdAt $createdAt;
  280.         return $this;
  281.     }
  282.     public function getPriority(): ?string
  283.     {
  284.         return $this->priority;
  285.     }
  286.     public function setPriority(string $priority): self
  287.     {
  288.         $this->priority $priority;
  289.         return $this;
  290.     }
  291.     public function getCreatedBy(): ?string
  292.     {
  293.         return $this->createdBy;
  294.     }
  295.     public function setCreatedBy(string $createdBy): self
  296.     {
  297.         $this->createdBy $createdBy;
  298.         return $this;
  299.     }
  300.     public function getSupplier(): ?string
  301.     {
  302.         return $this->supplier;
  303.     }
  304.     public function setSupplier(?string $supplier): self
  305.     {
  306.         $this->supplier $supplier;
  307.         return $this;
  308.     }
  309.     public function getStatus(): ?string
  310.     {
  311.         return $this->status;
  312.     }
  313.     public function setStatus(?string $status): self
  314.     {
  315.         $this->status $status;
  316.         return $this;
  317.     }
  318.     public function getUpdatedAt(): ?\DateTimeInterface
  319.     {
  320.         return $this->updatedAt;
  321.     }
  322.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  323.     {
  324.         $this->updatedAt $updatedAt;
  325.         return $this;
  326.     }
  327.     public function getUpdatedBy(): ?string
  328.     {
  329.         return $this->updatedBy;
  330.     }
  331.     public function setUpdatedBy(string $updatedBy): self
  332.     {
  333.         $this->updatedBy $updatedBy;
  334.         return $this;
  335.     }
  336.     public function getDaysBlock(): ?int
  337.     {
  338.         return $this->daysBlock;
  339.     }
  340.     public function setDaysBlock(?int $daysBlock): self
  341.     {
  342.         $this->daysBlock $daysBlock;
  343.         return $this;
  344.     }
  345.     public function getDateStart(): ?\DateTimeInterface
  346.     {
  347.         return $this->dateStart;
  348.     }
  349.     public function setDateStart(?\DateTimeInterface $dateStart): self
  350.     {
  351.         $this->dateStart $dateStart;
  352.         return $this;
  353.     }
  354.     public function getDateEnd(): ?\DateTimeInterface
  355.     {
  356.         return $this->dateEnd;
  357.     }
  358.     public function setDateEnd(?\DateTimeInterface $dateEnd): self
  359.     {
  360.         $this->dateEnd $dateEnd;
  361.         return $this;
  362.     }
  363.     public function getPax(): ?int
  364.     {
  365.         return $this->pax;
  366.     }
  367.     public function setPax(?int $pax): self
  368.     {
  369.         $this->pax $pax;
  370.         return $this;
  371.     }
  372.     public function getAccessKey(): ?string
  373.     {
  374.         return $this->accessKey;
  375.     }
  376.     public function setAccessKey(?string $accessKey): self
  377.     {
  378.         $this->accessKey $accessKey;
  379.         return $this;
  380.     }
  381.     public function getDescription(): ?string
  382.     {
  383.         return $this->description;
  384.     }
  385.     public function setDescription(?string $description): self
  386.     {
  387.         $this->description $description;
  388.         return $this;
  389.     }
  390.     public function getContract(): ?string
  391.     {
  392.         return $this->contract;
  393.     }
  394.     public function setContract(?string $contract): self
  395.     {
  396.         $this->contract $contract;
  397.         return $this;
  398.     }
  399.     public function getHtFile(): ?HtFile
  400.     {
  401.         return $this->htFile;
  402.     }
  403.     public function setHtFile(?HtFile $htFile): self
  404.     {
  405.         // unset the owning side of the relation if necessary
  406.         if ($htFile === null && $this->htFile !== null) {
  407.             $this->htFile->setReservation(null);
  408.         }
  409.         // set the owning side of the relation if necessary
  410.         if ($htFile !== null && $htFile->getReservation() !== $this) {
  411.             $htFile->setReservation($this);
  412.         }
  413.         $this->htFile $htFile;
  414.         return $this;
  415.     }
  416.     public function getAveFile(): ?AveFiles
  417.     {
  418.         return $this->aveFile;
  419.     }
  420.     public function setAveFile(?AveFiles $aveFile): self
  421.     {
  422.         $this->aveFile $aveFile;
  423.         // Mantener sincronizada la otra cara
  424.         if ($aveFile && $aveFile->getReservation() !== $this) {
  425.             $aveFile->setReservation($this);
  426.         }
  427.         return $this;
  428.     }
  429.     public function getToken(): ?string
  430.     {
  431.         return $this->token;
  432.     }
  433.     public function setToken(?string $token): self
  434.     {
  435.         $this->token $token;
  436.         return $this;
  437.     }
  438.     public function isSucoe(): ?bool
  439.     {
  440.         return $this->sucoe;
  441.     }
  442.     public function setSucoe(?bool $sucoe): self
  443.     {
  444.         $this->sucoe $sucoe;
  445.         return $this;
  446.     }
  447.     /**
  448.      * @return Collection|DocContract[]
  449.      */
  450.     public function getDocContracts(): Collection
  451.     {
  452.         return $this->docContracts;
  453.     }
  454.     public function addDocContract(DocContract $docContract): self
  455.     {
  456.         if (!$this->docContracts->contains($docContract)) {
  457.             $this->docContracts[] = $docContract;
  458.             $docContract->setReservation($this);
  459.         }
  460.         return $this;
  461.     }
  462.     public function removeDocContract(DocContract $docContract): self
  463.     {
  464.         if ($this->docContracts->removeElement($docContract)) {
  465.             // set the owning side to null (unless already changed)
  466.             if ($docContract->getReservation() === $this) {
  467.                 // $docContract->setReservation(null); // No se puede poner a null porque es nullable=false
  468.             }
  469.         }
  470.         return $this;
  471.     }
  472.     /**
  473.      * @ORM\PrePersist
  474.      */
  475.     public function prePersist()
  476.     {
  477.         if (empty($this->createdAt)) {
  478.             $this->createdAt = new \DateTime();
  479.         }
  480.         if (empty($this->updatedAt)) {
  481.             $this->updatedAt = new \DateTime();
  482.         }
  483.     }
  484.     /**
  485.      * @ORM\PreUpdate
  486.      */
  487.     public function preUpdate()
  488.     {
  489.         $this->updatedAt = new \DateTime();
  490.     }
  491.     /**
  492.      * @Assert\Callback
  493.      */
  494.     public function validateContact(ExecutionContextInterface $context)
  495.     {
  496.         // Si NO hay contacto registrado Y el campo de nombre no registrado está vacío
  497.         if (null === $this->getClientContact() && empty($this->getNameContactUnregistered())) {
  498.             // Añadimos el error al campo específico
  499.             $context->buildViolation('Si no selecciona un contacto, debe indicar el nombre del contacto no registrado.')
  500.                 ->atPath('nameContactUnregistered')
  501.                 ->addViolation();
  502.         }
  503.     }
  504.     public function setComAvGp(?float $comAvGp): self
  505.     {
  506.         $this->comAvGp $comAvGp;
  507.         return $this;
  508.     }
  509.     public function getComAvGp(): ?float
  510.     {
  511.         return $this->comAvGp;
  512.     }
  513.     public function setComHtGp(?float $comHtGp): self
  514.     {
  515.         $this->comHtGp $comHtGp;
  516.         return $this;
  517.     }
  518.     public function getComHtGp(): ?float
  519.     {
  520.         return $this->comHtGp;
  521.     }
  522. }