<?php
declare(strict_types=1);
/*
* Copyright (C) Office National de Publication et de Communication - All Rights Reserved
*
* Unauthorized copying of this file, via any medium is strictly prohibited by law
* This file is proprietary and confidential
*/
namespace App\Entity;
use DateTime;
use App\Entity\VideoOnpc;
use App\Entity\ActualiteOnpc;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Common\IsEmptyTrait;
use App\Entity\Common\UpdatableTrait;
use App\Entity\Common\IdAsStringTrait;
use App\Entity\Etablissement\DroitTrait;
use App\Entity\Etablissement\EmailTrait;
use App\Entity\Etablissement\ImageTrait;
use App\Entity\Etablissement\AdresseTrait;
use App\Entity\Etablissement\ElasticTrait;
use App\Entity\Etablissement\GestionTrait;
use Doctrine\Common\Collections\Collection;
use App\Entity\Etablissement\InsertionTrait;
use App\Entity\Etablissement\TelephoneTrait;
use App\Entity\Etablissement\DenominationTrait;
use App\Entity\Etablissement\InterventionTrait;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\Etablissement\ItemsInsertionTrait;
use Doctrine\Common\Persistence\ObjectManagerAware;
/**
* @ORM\Entity(repositoryClass="App\Repository\EtablissementRepository")
* @ORM\Table(name="etablissement")
*/
class Etablissement
// class Etablissement implements ObjectManagerAware
{
/**
* List of allowed EtablissementData fields for getData()
*/
public const ALLOWED_DATA_FIELDS = [
'presents_total' => ['Nombre de candidats' , ' élèves' , ''], // pour le client : garder uniquement ceci (au bac) / Exp : ET001-58 / ET001-59
'taux_reu_total' => ['Taux de réussite total' , '%' , ''], // pour le client : garder uniquement ceci
'taux_men_total' => ['Taux de mentions total' , '%' , ''], // pour le client : garder uniquement ceci
'taux_men_gnle' => ['Taux de mentions générale' , '%' , ''], // pour le client : garder uniquement ceci
'nombre_eleves_total' => ['Nombre d\'élèves' , ' élèves' , 'prospect'],
'nombre_d_eleves' => ['Nombre d\'élèves' , ' élèves' , 'prospect'],
'nombre_total_eleves' => ['Nombre d\'élèves' , ' élèves' , 'prospect'],
'nombre_total_classes' => ['Nombre de classes' , ' classes', 'prospect'],
];
/*
class Etablissement implements ObjectManagerAware
le implements est utilisé afin de passer l'entityManager à elasticTypesInternat
cette fonction est appelée uniquement lors du populate de la bdd elastic (je crois)
mais poser problème dans le backoffice !
*/
use AdresseTrait;
use DenominationTrait;
use DroitTrait;
use IdAsStringTrait;
use ElasticTrait;
use EmailTrait;
use GestionTrait;
use ImageTrait;
use InsertionTrait;
use ItemsInsertionTrait;
use InterventionTrait;
use TelephoneTrait;
use IsEmptyTrait;
use UpdatableTrait;
private const STATUTS_PUBLIC = ['privé participant service public', 'public'];
/** @ORM\Column(type="string", nullable=true) */
protected $type;
/** @ORM\Column(type="integer", nullable=true) */
protected $nombreEleves;
/** @ORM\Column(type="text", nullable=true) */
protected $url;
/** @ORM\Column(type="text", nullable=true) */
protected $video;
/** @ORM\Column(type="string", nullable=true) */
protected $motsCles;
// ----- Denomination ------------------------------------------------------
/** @ORM\Column(type="string", nullable=true) */
protected $denomination;
/** @ORM\Column(type="string", nullable=true) */
protected $denominationSigle;
/** @ORM\Column(type="string", nullable=true) */
protected $denominationExtension;
/** @ORM\Column(type="string", nullable=true) */
protected $denominationAbregee;
// ----- Gestion -----------------------------------------------------------
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Etablissement", cascade={"persist"}, inversedBy="geres", fetch="EAGER")
* @ORM\JoinColumn(name="gestionnaire_id", referencedColumnName="id")
*/
protected $gestionnaire;
// ----- Adresse -----------------------------------------------------------
// ----- Droit -------------------------------------------------------------
/** @ORM\Column(type="boolean", nullable=true) */
protected $droitPageWeb;
/** @ORM\Column(type="boolean", nullable=true) */
protected $droitActualite;
/** @ORM\ManyToOne(targetEntity="App\Entity\Ville", cascade={"persist"}) */
protected $ville;
/** @ORM\Column(type="string", nullable=true) */
protected $adresse1;
/** @ORM\Column(type="string", nullable=true) */
protected $adresse2;
/** @ORM\Column(type="string", nullable=true) */
protected $adresse3;
/** @ORM\Column(type="string", nullable=true) */
protected $codePostal;
/** @ORM\Column(type="string", nullable=true) */
protected $cedex;
/** @ORM\Column(type="decimal", precision=11, scale=8, nullable=true) */
protected $latitude;
/** @ORM\Column(type="decimal", precision=11, scale=8, nullable=true) */
protected $longitude;
// ----- Telephone ---------------------------------------------------------
/** @ORM\Column(type="string", nullable=true) */
protected $telephonePrincipal;
/** @ORM\Column(type="string", nullable=true) */
protected $fax;
// ----- E-mail ------------------------------------------------------------
/** @ORM\Column(type="string", nullable=true) */
protected $emailPrincipal;
// ----- Image -------------------------------------------------------------
/** @ORM\Column(type="string", nullable=true) */
protected $logoListe;
/** @ORM\Column(type="string", nullable=true) */
protected $logoFiche;
/** @ORM\Column(type="boolean", nullable=true) */
protected $diaporamaActif;
/** @ORM\Column(type="simple_array", nullable=true) */
protected $imagesDiaporama;
// ----- Intervention ------------------------------------------------------
// ----- Insertions --------------------------------------------------------
/** @ORM\OneToMany(targetEntity="Insertion", mappedBy="etablissement") */
protected $insertions;
// ----- ItemsInsertions --------------------------------------------------------
/**
* @ORM\OneToMany(targetEntity="ItemsInsertion", mappedBy="etablissement")
* @ORM\OrderBy({"diplomePlus": "ASC"})
*/
protected $itemsInsertions;
// ----- Données hors le Backoffice ----------------------------------------
/**
* @ORM\OneToMany(targetEntity="Actualite", mappedBy="etablissement", cascade={"persist"}, fetch="EXTRA_LAZY")
* @ORM\OrderBy({"dateActualisation": "DESC"})
*/
protected $actualites;
/**
* @ORM\OneToMany(targetEntity="OffreEmploi", mappedBy="etablissement", cascade={"persist"}, fetch="EXTRA_LAZY")
* @ORM\OrderBy({"dateActualisation": "DESC"})
*/
protected $offresEmploi;
// /** @ORM\OneToOne(targetEntity="PlaceDisponible", mappedBy="etablissement", cascade={"persist"}) */
// protected $placeDisponible;
/** @ORM\OneToOne(targetEntity="TexteReferencement", mappedBy="etablissement", cascade={"persist"}, fetch="EXTRA_LAZY") */
protected $texteReferencement;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $participant;
/** @ORM\ManyToOne(targetEntity="Categorie", cascade={"persist"}) */
protected $categoriePrimaire;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Etablissement", mappedBy="gestionnaire", fetch="EXTRA_LAZY")
* @ORM\OrderBy({"type" = "ASC"})
*/
protected $geres;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $catholique;
/** @ORM\Column(type="decimal", nullable=true, precision=2, scale=1) */
protected $ageAdmission;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Region", inversedBy="etablissements")
* @ORM\JoinColumn(nullable=true)
*/
private $region;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Departement", inversedBy="etablissements")
*/
private $departement;
/**
* @ORM\Column(type="boolean")
*/
private $actif;
/**
* @ORM\OneToMany(targetEntity="App\Entity\JPO", mappedBy="etablissement", fetch="EXTRA_LAZY")
*/
private $jPOs;
/**
* @ORM\OneToMany(targetEntity="App\Entity\SousTypesEtablissement", mappedBy="etablissement", fetch="EXTRA_LAZY")
*/
private $sousTypesEtablissements;
private $em;
/** @ORM\Column(type="string", nullable=true) */
private $internat;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $hasInternat;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $typesInternat;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $sousContrat;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $alternance;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\CategorieOrganisme", inversedBy="etablissements")
*/
private $categorieOrganisme;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\RubriqueFournisseur", inversedBy="etablissements", cascade={"persist"})
* @ORM\JoinColumn(name="rubrique", nullable=true)
*/
private $rubrique;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $typeClient;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $bloqueTxtRef;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Etablissement", inversedBy="etablissementsLiesInternat")
*/
private $internat2;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Etablissement", mappedBy="internat2", fetch="EXTRA_LAZY")
*/
private $etablissementsLiesInternat;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $facebook;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $bloqueBac2021;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $presenceWeb;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Etablissement")
*/
private $etablissementLie;
// /**
// * @ORM\OneToMany(targetEntity="App\Entity\Video", mappedBy="etablissement", orphanRemoval=true)
// */
// private $videoss;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" : false})
*/
private $videoPlus;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" : false})
*/
private $diapoPlus;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" : false})
*/
private $jpoPlus;
// /**
// * @ORM\OneToMany(targetEntity="App\Entity\Diaporama", mappedBy="etablissement", orphanRemoval=true)
// */
// private $diaporamass;
// /**
// * @ORM\OneToMany(targetEntity="App\Entity\Document", mappedBy="etablissement", orphanRemoval=true)
// */
// private $documents;
/**
* @ORM\ManyToMany(targetEntity=Document::class, mappedBy="etablissements")
*/
private $documents;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" : false})
*/
private $docPlus;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $diplomePlus;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $refus;
/**
* @ORM\ManyToMany(targetEntity=Diaporama::class, mappedBy="etablissements")
*/
private $diaporamas;
/**
* @ORM\ManyToMany(targetEntity=Video::class, mappedBy="etablissements")
*/
private $videos;
/**
* @ORM\ManyToOne(targetEntity=Logo::class, inversedBy="etablissements")
*/
private $logo;
/**
* @ORM\OneToMany(targetEntity=Produit::class, mappedBy="etablissement", orphanRemoval=true)
*/
private $produits;
/**
* @ORM\ManyToOne(targetEntity=Diaporama::class, inversedBy="etabs")
*/
private $diapoPrincipal;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $path;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $compositionEnsembleScolaire;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $lva;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $lvb;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $numeroAdministratifUai;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $siret;
/**
* @ORM\OneToMany(targetEntity=EtablissementData::class, mappedBy="etablissement", orphanRemoval=true)
*/
private $data;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $chiffres;
// /**
// * @ORM\ManyToOne(targetEntity="App\Entity\RubriqueFournisseur", inversedBy="etablissements")
// */
// private $rubriqueFournisseur;
/**
* @ORM\ManyToMany(targetEntity=VideoOnpc::class, mappedBy="annonceurs")
*/
private $videosOnpc;
/**
* @ORM\ManyToMany(targetEntity=ActualiteOnpc::class, mappedBy="annonceurs")
*/
private $actualitesOnpc;
public function __construct()
{
$this->maj = new DateTime();
$this->actif = false;
$this->geres = new ArrayCollection();
$this->categoriesSecondaires = new ArrayCollection();
$this->villesIntervention = new ArrayCollection();
$this->departementsIntervention = new ArrayCollection();
$this->actualites = new ArrayCollection();
$this->offresEmploi = new ArrayCollection();
$this->insertions = new ArrayCollection();
$this->itemsInsertions = new ArrayCollection();
$this->imagesDiaporama = [];
$this->jPOs = new ArrayCollection();
$this->sousTypesEtablissements = new ArrayCollection();
$this->responsableEtablissements = new ArrayCollection();
$this->etablissementsLiesInternat = new ArrayCollection();
$this->videos = new ArrayCollection();
$this->diaporamas = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->videoPlus = false;
$this->diapoPlus = false;
$this->jpoPlus = false;
$this->docPlus = false;
$this->produits = new ArrayCollection();
$this->data = new ArrayCollection();
$this->videosOnpc = new ArrayCollection();
$this->actualitesOnpc = new ArrayCollection();
}
public function setIdDistant(?string $idDistant): void
{
$this->idDistant = $idDistant;
}
public function getIdDistant(): ?string
{
return $this->idDistant;
}
public function setType(?string $type): void
{
$this->type = $type;
}
public function getType(): ?string
{
return $this->type;
}
public function setStatut(?string $statut): void
{
// $this->statut = $statut;
}
public function getStatut(): ?string
{
return '';
// return $this->statut;
}
public function setSiret(?string $siret): void
{
$this->siret = $siret;
}
public function getSiret(): ?string
{
return $this->siret;
}
public function setNaf(?string $naf): void
{
$this->naf = $naf;
}
public function getNaf(): ?string
{
return $this->naf;
}
public function setNombreEleves(?int $nombreEleves): void
{
$this->nombreEleves = $nombreEleves;
}
public function getNombreEleves(): ?int
{
return $this->nombreEleves;
}
public function setTarif(?string $tarif): void
{
$this->tarif = $tarif;
}
public function getTarif(): ?string
{
return $this->tarif;
}
public function setUrl(?string $url): void
{
$this->url = $url;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setVideo(?string $video): void
{
$this->video = $video;
}
public function getVideo(): ?string
{
return $this->video;
}
public function setMotsCles(?string $motsCles): void
{
$this->motsCles = $motsCles;
}
public function getMotsCles(): ?string
{
return $this->motsCles;
}
// ----- Données hors le Backoffice ----------------------------------------
public function getDateDerniereModification(): DateTime
{
$offreEmploi = $this->getOffresEmploi()->first();
$actualite = $this->getActualites()->first();
$placeDisponible = 0; //$this->getPlaceDisponible();
return max(array_filter([
$this->maj,
$offreEmploi ? $offreEmploi->getDateActualisation() : null,
$actualite ? $actualite->getDateActualisation() : null,
$placeDisponible ? $placeDisponible->getDateActualisation() : null,
]));
}
public function addActualite(Actualite $actualite): void
{
$this->actualites[] = $actualite;
}
public function removeActualite(Actualite $actualite): void
{
$this->actualites->removeElement($actualite);
}
public function getActualites(): Collection
{
return $this->actualites;
}
public function addOffreEmploi(OffreEmploi $offreEmploi): void
{
$this->offresEmploi[] = $offreEmploi;
}
public function removeOffreEmploi(OffreEmploi $offreEmploi): void
{
$this->offresEmploi->removeElement($offreEmploi);
}
public function getOffresEmploi(): Collection
{
return $this->offresEmploi;
}
public function getOffresEmploiValides(): Collection
{
return $this->offresEmploi->filter(static function ($offre) {
return $offre->isValid();
});
}
public function setPlaceDisponible(?PlaceDisponible $placeDisponible): void
{
$this->placeDisponible = $placeDisponible;
}
public function getPlaceDisponible(): ?PlaceDisponible
{
return $this->placeDisponible;
}
public function hasPlaceDisponible(): bool
{
return $this->placeDisponible && $this->placeDisponible->isValid();
}
public function setTexteReferencement(?TexteReferencement $texteReferencement): void
{
$this->texteReferencement = $texteReferencement;
}
public function getTexteReferencement(): ?TexteReferencement
{
return $this->texteReferencement;
}
public function compileTexteReferencement(): ?string
{
$texte = $this->getTexteReferencement();
if (!$texte) {
return null;
}
$contenu = '';
if ($texte->isActif()) {
$template = $texte->getTemplate();
$template = $template ? $template->getContenu() : null;
if ($template) {
$contenu .= '<p>'.$template.'</p>';
}
}
$contenu .= $texte->getContenu();
if (!$contenu) {
return null;
}
$categorie = $this->getCategoriePrimaire();
$ville = $this->getVille();
$departement = $ville ? $ville->getDepartement() : null;
return strtr($contenu, [
'<nom>' => $this->getDenomination() ?: '',
'<statut>' => $this->getStatut() ?: '',
'<catégorie>' => $categorie ? $categorie->getLibelle() : '',
'<ville>' => ($ville ? $ville->getLibelle() : null) ?: '',
'<dept>' => ($departement ? $departement->getLibelle() : null) ?: '',
'<nombre>' => ((int) $this->getNombreEleves()) ?: 'quelques',
]);
}
public function getParticipant(): ?bool
{
return $this->participant;
}
public function isParticipant(): ?bool
{
return true === $this->participant && !$this->refus;
}
public function isClient(): ?bool // Pour la Retrocompatibilité avec le code de l'Ass
{
return $this->isParticipant();
}
public function setParticipant(?bool $participant): self
{
$this->participant = $participant;
return $this;
}
public function getRegion(): ?Region
{
return $this->region;
}
public function setRegion(?Region $region): self
{
$this->region = $region;
return $this;
}
public function setAgeAdmission(?float $ageAdmission): void
{
$this->ageAdmission = $ageAdmission;
}
public function getAgeAdmission(): ?float
{
return (float) $this->ageAdmission;
}
public function getCatholique(): ?bool
{
return $this->catholique;
}
public function setCatholique(?bool $catholique): self
{
$this->catholique = $catholique;
return $this;
}
public function getDepartement(): ?Departement
{
return $this->departement;
}
public function setDepartement(?Departement $departement): self
{
$this->departement = $departement;
return $this;
}
public function getActif(): ?bool
{
return $this->actif;
}
public function setActif(bool $actif): self
{
$this->actif = $actif;
return $this;
}
/**
* @return Collection|JPO[]
*/
public function getJPOs(): ?Collection
{
return $this->jPOs;
}
public function addJPO(JPO $jPO): self
{
if (!$this->jPOs->contains($jPO)) {
$this->jPOs[] = $jPO;
$jPO->setEtablissement($this);
}
return $this;
}
public function removeJPO(JPO $jPO): self
{
if ($this->jPOs->contains($jPO)) {
$this->jPOs->removeElement($jPO);
// set the owning side to null (unless already changed)
if ($jPO->getEtablissement() === $this) {
$jPO->setEtablissement(null);
}
}
return $this;
}
public function __toString()
{
return $this->denomination;
}
/**
* @return Collection|SousTypesEtablissement[]
*/
public function getSousTypesEtablissements(): Collection
{
return $this->sousTypesEtablissements;
}
public function addSousTypesEtablissement(SousTypesEtablissement $sousTypesEtablissement): self
{
if (!$this->sousTypesEtablissements->contains($sousTypesEtablissement)) {
$this->sousTypesEtablissements[] = $sousTypesEtablissement;
$sousTypesEtablissement->setEtablissement($this);
}
return $this;
}
public function removeSousTypesEtablissement(SousTypesEtablissement $sousTypesEtablissement): self
{
if ($this->sousTypesEtablissements->contains($sousTypesEtablissement)) {
$this->sousTypesEtablissements->removeElement($sousTypesEtablissement);
// set the owning side to null (unless already changed)
if ($sousTypesEtablissement->getEtablissement() === $this) {
$sousTypesEtablissement->setEtablissement(null);
}
}
return $this;
}
public function getInternat(): ?string
{
return $this->internat;
}
public function setInternat(?string $internat): self
{
$this->internat = $internat;
return $this;
}
public function hasInternat(): ?bool
{
return $this->hasInternat;
}
public function setHasInternat(?bool $hasInternat): self
{
$this->hasInternat = $hasInternat;
return $this;
}
public function getTypesInternat(): ?string
{
return $this->typesInternat;
}
public function setTypesInternat(?string $typesInternat): self
{
$this->typesInternat = $typesInternat;
return $this;
}
public function getSousContrat(): ?bool
{
return $this->sousContrat;
}
public function setSousContrat(?bool $sousContrat): self
{
$this->sousContrat = $sousContrat;
return $this;
}
public function getAlternance(): ?bool
{
return $this->alternance;
}
public function setAlternance(?bool $alternance): self
{
$this->alternance = $alternance;
return $this;
}
public function getCategorieOrganisme(): ?CategorieOrganisme
{
return $this->categorieOrganisme;
}
public function setCategorieOrganisme(?CategorieOrganisme $categorieOrganisme): self
{
$this->categorieOrganisme = $categorieOrganisme;
return $this;
}
// public function getRubrique(): ?string
// {
// return $this->rubrique;
// }
//
// public function setRubrique(?string $rubrique): self
// {
// $this->rubrique = $rubrique;
//
// return $this;
// }
public function getRubrique(): ?RubriqueFournisseur
{
return $this->rubrique;
}
public function setRubrique(?RubriqueFournisseur $rubrique): self
{
$this->rubrique = $rubrique;
return $this;
}
public function getTypeClient(): ?string
{
return $this->typeClient;
}
public function setTypeClient(?string $typeClient): self
{
$this->typeClient = $typeClient;
return $this;
}
public function getBloqueTxtRef(): ?bool
{
return $this->bloqueTxtRef;
}
public function setBloqueTxtRef(?bool $bloqueTxtRef): self
{
$this->bloqueTxtRef = $bloqueTxtRef;
return $this;
}
public function getInternat2(): ?self
{
return $this->internat2;
}
public function setInternat2(?self $internat2): self
{
$this->internat2 = $internat2;
return $this;
}
/**
* @return Collection|self[]
*/
public function getEtablissementsLiesInternat(): Collection
{
return $this->etablissementsLiesInternat;
}
public function addEtablissementsLiesInternat(self $etablissementsLiesInternat): self
{
if (!$this->etablissementsLiesInternat->contains($etablissementsLiesInternat)) {
$this->etablissementsLiesInternat[] = $etablissementsLiesInternat;
$etablissementsLiesInternat->setInternat2($this);
}
return $this;
}
public function removeEtablissementsLiesInternat(self $etablissementsLiesInternat): self
{
if ($this->etablissementsLiesInternat->contains($etablissementsLiesInternat)) {
$this->etablissementsLiesInternat->removeElement($etablissementsLiesInternat);
// set the owning side to null (unless already changed)
if ($etablissementsLiesInternat->getInternat2() === $this) {
$etablissementsLiesInternat->setInternat2(null);
}
}
return $this;
}
public function getFacebook(): ?string
{
return $this->facebook;
}
public function setFacebook(?string $facebook): self
{
$this->facebook = $facebook;
return $this;
}
public function getBloqueBac2021(): ?bool
{
return $this->bloqueBac2021;
}
public function setBloqueBac2021(?bool $bloqueBac2021): self
{
$this->bloqueBac2021 = $bloqueBac2021;
return $this;
}
public function getPresenceWeb(): ?bool
{
return $this->presenceWeb;
}
public function setPresenceWeb(?bool $presenceWeb): self
{
$this->presenceWeb = $presenceWeb;
return $this;
}
// public function getRubriqueFournisseur(): ?RubriqueFournisseur
// {
// return $this->rubriqueFournisseur;
// }
//
// public function setRubriqueFournisseur(?RubriqueFournisseur $rubriqueFournisseur): self
// {
// $this->rubriqueFournisseur = $rubriqueFournisseur;
//
// return $this;
// }
public function getEtablissementLie(): ?self
{
return $this->etablissementLie;
}
public function setEtablissementLie(?self $etablissementLie): self
{
$this->etablissementLie = $etablissementLie;
return $this;
}
/**
* @return Collection|Video[]
*/
public function getVideos(): ?Collection
{
return $this->videos;
}
public function addVideo(Video $video): self
{
if (!$this->videos->contains($video)) {
$this->videos[] = $video;
$video->addEtablissement($this);
}
return $this;
}
public function removeVideo(Video $video): self
{
if ($this->videos->removeElement($video)) {
$video->removeEtablissement($this);
}
return $this;
}
public function getVideoPlus(): ?bool
{
return $this->videoPlus;
}
public function setVideoPlus(?bool $videoPlus): self
{
$this->videoPlus = $videoPlus;
return $this;
}
public function getDiapoPlus(): ?bool
{
return $this->diapoPlus;
}
public function setDiapoPlus(?bool $diapoPlus): self
{
$this->diapoPlus = $diapoPlus;
return $this;
}
public function getJpoPlus(): ?bool
{
return $this->jpoPlus;
}
public function setJpoPlus(?bool $jpoPlus): self
{
$this->jpoPlus = $jpoPlus;
return $this;
}
/**
* @return Collection|Diaporama[]
*/
public function getDiaporamas(): ?Collection
{
return $this->diaporamas;
}
public function addDiaporama(Diaporama $diaporama): self
{
if (!$this->diaporamas->contains($diaporama)) {
$this->diaporamas[] = $diaporama;
$diaporama->addEtablissement($this);
}
return $this;
}
public function removeDiaporama(Diaporama $diaporama): self
{
if ($this->diaporamas->removeElement($diaporama)) {
$diaporama->removeEtablissement($this);
}
return $this;
}
/**
* @return Collection<int, Document>
*/
public function getDocuments(): ?Collection
{
return $this->documents;
}
public function addDocument(Document $document): self
{
if (!$this->documents->contains($document)) {
$this->documents[] = $document;
$document->addEtablissement($this);
}
return $this;
}
public function removeDocument(Document $document): self
{
if ($this->documents->removeElement($document)) {
$document->removeEtablissement($this);
}
return $this;
}
public function getDocPlus(): ?bool
{
return $this->docPlus;
}
public function setDocPlus(bool $docPlus): self
{
$this->docPlus = $docPlus;
return $this;
}
public function isDiplomePlus(): ?bool
{
return $this->diplomePlus;
}
public function setDiplomePlus(?bool $diplomePlus): self
{
$this->diplomePlus = $diplomePlus;
return $this;
}
public function isRefus(): ?bool
{
return $this->refus;
}
public function setRefus(?bool $refus): self
{
$this->refus = $refus;
return $this;
}
public function getLogo(): ?Logo
{
return $this->logo;
}
public function setLogo(?Logo $logo): self
{
$this->logo = $logo;
return $this;
}
/**
* @return mixed
*/
public function getLogoFiche()
{
return $this->logoFiche;
}
/**
* @param mixed $logoFiche
*/
public function setLogoFiche($logoFiche): void
{
$this->logoFiche = $logoFiche;
}
public function getMainImageFromDiapo()
{
if ($this->getDiapoPlus()) {
$diapos = $this->getDiaporamas();
foreach ($diapos as $diapo) {
if ($diapo->getPrincipal()) {
return $diapo->getPhoto()[0];
}
}
}
// Si aucune dipo n'est flagué principale on prend la 1ère
$diapos = $this->getDiaporamas();
if (count($diapos) > 0)
return $diapos[0]->getPhoto()[0];
// if ($this->getImagesDiaporama())
// return $this->getImagesDiaporama()[0];
return null;
}
/**
* @return Collection<int, Produit>
*/
public function getProduits(): Collection
{
return $this->produits;
}
public function addProduit(Produit $produit): self
{
if (!$this->produits->contains($produit)) {
$this->produits[] = $produit;
$produit->setEtablissement($this);
}
return $this;
}
public function removeProduit(Produit $produit): self
{
if ($this->produits->removeElement($produit)) {
// set the owning side to null (unless already changed)
if ($produit->getEtablissement() === $this) {
$produit->setEtablissement(null);
}
}
return $this;
}
public function getNombreDiaposAutorises()
{
$maxDiapos = 1; // Si client et aucun produit alors c'est la valeur par défaut
$annees = [date('Y'), date('Y') - 1];
foreach ($annees as $annee) {
$produits = $this->produits;
foreach ($produits as $produit) {
if ($produit->anneeOP() == $annee) {
switch ($produit->getIdentifiant()) {
case 'EWDPH':
case 'EWDPHGS':
return 2;
case 'EWDIAPO':
case 'EWDIAPOG':
case 'EWINDIAP':
return 6;
case 'EWDIAPO+':
return 20;
}
}
}
}
return $maxDiapos;
}
/*
* @return array
*/
public function getImagesDiaporama(): array
{
return $this->imagesDiaporama;
}
public function getDiaporamaPrincipal(): ?Diaporama
{
foreach ($this->diaporamas as $diaporama) {
if ($diaporama->getPrincipal()) {
return $diaporama;
}
}
return null;
}
public function getDiapoPrincipal(): ?Diaporama
{
return $this->diapoPrincipal;
}
public function setDiapoPrincipal(?Diaporama $diapoPrincipal): self
{
$this->diapoPrincipal = $diapoPrincipal;
return $this;
}
public function getNombrePhotosMax() {
$produits = $this->produits;
foreach ($produits as $produit) {
$id = $produit->getIdentifiant();
if ($id == "EWDPH" || $id == "EWDPHGS")
return 2; // Photo double : deux photos par établissement
if ($id == "EWDIAPO" || $id == "EWDIAPOG" || $id == "EWINDIAP")
return 6; // Diaporama simple : un pour l’ensemble des établissements => 6 photos
if ($id == "EWDIAPO+" || $id == "EWDIAPOG+")
return 20; // Diaporama +
}
return 1; // Photo simple, standard dans l’offre de base
}
public function hasVideoSimple() {
$produits = $this->produits;
foreach ($produits as $produit)
if ($produit->getIdentifiant() == "EWVIDEO")
return true;
return false;
}
// Savoir si le produit "diapo simple" est hérité du gestionnaire
// public function hasDiapoGestionnaire() {
// $produits = $this->produits;
// foreach ($produits as $produit)
// if ($produit->getIdentifiant() == "EWDIAPOG" )
// return true;
// return false;
// }
/**
* @return mixed
*/
public function getGestionnaire()
{
return $this->gestionnaire;
}
/**
* @return mixed
*/
public function getDenomination()
{
return $this->denomination;
}
public function getPath(): ?string
{
return $this->path;
}
public function setPath(?string $path): self
{
$this->path = $path;
return $this;
}
public function getCompositionEnsembleScolaire(): ?string
{
return $this->compositionEnsembleScolaire;
}
public function setCompositionEnsembleScolaire(?string $compositionEnsembleScolaire): self
{
$this->compositionEnsembleScolaire = $compositionEnsembleScolaire;
return $this;
}
public function getLva(): ?string
{
return $this->lva;
}
public function setLva(?string $lva): self
{
$this->lva = $lva;
return $this;
}
public function getLvb(): ?string
{
return $this->lvb;
}
public function setLvb(?string $lvb): self
{
$this->lvb = $lvb;
return $this;
}
public function getNumeroAdministratifUai(): ?string
{
return $this->numeroAdministratifUai;
}
public function setNumeroAdministratifUai(?string $numeroAdministratifUai): self
{
$this->numeroAdministratifUai = $numeroAdministratifUai;
return $this;
}
/**
* @return Collection<int, EtablissementData>
*/
public function getData(): Collection
{
// Si c'est un client on ne retourne pas les champs réservés aux prospects
if ($this->isClient()) {
$filtered = $this->data->filter(function ($item) {
$field = $item->getField();
return !(
isset(self::ALLOWED_DATA_FIELDS[$field][2]) &&
self::ALLOWED_DATA_FIELDS[$field][2] === 'prospect'
);
});
return $filtered;
}
return $this->data;
/*
return $this->data;
// Filter $this->data to only include allowed fields (keys of associative array)
return $this->data->filter(function($data) {
return array_key_exists($data->getField(), self::ALLOWED_DATA_FIELDS);
});
*/
}
public function addData(EtablissementData $data): self
{
if (!$this->data->contains($data)) {
$this->data[] = $data;
$data->setEtablissement($this);
}
return $this;
}
public function removeData(EtablissementData $data): self
{
if ($this->data->removeElement($data)) {
// set the owning side to null (unless already changed)
if ($data->getEtablissement() === $this) {
$data->setEtablissement(null);
}
}
return $this;
}
public function getChiffres(): ?string
{
return $this->chiffres;
}
public function setChiffres(?string $chiffres): self
{
$this->chiffres = $chiffres;
return $this;
}
/**
* @return Collection<int, VideoOnpc>
*/
public function getVideosOnpc(): Collection
{
return $this->videosOnpc;
}
public function addVideoOnpc(VideoOnpc $video): self
{
if (!$this->videosOnpc->contains($video)) {
$this->videosOnpc[] = $video;
$video->addAnnonceur($this);
}
return $this;
}
public function removeVideoOnpc(VideoOnpc $video): self
{
if ($this->videosOnpc->removeElement($video)) {
$video->removeAnnonceur($this);
}
return $this;
}
// Actualites relation
/**
* @return Collection<int, ActualiteOnpc>
*/
public function getActualitesOnpc(): Collection
{
return $this->actualitesOnpc;
}
public function addActualiteOnpc(ActualiteOnpc $actualite): self
{
if (!$this->actualitesOnpc->contains($actualite)) {
$this->actualitesOnpc[] = $actualite;
$actualite->addAnnonceur($this);
}
return $this;
}
public function removeActualiteOnpc(ActualiteOnpc $actualite): self
{
if ($this->actualitesOnpc->removeElement($actualite)) {
$actualite->removeAnnonceur($this);
}
return $this;
}
}