<?php
namespace App\Entity\Gestiform\Formations\Session\Planning;
;
use App\Entity\AbstractEntity;
use App\Entity\Gestiform\Admin\MasterListe\Masterlistelg;
use App\Entity\Gestiform\Formations\Emargement\Emargement;
use App\Entity\Gestiform\Formations\Session\FormateurEvent;
use App\Entity\Gestiform\Formations\Catalogue\Module\Module;
use App\Entity\Gestiform\Formations\Session\SalleEvent;
use App\Entity\Gestiform\Formations\Session\SessionBlocModule;
use App\Repository\Gestiform\Formations\Session\Planning\EventRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=EventRepository::class)
*/
class Event extends AbstractEntity
{
/**
* @ORM\Column(type="datetime")
*/
private \DateTime $start;
/**
* @ORM\Column(type="datetime")
*/
private ?\DateTime $end = null;
/**
* @ORM\Column(type="integer")
*/
private int $hours;
/**
* @ORM\ManyToOne(targetEntity=Masterlistelg::class)
* @ORM\JoinColumn(nullable=true)
*/
private ?Masterlistelg $modalite = null;
/**
* @ORM\ManyToOne(targetEntity=Event::class, inversedBy="children")
*/
private ?Event $parent = null;
/**
* @ORM\OneToMany(targetEntity=Event::class, mappedBy="parent", cascade={"persist", "remove"})
*/
private Collection $children;
/**
* @ORM\OneToMany(targetEntity=PlanningEvent::class, mappedBy="event", cascade={"persist", "remove"})
*/
private Collection $planningEvents;
/**
* @ORM\ManyToOne(targetEntity=SessionBlocModule::class, inversedBy="events")
*/
private ?SessionBlocModule $sessionBlocModule = null;
/**
* @ORM\ManyToOne(targetEntity=Accompagnement::class, inversedBy="events", cascade={"persist"})
*/
private ?Accompagnement $accompagnement = null;
/**
* @ORM\ManyToOne(targetEntity=Module::class, inversedBy="events", cascade={"persist"})
*/
private ?Module $module = null;
/**
* @ORM\ManyToOne(targetEntity=Jury::class, inversedBy="events", cascade={"persist"})
*/
private ?Jury $jury = null;
/**
* @ORM\ManyToOne(targetEntity=Stage::class, inversedBy="events", cascade={"persist"})
*/
private ?Stage $stage = null;
/**
* @ORM\OneToMany(targetEntity=FormateurEvent::class, mappedBy="evenement", cascade={"persist", "remove"})
*/
private Collection $formateurEvents;
/**
* @ORM\OneToMany(targetEntity=SalleEvent::class, mappedBy="event", cascade={"persist", "remove"})
*/
private Collection $salleEvents;
/**
* @ORM\OneToMany(targetEntity=Emargement::class, mappedBy="event", cascade={"persist", "remove"})
*/
private Collection $emargements;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private ?bool $sendconvocationstagiaire = false;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private ?bool $sendconvocationformateur = false;
/**
* @ORM\Column(type="boolean")
*/
private bool $tempsPriseEnCompte = true;
public function __construct()
{
$this->children = new ArrayCollection();
$this->planningEvents = new ArrayCollection();
$this->salleEvents = new ArrayCollection();
$this->formateurEvents = new ArrayCollection();
$this->emargements = new ArrayCollection();
}
public function getStart(): ?\DateTime
{
return $this->start;
}
public function setStart(\DateTime $start): self
{
$this->start = $start;
return $this;
}
public function getEnd(): ?\DateTime
{
return $this->end;
}
public function setEnd(?\DateTime $end): self
{
$this->end = $end;
return $this;
}
public function getModalite(): ?Masterlistelg
{
return $this->modalite;
}
public function getModaliteOrParentModalite(): ?Masterlistelg
{
return $this->modalite ?? $this->getParent()?->getModalite();
}
public function setModalite(?Masterlistelg $modalite): self
{
$this->modalite = $modalite;
return $this;
}
public function getPlanningEvents(): Collection
{
return $this->planningEvents;
}
public function addPlanningEvent(PlanningEvent $planningEvent): self
{
if (!$this->planningEvents->contains($planningEvent)) {
$this->planningEvents[] = $planningEvent;
$planningEvent->setEvent($this);
}
return $this;
}
public function removePlanningEvent(PlanningEvent $planningEvent): self
{
$this->planningEvents->removeElement($planningEvent);
return $this;
}
public function getParent(): ?self
{
return $this->parent;
}
public function setParent(?self $parent): self
{
$this->parent = $parent;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getChildren(): Collection
{
return $this->children;
}
public function setChildren(Collection $children): self
{
$this->children = $children;
return $this;
}
public function addChild(self $child): self
{
if (!$this->children->contains($child)) {
$this->children[] = $child;
$child->setParent($this);
}
return $this;
}
public function removeChild(self $child): self
{
if ($this->children->removeElement($child)) {
// set the owning side to null (unless already changed)
if ($child->getParent() === $this) {
$child->setParent(null);
}
}
return $this;
}
public function getSessionBlocModule(): ?SessionBlocModule
{
return $this->sessionBlocModule;
}
public function getSessionBlocModuleOrParentSessionBlocModule(): ?SessionBlocModule
{
return $this->sessionBlocModule ?? $this->getParent()?->getSessionBlocModule();
}
public function setSessionBlocModule(?SessionBlocModule $sessionBlocModule): self
{
$this->sessionBlocModule = $sessionBlocModule;
return $this;
}
public function getAccompagnement(): ?Accompagnement
{
return $this->accompagnement;
}
public function getAccompagnementOrParentAccompagnement(): ?Accompagnement
{
return $this->accompagnement ?? $this->getParent()?->getAccompagnement();
}
public function setAccompagnement(?Accompagnement $accompagnement): self
{
$this->accompagnement = $accompagnement;
return $this;
}
public function getModule(): ?Module
{
return $this->module;
}
public function getModuleOrParentModule(): ?Module
{
return $this->module ?? $this->getParent()?->getModule();
}
public function setModule(?Module $module): self
{
$this->module = $module;
return $this;
}
public function getJury(): ?Jury
{
return $this->jury;
}
public function getJuryOrParentJury(): ?Jury
{
return $this->jury ?? $this->getParent()?->getJury();
}
public function setJury(?Jury $jury): self
{
$this->jury = $jury;
return $this;
}
public function getStage(): ?Stage
{
return $this->stage;
}
public function getStageOrParentStage(): ?Stage
{
return $this->stage ?? $this->getParent()?->getStage();
}
public function setStage(?Stage $stage): self
{
$this->stage = $stage;
return $this;
}
/**
* @return Collection<int, FormateurEvent>
*/
public function getFormateurEvents(): Collection
{
return $this->formateurEvents;
}
public function addFormateurEvent(FormateurEvent $formateurEvent): self
{
if (!$this->formateurEvents->contains($formateurEvent)) {
$this->formateurEvents->add($formateurEvent);
$formateurEvent->setEvenement($this);
}
return $this;
}
public function removeFormateurEvent(FormateurEvent $formateurEvent): self
{
if ($this->formateurEvents->removeElement($formateurEvent)) {
// set the owning side to null (unless already changed)
if ($formateurEvent->getEvenement() === $this) {
$formateurEvent->setEvenement(null);
}
}
return $this;
}
public function getHours(): int
{
return $this->hours;
}
public function setHours(int $hours): self
{
$this->hours = $hours;
return $this;
}
public function getSalleEvents(): Collection
{
return $this->salleEvents;
}
public function addSalleEvent(SalleEvent $salleEvent): self
{
if (!$this->salleEvents->contains($salleEvent)) {
$this->salleEvents->add($salleEvent);
}
return $this;
}
public function removeSalleEvent(SalleEvent $salleEvent): self
{
$this->salleEvents->removeElement($salleEvent);
return $this;
}
public function getSalleEventOrParentSalleEvent(): Collection
{
if ($this->getParent()?->getSalleEvents()->count()) {
return $this->salleEvents->count() ? $this->salleEvents : $this->getParent()?->getSalleEvents();
}
return $this->salleEvents;
}
/**
* @return Collection<int, Emargement>
*/
public function getEmargements(): Collection
{
return $this->emargements;
}
public function addEmargement(Emargement $emargement): self
{
if (!$this->emargements->contains($emargement)) {
$this->emargements->add($emargement);
$emargement->setEvent($this);
}
return $this;
}
public function removeEmargement(Emargement $emargement): self
{
if ($this->emargements->removeElement($emargement)) {
// set the owning side to null (unless already changed)
if ($emargement->getEvent() === $this) {
$emargement->setEvent(null);
}
}
return $this;
}
public function getTitle(): string
{
$title = $this->getId();
if ($this->getModule()?->getIntitule()) {
$title = $this->getModule()?->getFullIntituleType()??"";
}
if ($this->getAccompagnementOrParentAccompagnement()?->getType()?->getDesignation()??"") {
$title = $this->getAccompagnementOrParentAccompagnement()?->getType()?->getDesignation()??"";
}
if ($this->getStage()) {
$title = "Stage" ;
}
if ($this->getJury()) {
$title = "Jury";
}
return $title;
}
public function getCode(): string
{
return $this->getModule()?->getCode() ?? ""
?? $this->getAccompagnementOrParentAccompagnement()?->getType()?->getCode()
?? "" ?? $this->getJury()?->getParcours()?->getCode() ?? "";
}
public function getSendconvocationstagiaire(): ?bool
{
return $this->sendconvocationstagiaire;
}
public function setSendconvocationstagiaire(?bool $sendconvocationstagiaire): self
{
$this->sendconvocationstagiaire = $sendconvocationstagiaire;
return $this;
}
public function getSendconvocationformateur(): ?bool
{
return $this->sendconvocationformateur;
}
public function setSendconvocationformateur(?bool $sendconvocationformateur): self
{
$this->sendconvocationformateur = $sendconvocationformateur;
return $this;
}
public function getType(): ?string
{
$type = $this->getId();
if ($this->getModule()) {
$type ="Module" ;
}
if ($this->getAccompagnementOrParentAccompagnement()) {
$type ="Accompagnement" ;
}
if ($this->getStage()) {
$type = "Stage" ;
}
if ($this->getJury()) {
$type = "Jury";
}
return $type;
}
public function isTempsPriseEnCompte(): bool
{
return $this->tempsPriseEnCompte;
}
public function setTempsPriseEnCompte(bool $tempsPriseEnCompte): self
{
$this->tempsPriseEnCompte = $tempsPriseEnCompte;
return $this;
}
}