src/Entity/Gestiform/Formations/Session/Session.php line 27

  1. <?php
  2. namespace App\Entity\Gestiform\Formations\Session;
  3. use App\Entity\AbstractEntity;
  4. use App\Entity\Common\Adresse;
  5. use App\Entity\Gestiform\Admin\MasterListe\Masterlistelg;
  6. use App\Entity\Gestiform\Admin\Salle;
  7. use App\Entity\Gestiform\Admin\Site;
  8. use App\Entity\Gestiform\Formations\Actions\BondeCommandeParcour;
  9. use App\Entity\Gestiform\Formations\Catalogue\Parcours\Parcours;
  10. use App\Entity\Gestiform\Formations\Dossier\Dossier;
  11. use App\Entity\Gestiform\Formations\Dossier\HistoriqueDossier;
  12. use App\Entity\Gestiform\Formations\Reunion\Reunion;
  13. use App\Entity\Gestiform\Formations\Session\Planning\Planning;
  14. use App\Entity\Gestiform\Users\Employe;
  15. use App\Entity\Trait\ApiGestiformEntity;
  16. use App\Repository\Gestiform\Formations\Session\SessionRepository;
  17. use DateTime;
  18. use Doctrine\Common\Collections\ArrayCollection;
  19. use Doctrine\Common\Collections\Collection;
  20. use Doctrine\ORM\Mapping as ORM;
  21. use Symfony\Component\Serializer\Annotation as Serializer;
  22. #[ORM\Entity(repositoryClassSessionRepository::class)]
  23. class Session extends AbstractEntity
  24. {
  25.     use ApiGestiformEntity;
  26.     #[ORM\Column(type'string'length255nullablefalse)]
  27.     private string $intitule;
  28.     #[ORM\Column(type'string'length65nullabletrue)]
  29.     private ?string $type null;
  30.     #[ORM\Column(type'string'length65nullabletrue)]
  31.     private ?string $sessionDokelio null;
  32.     #[ORM\Column(type'string'length65nullabletrue)]
  33.     private ?string $dokelioParcours null;
  34.     #[ORM\Column(type'decimal'precision10scale2nullabletrue)]
  35.     private ?string $simulNbApprenants null;
  36.     #[ORM\Column(type'string'length255nullabletrue)]
  37.     private ?string $numeroSession null;
  38.     #[ORM\Column(type'integer'nullabletrue)]
  39.     private ?int $duree null;
  40.     #[ORM\Column(type'datetime'nullablefalse)]
  41.     private ?DateTime $dateDebut null;
  42.     #[ORM\Column(type'datetime'nullabletrue)]
  43.     private ?DateTime $dateDebutAffichage null;
  44.     #[ORM\Column(type'datetime'nullabletrue)]
  45.     private ?DateTime $dateFinAffichage null;
  46.     #[Serializer\Ignore]
  47.     #[ORM\OneToMany(mappedBy'session'targetEntityDossier::class)]
  48.     private Collection $dossiers;
  49.     #[ORM\Column(type'boolean')]
  50.     private bool $sitePartenaire false;
  51.     #[ORM\Column(type'boolean')]
  52.     private bool $guaranteed false;
  53.     #[ORM\Column(type'boolean')]
  54.     private bool $permenant false;
  55.     #[ORM\Column(type'boolean')]
  56.     private bool $publieSite false;
  57.     #[ORM\Column(type'boolean')]
  58.     private bool $datesLarges false;
  59.     #[ORM\JoinColumn(nullabletrue)]
  60.     #[ORM\ManyToOne(targetEntitySalle::class, inversedBy'sessions')]
  61.     private ?Salle $salleDefaut null;
  62.     #[ORM\JoinColumn(nullabletrue)]
  63.     #[ORM\ManyToOne(targetEntityParcours::class, cascade: ['persist'], inversedBy'sessions')]
  64.     private ?Parcours $parcours null;
  65.     #[ORM\JoinColumn(nullabletrue)]
  66.     #[ORM\ManyToOne(targetEntityAdresse::class)]
  67.     private ?Adresse $adressePartenaire null;
  68.     #[ORM\ManyToOne(targetEntityMasterlistelg::class)]
  69.     private ?Masterlistelg $statut null;
  70.     #[Serializer\Ignore]
  71.     #[ORM\JoinColumn(nullabletrue)]
  72.     #[ORM\ManyToOne(targetEntityEmploye::class)]
  73.     private ?Employe $referentPedagogique null;
  74.     #[Serializer\Ignore]
  75.     #[ORM\JoinColumn(nullabletrue)]
  76.     #[ORM\ManyToOne(targetEntityEmploye::class)]
  77.     private ?Employe $referentCoach null;
  78.     #[Serializer\Ignore]
  79.     #[ORM\JoinColumn(nullabletrue)]
  80.     #[ORM\ManyToOne(targetEntityEmploye::class)]
  81.     private ?Employe $referentAdministratif null;
  82.     #[Serializer\Ignore]
  83.     #[ORM\JoinColumn(nullabletrue)]
  84.     #[ORM\ManyToOne(targetEntityEmploye::class)]
  85.     private ?Employe $referentHandicap null;
  86.     #[ORM\JoinColumn(nullabletrue)]
  87.     #[ORM\OneToOne(inversedBy'session'targetEntityPlanning::class, cascade: ['persist'])]
  88.     private ?Planning $planning=null;
  89.     #[ORM\OneToMany(mappedBy'session'targetEntityReunion::class, cascade: ['persist'])]
  90.     private Collection $reunions;
  91.     #[ORM\OneToMany(mappedBy'session'targetEntityHistoriqueDossier::class, cascade: ['persist'])]
  92.     private Collection $historiqueDossiers;
  93.     #[ORM\OneToMany(mappedBy'session'targetEntitySessionBlocModule::class, cascade: ['all'])]
  94.     private Collection $sessionBlocModules;
  95.     #[ORM\ManyToMany(targetEntityBondeCommandeParcour::class, mappedBy'sessions')]
  96.     private Collection $bondeCommandeParcours;
  97.     #[Serializer\Ignore]
  98.     #[ORM\JoinColumn(nullabletrue)]
  99.     #[ORM\ManyToOne(targetEntitySite::class)]
  100.     private ?Site $site null;
  101.     public function __construct()
  102.     {
  103.         $this->dossiers = new ArrayCollection();
  104.         $this->reunions = new ArrayCollection();
  105.         $this->historiqueDossiers = new ArrayCollection();
  106.         $this->sessionBlocModules = new ArrayCollection();
  107.         $this->bondeCommandeParcours = new ArrayCollection();
  108.     }
  109.     /**
  110.      * @return Collection<int, Dossier>
  111.      */
  112.     public function getDossiers(): Collection
  113.     {
  114.         return $this->dossiers;
  115.     }
  116.     public function addDossier(Dossier $dossier): self
  117.     {
  118.         if (!$this->dossiers->contains($dossier)) {
  119.             $this->dossiers->add($dossier);
  120.             $dossier->setSession($this);
  121.         }
  122.         return $this;
  123.     }
  124.     public function removeDossier(Dossier $dossier): self
  125.     {
  126.         // set the owning side to null (unless already changed)
  127.         if ($this->dossiers->removeElement($dossier) && $dossier->getSession() === $this) {
  128.             $dossier->setSession(null);
  129.         }
  130.         return $this;
  131.     }
  132.     public function getIntitule(): ?string
  133.     {
  134.         return $this->intitule;
  135.     }
  136.     public function setIntitule(string $intitule): self
  137.     {
  138.         $this->intitule $intitule;
  139.         return $this;
  140.     }
  141.     public function getType(): ?string
  142.     {
  143.         return $this->type;
  144.     }
  145.     public function setType(string $type): self
  146.     {
  147.         $this->type $type;
  148.         return $this;
  149.     }
  150.     public function getSessionDokelio(): ?string
  151.     {
  152.         return $this->sessionDokelio;
  153.     }
  154.     public function setSessionDokelio(string $sessionDokelio): self
  155.     {
  156.         $this->sessionDokelio $sessionDokelio;
  157.         return $this;
  158.     }
  159.     public function getDokelioParcours(): ?string
  160.     {
  161.         return $this->dokelioParcours;
  162.     }
  163.     public function setDokelioParcours(string $dokelioParcours): self
  164.     {
  165.         $this->dokelioParcours $dokelioParcours;
  166.         return $this;
  167.     }
  168.     public function getSimulNbApprenants(): ?float
  169.     {
  170.         return $this->simulNbApprenants;
  171.     }
  172.     public function setSimulNbApprenants(?float $simulNbApprenants): self
  173.     {
  174.         $this->simulNbApprenants $simulNbApprenants;
  175.         return $this;
  176.     }
  177.     public function getNumeroSession(): ?string
  178.     {
  179.         return $this->numeroSession;
  180.     }
  181.     public function setNumeroSession(?string $numeroSession): self
  182.     {
  183.         $this->numeroSession $numeroSession;
  184.         return $this;
  185.     }
  186.     public function getDateDebut(): ?DateTime
  187.     {
  188.         return $this->dateDebut;
  189.     }
  190.     public function setDateDebut(DateTime $dateDebut): self
  191.     {
  192.         $this->dateDebut $dateDebut;
  193.         return $this;
  194.     }
  195.     public function getDateDebutAffichage(): ?DateTime
  196.     {
  197.         return $this->dateDebutAffichage;
  198.     }
  199.     public function setDateDebutAffichage(DateTime $dateDebutAffichage): self
  200.     {
  201.         $this->dateDebutAffichage $dateDebutAffichage;
  202.         return $this;
  203.     }
  204.     public function getDateFinAffichage(): ?DateTime
  205.     {
  206.         return $this->dateFinAffichage;
  207.     }
  208.     public function setDateFinAffichage(DateTime $dateFinAffichage): self
  209.     {
  210.         $this->dateFinAffichage $dateFinAffichage;
  211.         return $this;
  212.     }
  213.     public function isSitePartenaire(): ?bool
  214.     {
  215.         return $this->sitePartenaire;
  216.     }
  217.     public function setSitePartenaire(bool $sitePartenaire): self
  218.     {
  219.         $this->sitePartenaire $sitePartenaire;
  220.         return $this;
  221.     }
  222.     public function isPublieSite(): ?bool
  223.     {
  224.         return $this->publieSite;
  225.     }
  226.     public function setPublieSite(bool $publieSite): self
  227.     {
  228.         $this->publieSite $publieSite;
  229.         return $this;
  230.     }
  231.     public function isDatesLarges(): ?bool
  232.     {
  233.         return $this->datesLarges;
  234.     }
  235.     public function setDatesLarges(bool $datesLarges): self
  236.     {
  237.         $this->datesLarges $datesLarges;
  238.         return $this;
  239.     }
  240.     public function getSalleDefaut(): ?Salle
  241.     {
  242.         return $this->salleDefaut;
  243.     }
  244.     public function setSalleDefaut(?Salle $salleDefaut): self
  245.     {
  246.         $this->salleDefaut $salleDefaut;
  247.         return $this;
  248.     }
  249.     public function getParcours(): ?Parcours
  250.     {
  251.         return $this->parcours;
  252.     }
  253.     public function setParcours(?Parcours $parcours): self
  254.     {
  255.         $this->parcours $parcours;
  256.         return $this;
  257.     }
  258.     public function getAdressePartenaire(): ?Adresse
  259.     {
  260.         return $this->adressePartenaire;
  261.     }
  262.     public function setAdressePartenaire(?Adresse $adressePartenaire): self
  263.     {
  264.         $this->adressePartenaire $adressePartenaire;
  265.         return $this;
  266.     }
  267.     public function getStatut(): ?Masterlistelg
  268.     {
  269.         return $this->statut;
  270.     }
  271.     public function setStatut(?Masterlistelg $statut): self
  272.     {
  273.         $this->statut $statut;
  274.         return $this;
  275.     }
  276.     public function getReferentPedagogique(): ?Employe
  277.     {
  278.         return $this->referentPedagogique;
  279.     }
  280.     public function setReferentPedagogique(?Employe $referentPedagogique): self
  281.     {
  282.         $this->referentPedagogique $referentPedagogique;
  283.         return $this;
  284.     }
  285.     public function getReferentCoach(): ?Employe
  286.     {
  287.         return $this->referentCoach;
  288.     }
  289.     public function setReferentCoach(?Employe $referentCoach): self
  290.     {
  291.         $this->referentCoach $referentCoach;
  292.         return $this;
  293.     }
  294.     public function getReferentAdministratif(): ?Employe
  295.     {
  296.         return $this->referentAdministratif;
  297.     }
  298.     public function setReferentAdministratif(?Employe $referentAdministratif): self
  299.     {
  300.         $this->referentAdministratif $referentAdministratif;
  301.         return $this;
  302.     }
  303.     public function getReferentHandicap(): ?Employe
  304.     {
  305.         return $this->referentHandicap;
  306.     }
  307.     public function setReferentHandicap(?Employe $referentHandicap): self
  308.     {
  309.         $this->referentHandicap $referentHandicap;
  310.         return $this;
  311.     }
  312.     public function getPlanning(): ?Planning
  313.     {
  314.         return $this->planning;
  315.     }
  316.     public function setPlanning(?Planning $planning): self
  317.     {
  318.         $this->planning $planning;
  319.         return $this;
  320.     }
  321.     /**
  322.      * @return Collection<int, Reunion>
  323.      */
  324.     public function getReunions(): Collection
  325.     {
  326.         return $this->reunions;
  327.     }
  328.     public function addReunion(Reunion $reunion): self
  329.     {
  330.         if (!$this->reunions->contains($reunion)) {
  331.             $this->reunions->add($reunion);
  332.             $reunion->setSession($this);
  333.         }
  334.         return $this;
  335.     }
  336.     public function removeReunion(Reunion $reunion): self
  337.     {
  338.         // set the owning side to null (unless already changed)
  339.         if ($this->reunions->removeElement($reunion) && $reunion->getSession() === $this) {
  340.             $reunion->setSession(null);
  341.         }
  342.         return $this;
  343.     }
  344.     /**
  345.      * @return Collection<int, HistoriqueDossier>
  346.      */
  347.     public function getHistoriqueDossiers(): Collection
  348.     {
  349.         return $this->historiqueDossiers;
  350.     }
  351.     public function addHistoriqueDossier(HistoriqueDossier $historiqueDossier): self
  352.     {
  353.         if (!$this->historiqueDossiers->contains($historiqueDossier)) {
  354.             $this->historiqueDossiers->add($historiqueDossier);
  355.             $historiqueDossier->setSession($this);
  356.         }
  357.         return $this;
  358.     }
  359.     public function removeHistoriqueDossier(HistoriqueDossier $historiqueDossier): self
  360.     {
  361.         // set the owning side to null (unless already changed)
  362.         if ($this->historiqueDossiers->removeElement($historiqueDossier) && $historiqueDossier->getSession() === $this) {
  363.             $historiqueDossier->setSession(null);
  364.         }
  365.         return $this;
  366.     }
  367.     public function getSessionBlocModules(): Collection
  368.     {
  369.         return $this->sessionBlocModules;
  370.     }
  371.     public function addSessionBlocModule(SessionBlocModule $sessionBlocModule): self
  372.     {
  373.         if (!$this->sessionBlocModules->contains($sessionBlocModule)) {
  374.             $this->sessionBlocModules->add($sessionBlocModule);
  375.             $sessionBlocModule->setSession($this);
  376.         }
  377.         return $this;
  378.     }
  379.     public function removeSessionBlocModule(SessionBlocModule $sessionBlocModule): self
  380.     {
  381.         // set the owning side to null (unless already changed)
  382.         if ($this->sessionBlocModules->removeElement($sessionBlocModule) && $sessionBlocModule->getSession() === $this) {
  383.             $sessionBlocModule->setSession(null);
  384.         }
  385.         return $this;
  386.     }
  387.     /**
  388.      * @return Collection<int, BondeCommandeParcour>
  389.      */
  390.     public function getBondeCommandeParcours(): Collection
  391.     {
  392.         return $this->bondeCommandeParcours;
  393.     }
  394.     public function addBondeCommandeParcour(BondeCommandeParcour $bondeCommandeParcour): self
  395.     {
  396.         if (!$this->bondeCommandeParcours->contains($bondeCommandeParcour)) {
  397.             $this->bondeCommandeParcours->add($bondeCommandeParcour);
  398.             $bondeCommandeParcour->addSession($this);
  399.         }
  400.         return $this;
  401.     }
  402.     public function removeBondeCommandeParcour(BondeCommandeParcour $bondeCommandeParcour): self
  403.     {
  404.         if ($this->bondeCommandeParcours->removeElement($bondeCommandeParcour)) {
  405.             $bondeCommandeParcour->removeSession($this);
  406.         }
  407.         return $this;
  408.     }
  409.     public function getDuree(): ?int
  410.     {
  411.         return $this->duree;
  412.     }
  413.     public function setDuree(?int $duree): self
  414.     {
  415.         $this->duree $duree;
  416.         return $this;
  417.     }
  418.     public function getSite(): ?Site
  419.     {
  420.         return $this->site;
  421.     }
  422.     public function setSite(?Site $site): self
  423.     {
  424.         $this->site $site;
  425.         return $this;
  426.     }
  427.     /**
  428.      * @throws \DateMalformedStringException
  429.      */
  430.     public function getAllSemaineSession(): array
  431.     {
  432.         $resultat=[];
  433.         if($this->getPlanning()->getStart() instanceof \DateTime){
  434.         $datecourant=clone $this->getPlanning()?->getStart();
  435.         $dateFin=$this->getPlanning()->getEnd();
  436.         $i=0;
  437.         while($datecourant <= $dateFin && $i 150)
  438.         {
  439.             $i++;
  440.             $monweek=clone $datecourant;
  441.             $resultat[]=$monweek;
  442.             $datecourant->modify("+7 day");
  443.             $datecourant->modify('monday this week');
  444.         }
  445.         return $resultat;
  446.         }
  447.         else
  448.         {
  449.             return [];
  450.         }
  451.     }
  452.     public function isPermenant(): ?bool
  453.     {
  454.         return $this->permenant;
  455.     }
  456.     public function setPermenant(bool $permenant): self
  457.     {
  458.         $this->permenant $permenant;
  459.         return $this;
  460.     }
  461.     public function isGuaranteed(): ?bool
  462.     {
  463.         return $this->guaranteed;
  464.     }
  465.     public function setGuaranteed(bool $guaranteed): self
  466.     {
  467.         $this->guaranteed $guaranteed;
  468.         return $this;
  469.     }
  470. }