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

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