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

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