src/Entity/Gestiform/Users/Formateur.php line 25

  1. <?php
  2. namespace App\Entity\Gestiform\Users;
  3. use DateTime;
  4. use JsonException;
  5. use App\Entity\Common\Adresse;
  6. use App\Entity\Common\Upload;
  7. use App\Entity\Gestiform\Admin\MasterListe\Masterlistelg;
  8. use App\Entity\Gestiform\Formations\Catalogue\Parcours\Parcours;
  9. use App\Entity\Gestiform\Formations\Dossier\HistoriqueComment;
  10. use App\Entity\Gestiform\Formations\Entreprise\Contrat;
  11. use App\Entity\Gestiform\Formations\Entreprise\Entreprise;
  12. use App\Entity\Gestiform\Formations\Entreprise\FormateurEntreprise;
  13. use App\Entity\Gestiform\Formations\Formateur\FormateurModule;
  14. use App\Entity\Gestiform\Formations\Session\FormateurEvent;
  15. use App\Entity\Gestiform\Formations\Session\Planning\ApprenantLivrable;
  16. use App\Entity\Gestiform\Formations\Session\Planning\LignePrestation;
  17. use App\Repository\Gestiform\Users\FormateurRepository;
  18. use Doctrine\Common\Collections\ArrayCollection;
  19. use Doctrine\Common\Collections\Collection;
  20. use Doctrine\ORM\Mapping as ORM;
  21. #[ORM\Entity(repositoryClassFormateurRepository::class)]
  22. class Formateur extends Personne
  23. {
  24.     #[ORM\Column(type'string'length255nullabletrue)]
  25.     private ?string $prefecture null;
  26.     #[ORM\Column(type'string'length255nullabletrue)]
  27.     private ?string $numeroActivite null;
  28.     #[ORM\Column(type'string'length255nullabletrue)]
  29.     private ?string $numeroActivite2 null;
  30.     #[ORM\Column(type'string'nullabletrue)]
  31.     private ?string $listeCompetences null;
  32.     #[ORM\Column(type'datetime'nullabletrue)]
  33.     private ?DateTime $debutHabilitation null;
  34.     #[ORM\Column(type'datetime'nullabletrue)]
  35.     private ?DateTime $finHabilitation null;
  36.     #[ORM\Column(type'boolean'nullabletrue)]
  37.     private ?bool $juryUniquement null;
  38.     #[ORM\JoinColumn(nullabletrue)]
  39.     #[ORM\ManyToOne(targetEntityMasterlistelg::class)]
  40.     private ?Masterlistelg $statut null;
  41.     #[ORM\OneToMany(mappedBy'formateur'targetEntityFormateurModule::class, cascade: ['persist'])]
  42.     private Collection $formateurModules;
  43.     #[ORM\OneToMany(mappedBy'formateur'targetEntityParcours::class, cascade: ['persist'])]
  44.     private Collection $parcoursRNCP;
  45.     #[ORM\OneToMany(mappedBy'formateur'targetEntityFormateurEntreprise::class, cascade: ['persist'])]
  46.     private Collection $formateurEntreprises;
  47.     #[ORM\ManyToMany(targetEntityContrat::class, mappedBy'formateurs'cascade: ['persist'])]
  48.     private Collection $contrats;
  49.     #[ORM\ManyToMany(targetEntityLignePrestation::class, mappedBy'formateurs'cascade: ['all'])]
  50.     private Collection $lignePrestations;
  51.     #[ORM\OneToMany(mappedBy'formateur'targetEntityFormateurEvent::class, cascade: ['all'])]
  52.     private Collection $formateurEvents;
  53.     #[ORM\Column(type'text'nullabletrue)]
  54.     private ?string $missionProposee null;
  55.     #[ORM\OneToMany(mappedBy'formateur'targetEntityApprenantLivrable::class, cascade: ['persist'])]
  56.     private Collection $apprenantLivrables;
  57.     #[ORM\OneToMany(mappedBy'formateur'targetEntityHistoriqueComment::class, cascade: ['all'])]
  58.     private Collection $historiqueComments;
  59.     public function __construct()
  60.     {
  61.         parent::__construct();
  62.         $this->formateurModules = new ArrayCollection();
  63.         $this->formateurEntreprises = new ArrayCollection();
  64.         $this->formateurEvents = new ArrayCollection();
  65.         $this->contrats = new ArrayCollection();
  66.         $this->lignePrestations = new ArrayCollection();
  67.         $this->apprenantLivrables = new ArrayCollection();
  68.         $this->historiqueComments = new ArrayCollection();
  69.         $this->parcoursRNCP = new ArrayCollection();
  70.     }
  71.     public function getJuryUniquement(): ?bool
  72.     {
  73.         return $this->juryUniquement;
  74.     }
  75.     public function setJuryUniquement(?bool $juryUniquement): self
  76.     {
  77.         $this->juryUniquement $juryUniquement;
  78.         return $this;
  79.     }
  80.     public function getListeCompetences(): ?string
  81.     {
  82.         return $this->listeCompetences;
  83.     }
  84.     public function setListeCompetences(?string $listeCompetences): self
  85.     {
  86.         $this->listeCompetences $listeCompetences;
  87.         return $this;
  88.     }
  89.     public function getStatut(): ?Masterlistelg
  90.     {
  91.         return $this->statut;
  92.     }
  93.     public function setStatut(?Masterlistelg $statut): self
  94.     {
  95.         $this->statut $statut;
  96.         return $this;
  97.     }
  98.     /**
  99.      * @return Collection<int, FormateurModule>
  100.      */
  101.     public function getFormateurModules(): Collection
  102.     {
  103.         return $this->formateurModules;
  104.     }
  105.     public function addFormateurModule(FormateurModule $formateurModule): self
  106.     {
  107.         if (!$this->formateurModules->contains($formateurModule)) {
  108.             $this->formateurModules->add($formateurModule);
  109.             $formateurModule->setFormateur($this);
  110.         }
  111.         return $this;
  112.     }
  113.     public function removeFormateurModule(FormateurModule $formateurModule): self
  114.     {
  115.         // set the owning side to null (unless already changed)
  116.         if ($this->formateurModules->removeElement($formateurModule) && $formateurModule->getFormateur() === $this) {
  117.             $formateurModule->setFormateur(null);
  118.         }
  119.         return $this;
  120.     }
  121.     /**
  122.      * @return Collection<int, FormateurEntreprise>
  123.      */
  124.     public function getFormateurEntreprises(): Collection
  125.     {
  126.         return $this->formateurEntreprises;
  127.     }
  128.     public function addFormateurEntreprise(FormateurEntreprise $formateurEntreprise): self
  129.     {
  130.         if (!$this->formateurEntreprises->contains($formateurEntreprise)) {
  131.             $this->formateurEntreprises->add($formateurEntreprise);
  132.             $formateurEntreprise->setFormateur($this);
  133.         }
  134.         return $this;
  135.     }
  136.     public function removeFormateurEntreprise(FormateurEntreprise $formateurEntreprise): self
  137.     {
  138.         // set the owning side to null (unless already changed)
  139.         if ($this->formateurEntreprises->removeElement($formateurEntreprise) && $formateurEntreprise->getFormateur() === $this) {
  140.             $formateurEntreprise->setFormateur(null);
  141.         }
  142.         return $this;
  143.     }
  144.     public function getEntreprise(): ?Entreprise
  145.     {
  146.         $formateurEntreprises $this->getFormateurEntreprises();
  147.         if ($formateurEntreprises->isEmpty()) {
  148.             return null;
  149.         }
  150.         $firstRelation $formateurEntreprises->first();
  151.         return $firstRelation $firstRelation->getEntreprise() : null;
  152.     }
  153.     public function getPrefecture(): ?string
  154.     {
  155.         return $this->prefecture;
  156.     }
  157.     public function setPrefecture(?string $prefecture): self
  158.     {
  159.         $this->prefecture $prefecture;
  160.         return $this;
  161.     }
  162.     public function getNumeroActivite(): ?string
  163.     {
  164.         return $this->numeroActivite;
  165.     }
  166.     public function setNumeroActivite(?string $numeroActivite): self
  167.     {
  168.         $this->numeroActivite $numeroActivite;
  169.         return $this;
  170.     }
  171.     public function getNumeroActivite2(): ?string
  172.     {
  173.         return $this->numeroActivite2;
  174.     }
  175.     public function setNumeroActivite2(?string $numeroActivite2): Formateur
  176.     {
  177.         $this->numeroActivite2 $numeroActivite2;
  178.         return $this;
  179.     }
  180.     /**
  181.      * @return Collection<int, FormateurEvent>
  182.      */
  183.     public function getFormateurEvents(): Collection
  184.     {
  185.         return $this->formateurEvents;
  186.     }
  187.     public function addFormateurEvent(FormateurEvent $formateurEvent): self
  188.     {
  189.         if (!$this->formateurEvents->contains($formateurEvent)) {
  190.             $this->formateurEvents->add($formateurEvent);
  191.             $formateurEvent->setFormateur($this);
  192.         }
  193.         return $this;
  194.     }
  195.     public function removeFormateurEvent(FormateurEvent $formateurEvent): self
  196.     {
  197.         // set the owning side to null (unless already changed)
  198.         if ($this->formateurEvents->removeElement($formateurEvent) && $formateurEvent->getFormateur() === $this) {
  199.             $formateurEvent->setFormateur(null);
  200.         }
  201.         return $this;
  202.     }
  203.     public function getMissionProposee()
  204.     {
  205.         if ($this->missionProposee === null) {
  206.             return [];
  207.         }
  208.         return json_decode($this->missionProposeetrue512JSON_THROW_ON_ERROR);
  209.     }
  210.     /**
  211.      * @throws JsonException
  212.      */
  213.     public function addMissionProposee(string $idstring $title$state null$sevent = []): self
  214.     {
  215.         $missionProposee = [];
  216.         if (!empty($this->missionProposee)) {
  217.             try {
  218.                 $missionProposee json_decode($this->missionProposeetrue512JSON_THROW_ON_ERROR);
  219.             } catch (\JsonException $e) {
  220.                 dump($e->getMessage());
  221.                 $missionProposee = [];
  222.             }
  223.         }
  224.         $exist false;
  225.         foreach ($missionProposee as &$item) {
  226.             if ($item['id'] === $id) {
  227.                 $item['title'] = $title;
  228.                 $item['state'] = $state;
  229.                 $exist true;
  230.                 break;
  231.             }
  232.         }
  233.         if (!$exist) {
  234.             $missionProposee[] = [
  235.                 'id'    => $id,
  236.                 'title' => $title,
  237.                 'state' => $state,
  238.                 'week'  => $sevent['week'] ?? null,
  239.                 'start' => $sevent['start'] ?? null,
  240.                 'end'   => $sevent['end'] ?? null,
  241.             ];
  242.         }
  243.         $this->missionProposee json_encode($missionProposeeJSON_THROW_ON_ERROR);
  244.         return $this;
  245.     }
  246.     /**
  247.      * @throws JsonException
  248.      */
  249.     public function removeMissionProposee(string $idEvent): self
  250.     {
  251.         $missionProposee = [];
  252.         if (!empty($this->missionProposee)) {
  253.             try {
  254.                 $missionProposee json_decode($this->missionProposeetrue512JSON_THROW_ON_ERROR);
  255.             } catch (\JsonException $e) {
  256.                 dump($e->getMessage());
  257.                 $missionProposee = [];
  258.             }
  259.         }
  260.         foreach ($missionProposee as $key => $item) {
  261.             if (($item['id'] ?? null) === $idEvent) {
  262.                 unset($missionProposee[$key]);
  263.             }
  264.         }
  265.         // Réindexation du tableau
  266.         $this->missionProposee json_encode(array_values($missionProposee), JSON_THROW_ON_ERROR);
  267.         return $this;
  268.     }
  269.     public function setMissionProposee(?string $missionProposee): self
  270.     {
  271.         $this->missionProposee $missionProposee;
  272.         return $this;
  273.     }
  274.     /**
  275.      * @throws JsonException
  276.      */
  277.     public function getMissionProposeeById(string $id)
  278.     {
  279.         $missionProposee json_decode((string) $this->missionProposeetrue512JSON_THROW_ON_ERROR) ?? [];
  280.         foreach ($missionProposee as $item) {
  281.             if ($item['id'] === $id) {
  282.                 return $item;
  283.             }
  284.         }
  285.         return null;
  286.     }
  287.     /**
  288.      * @return Collection<int, Contrat>
  289.      */
  290.     public function getContrats(): Collection
  291.     {
  292.         return $this->contrats;
  293.     }
  294.     public function addContrat(Contrat $contrat): self
  295.     {
  296.         if (!$this->contrats->contains($contrat)) {
  297.             $this->contrats->add($contrat);
  298.             $contrat->addFormateur($this);
  299.         }
  300.         return $this;
  301.     }
  302.     public function removeContrat(Contrat $contrat): self
  303.     {
  304.         if ($this->contrats->removeElement($contrat)) {
  305.             $contrat->removeFormateur($this);
  306.         }
  307.         return $this;
  308.     }
  309.     /**
  310.      * @return Collection<int, LignePrestation>
  311.      */
  312.     public function getLignePrestations(): Collection
  313.     {
  314.         return $this->lignePrestations;
  315.     }
  316.     public function addLignePrestation(LignePrestation $lignePrestation): self
  317.     {
  318.         if (!$this->lignePrestations->contains($lignePrestation)) {
  319.             $this->lignePrestations->add($lignePrestation);
  320.             $lignePrestation->addFormateur($this);
  321.         }
  322.         return $this;
  323.     }
  324.     public function removeLignePrestation(LignePrestation $lignePrestation): self
  325.     {
  326.         if ($this->lignePrestations->removeElement($lignePrestation)) {
  327.             $lignePrestation->removeFormateur($this);
  328.         }
  329.         return $this;
  330.     }
  331.     /**
  332.      * @throws JsonException
  333.      */
  334.     public function verifMissionProposee(string $id): bool
  335.     {
  336.         $missionProposee json_decode((string) $this->missionProposeetrue512JSON_THROW_ON_ERROR) ?? [];
  337.         $exist false;
  338.         foreach ($missionProposee as $item) {
  339.             if ($item['id'] === $id) {
  340.                 $exist true;
  341.             }
  342.         }
  343.         return $exist;
  344.     }
  345.     /**
  346.      * @return Collection<int, ApprenantLivrable>
  347.      */
  348.     public function getApprenantLivrables(): Collection
  349.     {
  350.         return $this->apprenantLivrables;
  351.     }
  352.     public function addApprenantLivrable(ApprenantLivrable $apprenantLivrable): self
  353.     {
  354.         if (!$this->apprenantLivrables->contains($apprenantLivrable)) {
  355.             $this->apprenantLivrables->add($apprenantLivrable);
  356.             $apprenantLivrable->setFormateur($this);
  357.         }
  358.         return $this;
  359.     }
  360.     public function removeApprenantLivrable(ApprenantLivrable $apprenantLivrable): self
  361.     {
  362.         // set the owning side to null (unless already changed)
  363.         if ($this->apprenantLivrables->removeElement($apprenantLivrable) && $apprenantLivrable->getFormateur() === $this) {
  364.             $apprenantLivrable->setFormateur(null);
  365.         }
  366.         return $this;
  367.     }
  368.     /**
  369.      * @return Collection<int, HistoriqueComment>
  370.      */
  371.     public function getHistoriqueComments(): Collection
  372.     {
  373.         return $this->historiqueComments;
  374.     }
  375.     public function addHistoriqueComment(HistoriqueComment $historiqueComment): self
  376.     {
  377.         if (!$this->historiqueComments->contains($historiqueComment)) {
  378.             $this->historiqueComments->add($historiqueComment);
  379.             $historiqueComment->setFormateur($this);
  380.         }
  381.         return $this;
  382.     }
  383.     public function removeHistoriqueComment(HistoriqueComment $historiqueComment): self
  384.     {
  385.         // set the owning side to null (unless already changed)
  386.         if ($this->historiqueComments->removeElement($historiqueComment) && $historiqueComment->getFormateur() === $this) {
  387.             $historiqueComment->setFormateur($this);
  388.         }
  389.         return $this;
  390.     }
  391.     public function getDebutHabilitation(): ?DateTime
  392.     {
  393.         return $this->debutHabilitation;
  394.     }
  395.     public function setDebutHabilitation(?DateTime $debutHabilitation): self
  396.     {
  397.         $this->debutHabilitation $debutHabilitation;
  398.         return $this;
  399.     }
  400.     public function getFinHabilitation(): ?DateTime
  401.     {
  402.         return $this->finHabilitation;
  403.     }
  404.     public function setFinHabilitation(?DateTime $finHabilitation): self
  405.     {
  406.         $this->finHabilitation $finHabilitation;
  407.         return $this;
  408.     }
  409.     public function isJuryUniquement(): ?bool
  410.     {
  411.         return $this->juryUniquement;
  412.     }
  413.     /**
  414.      * @return Collection<int, Parcours>
  415.      */
  416.     public function getParcoursRNCP(): Collection
  417.     {
  418.         return $this->parcoursRNCP;
  419.     }
  420.     public function addParcoursRNCP(Parcours $parcoursRNCP): self
  421.     {
  422.         if (!$this->parcoursRNCP->contains($parcoursRNCP)) {
  423.             $this->parcoursRNCP->add($parcoursRNCP);
  424.             $parcoursRNCP->setFormateur($this);
  425.         }
  426.         return $this;
  427.     }
  428.     public function removeParcoursRNCP(Parcours $parcoursRNCP): self
  429.     {
  430.         // set the owning side to null (unless already changed)
  431.         if ($this->parcoursRNCP->removeElement($parcoursRNCP) && $parcoursRNCP->getFormateur() === $this) {
  432.             $parcoursRNCP->setFormateur(null);
  433.         }
  434.         return $this;
  435.     }
  436. }