src/Entity/Events.php line 17

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\EventsRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use App\Entity\TaxonomyValue;
  10. use App\Enum\EventStatus;
  11. #[ORM\Entity(repositoryClassEventsRepository::class)]
  12. #[UniqueEntity(fields: ['extCode'], message'Este código ya está en uso.')]
  13. class Events
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\Column(length255)]
  20.     private ?string $Name null;
  21.     #[ORM\Column(length255)]
  22.     private ?string $extCode null;
  23.     #[ORM\Column(type'boolean')]
  24.     private bool $published true;
  25.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  26.     private ?\DateTimeInterface $startDate null;
  27.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  28.     private ?\DateTimeInterface $endDate null;
  29.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  30.     private ?\DateTimeInterface $inscripcionesInicio null;
  31.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  32.     private ?\DateTimeInterface $inscripcionesFin null;
  33.     #[ORM\Column(typeTypes::TIME_MUTABLEnullabletrue)]
  34.     private ?\DateTimeInterface $startTime null;
  35.     #[ORM\Column(typeTypes::TIME_MUTABLEnullabletrue)]
  36.     private ?\DateTimeInterface $endTime null;
  37.     #[ORM\Column(nullabletrue)]
  38.     private ?int $maxRegistrations null;
  39.     #[ORM\OneToMany(mappedBy'eventId'targetEntityRegistrations::class, orphanRemovaltrue)]
  40.     private Collection $registrations;
  41.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  42.     private ?\DateTimeInterface $created null;
  43.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  44.     private ?\DateTimeInterface $updated null;
  45.     #[ORM\Column(nullabletrue)]
  46.     private ?bool $generationQr null;
  47.     /**
  48.      * @ORM\ManyToOne(targetEntity="App\Entity\Centers")
  49.      * @ORM\JoinColumn(name="id", referencedColumnName="id")
  50.      */
  51.     private $center_id;
  52.     #[ORM\ManyToOne(inversedBy'events')]
  53.     #[ORM\JoinColumn(nullabletrue)]
  54.     private ?Centers $center null;
  55.     #[ORM\ManyToMany(targetEntityUser::class, inversedBy'events')]
  56.     private Collection $courseUser;
  57.     #[ORM\Column(enumTypeEventStatus::class)]
  58.     private EventStatus $status;
  59.     #[ORM\ManyToMany(targetEntityUser::class, inversedBy'managedEvents')]
  60.     #[ORM\JoinTable(name'events_manager_user')]
  61.     private Collection $managerUsers;
  62.     #[ORM\Column(nullabletrue)]
  63.     private ?int $Hours null;
  64.     #[ORM\Column(nullabletrue)]
  65.     private ?int $Participants null;
  66.     #[ORM\Column(length255nullabletrue)]
  67.     private ?string $TargetGroups null;
  68.     #[ORM\ManyToOne]
  69.     #[ORM\JoinColumn(nullabletrue)]
  70.     private ?TaxonomyValue $modality null;
  71.     #[ORM\Column(length255nullabletrue)]
  72.     private ?string $TargetAdmin null;
  73.     #[ORM\Column(nullabletrue)]
  74.     private ?int $totalDays null;
  75.     #[ORM\Column(nullabletrue)]
  76.     private ?int $shift null;
  77.     #[ORM\Column(nullabletrue)]
  78.     private ?int $numberCheckings null;
  79.     #[ORM\Column(nullabletrue)]
  80.     private ?float $minCompliance null;
  81.     #[ORM\Column(length255nullabletrue)]
  82.     private ?string $image null;
  83.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  84.     private ?string $description null;
  85.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  86.     private ?string $objetives null;
  87.     #[ORM\ManyToMany(targetEntityTaxonomyValue::class, inversedBy'events')]
  88.     private Collection $areaTematica;
  89.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  90.     private ?string $skills null;
  91.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  92.     private ?string $contents null;
  93.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  94.     private ?string $plannedMaterials null;
  95.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  96.     private ?string $internalObservations null;
  97.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => true])]
  98.     private bool $controlAsistencias true;
  99.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  100.     private bool $cuestionarioConocimiento false;
  101.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  102.     private bool $actividadesPracticas false;
  103.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  104.     private ?string $evaluacionCertificacionInterna null;
  105.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  106.     private ?string $Prerequisites null;
  107.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  108.     private ?string $TechnicalRequirements null;
  109.     #[ORM\Column(length255nullabletrue)]
  110.     private ?string $DateAndTime null;
  111.     #[ORM\Column(type'string'length255nullabletrue)]
  112.     private ?string $Location null;
  113.     #[ORM\OneToMany(mappedBy'event'targetEntityEventRequest::class, orphanRemovaltrue)]
  114.     private Collection $eventRequests;
  115.     #[ORM\OneToMany(mappedBy'event'targetEntityRegistrationQualification::class, orphanRemovaltrue)]
  116.     private Collection $registrationQualifications;
  117.     public function __construct()
  118.     {
  119.         $this->status EventStatus::ABIERTO;
  120.         $this->registrations = new ArrayCollection();
  121.         $this->courseUser = new ArrayCollection();
  122.         $this->managerUsers = new ArrayCollection();
  123.         $this->areaTematica = new ArrayCollection();
  124.         $this->eventRequests = new ArrayCollection();
  125.         $this->registrationQualifications = new ArrayCollection();
  126.     }
  127.     public function __toString(): string
  128.     {
  129.         return "$this->Name ($this->id)";
  130.     }
  131.     public function getId(): ?int
  132.     {
  133.         return $this->id;
  134.     }
  135.     public function getName(): ?string
  136.     {
  137.         return $this->Name;
  138.     }
  139.     public function setName(string $Name): static
  140.     {
  141.         $this->Name $Name;
  142.         return $this;
  143.     }
  144.     public function getExtCode(): ?string
  145.     {
  146.         return $this->extCode;
  147.     }
  148.     public function setExtCode(string $extCode): static
  149.     {
  150.         $this->extCode $extCode;
  151.         return $this;
  152.     }
  153.     public function getStartDate(): ?\DateTimeInterface
  154.     {
  155.         return $this->startDate;
  156.     }
  157.     public function setStartDate(\DateTimeInterface $startDate): static
  158.     {
  159.         $this->startDate $startDate;
  160.         return $this;
  161.     }
  162.     public function getEndDate(): ?\DateTimeInterface
  163.     {
  164.         return $this->endDate;
  165.     }
  166.     public function setEndDate(\DateTimeInterface $endDate): static
  167.     {
  168.         $this->endDate $endDate;
  169.         return $this;
  170.     }
  171.     public function getStartTime(): ?\DateTimeInterface
  172.     {
  173.         return $this->startTime;
  174.     }
  175.     public function setStartTime(\DateTimeInterface $startTime): static
  176.     {
  177.         $this->startTime $startTime;
  178.         return $this;
  179.     }
  180.     public function getEndTime(): ?\DateTimeInterface
  181.     {
  182.         return $this->endTime;
  183.     }
  184.     public function setEndTime(\DateTimeInterface $endTime): static
  185.     {
  186.         $this->endTime $endTime;
  187.         return $this;
  188.     }
  189.     public function getMaxRegistrations(): ?int
  190.     {
  191.         return $this->maxRegistrations;
  192.     }
  193.     public function setMaxRegistrations(?int $maxRegistrations): static
  194.     {
  195.         $this->maxRegistrations $maxRegistrations;
  196.         return $this;
  197.     }
  198.     /**
  199.      * @return Collection<int, Registrations>
  200.      */
  201.     public function getRegistrations(): Collection
  202.     {
  203.         return $this->registrations;
  204.     }
  205.     /**
  206.      * @return Collection<int, Registrations>
  207.      */
  208.     public function getActiveRegistrations(): Collection
  209.     {
  210.         return $this->registrations->filter(static function (Registrations $registration): bool {
  211.             return (bool) $registration->isActive();
  212.         });
  213.     }
  214.     public function addRegistration(Registrations $registration): static
  215.     {
  216.         if (!$this->registrations->contains($registration)) {
  217.             $this->registrations->add($registration);
  218.             $registration->setEventId($this);
  219.         }
  220.         return $this;
  221.     }
  222.     public function removeRegistration(Registrations $registration): static
  223.     {
  224.         if ($this->registrations->removeElement($registration)) {
  225.             // set the owning side to null (unless already changed)
  226.             if ($registration->getEventId() === $this) {
  227.                 $registration->setEventId(null);
  228.             }
  229.         }
  230.         return $this;
  231.     }
  232.     public function getCreated(): ?\DateTimeInterface
  233.     {
  234.         return $this->created;
  235.     }
  236.     public function setCreated(\DateTimeInterface $created): static
  237.     {
  238.         $this->created $created;
  239.         return $this;
  240.     }
  241.     public function getUpdated(): ?\DateTimeInterface
  242.     {
  243.         return $this->updated;
  244.     }
  245.     public function setUpdated(\DateTimeInterface $updated): static
  246.     {
  247.         $this->updated $updated;
  248.         return $this;
  249.     }
  250.     public function isGenerationQr(): ?bool
  251.     {
  252.         return $this->generationQr;
  253.     }
  254.     public function setGenerationQr(bool $generationQr): static
  255.     {
  256.         $this->generationQr $generationQr;
  257.         return $this;
  258.     }
  259.     public function getCenter(): ?Centers
  260.     {
  261.         return $this->center;
  262.     }
  263.     public function setCenter(?Centers $center): static
  264.     {
  265.         $this->center $center;
  266.         return $this;
  267.     }
  268.     /**
  269.      * @return Collection<int, User>
  270.      */
  271.     public function getCourseUser(): Collection
  272.     {
  273.         return $this->courseUser;
  274.     }
  275.     public function addCourseUser(User $courseUser): static
  276.     {
  277.         if (!$this->courseUser->contains($courseUser)) {
  278.             $this->courseUser->add($courseUser);
  279.         }
  280.         return $this;
  281.     }
  282.     public function removeCourseUser(User $courseUser): static
  283.     {
  284.         $this->courseUser->removeElement($courseUser);
  285.         return $this;
  286.     }
  287.     public function getStatus(): EventStatus
  288.     {
  289.         return $this->status;
  290.     }
  291.     public function setStatus(EventStatus $status): self
  292.     {
  293.         $this->status $status;
  294.         return $this;
  295.     }
  296.     /**
  297.      * @return Collection<int, User>
  298.      */
  299.     public function getManagerUsers(): Collection
  300.     {
  301.         return $this->managerUsers;
  302.     }
  303.     public function addManagerUser(User $managerUser): static
  304.     {
  305.         if (!$this->managerUsers->contains($managerUser)) {
  306.             $this->managerUsers->add($managerUser);
  307.             if (!$managerUser->getManagedEvents()->contains($this)) {
  308.                 $managerUser->getManagedEvents()->add($this);
  309.             }
  310.         }
  311.  
  312.         return $this;
  313.     }
  314.     public function removeManagerUser(User $managerUser): static
  315.     {
  316.         if ($this->managerUsers->removeElement($managerUser)) {
  317.             $managerUser->getManagedEvents()->removeElement($this);
  318.         }
  319.         return $this;
  320.     }
  321.     public function getHours(): ?int
  322.     {
  323.         return $this->Hours;
  324.     }
  325.     public function setHours(?int $Hours): static
  326.     {
  327.         $this->Hours $Hours;
  328.         return $this;
  329.     }
  330.     public function getParticipants(): ?int
  331.     {
  332.         return $this->Participants;
  333.     }
  334.     public function setParticipants(?int $Participants): static
  335.     {
  336.         $this->Participants $Participants;
  337.         return $this;
  338.     }
  339.     public function getTargetGroups(): ?string
  340.     {
  341.         return $this->TargetGroups;
  342.     }
  343.     public function setTargetGroups(?string $TargetGroups): static
  344.     {
  345.         $this->TargetGroups $TargetGroups;
  346.         return $this;
  347.     }
  348.     public function getModality(): ?TaxonomyValue
  349.     {
  350.         return $this->modality;
  351.     }
  352.     public function setModality(?TaxonomyValue $modality): self
  353.     {
  354.         $this->modality $modality;
  355.         return $this;
  356.     }
  357.     public function getTargetAdmin(): ?string
  358.     {
  359.         return $this->TargetAdmin;
  360.     }
  361.     public function setTargetAdmin(?string $TargetAdmin): static
  362.     {
  363.         $this->TargetAdmin $TargetAdmin;
  364.         return $this;
  365.     }
  366.     public function getTotalDays(): ?int
  367.     {
  368.         return $this->totalDays;
  369.     }
  370.     public function setTotalDays(?int $totalDays): static
  371.     {
  372.         $this->totalDays $totalDays;
  373.         return $this;
  374.     }
  375.     public function getShift(): ?int
  376.     {
  377.         return $this->shift;
  378.     }
  379.     public function setShift(int $shift): static
  380.     {
  381.         $this->shift $shift;
  382.         return $this;
  383.     }
  384.     public function getNumberCheckings(): ?int
  385.     {
  386.         return $this->numberCheckings;
  387.     }
  388.     public function setNumberCheckings(?int $numberCheckings): static
  389.     {
  390.         $this->numberCheckings $numberCheckings;
  391.         return $this;
  392.     }
  393.     public function getMinCompliance(): ?float
  394.     {
  395.         return $this->minCompliance;
  396.     }
  397.     public function setMinCompliance(?float $minCompliance): static
  398.     {
  399.         $this->minCompliance $minCompliance;
  400.         return $this;
  401.     }
  402.     public function getImage(): ?string
  403.     {
  404.         return $this->image;
  405.     }
  406.     public function setImage(?string $image): self
  407.         {
  408.             $this->image $image;
  409.             return $this;
  410.         }
  411.     public function getDescription(): ?string
  412.     {
  413.         return $this->description;
  414.     }
  415.     public function setDescription(?string $description): static
  416.     {
  417.         $this->description $description;
  418.         return $this;
  419.     }
  420.     public function getObjetives(): ?string
  421.     {
  422.         return $this->objetives;
  423.     }
  424.     public function setObjetives(?string $objetives): static
  425.     {
  426.         $this->objetives $objetives;
  427.         return $this;
  428.     }
  429.     /**
  430.      * @return Collection<int, TaxonomyValue>
  431.      */
  432.     public function getAreaTematica(): Collection
  433.     {
  434.         return $this->areaTematica;
  435.     }
  436.     public function addAreaTematica(TaxonomyValue $areaTematica): static
  437.     {
  438.         if (!$this->areaTematica->contains($areaTematica)) {
  439.             $this->areaTematica->add($areaTematica);
  440.         }
  441.         return $this;
  442.     }
  443.     public function setAreaTematica(Collection $areaTematica): self
  444.     {
  445.         $this->areaTematica $areaTematica;
  446.         return $this;
  447.     }
  448.     public function removeAreaTematica(TaxonomyValue $areaTematica): static
  449.     {
  450.         $this->areaTematica->removeElement($areaTematica);
  451.         return $this;
  452.     }
  453.     public function getSkills(): ?string
  454.     {
  455.         return $this->skills;
  456.     }
  457.     public function setSkills(?string $skills): static
  458.     {
  459.         $this->skills $skills;
  460.         return $this;
  461.     }
  462.     public function getContents(): ?string
  463.     {
  464.         return $this->contents;
  465.     }
  466.     public function setContents(?string $contents): static
  467.     {
  468.         $this->contents $contents;
  469.         return $this;
  470.     }
  471.     public function getPlannedMaterials(): ?string
  472.     {
  473.         return $this->plannedMaterials;
  474.     }
  475.     public function setPlannedMaterials(?string $plannedMaterials): static
  476.     {
  477.         $this->plannedMaterials $plannedMaterials;
  478.         return $this;
  479.     }
  480.     public function getInternalObservations(): ?string
  481.     {
  482.         return $this->internalObservations;
  483.     }
  484.     public function setInternalObservations(?string $internalObservations): static
  485.     {
  486.         $this->internalObservations $internalObservations;
  487.         return $this;
  488.     }
  489.     public function isControlAsistencias(): bool
  490.     {
  491.         return $this->controlAsistencias;
  492.     }
  493.     public function setControlAsistencias(bool $controlAsistencias): static
  494.     {
  495.         $this->controlAsistencias $controlAsistencias;
  496.         return $this;
  497.     }
  498.     public function isCuestionarioConocimiento(): bool
  499.     {
  500.         return $this->cuestionarioConocimiento;
  501.     }
  502.     public function setCuestionarioConocimiento(bool $cuestionarioConocimiento): static
  503.     {
  504.         $this->cuestionarioConocimiento $cuestionarioConocimiento;
  505.         return $this;
  506.     }
  507.     public function isActividadesPracticas(): bool
  508.     {
  509.         return $this->actividadesPracticas;
  510.     }
  511.     public function setActividadesPracticas(bool $actividadesPracticas): static
  512.     {
  513.         $this->actividadesPracticas $actividadesPracticas;
  514.         return $this;
  515.     }
  516.     public function getEvaluacionCertificacionInterna(): ?string
  517.     {
  518.         return $this->evaluacionCertificacionInterna;
  519.     }
  520.     public function setEvaluacionCertificacionInterna(?string $evaluacionCertificacionInterna): static
  521.     {
  522.         $this->evaluacionCertificacionInterna $evaluacionCertificacionInterna;
  523.         return $this;
  524.     }
  525.     public function getPrerequisites(): ?string
  526.     {
  527.         return $this->Prerequisites;
  528.     }
  529.     public function setPrerequisites(?string $Prerequisites): static
  530.     {
  531.         $this->Prerequisites $Prerequisites;
  532.         return $this;
  533.     }
  534.     public function getTechnicalRequirements(): ?string
  535.     {
  536.         return $this->TechnicalRequirements;
  537.     }
  538.     public function setTechnicalRequirements(?string $TechnicalRequirements): static
  539.     {
  540.         $this->TechnicalRequirements $TechnicalRequirements;
  541.         return $this;
  542.     }
  543.     public function getDateAndTime(): ?string
  544.     {
  545.         return $this->DateAndTime;
  546.     }
  547.     public function setDateAndTime(?string $DateAndTime): static
  548.     {
  549.         $this->DateAndTime $DateAndTime;
  550.         return $this;
  551.     }
  552.     public function getLocation(): ?string
  553.     {
  554.         return $this->Location;
  555.     }
  556.     public function setLocation(?string $Location): static
  557.     {
  558.         $this->Location $Location;
  559.         return $this;
  560.     }
  561.     /**
  562.      * @return Collection<int, EventRequest>
  563.      */
  564.     public function getEventRequests(): Collection
  565.     {
  566.         return $this->eventRequests;
  567.     }
  568.     public function addEventRequest(EventRequest $eventRequest): static
  569.     {
  570.         if (!$this->eventRequests->contains($eventRequest)) {
  571.             $this->eventRequests->add($eventRequest);
  572.             $eventRequest->setEvent($this);
  573.         }
  574.         return $this;
  575.     }
  576.     public function removeEventRequest(EventRequest $eventRequest): static
  577.     {
  578.         if ($this->eventRequests->removeElement($eventRequest)) {
  579.             // set the owning side to null (unless already changed)
  580.             if ($eventRequest->getEvent() === $this) {
  581.                 $eventRequest->setEvent(null);
  582.             }
  583.         }
  584.         return $this;
  585.     }
  586.     /**
  587.      * @return Collection<int, RegistrationQualification>
  588.      */
  589.     public function getRegistrationQualifications(): Collection
  590.     {
  591.         return $this->registrationQualifications;
  592.     }
  593.     public function addRegistrationQualification(RegistrationQualification $registrationQualification): static
  594.     {
  595.         if (!$this->registrationQualifications->contains($registrationQualification)) {
  596.             $this->registrationQualifications->add($registrationQualification);
  597.             $registrationQualification->setEvent($this);
  598.         }
  599.         return $this;
  600.     }
  601.     public function removeRegistrationQualification(RegistrationQualification $registrationQualification): static
  602.     {
  603.         if ($this->registrationQualifications->removeElement($registrationQualification)) {
  604.             if ($registrationQualification->getEvent() === $this) {
  605.                 $registrationQualification->setEvent(null);
  606.             }
  607.         }
  608.         return $this;
  609.     }
  610.     public function getInscripcionesInicio(): ?\DateTimeInterface
  611.     {
  612.         return $this->inscripcionesInicio;
  613.     }
  614.     public function setInscripcionesInicio(?\DateTimeInterface $fecha): self
  615.     {
  616.         $this->inscripcionesInicio $fecha;
  617.         return $this;
  618.     }
  619.     public function getInscripcionesFin(): ?\DateTimeInterface
  620.     {
  621.         return $this->inscripcionesFin;
  622.     }
  623.     public function setInscripcionesFin(?\DateTimeInterface $fecha): self
  624.     {
  625.         $this->inscripcionesFin $fecha;
  626.         return $this;
  627.     }
  628.     public function isPublished(): bool
  629.     {
  630.         return $this->published;
  631.     }
  632.     public function setPublished(bool $published): self
  633.     {
  634.         $this->published $published;
  635.         return $this;
  636.     }
  637.     public function isInscripcionAbierta(): bool
  638.     {
  639.         if (!$this->published || !$this->inscripcionesInicio || !$this->inscripcionesFin) {
  640.             return false;
  641.         }
  642.         $today = new \DateTime('today');
  643.         return $today >= $this->inscripcionesInicio && $today <= $this->inscripcionesFin;
  644.     }
  645.     //TODO: Borrar (Temporal)
  646.     public function isActivo(): bool
  647.     {
  648.         return $this->status === EventStatus::ABIERTO;
  649.     }
  650. }