<?php
namespace App\Entity\Gestiform\Formations\Session;
use App\Entity\AbstractEntity;
use App\Entity\Common\Adresse;
use App\Entity\Gestiform\Admin\MasterListe\Masterlistelg;
use App\Entity\Gestiform\Admin\Salle;
use App\Entity\Gestiform\Admin\Site;
use App\Entity\Gestiform\Formations\Actions\BondeCommandeParcour;
use App\Entity\Gestiform\Formations\Catalogue\Parcours\Parcours;
use App\Entity\Gestiform\Formations\Dossier\Dossier;
use App\Entity\Gestiform\Formations\Dossier\HistoriqueDossier;
use App\Entity\Gestiform\Formations\Reunion\Reunion;
use App\Entity\Gestiform\Formations\Session\Planning\Planning;
use App\Entity\Gestiform\Users\Employe;
use App\Repository\Gestiform\Formations\Session\SessionRepository;
use App\Trait\ApiGestiformEntity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Entity(repositoryClass=SessionRepository::class)
*/
class Session extends AbstractEntity
{
use ApiGestiformEntity;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private string $intitule;
/**
* @ORM\Column(type="string", length=65, nullable=true)
*/
private ?string $type = null;
/**
* @ORM\Column(type="string", length=65, nullable=true)
*/
private ?string $sessionDokelio = null;
/**
* @ORM\Column(type="string", length=65, nullable=true)
*/
private ?string $dokelioParcours = null;
/**
* @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
*/
private ?float $simulNbApprenants = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $numeroSession = null;
/**
* @ORM\Column(type="integer",nullable=true)
*/
private ?int $duree = null;
/**
* @ORM\Column(type="datetime", nullable=false)
*/
private ?\DateTime $dateDebut = null;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTime $dateDebutAffichage = null;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTime $dateFinAffichage = null;
/**
* @ORM\OneToMany(targetEntity=Dossier::class, mappedBy="session")
* @Serializer\Ignore()
*/
private Collection $dossiers;
/**
* @ORM\Column(type="boolean")
*/
private bool $sitePartenaire = false;
/**
* @ORM\Column(type="boolean")
*/
private bool $publieSite = false;
/**
* @ORM\Column(type="boolean")
*/
private bool $datesLarges = false;
/**
* @ORM\ManyToOne(targetEntity=Salle::class, inversedBy="sessions")
* @ORM\JoinColumn(nullable=true)
*/
private ?Salle $salleDefaut = null;
/**
* @ORM\ManyToOne(targetEntity=Parcours::class, inversedBy="sessions", cascade={"persist"})
* @ORM\JoinColumn(nullable=true)
*/
private ?Parcours $parcours = null;
/**
* @ORM\ManyToOne(targetEntity=Adresse::class)
* @ORM\JoinColumn(nullable=true)
*/
private ?Adresse $adressePartenaire = null;
/**
* @ORM\ManyToOne(targetEntity=Masterlistelg::class)
*/
private ?Masterlistelg $statut = null;
/**
* @ORM\ManyToOne(targetEntity=Employe::class)
* @ORM\JoinColumn(nullable=true)
* @Serializer\Ignore()
*/
private ?Employe $referentPedagogique = null;
/**
* @ORM\ManyToOne(targetEntity=Employe::class)
* @ORM\JoinColumn(nullable=true)
* @Serializer\Ignore()
*/
private ?Employe $referentCoach = null;
/**
* @ORM\ManyToOne(targetEntity=Employe::class)
* @ORM\JoinColumn(nullable=true)
* @Serializer\Ignore()
*/
private ?Employe $referentAdministratif = null;
/**
* @ORM\ManyToOne(targetEntity=Employe::class)
* @ORM\JoinColumn(nullable=true)
* @Serializer\Ignore()
*/
private ?Employe $referentHandicap = null;
/**
* @ORM\OneToOne(targetEntity=Planning::class, inversedBy="session", cascade={"persist"})
* @ORM\JoinColumn(nullable=true)
*/
private ?Planning $planning=null;
/**
* @ORM\OneToMany(targetEntity=Reunion::class, mappedBy="session",cascade={"persist"})
*/
private Collection $reunions;
/**
* @ORM\OneToMany(targetEntity=HistoriqueDossier::class, mappedBy="session",cascade={"persist"})
*/
private Collection $historiqueDossiers;
/**
* @ORM\OneToMany(targetEntity=SessionBlocModule::class, mappedBy="session",cascade={"all"})
*/
private Collection $sessionBlocModules;
/**
* @ORM\ManyToMany(targetEntity=BondeCommandeParcour::class, mappedBy="sessions")
*/
private Collection $bondeCommandeParcours;
/**
* @ORM\ManyToOne(targetEntity=Site::class)
* @ORM\JoinColumn(nullable=true)
* @Serializer\Ignore()
*/
private ?Site $site = null;
public function __construct()
{
$this->dossiers = new ArrayCollection();
$this->reunions = new ArrayCollection();
$this->historiqueDossiers = new ArrayCollection();
$this->sessionBlocModules = new ArrayCollection();
$this->bondeCommandeParcours = new ArrayCollection();
}
/**
* @return Collection<int, Dossier>
*/
public function getDossiers(): Collection
{
return $this->dossiers;
}
public function addDossier(Dossier $dossier): self
{
if (!$this->dossiers->contains($dossier)) {
$this->dossiers->add($dossier);
$dossier->setSession($this);
}
return $this;
}
public function removeDossier(Dossier $dossier): self
{
if ($this->dossiers->removeElement($dossier)) {
// set the owning side to null (unless already changed)
if ($dossier->getSession() === $this) {
$dossier->setSession(null);
}
}
return $this;
}
public function getIntitule(): ?string
{
return $this->intitule;
}
public function setIntitule(string $intitule): self
{
$this->intitule = $intitule;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getSessionDokelio(): ?string
{
return $this->sessionDokelio;
}
public function setSessionDokelio(string $sessionDokelio): self
{
$this->sessionDokelio = $sessionDokelio;
return $this;
}
public function getDokelioParcours(): ?string
{
return $this->dokelioParcours;
}
public function setDokelioParcours(string $dokelioParcours): self
{
$this->dokelioParcours = $dokelioParcours;
return $this;
}
public function getSimulNbApprenants(): ?string
{
return $this->simulNbApprenants;
}
public function setSimulNbApprenants(?string $simulNbApprenants): self
{
$this->simulNbApprenants = $simulNbApprenants;
return $this;
}
public function getNumeroSession(): ?string
{
return $this->numeroSession;
}
public function setNumeroSession(?string $numeroSession): self
{
$this->numeroSession = $numeroSession;
return $this;
}
public function getDateDebut(): ?\DateTime
{
return $this->dateDebut;
}
public function setDateDebut(\DateTime $dateDebut): self
{
$this->dateDebut = $dateDebut;
return $this;
}
public function getDateDebutAffichage(): ?\DateTime
{
return $this->dateDebutAffichage;
}
public function setDateDebutAffichage(\DateTime $dateDebutAffichage): self
{
$this->dateDebutAffichage = $dateDebutAffichage;
return $this;
}
public function getDateFinAffichage(): ?\DateTime
{
return $this->dateFinAffichage;
}
public function setDateFinAffichage(\DateTime $dateFinAffichage): self
{
$this->dateFinAffichage = $dateFinAffichage;
return $this;
}
public function isSitePartenaire(): ?bool
{
return $this->sitePartenaire;
}
public function setSitePartenaire(bool $sitePartenaire): self
{
$this->sitePartenaire = $sitePartenaire;
return $this;
}
public function isPublieSite(): ?bool
{
return $this->publieSite;
}
public function setPublieSite(bool $publieSite): self
{
$this->publieSite = $publieSite;
return $this;
}
public function isDatesLarges(): ?bool
{
return $this->datesLarges;
}
public function setDatesLarges(bool $datesLarges): self
{
$this->datesLarges = $datesLarges;
return $this;
}
public function getSalleDefaut(): ?Salle
{
return $this->salleDefaut;
}
public function setSalleDefaut(?Salle $salleDefaut): self
{
$this->salleDefaut = $salleDefaut;
return $this;
}
public function getParcours(): ?Parcours
{
return $this->parcours;
}
public function setParcours(?Parcours $parcours): self
{
$this->parcours = $parcours;
return $this;
}
public function getAdressePartenaire(): ?Adresse
{
return $this->adressePartenaire;
}
public function setAdressePartenaire(?Adresse $adressePartenaire): self
{
$this->adressePartenaire = $adressePartenaire;
return $this;
}
public function getStatut(): ?Masterlistelg
{
return $this->statut;
}
public function setStatut(?Masterlistelg $statut): self
{
$this->statut = $statut;
return $this;
}
public function getReferentPedagogique(): ?Employe
{
return $this->referentPedagogique;
}
public function setReferentPedagogique(?Employe $referentPedagogique): self
{
$this->referentPedagogique = $referentPedagogique;
return $this;
}
public function getReferentCoach(): ?Employe
{
return $this->referentCoach;
}
public function setReferentCoach(?Employe $referentCoach): self
{
$this->referentCoach = $referentCoach;
return $this;
}
public function getReferentAdministratif(): ?Employe
{
return $this->referentAdministratif;
}
public function setReferentAdministratif(?Employe $referentAdministratif): self
{
$this->referentAdministratif = $referentAdministratif;
return $this;
}
public function getReferentHandicap(): ?Employe
{
return $this->referentHandicap;
}
public function setReferentHandicap(?Employe $referentHandicap): self
{
$this->referentHandicap = $referentHandicap;
return $this;
}
public function getPlanning(): ?Planning
{
return $this->planning;
}
public function setPlanning(?Planning $planning): self
{
$this->planning = $planning;
return $this;
}
/**
* @return Collection<int, Reunion>
*/
public function getReunions(): Collection
{
return $this->reunions;
}
public function addReunion(Reunion $reunion): self
{
if (!$this->reunions->contains($reunion)) {
$this->reunions->add($reunion);
$reunion->setSession($this);
}
return $this;
}
public function removeReunion(Reunion $reunion): self
{
if ($this->reunions->removeElement($reunion)) {
// set the owning side to null (unless already changed)
if ($reunion->getSession() === $this) {
$reunion->setSession(null);
}
}
return $this;
}
/**
* @return Collection<int, HistoriqueDossier>
*/
public function getHistoriqueDossiers(): Collection
{
return $this->historiqueDossiers;
}
public function addHistoriqueDossier(HistoriqueDossier $historiqueDossier): self
{
if (!$this->historiqueDossiers->contains($historiqueDossier)) {
$this->historiqueDossiers->add($historiqueDossier);
$historiqueDossier->setSession($this);
}
return $this;
}
public function removeHistoriqueDossier(HistoriqueDossier $historiqueDossier): self
{
if ($this->historiqueDossiers->removeElement($historiqueDossier)) {
// set the owning side to null (unless already changed)
if ($historiqueDossier->getSession() === $this) {
$historiqueDossier->setSession(null);
}
}
return $this;
}
public function getSessionBlocModules(): Collection
{
return $this->sessionBlocModules;
}
public function addSessionBlocModule(SessionBlocModule $sessionBlocModule): self
{
if (!$this->sessionBlocModules->contains($sessionBlocModule)) {
$this->sessionBlocModules->add($sessionBlocModule);
$sessionBlocModule->setSession($this);
}
return $this;
}
public function removeSessionBlocModule(SessionBlocModule $sessionBlocModule): self
{
if ($this->sessionBlocModules->removeElement($sessionBlocModule)) {
// set the owning side to null (unless already changed)
if ($sessionBlocModule->getSession() === $this) {
$sessionBlocModule->setSession(null);
}
}
return $this;
}
/**
* @return Collection<int, BondeCommandeParcour>
*/
public function getBondeCommandeParcours(): Collection
{
return $this->bondeCommandeParcours;
}
public function addBondeCommandeParcour(BondeCommandeParcour $bondeCommandeParcour): self
{
if (!$this->bondeCommandeParcours->contains($bondeCommandeParcour)) {
$this->bondeCommandeParcours->add($bondeCommandeParcour);
$bondeCommandeParcour->addSession($this);
}
return $this;
}
public function removeBondeCommandeParcour(BondeCommandeParcour $bondeCommandeParcour): self
{
if ($this->bondeCommandeParcours->removeElement($bondeCommandeParcour)) {
$bondeCommandeParcour->removeSession($this);
}
return $this;
}
public function getDuree(): ?int
{
return $this->duree;
}
public function setDuree(?int $duree): self
{
$this->duree = $duree;
return $this;
}
public function getSite(): ?Site
{
return $this->site;
}
public function setSite(?Site $site): self
{
$this->site = $site;
return $this;
}
/**
* @throws \DateMalformedStringException
*/
public function getAllSemaineSession(): array
{
$resultat=[];
if($this->getPlanning()->getStart()){
$datecourant=clone $this->getPlanning()?->getStart();
$dateFin=$this->getPlanning()->getEnd();
$i=0;
while($datecourant<=$dateFin and $i<150)
{
$i++;
$monweek=clone $datecourant;
$resultat[]=$monweek;
$datecourant->modify("+7 day");
$datecourant->modify('monday this week');
}
return $resultat;
}
else
{
return [];
}
}
}