<?php
namespace App\Entity\Gestiform\Users;
use App\Entity\Common\Adresse;
use App\Entity\Common\Upload;
use App\Entity\Gestiform\Admin\MasterListe\Masterlistelg;
use App\Entity\Gestiform\Formations\Catalogue\Parcours\Parcours;
use App\Entity\Gestiform\Formations\Dossier\HistoriqueComment;
use App\Entity\Gestiform\Formations\Entreprise\Contrat;
use App\Entity\Gestiform\Formations\Entreprise\Entreprise;
use App\Entity\Gestiform\Formations\Entreprise\FormateurEntreprise;
use App\Entity\Gestiform\Formations\Formateur\FormateurModule;
use App\Entity\Gestiform\Formations\Session\FormateurEvent;
use App\Entity\Gestiform\Formations\Session\Planning\ApprenantLivrable;
use App\Entity\Gestiform\Formations\Session\Planning\LignePrestation;
use App\Repository\Gestiform\Users\FormateurRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=FormateurRepository::class)
*/
class Formateur extends Personne
{
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $prefecture = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $numeroActivite = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $numeroActivite2 = null;
public function getNumeroActivite2(): ?string
{
return $this->numeroActivite2;
}
public function setNumeroActivite2(?string $numeroActivite2): Formateur
{
$this->numeroActivite2 = $numeroActivite2;
return $this;
}
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $listeCompetences = null;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTime $debutHabilitation = null;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTime $finHabilitation = null;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private ?bool $juryUniquement = null;
/**
* @ORM\ManyToOne(targetEntity=Masterlistelg::class)
* @ORM\JoinColumn(nullable=true)
*/
private ?Masterlistelg $statut = null;
/**
* @ORM\OneToMany(targetEntity=FormateurModule::class, mappedBy="formateur", cascade={"persist"})
*/
private Collection $formateurModules;
/**
* @ORM\OneToMany(targetEntity=Parcours::class, mappedBy="formateur", cascade={"persist"})
*/
private Collection $parcoursRNCP;
/**
* @ORM\OneToMany(targetEntity=FormateurEntreprise::class, mappedBy="formateur",cascade={"persist"})
*/
private Collection $formateurEntreprises;
/**
* @ORM\ManyToMany(targetEntity=Contrat::class, mappedBy="formateurs",cascade={"persist"})
*/
private Collection $contrats;
/**
* @ORM\ManyToMany(targetEntity=LignePrestation::class, mappedBy="formateurs",cascade={"all"})
*/
private Collection $lignePrestations;
/**
* @ORM\OneToMany(targetEntity=FormateurEvent::class, mappedBy="formateur", cascade={"all"})
*/
private Collection $formateurEvents;
/**
* @ORM\Column( type="text", nullable=true)
*/
private ?string $missionProposee = null;
/**
* @ORM\OneToMany(targetEntity=ApprenantLivrable::class, mappedBy="formateur", cascade={"persist"})
*/
private Collection $apprenantLivrables;
/**
* @ORM\OneToMany(targetEntity=HistoriqueComment::class, mappedBy="formateur", cascade={"all"})
*/
private Collection $historiqueComments;
public function __construct()
{
parent::__construct();
$this->formateurModules = new ArrayCollection();
$this->formateurEntreprises = new ArrayCollection();
$this->formateurEvents = new ArrayCollection();
$this->contrats = new ArrayCollection();
$this->lignePrestations = new ArrayCollection();
$this->apprenantLivrables = new ArrayCollection();
$this->historiqueComments = new ArrayCollection();
$this->parcoursRNCP = new ArrayCollection();
}
public function getJuryUniquement(): ?bool
{
return $this->juryUniquement;
}
public function setJuryUniquement(?bool $juryUniquement): self
{
$this->juryUniquement = $juryUniquement;
return $this;
}
public function getListeCompetences(): ?string
{
return $this->listeCompetences;
}
public function setListeCompetences(?string $listeCompetences): self
{
$this->listeCompetences = $listeCompetences;
return $this;
}
public function getStatut(): ?Masterlistelg
{
return $this->statut;
}
public function setStatut(?Masterlistelg $statut): self
{
$this->statut = $statut;
return $this;
}
/**
* @return Collection<int, FormateurModule>
*/
public function getFormateurModules(): Collection
{
return $this->formateurModules;
}
public function addFormateurModule(FormateurModule $formateurModule): self
{
if (!$this->formateurModules->contains($formateurModule)) {
$this->formateurModules->add($formateurModule);
$formateurModule->setFormateur($this);
}
return $this;
}
public function removeFormateurModule(FormateurModule $formateurModule): self
{
if ($this->formateurModules->removeElement($formateurModule)) {
// set the owning side to null (unless already changed)
if ($formateurModule->getFormateur() === $this) {
$formateurModule->setFormateur(null);
}
}
return $this;
}
/**
* @return Collection<int, FormateurEntreprise>
*/
public function getFormateurEntreprises(): Collection
{
return $this->formateurEntreprises;
}
public function addFormateurEntreprise(FormateurEntreprise $formateurEntreprise): self
{
if (!$this->formateurEntreprises->contains($formateurEntreprise)) {
$this->formateurEntreprises->add($formateurEntreprise);
$formateurEntreprise->setFormateur($this);
}
return $this;
}
public function removeFormateurEntreprise(FormateurEntreprise $formateurEntreprise): self
{
if ($this->formateurEntreprises->removeElement($formateurEntreprise)) {
// set the owning side to null (unless already changed)
if ($formateurEntreprise->getFormateur() === $this) {
$formateurEntreprise->setFormateur(null);
}
}
return $this;
}
public function getEntreprise(): ?Entreprise
{
$formateurEntreprises = $this->getFormateurEntreprises();
if ($formateurEntreprises->isEmpty()) {
return null;
}
$firstRelation = $formateurEntreprises->first();
return $firstRelation ? $firstRelation->getEntreprise() : null;
}
public function getPrefecture(): ?string
{
return $this->prefecture;
}
public function setPrefecture(?string $prefecture): self
{
$this->prefecture = $prefecture;
return $this;
}
public function getNumeroActivite(): ?string
{
return $this->numeroActivite;
}
public function setNumeroActivite(?string $numeroActivite): self
{
$this->numeroActivite = $numeroActivite;
return $this;
}
/**
* @return Collection<int, FormateurEvent>
*/
public function getFormateurEvents(): Collection
{
return $this->formateurEvents;
}
public function addFormateurEvent(FormateurEvent $formateurEvent): self
{
if (!$this->formateurEvents->contains($formateurEvent)) {
$this->formateurEvents->add($formateurEvent);
$formateurEvent->setFormateur($this);
}
return $this;
}
public function removeFormateurEvent(FormateurEvent $formateurEvent): self
{
if ($this->formateurEvents->removeElement($formateurEvent)) {
// set the owning side to null (unless already changed)
if ($formateurEvent->getFormateur() === $this) {
$formateurEvent->setFormateur(null);
}
}
return $this;
}
public function getMissionProposee()
{
if ($this->missionProposee === null) {
return [];
}
return json_decode($this->missionProposee, true, 512, JSON_THROW_ON_ERROR);
}
/**
* @throws \JsonException
*/
public function addMissionProposee(string $id, string $title, $state = null, $sevent=[]): self
{
$missionProposee = json_decode($this->missionProposee, true, 512, JSON_THROW_ON_ERROR) ?? [];
$exist = false;
foreach ($missionProposee as &$item) {
if ($item['id'] === $id) {
$item['title'] = $title;
$item['state'] = $state;
$exist = true;
}
}
if (!$exist) {
$missionProposee[] = [
'id' => $id,
'title' => $title,
'state' => $state,
'week' => $sevent['week'],
'start' => $sevent['start'],
'end' => $sevent['end']
];
}
$this->missionProposee = json_encode($missionProposee, JSON_THROW_ON_ERROR);
return $this;
}
/**
* @throws \JsonException
*/
public function removeMissionProposee(string $idEvent): self
{
$missionProposee = json_decode($this->missionProposee, true, 512, JSON_THROW_ON_ERROR) ?? [];
foreach ($missionProposee as $key => $item) {
if ($item['id'] === $idEvent) {
unset($missionProposee[$key]);
}
}
$this->missionProposee = json_encode(array_values($missionProposee), JSON_THROW_ON_ERROR);
return $this;
}
public function setMissionProposee(?string $missionProposee): self
{
$this->missionProposee = $missionProposee;
return $this;
}
/**
* @throws \JsonException
*/
public function getMissionProposeeById(string $id)
{
$missionProposee = json_decode($this->missionProposee, true, 512, JSON_THROW_ON_ERROR) ?? [];
foreach ($missionProposee as $item) {
if ($item['id'] === $id) {
return $item;
}
}
return null;
}
/**
* @return Collection<int, Contrat>
*/
public function getContrats(): Collection
{
return $this->contrats;
}
public function addContrat(Contrat $contrat): self
{
if (!$this->contrats->contains($contrat)) {
$this->contrats->add($contrat);
$contrat->addFormateur($this);
}
return $this;
}
public function removeContrat(Contrat $contrat): self
{
if ($this->contrats->removeElement($contrat)) {
$contrat->removeFormateur($this);
}
return $this;
}
/**
* @return Collection<int, LignePrestation>
*/
public function getLignePrestations(): Collection
{
return $this->lignePrestations;
}
public function addLignePrestation(LignePrestation $lignePrestation): self
{
if (!$this->lignePrestations->contains($lignePrestation)) {
$this->lignePrestations->add($lignePrestation);
$lignePrestation->addFormateur($this);
}
return $this;
}
public function removeLignePrestation(LignePrestation $lignePrestation): self
{
if ($this->lignePrestations->removeElement($lignePrestation)) {
$lignePrestation->removeFormateur($this);
}
return $this;
}
/**
* @throws \JsonException
*/
public function verifMissionProposee(string $id): bool
{
$missionProposee = json_decode($this->missionProposee, true, 512, JSON_THROW_ON_ERROR) ?? [];
$exist = false;
foreach ($missionProposee as $item) {
if ($item['id'] === $id) {
$exist = true;
}
}
return $exist;
}
/**
* @return Collection<int, ApprenantLivrable>
*/
public function getApprenantLivrables(): Collection
{
return $this->apprenantLivrables;
}
public function addApprenantLivrable(ApprenantLivrable $apprenantLivrable): self
{
if (!$this->apprenantLivrables->contains($apprenantLivrable)) {
$this->apprenantLivrables->add($apprenantLivrable);
$apprenantLivrable->setFormateur($this);
}
return $this;
}
public function removeApprenantLivrable(ApprenantLivrable $apprenantLivrable): self
{
if ($this->apprenantLivrables->removeElement($apprenantLivrable)) {
// set the owning side to null (unless already changed)
if ($apprenantLivrable->getFormateur() === $this) {
$apprenantLivrable->setFormateur(null);
}
}
return $this;
}
/**
* @return Collection<int, HistoriqueComment>
*/
public function getHistoriqueComments(): Collection
{
return $this->historiqueComments;
}
public function addHistoriqueComment(HistoriqueComment $historiqueComment): self
{
if (!$this->historiqueComments->contains($historiqueComment)) {
$this->historiqueComments->add($historiqueComment);
$historiqueComment->setFormateur($this);
}
return $this;
}
public function removeHistoriqueComment(HistoriqueComment $historiqueComment): self
{
if ($this->historiqueComments->removeElement($historiqueComment)) {
// set the owning side to null (unless already changed)
if ($historiqueComment->getFormateur() === $this) {
$historiqueComment->setFormateur($this);
}
}
return $this;
}
public function getDebutHabilitation(): ?\DateTime
{
return $this->debutHabilitation;
}
public function setDebutHabilitation(?\DateTime $debutHabilitation): self
{
$this->debutHabilitation = $debutHabilitation;
return $this;
}
public function getFinHabilitation(): ?\DateTime
{
return $this->finHabilitation;
}
public function setFinHabilitation(?\DateTime $finHabilitation): self
{
$this->finHabilitation = $finHabilitation;
return $this;
}
public function isJuryUniquement(): ?bool
{
return $this->juryUniquement;
}
/**
* @return Collection<int, Parcours>
*/
public function getParcoursRNCP(): Collection
{
return $this->parcoursRNCP;
}
public function addParcoursRNCP(Parcours $parcoursRNCP): self
{
if (!$this->parcoursRNCP->contains($parcoursRNCP)) {
$this->parcoursRNCP->add($parcoursRNCP);
$parcoursRNCP->setFormateur($this);
}
return $this;
}
public function removeParcoursRNCP(Parcours $parcoursRNCP): self
{
if ($this->parcoursRNCP->removeElement($parcoursRNCP)) {
// set the owning side to null (unless already changed)
if ($parcoursRNCP->getFormateur() === $this) {
$parcoursRNCP->setFormateur(null);
}
}
return $this;
}
}