src/Entity/Gestiform/Formations/Session/Planning/Event.php line 20

  1. <?php
  2. namespace App\Entity\Gestiform\Formations\Session\Planning;
  3. ;
  4. use App\Entity\AbstractEntity;
  5. use App\Entity\Gestiform\Admin\MasterListe\Masterlistelg;
  6. use App\Entity\Gestiform\Formations\Catalogue\Module\Module;
  7. use App\Entity\Gestiform\Formations\Emargement\Emargement;
  8. use App\Entity\Gestiform\Formations\Session\FormateurEvent;
  9. use App\Entity\Gestiform\Formations\Session\SalleEvent;
  10. use App\Entity\Gestiform\Formations\Session\SessionBlocModule;
  11. use App\Repository\Gestiform\Formations\Session\Planning\EventRepository;
  12. use DateTime;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use Doctrine\Common\Collections\Collection;
  15. use Doctrine\ORM\Mapping as ORM;
  16. #[ORM\Entity(repositoryClassEventRepository::class)]
  17. class Event extends AbstractEntity
  18. {
  19.     #[ORM\Column(type'datetime')]
  20.     private DateTime $start;
  21.     #[ORM\Column(type'datetime')]
  22.     private ?DateTime $end null;
  23.     #[ORM\Column(type'integer')]
  24.     private int $hours;
  25.     #[ORM\JoinColumn(nullabletrue)]
  26.     #[ORM\ManyToOne(targetEntityMasterlistelg::class)]
  27.     private ?Masterlistelg $modalite null;
  28.     #[ORM\ManyToOne(targetEntityEvent::class, inversedBy'children')]
  29.     private ?Event $parent null;
  30.     #[ORM\OneToMany(mappedBy'parent'targetEntityEvent::class, cascade: ['persist''remove'])]
  31.     private Collection $children;
  32.     #[ORM\OneToMany(mappedBy'event'targetEntityPlanningEvent::class, cascade: ['persist''remove'])]
  33.     private Collection $planningEvents;
  34.     #[ORM\ManyToOne(targetEntitySessionBlocModule::class, inversedBy'events')]
  35.     private ?SessionBlocModule $sessionBlocModule null;
  36.     #[ORM\ManyToOne(targetEntityAccompagnement::class, cascade: ['persist'], inversedBy'events')]
  37.     private ?Accompagnement $accompagnement null;
  38.     #[ORM\ManyToOne(targetEntityModule::class, cascade: ['persist'], inversedBy'events')]
  39.     private ?Module $module null;
  40.     #[ORM\ManyToOne(targetEntityJury::class, cascade: ['persist'], inversedBy'events')]
  41.     private ?Jury $jury null;
  42.     #[ORM\ManyToOne(targetEntityStage::class, cascade: ['persist'], inversedBy'events')]
  43.     private ?Stage $stage null;
  44.     #[ORM\OneToMany(mappedBy'evenement'targetEntityFormateurEvent::class, cascade: ['persist''remove'])]
  45.     private Collection $formateurEvents;
  46.     #[ORM\OneToMany(mappedBy'event'targetEntitySalleEvent::class, cascade: ['persist''remove'])]
  47.     private Collection $salleEvents;
  48.     #[ORM\OneToMany(mappedBy'event'targetEntityEmargement::class, cascade: ['persist''remove'])]
  49.     private Collection $emargements;
  50.     #[ORM\Column(type'boolean'nullabletrue)]
  51.     private ?bool $sendconvocationstagiaire false;
  52.     #[ORM\Column(type'boolean'nullabletrue)]
  53.     private ?bool $sendconvocationformateur false;
  54.     #[ORM\Column(type'boolean')]
  55.     private bool $tempsPriseEnCompte true;
  56.     #[ORM\OneToMany(mappedBy'event'targetEntityFormulaireEvent::class)]
  57.     private Collection $formulaireEvents;
  58.     public function __construct()
  59.     {
  60.         $this->children = new ArrayCollection();
  61.         $this->planningEvents = new ArrayCollection();
  62.         $this->salleEvents = new ArrayCollection();
  63.         $this->formateurEvents = new ArrayCollection();
  64.         $this->emargements = new ArrayCollection();
  65.         $this->formulaireEvents = new ArrayCollection();
  66.     }
  67.     public function getStart(): ?DateTime
  68.     {
  69.         return $this->start;
  70.     }
  71.     public function setStart(DateTime $start): self
  72.     {
  73.         $this->start $start;
  74.         return $this;
  75.     }
  76.     public function getEnd(): ?DateTime
  77.     {
  78.         return $this->end;
  79.     }
  80.     public function setEnd(?DateTime $end): self
  81.     {
  82.         $this->end $end;
  83.         return $this;
  84.     }
  85.     public function getModalite(): ?Masterlistelg
  86.     {
  87.         return $this->modalite;
  88.     }
  89.     public function getModaliteOrParentModalite(): ?Masterlistelg
  90.     {
  91.         return $this->modalite ?? $this->getParent()?->getModalite();
  92.     }
  93.     public function setModalite(?Masterlistelg $modalite): self
  94.     {
  95.         $this->modalite $modalite;
  96.         return $this;
  97.     }
  98.     public function getPlanningEvents(): Collection
  99.     {
  100.         return $this->planningEvents;
  101.     }
  102.     public function addPlanningEvent(PlanningEvent $planningEvent): self
  103.     {
  104.         if (!$this->planningEvents->contains($planningEvent)) {
  105.             $this->planningEvents[] = $planningEvent;
  106.             $planningEvent->setEvent($this);
  107.         }
  108.         return $this;
  109.     }
  110.     public function removePlanningEvent(PlanningEvent $planningEvent): self
  111.     {
  112.         $this->planningEvents->removeElement($planningEvent);
  113.         return $this;
  114.     }
  115.     public function getParent(): ?self
  116.     {
  117.         return $this->parent;
  118.     }
  119.     public function setParent(?self $parent): self
  120.     {
  121.         $this->parent $parent;
  122.         return $this;
  123.     }
  124.     /**
  125.      * @return Collection<int, self>
  126.      */
  127.     public function getChildren(): Collection
  128.     {
  129.         return $this->children;
  130.     }
  131.     public function setChildren(Collection $children): self
  132.     {
  133.         $this->children $children;
  134.         return $this;
  135.     }
  136.     public function addChild(self $child): self
  137.     {
  138.         if (!$this->children->contains($child)) {
  139.             $this->children[] = $child;
  140.             $child->setParent($this);
  141.         }
  142.         return $this;
  143.     }
  144.     public function removeChild(self $child): self
  145.     {
  146.         // set the owning side to null (unless already changed)
  147.         if ($this->children->removeElement($child) && $child->getParent() === $this) {
  148.             $child->setParent(null);
  149.         }
  150.         return $this;
  151.     }
  152.     public function getSessionBlocModule(): ?SessionBlocModule
  153.     {
  154.         return $this->sessionBlocModule;
  155.     }
  156.     public function getSessionBlocModuleOrParentSessionBlocModule(): ?SessionBlocModule
  157.     {
  158.         return $this->sessionBlocModule ?? $this->getParent()?->getSessionBlocModule();
  159.     }
  160.     public function setSessionBlocModule(?SessionBlocModule $sessionBlocModule): self
  161.     {
  162.         $this->sessionBlocModule $sessionBlocModule;
  163.         return $this;
  164.     }
  165.     public function getAccompagnement(): ?Accompagnement
  166.     {
  167.         return $this->accompagnement;
  168.     }
  169.     public function getAccompagnementOrParentAccompagnement(): ?Accompagnement
  170.     {
  171.         return $this->accompagnement ?? $this->getParent()?->getAccompagnement();
  172.     }
  173.     public function setAccompagnement(?Accompagnement $accompagnement): self
  174.     {
  175.         $this->accompagnement $accompagnement;
  176.         return $this;
  177.     }
  178.     public function getModule(): ?Module
  179.     {
  180.         return $this->module;
  181.     }
  182.     public function getModuleOrParentModule(): ?Module
  183.     {
  184.         return $this->module ?? $this->getParent()?->getModule();
  185.     }
  186.     public function setModule(?Module $module): self
  187.     {
  188.         $this->module $module;
  189.         return $this;
  190.     }
  191.     public function getJury(): ?Jury
  192.     {
  193.         return $this->jury;
  194.     }
  195.     public function getJuryOrParentJury(): ?Jury
  196.     {
  197.         return $this->jury ?? $this->getParent()?->getJury();
  198.     }
  199.     public function setJury(?Jury $jury): self
  200.     {
  201.         $this->jury $jury;
  202.         return $this;
  203.     }
  204.     public function getStage(): ?Stage
  205.     {
  206.         return $this->stage;
  207.     }
  208.     public function getStageOrParentStage(): ?Stage
  209.     {
  210.         return $this->stage ?? $this->getParent()?->getStage();
  211.     }
  212.     public function setStage(?Stage $stage): self
  213.     {
  214.         $this->stage $stage;
  215.         return $this;
  216.     }
  217.     /**
  218.      * @return Collection<int, FormateurEvent>
  219.      */
  220.     public function getFormateurEvents(): Collection
  221.     {
  222.         return $this->formateurEvents;
  223.     }
  224.     public function addFormateurEvent(FormateurEvent $formateurEvent): self
  225.     {
  226.         if (!$this->formateurEvents->contains($formateurEvent)) {
  227.             $this->formateurEvents->add($formateurEvent);
  228.             $formateurEvent->setEvenement($this);
  229.         }
  230.         return $this;
  231.     }
  232.     public function removeFormateurEvent(FormateurEvent $formateurEvent): self
  233.     {
  234.         // set the owning side to null (unless already changed)
  235.         if ($this->formateurEvents->removeElement($formateurEvent) && $formateurEvent->getEvenement() === $this) {
  236.             $formateurEvent->setEvenement(null);
  237.         }
  238.         return $this;
  239.     }
  240.     public function getHours(): int
  241.     {
  242.         return $this->hours;
  243.     }
  244.     public function setHours(int $hours): self
  245.     {
  246.         $this->hours $hours;
  247.         return $this;
  248.     }
  249.     public function getSalleEvents(): Collection
  250.     {
  251.         return $this->salleEvents;
  252.     }
  253.     public function addSalleEvent(SalleEvent $salleEvent): self
  254.     {
  255.         if (!$this->salleEvents->contains($salleEvent)) {
  256.             $this->salleEvents->add($salleEvent);
  257.         }
  258.         return $this;
  259.     }
  260.     public function removeSalleEvent(SalleEvent $salleEvent): self
  261.     {
  262.         $this->salleEvents->removeElement($salleEvent);
  263.         return $this;
  264.     }
  265.     public function getSalleEventOrParentSalleEvent(): Collection
  266.     {
  267.         if ($this->getParent()?->getSalleEvents()->count()) {
  268.             return $this->salleEvents->count() ? $this->salleEvents $this->getParent()?->getSalleEvents();
  269.         }
  270.         return $this->salleEvents;
  271.     }
  272.     /**
  273.      * @return Collection<int, Emargement>
  274.      */
  275.     public function getEmargements(): Collection
  276.     {
  277.         return $this->emargements;
  278.     }
  279.     public function addEmargement(Emargement $emargement): self
  280.     {
  281.         if (!$this->emargements->contains($emargement)) {
  282.             $this->emargements->add($emargement);
  283.             $emargement->setEvent($this);
  284.         }
  285.         return $this;
  286.     }
  287.     public function removeEmargement(Emargement $emargement): self
  288.     {
  289.         // set the owning side to null (unless already changed)
  290.         if ($this->emargements->removeElement($emargement) && $emargement->getEvent() === $this) {
  291.             $emargement->setEvent(null);
  292.         }
  293.         return $this;
  294.     }
  295.     public function getTitle(): string
  296.     {
  297.         $title $this->getId();
  298.         if ($this->getModule()?->getIntitule()) {
  299.             $title $this->getModule()?->getFullIntituleType()??"";
  300.         }
  301.         if (($this->getAccompagnementOrParentAccompagnement()?->getType()?->getDesignation() ?? "") !== '' &&
  302.             ($this->getAccompagnementOrParentAccompagnement()?->getType()?->getDesignation() ?? "") !== '0') {
  303.             $title $this->getAccompagnementOrParentAccompagnement()?->getType()?->getDesignation()??"";
  304.         }
  305.         if ($this->getStage() instanceof Stage) {
  306.             $title "Stage" ;
  307.         }
  308.         if ($this->getJury() instanceof Jury) {
  309.             $title "Jury";
  310.         }
  311.         return $title;
  312.     }
  313.     public function getCode(): string
  314.     {
  315.         return $this->getModule()?->getCode() ?? ""
  316.             ?? $this->getAccompagnementOrParentAccompagnement()?->getType()?->getCode()
  317.             ?? "" ?? $this->getJury()?->getParcours()?->getCode() ?? "";
  318.     }
  319.     public function getSendconvocationstagiaire(): ?bool
  320.     {
  321.         return $this->sendconvocationstagiaire;
  322.     }
  323.     public function setSendconvocationstagiaire(?bool $sendconvocationstagiaire): self
  324.     {
  325.         $this->sendconvocationstagiaire $sendconvocationstagiaire;
  326.         return $this;
  327.     }
  328.     public function getSendconvocationformateur(): ?bool
  329.     {
  330.         return $this->sendconvocationformateur;
  331.     }
  332.     public function setSendconvocationformateur(?bool $sendconvocationformateur): self
  333.     {
  334.         $this->sendconvocationformateur $sendconvocationformateur;
  335.         return $this;
  336.     }
  337.     public function getType(): ?string
  338.     {
  339.         $type $this->getId();
  340.         if ($this->getModule() instanceof Module) {
  341.             $type ="Module" ;
  342.         }
  343.         if ($this->getAccompagnementOrParentAccompagnement() instanceof Accompagnement) {
  344.             $type ="Accompagnement" ;
  345.         }
  346.         if ($this->getStage() instanceof Stage) {
  347.             $type "Stage" ;
  348.         }
  349.         if ($this->getJury() instanceof Jury) {
  350.             $type "Jury";
  351.         }
  352.         return $type;
  353.     }
  354.     public function isTempsPriseEnCompte(): bool
  355.     {
  356.         return $this->tempsPriseEnCompte;
  357.     }
  358.     public function setTempsPriseEnCompte(bool $tempsPriseEnCompte): self
  359.     {
  360.         $this->tempsPriseEnCompte $tempsPriseEnCompte;
  361.         return $this;
  362.     }
  363.     public function isJustFinished(): bool
  364.     {
  365.         $now = new \DateTime();
  366.         return
  367.             $now->format('H') === '17'
  368.             && $this->getEnd()?->format('Y-m-d') === $now->format('Y-m-d');
  369.     }
  370.     public function isSendconvocationstagiaire(): ?bool
  371.     {
  372.         return $this->sendconvocationstagiaire;
  373.     }
  374.     public function isSendconvocationformateur(): ?bool
  375.     {
  376.         return $this->sendconvocationformateur;
  377.     }
  378.     /**
  379.      * @return Collection<int, FormulaireEvent>
  380.      */
  381.     public function getFormulaireEvents(): Collection
  382.     {
  383.         return $this->formulaireEvents;
  384.     }
  385.     public function addFormulaireEvent(FormulaireEvent $formulaireEvent): static
  386.     {
  387.         if (!$this->formulaireEvents->contains($formulaireEvent)) {
  388.             $this->formulaireEvents->add($formulaireEvent);
  389.             $formulaireEvent->setEvent($this);
  390.         }
  391.         return $this;
  392.     }
  393.     public function removeFormulaireEvent(FormulaireEvent $formulaireEvent): static
  394.     {
  395.         if ($this->formulaireEvents->removeElement($formulaireEvent)) {
  396.             // set the owning side to null (unless already changed)
  397.             if ($formulaireEvent->getEvent() === $this) {
  398.                 $formulaireEvent->setEvent(null);
  399.             }
  400.         }
  401.         return $this;
  402.     }
  403. }