src/Entity/Etablissement.php line 1370

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * Copyright (C) Office National de Publication et de Communication - All Rights Reserved
  5.  *
  6.  * Unauthorized copying of this file, via any medium is strictly prohibited by law
  7.  * This file is proprietary and confidential
  8.  */
  9. namespace App\Entity;
  10. use DateTime;
  11. use App\Entity\VideoOnpc;
  12. use App\Entity\ActualiteOnpc;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use App\Entity\Common\IsEmptyTrait;
  15. use App\Entity\Common\UpdatableTrait;
  16. use App\Entity\Common\IdAsStringTrait;
  17. use App\Entity\Etablissement\DroitTrait;
  18. use App\Entity\Etablissement\EmailTrait;
  19. use App\Entity\Etablissement\ImageTrait;
  20. use App\Entity\Etablissement\AdresseTrait;
  21. use App\Entity\Etablissement\ElasticTrait;
  22. use App\Entity\Etablissement\GestionTrait;
  23. use Doctrine\Common\Collections\Collection;
  24. use App\Entity\Etablissement\InsertionTrait;
  25. use App\Entity\Etablissement\TelephoneTrait;
  26. use App\Entity\Etablissement\DenominationTrait;
  27. use App\Entity\Etablissement\InterventionTrait;
  28. use Doctrine\Common\Collections\ArrayCollection;
  29. use App\Entity\Etablissement\ItemsInsertionTrait;
  30. use Doctrine\Common\Persistence\ObjectManagerAware;
  31. /**
  32.  * @ORM\Entity(repositoryClass="App\Repository\EtablissementRepository")
  33.  * @ORM\Table(name="etablissement")
  34.  */
  35. class Etablissement
  36. // class Etablissement implements ObjectManagerAware
  37. {
  38.     /**
  39.      * List of allowed EtablissementData fields for getData()
  40.      */
  41.     public const ALLOWED_DATA_FIELDS = [
  42.         'presents_total'       => ['Nombre de candidats'        ' élèves' ''], // pour le client : garder uniquement ceci (au bac) / Exp : ET001-58 / ET001-59
  43.         'taux_reu_total'       => ['Taux de réussite total'     '%'       ''], // pour le client : garder uniquement ceci
  44.         'taux_men_total'       => ['Taux de mentions total'     '%'       ''], // pour le client : garder uniquement ceci
  45.         'taux_men_gnle'        => ['Taux de mentions générale'  '%'       ''], // pour le client : garder uniquement ceci
  46.         'nombre_eleves_total'  => ['Nombre d\'élèves'           ' élèves' 'prospect'],
  47.         'nombre_d_eleves'      => ['Nombre d\'élèves'           ' élèves' 'prospect'],
  48.         'nombre_total_eleves'  => ['Nombre d\'élèves'           ' élèves' 'prospect'],
  49.         'nombre_total_classes' => ['Nombre de classes'          ' classes''prospect'],
  50.     ];
  51.     /*
  52.      class Etablissement implements ObjectManagerAware
  53.      le implements est utilisé afin de passer l'entityManager à elasticTypesInternat
  54.      cette fonction est appelée uniquement lors du populate de la bdd elastic (je crois)
  55.      mais poser problème dans le backoffice !
  56.     */
  57.     use AdresseTrait;
  58.     use DenominationTrait;
  59.     use DroitTrait;
  60.     use IdAsStringTrait;
  61.     use ElasticTrait;
  62.     use EmailTrait;
  63.     use GestionTrait;
  64.     use ImageTrait;
  65.     use InsertionTrait;
  66.     use ItemsInsertionTrait;
  67.     use InterventionTrait;
  68.     use TelephoneTrait;
  69.     use IsEmptyTrait;
  70.     use UpdatableTrait;
  71.     private const STATUTS_PUBLIC = ['privé participant service public''public'];
  72.     /** @ORM\Column(type="string", nullable=true) */
  73.     protected $type;
  74.     /** @ORM\Column(type="integer", nullable=true) */
  75.     protected $nombreEleves;
  76.     /** @ORM\Column(type="text", nullable=true) */
  77.     protected $url;
  78.     /** @ORM\Column(type="text", nullable=true) */
  79.     protected $video;
  80.     /** @ORM\Column(type="string", nullable=true) */
  81.     protected $motsCles;
  82.     // ----- Denomination ------------------------------------------------------
  83.     /** @ORM\Column(type="string", nullable=true) */
  84.     protected $denomination;
  85.     /** @ORM\Column(type="string", nullable=true) */
  86.     protected $denominationSigle;
  87.     /** @ORM\Column(type="string", nullable=true) */
  88.     protected $denominationExtension;
  89.     /** @ORM\Column(type="string", nullable=true) */
  90.     protected $denominationAbregee;
  91.     // ----- Gestion -----------------------------------------------------------
  92.     /**
  93.      * @ORM\ManyToOne(targetEntity="App\Entity\Etablissement", cascade={"persist"}, inversedBy="geres", fetch="EAGER")
  94.      * @ORM\JoinColumn(name="gestionnaire_id", referencedColumnName="id")
  95.      */
  96.     protected $gestionnaire;
  97.     // ----- Adresse -----------------------------------------------------------
  98.     // ----- Droit -------------------------------------------------------------
  99.     /** @ORM\Column(type="boolean", nullable=true) */
  100.     protected $droitPageWeb;
  101.     /** @ORM\Column(type="boolean", nullable=true) */
  102.     protected $droitActualite;
  103.     /** @ORM\ManyToOne(targetEntity="App\Entity\Ville", cascade={"persist"}) */
  104.     protected $ville;
  105.     /** @ORM\Column(type="string", nullable=true) */
  106.     protected $adresse1;
  107.     /** @ORM\Column(type="string", nullable=true) */
  108.     protected $adresse2;
  109.     /** @ORM\Column(type="string", nullable=true) */
  110.     protected $adresse3;
  111.     /** @ORM\Column(type="string", nullable=true) */
  112.     protected $codePostal;
  113.     /** @ORM\Column(type="string", nullable=true) */
  114.     protected $cedex;
  115.     /** @ORM\Column(type="decimal", precision=11, scale=8, nullable=true) */
  116.     protected $latitude;
  117.     /** @ORM\Column(type="decimal", precision=11, scale=8, nullable=true) */
  118.     protected $longitude;
  119.     // ----- Telephone ---------------------------------------------------------
  120.     /** @ORM\Column(type="string", nullable=true) */
  121.     protected $telephonePrincipal;
  122.     /** @ORM\Column(type="string", nullable=true) */
  123.     protected $fax;
  124.     // ----- E-mail ------------------------------------------------------------
  125.     /** @ORM\Column(type="string", nullable=true) */
  126.     protected $emailPrincipal;
  127.     // ----- Image -------------------------------------------------------------
  128.     /** @ORM\Column(type="string", nullable=true) */
  129.     protected $logoListe;
  130.     /** @ORM\Column(type="string", nullable=true) */
  131.     protected $logoFiche;
  132.     /** @ORM\Column(type="boolean", nullable=true) */
  133.     protected $diaporamaActif;
  134.     /** @ORM\Column(type="simple_array", nullable=true) */
  135.     protected $imagesDiaporama;
  136.     // ----- Intervention ------------------------------------------------------
  137.     // ----- Insertions --------------------------------------------------------
  138.     /** @ORM\OneToMany(targetEntity="Insertion", mappedBy="etablissement") */
  139.     protected $insertions;
  140.     // ----- ItemsInsertions --------------------------------------------------------
  141.     /**
  142.      * @ORM\OneToMany(targetEntity="ItemsInsertion", mappedBy="etablissement")
  143.      * @ORM\OrderBy({"diplomePlus": "ASC"})
  144.      */
  145.     protected $itemsInsertions;
  146.     // ----- Données hors le Backoffice ----------------------------------------
  147.     /**
  148.      * @ORM\OneToMany(targetEntity="Actualite", mappedBy="etablissement", cascade={"persist"}, fetch="EXTRA_LAZY")
  149.      * @ORM\OrderBy({"dateActualisation": "DESC"})
  150.      */
  151.     protected $actualites;
  152.     /**
  153.      * @ORM\OneToMany(targetEntity="OffreEmploi", mappedBy="etablissement", cascade={"persist"}, fetch="EXTRA_LAZY")
  154.      * @ORM\OrderBy({"dateActualisation": "DESC"})
  155.      */
  156.     protected $offresEmploi;
  157.     // /** @ORM\OneToOne(targetEntity="PlaceDisponible", mappedBy="etablissement", cascade={"persist"}) */
  158.     // protected $placeDisponible;
  159.     /** @ORM\OneToOne(targetEntity="TexteReferencement", mappedBy="etablissement", cascade={"persist"}, fetch="EXTRA_LAZY") */
  160.     protected $texteReferencement;
  161.     /**
  162.      * @ORM\Column(type="boolean", nullable=true)
  163.      */
  164.     private $participant;
  165.     /** @ORM\ManyToOne(targetEntity="Categorie", cascade={"persist"}) */
  166.     protected $categoriePrimaire;
  167.     /**
  168.      * @ORM\OneToMany(targetEntity="App\Entity\Etablissement", mappedBy="gestionnaire", fetch="EXTRA_LAZY")
  169.      * @ORM\OrderBy({"type" = "ASC"})
  170.      */
  171.     protected $geres;
  172.     /**
  173.      * @ORM\Column(type="boolean", nullable=true)
  174.      */
  175.     private $catholique;
  176.     /** @ORM\Column(type="decimal", nullable=true, precision=2, scale=1) */
  177.     protected $ageAdmission;
  178.     /**
  179.      * @ORM\ManyToOne(targetEntity="App\Entity\Region", inversedBy="etablissements")
  180.      * @ORM\JoinColumn(nullable=true)
  181.      */
  182.     private $region;
  183.     /**
  184.      * @ORM\ManyToOne(targetEntity="App\Entity\Departement", inversedBy="etablissements")
  185.      */
  186.     private $departement;
  187.     /**
  188.      * @ORM\Column(type="boolean")
  189.      */
  190.     private $actif;
  191.     /**
  192.      * @ORM\OneToMany(targetEntity="App\Entity\JPO", mappedBy="etablissement", fetch="EXTRA_LAZY")
  193.      */
  194.     private $jPOs;
  195.     /**
  196.      * @ORM\OneToMany(targetEntity="App\Entity\SousTypesEtablissement", mappedBy="etablissement", fetch="EXTRA_LAZY")
  197.      */
  198.     private $sousTypesEtablissements;
  199.     private $em;
  200.     /** @ORM\Column(type="string", nullable=true) */
  201.     private $internat;
  202.     /**
  203.      * @ORM\Column(type="boolean", nullable=true)
  204.      */
  205.     private $hasInternat;
  206.     /**
  207.      * @ORM\Column(type="string", length=50, nullable=true)
  208.      */
  209.     private $typesInternat;
  210.     /**
  211.      * @ORM\Column(type="boolean", nullable=true)
  212.      */
  213.     private $sousContrat;
  214.     /**
  215.      * @ORM\Column(type="boolean", nullable=true)
  216.      */
  217.     private $alternance;
  218.     /**
  219.      * @ORM\ManyToOne(targetEntity="App\Entity\CategorieOrganisme", inversedBy="etablissements")
  220.      */
  221.     private $categorieOrganisme;
  222.     /**
  223.      * @ORM\ManyToOne(targetEntity="App\Entity\RubriqueFournisseur", inversedBy="etablissements", cascade={"persist"})
  224.      * @ORM\JoinColumn(name="rubrique", nullable=true)
  225.      */
  226.     private $rubrique;
  227.     /**
  228.      * @ORM\Column(type="string", length=255, nullable=true)
  229.      */
  230.     private $typeClient;
  231.     /**
  232.      * @ORM\Column(type="boolean", nullable=true)
  233.      */
  234.     private $bloqueTxtRef;
  235.     /**
  236.      * @ORM\ManyToOne(targetEntity="App\Entity\Etablissement", inversedBy="etablissementsLiesInternat")
  237.      */
  238.     private $internat2;
  239.     /**
  240.      * @ORM\OneToMany(targetEntity="App\Entity\Etablissement", mappedBy="internat2", fetch="EXTRA_LAZY")
  241.      */
  242.     private $etablissementsLiesInternat;
  243.     /**
  244.      * @ORM\Column(type="string", length=255, nullable=true)
  245.      */
  246.     private $facebook;
  247.     /**
  248.      * @ORM\Column(type="boolean", nullable=true)
  249.      */
  250.     private $bloqueBac2021;
  251.     /**
  252.      * @ORM\Column(type="boolean", nullable=true)
  253.      */
  254.     private $presenceWeb;
  255.     /**
  256.      * @ORM\ManyToOne(targetEntity="App\Entity\Etablissement")
  257.      */
  258.     private $etablissementLie;
  259. //    /**
  260. //     * @ORM\OneToMany(targetEntity="App\Entity\Video", mappedBy="etablissement", orphanRemoval=true)
  261. //     */
  262. //    private $videoss;
  263.     /**
  264.      * @ORM\Column(type="boolean", nullable=false, options={"default" : false})
  265.      */
  266.     private $videoPlus;
  267.     /**
  268.      * @ORM\Column(type="boolean", nullable=false, options={"default" : false})
  269.      */
  270.     private $diapoPlus;
  271.     /**
  272.      * @ORM\Column(type="boolean", nullable=false, options={"default" : false})
  273.      */
  274.     private $jpoPlus;
  275. //    /**
  276. //     * @ORM\OneToMany(targetEntity="App\Entity\Diaporama", mappedBy="etablissement", orphanRemoval=true)
  277. //     */
  278. //    private $diaporamass;
  279.     // /**
  280.     //  * @ORM\OneToMany(targetEntity="App\Entity\Document", mappedBy="etablissement", orphanRemoval=true)
  281.     //  */
  282.     // private $documents;
  283.     /**
  284.      * @ORM\ManyToMany(targetEntity=Document::class, mappedBy="etablissements")
  285.      */
  286.     private $documents;
  287.     /**
  288.      * @ORM\Column(type="boolean", nullable=false, options={"default" : false})
  289.      */
  290.     private $docPlus;
  291.     /**
  292.      * @ORM\Column(type="boolean", nullable=true)
  293.      */
  294.     private $diplomePlus;
  295.     /**
  296.      * @ORM\Column(type="boolean", nullable=true)
  297.      */
  298.     private $refus;
  299.     /**
  300.      * @ORM\ManyToMany(targetEntity=Diaporama::class, mappedBy="etablissements")
  301.      */
  302.     private $diaporamas;
  303.     /**
  304.      * @ORM\ManyToMany(targetEntity=Video::class, mappedBy="etablissements")
  305.      */
  306.     private $videos;
  307.     /**
  308.      * @ORM\ManyToOne(targetEntity=Logo::class, inversedBy="etablissements")
  309.      */
  310.     private $logo;
  311.     /**
  312.      * @ORM\OneToMany(targetEntity=Produit::class, mappedBy="etablissement", orphanRemoval=true)
  313.      */
  314.     private $produits;
  315.     /**
  316.      * @ORM\ManyToOne(targetEntity=Diaporama::class, inversedBy="etabs")
  317.      */
  318.     private $diapoPrincipal;
  319.     /**
  320.      * @ORM\Column(type="string", length=255, nullable=true)
  321.      */
  322.     private $path;
  323.     /**
  324.      * @ORM\Column(type="text", nullable=true)
  325.      */
  326.     private $compositionEnsembleScolaire;
  327.     /**
  328.      * @ORM\Column(type="string", length=255, nullable=true)
  329.      */
  330.     private $lva;
  331.     /**
  332.      * @ORM\Column(type="string", length=255, nullable=true)
  333.      */
  334.     private $lvb;
  335.     /**
  336.      * @ORM\Column(type="string", length=100, nullable=true)
  337.      */
  338.     private $numeroAdministratifUai;
  339.     /**
  340.      * @ORM\Column(type="string", length=100, nullable=true)
  341.      */
  342.     private $siret;
  343.     /**
  344.      * @ORM\OneToMany(targetEntity=EtablissementData::class, mappedBy="etablissement", orphanRemoval=true)
  345.      */
  346.     private $data;
  347.     /**
  348.      * @ORM\Column(type="text", nullable=true)
  349.      */
  350.     private $chiffres;
  351.     // /**
  352.     //  * @ORM\ManyToOne(targetEntity="App\Entity\RubriqueFournisseur", inversedBy="etablissements")
  353.     //  */
  354.     // private $rubriqueFournisseur;
  355.     /**
  356.      * @ORM\ManyToMany(targetEntity=VideoOnpc::class, mappedBy="annonceurs")
  357.      */
  358.     private $videosOnpc;
  359.     /**
  360.      * @ORM\ManyToMany(targetEntity=ActualiteOnpc::class, mappedBy="annonceurs")
  361.      */
  362.     private $actualitesOnpc;    
  363.     public function __construct()
  364.     {
  365.         $this->maj = new DateTime();
  366.         $this->actif false;
  367.         $this->geres = new ArrayCollection();
  368.         $this->categoriesSecondaires = new ArrayCollection();
  369.         $this->villesIntervention = new ArrayCollection();
  370.         $this->departementsIntervention = new ArrayCollection();
  371.         $this->actualites = new ArrayCollection();
  372.         $this->offresEmploi = new ArrayCollection();
  373.         $this->insertions = new ArrayCollection();
  374.         $this->itemsInsertions = new ArrayCollection();
  375.         $this->imagesDiaporama = [];
  376.         $this->jPOs = new ArrayCollection();
  377.         $this->sousTypesEtablissements = new ArrayCollection();
  378.         $this->responsableEtablissements = new ArrayCollection();
  379.         $this->etablissementsLiesInternat = new ArrayCollection();
  380.         $this->videos = new ArrayCollection();
  381.         $this->diaporamas = new ArrayCollection();
  382.         $this->documents = new ArrayCollection();
  383.         $this->videoPlus false;
  384.         $this->diapoPlus false;
  385.         $this->jpoPlus false;
  386.         $this->docPlus false;
  387.         $this->produits = new ArrayCollection();
  388.         $this->data = new ArrayCollection();
  389.         $this->videosOnpc = new ArrayCollection();
  390.         $this->actualitesOnpc = new ArrayCollection();
  391.     }
  392.     public function setIdDistant(?string $idDistant): void
  393.     {
  394.         $this->idDistant $idDistant;
  395.     }
  396.     public function getIdDistant(): ?string
  397.     {
  398.         return $this->idDistant;
  399.     }
  400.     public function setType(?string $type): void
  401.     {
  402.         $this->type $type;
  403.     }
  404.     public function getType(): ?string
  405.     {
  406.         return $this->type;
  407.     }
  408.     public function setStatut(?string $statut): void
  409.     {
  410.         // $this->statut = $statut;
  411.     }
  412.     public function getStatut(): ?string
  413.     {
  414.         return '';
  415.         // return $this->statut;
  416.     }
  417.     public function setSiret(?string $siret): void
  418.     {
  419.         $this->siret $siret;
  420.     }
  421.     public function getSiret(): ?string
  422.     {
  423.         return $this->siret;
  424.     }
  425.     public function setNaf(?string $naf): void
  426.     {
  427.         $this->naf $naf;
  428.     }
  429.     public function getNaf(): ?string
  430.     {
  431.         return $this->naf;
  432.     }
  433.     public function setNombreEleves(?int $nombreEleves): void
  434.     {
  435.         $this->nombreEleves $nombreEleves;
  436.     }
  437.     public function getNombreEleves(): ?int
  438.     {
  439.         return $this->nombreEleves;
  440.     }
  441.     public function setTarif(?string $tarif): void
  442.     {
  443.         $this->tarif $tarif;
  444.     }
  445.     public function getTarif(): ?string
  446.     {
  447.         return $this->tarif;
  448.     }
  449.     public function setUrl(?string $url): void
  450.     {
  451.         $this->url $url;
  452.     }
  453.     public function getUrl(): ?string
  454.     {
  455.         return $this->url;
  456.     }
  457.     public function setVideo(?string $video): void
  458.     {
  459.         $this->video $video;
  460.     }
  461.     public function getVideo(): ?string
  462.     {
  463.         return $this->video;
  464.     }
  465.     public function setMotsCles(?string $motsCles): void
  466.     {
  467.         $this->motsCles $motsCles;
  468.     }
  469.     public function getMotsCles(): ?string
  470.     {
  471.         return $this->motsCles;
  472.     }
  473.     // ----- Données hors le Backoffice ----------------------------------------
  474.     public function getDateDerniereModification(): DateTime
  475.     {
  476.         $offreEmploi $this->getOffresEmploi()->first();
  477.         $actualite $this->getActualites()->first();
  478.         $placeDisponible 0//$this->getPlaceDisponible();
  479.         return max(array_filter([
  480.             $this->maj,
  481.             $offreEmploi $offreEmploi->getDateActualisation() : null,
  482.             $actualite $actualite->getDateActualisation() : null,
  483.             $placeDisponible $placeDisponible->getDateActualisation() : null,
  484.         ]));
  485.     }
  486.     public function addActualite(Actualite $actualite): void
  487.     {
  488.         $this->actualites[] = $actualite;
  489.     }
  490.     public function removeActualite(Actualite $actualite): void
  491.     {
  492.         $this->actualites->removeElement($actualite);
  493.     }
  494.     public function getActualites(): Collection
  495.     {
  496.         return $this->actualites;
  497.     }
  498.     public function addOffreEmploi(OffreEmploi $offreEmploi): void
  499.     {
  500.         $this->offresEmploi[] = $offreEmploi;
  501.     }
  502.     public function removeOffreEmploi(OffreEmploi $offreEmploi): void
  503.     {
  504.         $this->offresEmploi->removeElement($offreEmploi);
  505.     }
  506.     public function getOffresEmploi(): Collection
  507.     {
  508.         return $this->offresEmploi;
  509.     }
  510.     public function getOffresEmploiValides(): Collection
  511.     {
  512.         return $this->offresEmploi->filter(static function ($offre) {
  513.             return $offre->isValid();
  514.         });
  515.     }
  516.     public function setPlaceDisponible(?PlaceDisponible $placeDisponible): void
  517.     {
  518.         $this->placeDisponible $placeDisponible;
  519.     }
  520.     public function getPlaceDisponible(): ?PlaceDisponible
  521.     {
  522.         return $this->placeDisponible;
  523.     }
  524.     public function hasPlaceDisponible(): bool
  525.     {
  526.         return $this->placeDisponible && $this->placeDisponible->isValid();
  527.     }
  528.     public function setTexteReferencement(?TexteReferencement $texteReferencement): void
  529.     {
  530.         $this->texteReferencement $texteReferencement;
  531.     }
  532.     public function getTexteReferencement(): ?TexteReferencement
  533.     {
  534.         return $this->texteReferencement;
  535.     }
  536.     public function compileTexteReferencement(): ?string
  537.     {
  538.         $texte $this->getTexteReferencement();
  539.         if (!$texte) {
  540.             return null;
  541.         }
  542.         $contenu '';
  543.         if ($texte->isActif()) {
  544.             $template $texte->getTemplate();
  545.             $template $template $template->getContenu() : null;
  546.             if ($template) {
  547.                 $contenu .= '<p>'.$template.'</p>';
  548.             }
  549.         }
  550.         $contenu .= $texte->getContenu();
  551.         if (!$contenu) {
  552.             return null;
  553.         }
  554.         $categorie $this->getCategoriePrimaire();
  555.         $ville $this->getVille();
  556.         $departement $ville $ville->getDepartement() : null;
  557.         return strtr($contenu, [
  558.             '<nom>' => $this->getDenomination() ?: '',
  559.             '<statut>' => $this->getStatut() ?: '',
  560.             '<catégorie>' => $categorie $categorie->getLibelle() : '',
  561.             '<ville>' => ($ville $ville->getLibelle() : null) ?: '',
  562.             '<dept>' => ($departement $departement->getLibelle() : null) ?: '',
  563.             '<nombre>' => ((int) $this->getNombreEleves()) ?: 'quelques',
  564.         ]);
  565.     }
  566.     public function getParticipant(): ?bool
  567.     {
  568.         return $this->participant;
  569.     }
  570.     public function isParticipant(): ?bool
  571.     {
  572.         return true === $this->participant && !$this->refus;
  573.     }
  574.     public function isClient(): ?bool   // Pour la Retrocompatibilité avec le code de l'Ass
  575.     {
  576.         return $this->isParticipant();
  577.     }
  578.     public function setParticipant(?bool $participant): self
  579.     {
  580.         $this->participant $participant;
  581.         return $this;
  582.     }
  583.     public function getRegion(): ?Region
  584.     {
  585.         return $this->region;
  586.     }
  587.     public function setRegion(?Region $region): self
  588.     {
  589.         $this->region $region;
  590.         return $this;
  591.     }
  592.     public function setAgeAdmission(?float $ageAdmission): void
  593.     {
  594.         $this->ageAdmission $ageAdmission;
  595.     }
  596.     public function getAgeAdmission(): ?float
  597.     {
  598.         return (float) $this->ageAdmission;
  599.     }
  600.     public function getCatholique(): ?bool
  601.     {
  602.         return $this->catholique;
  603.     }
  604.     public function setCatholique(?bool $catholique): self
  605.     {
  606.         $this->catholique $catholique;
  607.         return $this;
  608.     }
  609.     public function getDepartement(): ?Departement
  610.     {
  611.         return $this->departement;
  612.     }
  613.     public function setDepartement(?Departement $departement): self
  614.     {
  615.         $this->departement $departement;
  616.         return $this;
  617.     }
  618.     public function getActif(): ?bool
  619.     {
  620.         return $this->actif;
  621.     }
  622.     public function setActif(bool $actif): self
  623.     {
  624.         $this->actif $actif;
  625.         return $this;
  626.     }
  627.     /**
  628.      * @return Collection|JPO[]
  629.      */
  630.     public function getJPOs(): ?Collection
  631.     {
  632.         return $this->jPOs;
  633.     }
  634.     public function addJPO(JPO $jPO): self
  635.     {
  636.         if (!$this->jPOs->contains($jPO)) {
  637.             $this->jPOs[] = $jPO;
  638.             $jPO->setEtablissement($this);
  639.         }
  640.         return $this;
  641.     }
  642.     public function removeJPO(JPO $jPO): self
  643.     {
  644.         if ($this->jPOs->contains($jPO)) {
  645.             $this->jPOs->removeElement($jPO);
  646.             // set the owning side to null (unless already changed)
  647.             if ($jPO->getEtablissement() === $this) {
  648.                 $jPO->setEtablissement(null);
  649.             }
  650.         }
  651.         return $this;
  652.     }
  653.     public function __toString()
  654.     {
  655.         return $this->denomination;
  656.     }
  657.     /**
  658.      * @return Collection|SousTypesEtablissement[]
  659.      */
  660.     public function getSousTypesEtablissements(): Collection
  661.     {
  662.         return $this->sousTypesEtablissements;
  663.     }
  664.     public function addSousTypesEtablissement(SousTypesEtablissement $sousTypesEtablissement): self
  665.     {
  666.         if (!$this->sousTypesEtablissements->contains($sousTypesEtablissement)) {
  667.             $this->sousTypesEtablissements[] = $sousTypesEtablissement;
  668.             $sousTypesEtablissement->setEtablissement($this);
  669.         }
  670.         return $this;
  671.     }
  672.     public function removeSousTypesEtablissement(SousTypesEtablissement $sousTypesEtablissement): self
  673.     {
  674.         if ($this->sousTypesEtablissements->contains($sousTypesEtablissement)) {
  675.             $this->sousTypesEtablissements->removeElement($sousTypesEtablissement);
  676.             // set the owning side to null (unless already changed)
  677.             if ($sousTypesEtablissement->getEtablissement() === $this) {
  678.                 $sousTypesEtablissement->setEtablissement(null);
  679.             }
  680.         }
  681.         return $this;
  682.     }
  683.     public function getInternat(): ?string
  684.     {
  685.         return $this->internat;
  686.     }
  687.     public function setInternat(?string $internat): self
  688.     {
  689.         $this->internat $internat;
  690.         return $this;
  691.     }
  692.     public function hasInternat(): ?bool
  693.     {
  694.         return $this->hasInternat;
  695.     }
  696.     public function setHasInternat(?bool $hasInternat): self
  697.     {
  698.         $this->hasInternat $hasInternat;
  699.         return $this;
  700.     }
  701.     public function getTypesInternat(): ?string
  702.     {
  703.         return $this->typesInternat;
  704.     }
  705.     public function setTypesInternat(?string $typesInternat): self
  706.     {
  707.         $this->typesInternat $typesInternat;
  708.         return $this;
  709.     }
  710.     public function getSousContrat(): ?bool
  711.     {
  712.         return $this->sousContrat;
  713.     }
  714.     public function setSousContrat(?bool $sousContrat): self
  715.     {
  716.         $this->sousContrat $sousContrat;
  717.         return $this;
  718.     }
  719.     public function getAlternance(): ?bool
  720.     {
  721.         return $this->alternance;
  722.     }
  723.     public function setAlternance(?bool $alternance): self
  724.     {
  725.         $this->alternance $alternance;
  726.         return $this;
  727.     }
  728.     public function getCategorieOrganisme(): ?CategorieOrganisme
  729.     {
  730.         return $this->categorieOrganisme;
  731.     }
  732.     public function setCategorieOrganisme(?CategorieOrganisme $categorieOrganisme): self
  733.     {
  734.         $this->categorieOrganisme $categorieOrganisme;
  735.         return $this;
  736.     }
  737.     // public function getRubrique(): ?string
  738.     // {
  739.     //     return $this->rubrique;
  740.     // }
  741.     //
  742.     // public function setRubrique(?string $rubrique): self
  743.     // {
  744.     //     $this->rubrique = $rubrique;
  745.     //
  746.     //     return $this;
  747.     // }
  748.     public function getRubrique(): ?RubriqueFournisseur
  749.     {
  750.         return $this->rubrique;
  751.     }
  752.     public function setRubrique(?RubriqueFournisseur $rubrique): self
  753.     {
  754.         $this->rubrique $rubrique;
  755.         return $this;
  756.     }
  757.     public function getTypeClient(): ?string
  758.     {
  759.         return $this->typeClient;
  760.     }
  761.     public function setTypeClient(?string $typeClient): self
  762.     {
  763.         $this->typeClient $typeClient;
  764.         return $this;
  765.     }
  766.     public function getBloqueTxtRef(): ?bool
  767.     {
  768.         return $this->bloqueTxtRef;
  769.     }
  770.     public function setBloqueTxtRef(?bool $bloqueTxtRef): self
  771.     {
  772.         $this->bloqueTxtRef $bloqueTxtRef;
  773.         return $this;
  774.     }
  775.     public function getInternat2(): ?self
  776.     {
  777.         return $this->internat2;
  778.     }
  779.     public function setInternat2(?self $internat2): self
  780.     {
  781.         $this->internat2 $internat2;
  782.         return $this;
  783.     }
  784.     /**
  785.      * @return Collection|self[]
  786.      */
  787.     public function getEtablissementsLiesInternat(): Collection
  788.     {
  789.         return $this->etablissementsLiesInternat;
  790.     }
  791.     public function addEtablissementsLiesInternat(self $etablissementsLiesInternat): self
  792.     {
  793.         if (!$this->etablissementsLiesInternat->contains($etablissementsLiesInternat)) {
  794.             $this->etablissementsLiesInternat[] = $etablissementsLiesInternat;
  795.             $etablissementsLiesInternat->setInternat2($this);
  796.         }
  797.         return $this;
  798.     }
  799.     public function removeEtablissementsLiesInternat(self $etablissementsLiesInternat): self
  800.     {
  801.         if ($this->etablissementsLiesInternat->contains($etablissementsLiesInternat)) {
  802.             $this->etablissementsLiesInternat->removeElement($etablissementsLiesInternat);
  803.             // set the owning side to null (unless already changed)
  804.             if ($etablissementsLiesInternat->getInternat2() === $this) {
  805.                 $etablissementsLiesInternat->setInternat2(null);
  806.             }
  807.         }
  808.         return $this;
  809.     }
  810.     public function getFacebook(): ?string
  811.     {
  812.         return $this->facebook;
  813.     }
  814.     public function setFacebook(?string $facebook): self
  815.     {
  816.         $this->facebook $facebook;
  817.         return $this;
  818.     }
  819.     public function getBloqueBac2021(): ?bool
  820.     {
  821.         return $this->bloqueBac2021;
  822.     }
  823.     public function setBloqueBac2021(?bool $bloqueBac2021): self
  824.     {
  825.         $this->bloqueBac2021 $bloqueBac2021;
  826.         return $this;
  827.     }
  828.     public function getPresenceWeb(): ?bool
  829.     {
  830.         return $this->presenceWeb;
  831.     }
  832.     public function setPresenceWeb(?bool $presenceWeb): self
  833.     {
  834.         $this->presenceWeb $presenceWeb;
  835.         return $this;
  836.     }
  837.     // public function getRubriqueFournisseur(): ?RubriqueFournisseur
  838.     // {
  839.     //     return $this->rubriqueFournisseur;
  840.     // }
  841.     //
  842.     // public function setRubriqueFournisseur(?RubriqueFournisseur $rubriqueFournisseur): self
  843.     // {
  844.     //     $this->rubriqueFournisseur = $rubriqueFournisseur;
  845.     //
  846.     //     return $this;
  847.     // }
  848.     public function getEtablissementLie(): ?self
  849.     {
  850.         return $this->etablissementLie;
  851.     }
  852.     public function setEtablissementLie(?self $etablissementLie): self
  853.     {
  854.         $this->etablissementLie $etablissementLie;
  855.         return $this;
  856.     }
  857.     /**
  858.      * @return Collection|Video[]
  859.      */
  860.     public function getVideos(): ?Collection
  861.     {
  862.         return $this->videos;
  863.     }
  864.     public function addVideo(Video $video): self
  865.     {
  866.         if (!$this->videos->contains($video)) {
  867.             $this->videos[] = $video;
  868.             $video->addEtablissement($this);
  869.         }
  870.         return $this;
  871.     }
  872.     public function removeVideo(Video $video): self
  873.     {
  874.         if ($this->videos->removeElement($video)) {
  875.             $video->removeEtablissement($this);
  876.         }
  877.         return $this;
  878.     }
  879.     public function getVideoPlus(): ?bool
  880.     {
  881.         return $this->videoPlus;
  882.     }
  883.     public function setVideoPlus(?bool $videoPlus): self
  884.     {
  885.         $this->videoPlus $videoPlus;
  886.         return $this;
  887.     }
  888.     public function getDiapoPlus(): ?bool
  889.     {
  890.         return $this->diapoPlus;
  891.     }
  892.     public function setDiapoPlus(?bool $diapoPlus): self
  893.     {
  894.         $this->diapoPlus $diapoPlus;
  895.         return $this;
  896.     }
  897.     public function getJpoPlus(): ?bool
  898.     {
  899.         return $this->jpoPlus;
  900.     }
  901.     public function setJpoPlus(?bool $jpoPlus): self
  902.     {
  903.         $this->jpoPlus $jpoPlus;
  904.         return $this;
  905.     }
  906.     /**
  907.      * @return Collection|Diaporama[]
  908.      */
  909.     public function getDiaporamas(): ?Collection
  910.     {
  911.         return $this->diaporamas;
  912.     }
  913.     public function addDiaporama(Diaporama $diaporama): self
  914.     {
  915.         if (!$this->diaporamas->contains($diaporama)) {
  916.             $this->diaporamas[] = $diaporama;
  917.             $diaporama->addEtablissement($this);
  918.         }
  919.         return $this;
  920.     }
  921.     public function removeDiaporama(Diaporama $diaporama): self
  922.     {
  923.         if ($this->diaporamas->removeElement($diaporama)) {
  924.             $diaporama->removeEtablissement($this);
  925.         }
  926.         return $this;
  927.     }
  928.     /**
  929.      * @return Collection<int, Document>
  930.      */
  931.     public function getDocuments(): ?Collection
  932.     {
  933.         return $this->documents;
  934.     }
  935.     public function addDocument(Document $document): self
  936.     {
  937.         if (!$this->documents->contains($document)) {
  938.             $this->documents[] = $document;
  939.             $document->addEtablissement($this);
  940.         }
  941.         return $this;
  942.     }
  943.     public function removeDocument(Document $document): self
  944.     {
  945.         if ($this->documents->removeElement($document)) {
  946.             $document->removeEtablissement($this);
  947.         }
  948.         return $this;
  949.     }
  950.     public function getDocPlus(): ?bool
  951.     {
  952.         return $this->docPlus;
  953.     }
  954.     public function setDocPlus(bool $docPlus): self
  955.     {
  956.         $this->docPlus $docPlus;
  957.         return $this;
  958.     }
  959.     public function isDiplomePlus(): ?bool
  960.     {
  961.         return $this->diplomePlus;
  962.     }
  963.     public function setDiplomePlus(?bool $diplomePlus): self
  964.     {
  965.         $this->diplomePlus $diplomePlus;
  966.         return $this;
  967.     }
  968.     public function isRefus(): ?bool
  969.     {
  970.         return $this->refus;
  971.     }
  972.     public function setRefus(?bool $refus): self
  973.     {
  974.         $this->refus $refus;
  975.         return $this;
  976.     }
  977.     public function getLogo(): ?Logo
  978.     {
  979.         return $this->logo;
  980.     }
  981.     public function setLogo(?Logo $logo): self
  982.     {
  983.         $this->logo $logo;
  984.         return $this;
  985.     }
  986.     /**
  987.      * @return mixed
  988.      */
  989.     public function getLogoFiche()
  990.     {
  991.         return $this->logoFiche;
  992.     }
  993.     /**
  994.      * @param mixed $logoFiche
  995.      */
  996.     public function setLogoFiche($logoFiche): void
  997.     {
  998.         $this->logoFiche $logoFiche;
  999.     }
  1000.     public function getMainImageFromDiapo()
  1001.     {
  1002.         if ($this->getDiapoPlus()) {
  1003.             $diapos $this->getDiaporamas();
  1004.             foreach ($diapos as $diapo) {
  1005.                 if ($diapo->getPrincipal()) {
  1006.                     return $diapo->getPhoto()[0];
  1007.                 }
  1008.             }
  1009.         }
  1010.         // Si aucune dipo n'est flagué principale on prend la 1ère
  1011.         $diapos $this->getDiaporamas();
  1012.         if (count($diapos) > 0)
  1013.             return $diapos[0]->getPhoto()[0];
  1014.         // if ($this->getImagesDiaporama())
  1015.         //     return $this->getImagesDiaporama()[0];
  1016.         return null;
  1017.     }
  1018.     /**
  1019.      * @return Collection<int, Produit>
  1020.      */
  1021.     public function getProduits(): Collection
  1022.     {
  1023.         return $this->produits;
  1024.     }
  1025.     public function addProduit(Produit $produit): self
  1026.     {
  1027.         if (!$this->produits->contains($produit)) {
  1028.             $this->produits[] = $produit;
  1029.             $produit->setEtablissement($this);
  1030.         }
  1031.         return $this;
  1032.     }
  1033.     public function removeProduit(Produit $produit): self
  1034.     {
  1035.         if ($this->produits->removeElement($produit)) {
  1036.             // set the owning side to null (unless already changed)
  1037.             if ($produit->getEtablissement() === $this) {
  1038.                 $produit->setEtablissement(null);
  1039.             }
  1040.         }
  1041.         return $this;
  1042.     }
  1043.     public function getNombreDiaposAutorises()
  1044.     {
  1045.         $maxDiapos 1// Si client et aucun produit alors c'est la valeur par défaut
  1046.         $annees = [date('Y'), date('Y') - 1];
  1047.         foreach ($annees as $annee) {
  1048.             $produits $this->produits;
  1049.             foreach ($produits as $produit) {
  1050.                 if ($produit->anneeOP() == $annee) {
  1051.                     switch ($produit->getIdentifiant()) {
  1052.                         case 'EWDPH':
  1053.                         case 'EWDPHGS':
  1054.                             return 2;
  1055.                         case 'EWDIAPO':
  1056.                         case 'EWDIAPOG':
  1057.                         case 'EWINDIAP':
  1058.                             return 6;
  1059.                         case 'EWDIAPO+':
  1060.                             return 20;
  1061.                     }
  1062.                 }
  1063.             }
  1064.         }
  1065.         return $maxDiapos;
  1066.     }
  1067.     /*
  1068.      * @return array
  1069.      */
  1070.     public function getImagesDiaporama(): array
  1071.     {
  1072.         return $this->imagesDiaporama;
  1073.     }
  1074.     public function getDiaporamaPrincipal(): ?Diaporama
  1075.     {
  1076.         foreach ($this->diaporamas as $diaporama) {
  1077.             if ($diaporama->getPrincipal()) {
  1078.                 return $diaporama;
  1079.             }
  1080.         }
  1081.         return null;
  1082.     }
  1083.     public function getDiapoPrincipal(): ?Diaporama
  1084.     {
  1085.         return $this->diapoPrincipal;
  1086.     }
  1087.     public function setDiapoPrincipal(?Diaporama $diapoPrincipal): self
  1088.     {
  1089.         $this->diapoPrincipal $diapoPrincipal;
  1090.         return $this;
  1091.     }
  1092.     public function getNombrePhotosMax() {
  1093.         $produits $this->produits;
  1094.         foreach ($produits as $produit) {
  1095.             $id $produit->getIdentifiant();
  1096.             if ($id == "EWDPH" || $id == "EWDPHGS")
  1097.                 return 2// Photo double : deux photos par établissement
  1098.             if ($id == "EWDIAPO" || $id == "EWDIAPOG" || $id == "EWINDIAP")
  1099.                 return 6// Diaporama simple : un pour l’ensemble des établissements => 6 photos
  1100.             if ($id == "EWDIAPO+" || $id == "EWDIAPOG+")
  1101.                 return 20// Diaporama +
  1102.         }
  1103.         return 1// Photo simple, standard dans l’offre de base
  1104.     }
  1105.     public function hasVideoSimple() {
  1106.         $produits $this->produits;
  1107.         foreach ($produits as $produit
  1108.             if ($produit->getIdentifiant() == "EWVIDEO")
  1109.                 return true;
  1110.         return false;  
  1111.     }
  1112.     // Savoir si le produit "diapo simple" est hérité du gestionnaire
  1113.     // public function hasDiapoGestionnaire() {
  1114.     //     $produits = $this->produits;
  1115.     //     foreach ($produits as $produit) 
  1116.     //         if ($produit->getIdentifiant() == "EWDIAPOG" )
  1117.     //             return true;
  1118.     //     return false;
  1119.     // }    
  1120.     /**
  1121.      * @return mixed
  1122.      */
  1123.     public function getGestionnaire()
  1124.     {
  1125.         return $this->gestionnaire;
  1126.     }
  1127.     /**
  1128.      * @return mixed
  1129.      */
  1130.     public function getDenomination()
  1131.     {
  1132.         return $this->denomination;
  1133.     }
  1134.     public function getPath(): ?string
  1135.     {
  1136.         return $this->path;
  1137.     }
  1138.     public function setPath(?string $path): self
  1139.     {
  1140.         $this->path $path;
  1141.         return $this;
  1142.     }
  1143.     public function getCompositionEnsembleScolaire(): ?string
  1144.     {
  1145.         return $this->compositionEnsembleScolaire;
  1146.     }
  1147.     public function setCompositionEnsembleScolaire(?string $compositionEnsembleScolaire): self
  1148.     {
  1149.         $this->compositionEnsembleScolaire $compositionEnsembleScolaire;
  1150.         return $this;
  1151.     }
  1152.     public function getLva(): ?string
  1153.     {
  1154.         return $this->lva;
  1155.     }
  1156.     public function setLva(?string $lva): self
  1157.     {
  1158.         $this->lva $lva;
  1159.         return $this;
  1160.     }
  1161.     public function getLvb(): ?string
  1162.     {
  1163.         return $this->lvb;
  1164.     }
  1165.     public function setLvb(?string $lvb): self
  1166.     {
  1167.         $this->lvb $lvb;
  1168.         return $this;
  1169.     }
  1170.     public function getNumeroAdministratifUai(): ?string
  1171.     {
  1172.         return $this->numeroAdministratifUai;
  1173.     }
  1174.     public function setNumeroAdministratifUai(?string $numeroAdministratifUai): self
  1175.     {
  1176.         $this->numeroAdministratifUai $numeroAdministratifUai;
  1177.         return $this;
  1178.     }
  1179.     /**
  1180.      * @return Collection<int, EtablissementData>
  1181.      */
  1182.     public function getData(): Collection
  1183.     {
  1184.         // Si c'est un client on ne retourne pas les champs réservés aux prospects
  1185.         if ($this->isClient()) {
  1186.             $filtered $this->data->filter(function ($item) {
  1187.                 $field $item->getField();
  1188.                 return !(
  1189.                     isset(self::ALLOWED_DATA_FIELDS[$field][2]) &&
  1190.                     self::ALLOWED_DATA_FIELDS[$field][2] === 'prospect'
  1191.                 );
  1192.             });
  1193.             return $filtered;
  1194.         }
  1195.         return $this->data;
  1196.         /*
  1197.         return $this->data;
  1198.         // Filter $this->data to only include allowed fields (keys of associative array)
  1199.         return $this->data->filter(function($data) {
  1200.             return array_key_exists($data->getField(), self::ALLOWED_DATA_FIELDS);
  1201.         });
  1202.         */
  1203.     }
  1204.     public function addData(EtablissementData $data): self
  1205.     {
  1206.         if (!$this->data->contains($data)) {
  1207.             $this->data[] = $data;
  1208.             $data->setEtablissement($this);
  1209.         }
  1210.         return $this;
  1211.     }
  1212.     public function removeData(EtablissementData $data): self
  1213.     {
  1214.         if ($this->data->removeElement($data)) {
  1215.             // set the owning side to null (unless already changed)
  1216.             if ($data->getEtablissement() === $this) {
  1217.                 $data->setEtablissement(null);
  1218.             }
  1219.         }
  1220.         return $this;
  1221.     }
  1222.     public function getChiffres(): ?string
  1223.     {
  1224.         return $this->chiffres;
  1225.     }
  1226.     public function setChiffres(?string $chiffres): self
  1227.     {
  1228.         $this->chiffres $chiffres;
  1229.         return $this;
  1230.     }
  1231.     /**
  1232.      * @return Collection<int, VideoOnpc>
  1233.      */
  1234.     public function getVideosOnpc(): Collection
  1235.     {
  1236.         return $this->videosOnpc;
  1237.     }
  1238.     public function addVideoOnpc(VideoOnpc $video): self
  1239.     {
  1240.         if (!$this->videosOnpc->contains($video)) {
  1241.             $this->videosOnpc[] = $video;
  1242.             $video->addAnnonceur($this);
  1243.         }
  1244.         return $this;
  1245.     }
  1246.     public function removeVideoOnpc(VideoOnpc $video): self
  1247.     {
  1248.         if ($this->videosOnpc->removeElement($video)) {
  1249.             $video->removeAnnonceur($this);
  1250.         }
  1251.         return $this;
  1252.     }
  1253.     // Actualites relation
  1254.     /**
  1255.      * @return Collection<int, ActualiteOnpc>
  1256.      */
  1257.     public function getActualitesOnpc(): Collection
  1258.     {
  1259.         return $this->actualitesOnpc;
  1260.     }
  1261.     public function addActualiteOnpc(ActualiteOnpc $actualite): self
  1262.     {
  1263.         if (!$this->actualitesOnpc->contains($actualite)) {
  1264.             $this->actualitesOnpc[] = $actualite;
  1265.             $actualite->addAnnonceur($this);
  1266.         }
  1267.         return $this;
  1268.     }
  1269.     public function removeActualiteOnpc(ActualiteOnpc $actualite): self
  1270.     {
  1271.         if ($this->actualitesOnpc->removeElement($actualite)) {
  1272.             $actualite->removeAnnonceur($this);
  1273.         }
  1274.         return $this;
  1275.     }    
  1276. }