<?php
namespace App\Entity\AssistantMaternel;
use \JsonSerializable;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Criteria;
use App\Entity\MAM\MAM;
use App\Entity\Commun\Utilisateur;
use App\Entity\Referentiel\SecteurPmi;
use App\Entity\Referentiel\Commune;
use App\Entity\Referentiel\Canton;
use App\Entity\Referentiel\EnumLieuAccueil;
use App\Entity\Referentiel\Periode;
use App\Entity\Referentiel\LieuAccueil;
use App\Entity\Referentiel\TypeAccueil;
use \App\Entity\Referentiel\FrequenceDispo;
use App\Entity\OffreAccueil\DispoPublicAssmat;
use App\Entity\OffreAccueil\DispoVacancesAssmat;
use App\Entity\OffreAccueil\PreferencesPublication;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\AssistantMaternel\AssistantMaternelRepository")
* @ORM\Table(
* name="efc.assistant_maternel",
* uniqueConstraints={@ORM\UniqueConstraint(name="assistant_maternel_un",columns={"id_fonctionnel"})},
* indexes={@ORM\Index(name="id_fonc_idx", columns={"id_fonctionnel"}),@ORM\Index(name="assmat_email_idx", columns={"email"})}
* )
*/
class AssistantMaternel implements JsonSerializable
{
// <editor-fold defaultstate="collapsed" desc="Champs privés">
// use App\Entity\Commun\PersonneTrait;
use \App\Entity\Commun\IdTrait;
use \App\Entity\Commun\DateNaissanceTrait;
use \App\Entity\Commun\PhotosTrait;
/**
* @ORM\Column(type="string", length=70)
*/
private $id_fonctionnel;
/**
* @ORM\Column(type="string", length=50)
*/
private $nom_famille;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $nom_naissance;
/**
* @ORM\Column(type="string", length=50)
*/
private $prenom;
/**
* @ORM\Column(type="date", nullable=true)
*/
private $date_naissance;
/**
* @ORM\Column(type="string", length=100)
*/
private $adresse;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $adresse_complement;
/**
* @ORM\Column(type="string", length=5)
*/
private $code_postal;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $bureau_distributeur;
/**
* @ORM\Column(type="string", length=10, nullable=true)
*/
private $tel_fixe;
/**
* @ORM\Column(type="string", length=10, nullable=true)
*/
private $tel_portable;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $date_modif_tel_fixe;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $date_modif_tel_portable;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $date_modif_mail;
/**
* @ORM\Column(type="boolean")
*/
private $liste_rouge_tel_fixe;
/**
* @ORM\Column(type="boolean")
*/
private $liste_rouge_tel_portable;
/**
* @ORM\Column(type="boolean")
*/
private $liste_rouge_mail;
/**
* @ORM\Column(type="date", nullable=true)
*/
private $date_premier_agrement_domicile;
/**
* @ORM\Column(type="date", nullable=true)
*/
private $date_debut_agrement_domicile;
/**
* @ORM\Column(type="date", nullable=true)
*/
private $date_fin_agrement_domicile;
/**
* @ORM\Column(type="date", nullable=true)
*/
private $date_premier_agrement_mam;
/**
* @ORM\Column(type="date", nullable=true)
*/
private $date_debut_agrement_mam;
/**
* @ORM\Column(type="date", nullable=true)
*/
private $date_fin_agrement_mam;
/**
* @ORM\Column(type="boolean")
*/
private $participe;
/**
* @ORM\Column(type="boolean")
*/
private $archive_domicile;
/**
* @ORM\Column(type="boolean")
*/
private $archive_mam;
/**
* @ORM\Column(type="boolean", nullable=false)
*/
private $oppose;
/**
* @ORM\Column(type="boolean")
*/
private $supprime;
/**
* @ORM\Column(type="boolean")
*/
private $supprime_domicile;
/**
* @ORM\Column(type="boolean")
*/
private $supprime_mam;
/**
*
* @var string
*
* @Assert\Email(
* message = "L'adresse mail '{{ value }}' n'est pas valide.",
* )
*
* La regex permet de transmettre une contrainte de validation avec un format plus strict au niveau du navigateur
* @Assert\Regex(
* pattern="/^([a-zA-Z0-9'_\-\.\+]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/",
* match=true,
* message="L'adresse mail '{{ value }}' n'est pas valide."
* )
* @ORM\Column(type="string", length=250, nullable=true)
*/
private $email;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $formation2_effectuee;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $formation1_effectuee;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $suspension_dom;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $suspension_mam;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $cta_dom;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $cta_mam;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $creche;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $assistant_familial;
/**
* @ORM\Column(type="datetime")
*/
private $date_maj_departement;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $date_maj_assmat;
/**
* Le secteur de PMI est nullable car certains départements n'ont pas de secteurs de PMI
* @ORM\ManyToOne(targetEntity="App\Entity\Referentiel\SecteurPmi", inversedBy="assmats")
* @ORM\JoinColumn(name="id_secteur_pmi", referencedColumnName="id", nullable=true)
*/
private $secteur_pmi;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Referentiel\Commune", inversedBy="assmats")
* @ORM\JoinColumn(name="id_commune", referencedColumnName="id")
*/
private $commune;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Referentiel\Canton", inversedBy="assmats")
* @ORM\JoinColumn(name="id_canton", referencedColumnName="id")
*/
private $canton;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\MAM\MAM", inversedBy="assmats")
* @ORM\JoinColumn(name="id_mam", referencedColumnName="id", nullable=true)
*/
private $mam;
/**
* @ORM\OneToMany(targetEntity="App\Entity\AssistantMaternel\Agrement", mappedBy="assmat")
*/
private $agrements;
/**
* @ORM\OneToMany(targetEntity="App\Entity\GDA\Accueil", mappedBy="assmat")
* @ORM\OrderBy({"date_debut" = "DESC","date_fin" = "DESC"})
*/
private $accueils;
/**
* Disponiblités issues des déclarations d'accueil du GDA
* @ORM\OneToMany(targetEntity="App\Entity\GDA\PlanningDispo", mappedBy="assmat")
*/
private $dispos;
/**
* Identifiants de connexion de l'assmat
* @ORM\OneToOne(targetEntity="App\Entity\Commun\Utilisateur", inversedBy="assistant_maternel")
* @ORM\JoinColumn(name="id_utilisateur", referencedColumnName="id")
*/
private $utilisateur;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Commun\Utilisateur")
* @ORM\JoinColumn(name="id_puericultrice", referencedColumnName="id")
*/
private $puericultrice;
/**
* Propres enfants de l'assistant maternel, utilisé pour le calcul des dépassement pour ses enfants de moins de 11 ans
* @ORM\OneToMany(targetEntity="App\Entity\AssistantMaternel\EnfantAssmat", mappedBy="assmat")
* @ORM\OrderBy({"date_naissance" = "DESC"})
*/
private $enfantsAssmat;
/**
* @ORM\OneToMany(targetEntity="App\Entity\GDA\DepassementAssmat", mappedBy="assmat")
*/
private $depassements;
/**
* Préférences de publication site grand public
* @ORM\OneToOne(targetEntity="App\Entity\OffreAccueil\PreferencesPublication", mappedBy="assmat")
*/
private $preferences_publication;
/**
* Présentation offre d'accueil site grand public
* @ORM\OneToOne(targetEntity="App\Entity\OffreAccueil\PresentationAssmat", mappedBy="assmat")
*/
private $presentation_assmat;
/**
* Disponiblités publiques de l'assistant maternel, utilisé pour le planning de dispo offre d'accueil site grand public
* @ORM\OneToMany(targetEntity="App\Entity\OffreAccueil\DispoPublicAssmat", mappedBy="assmat")
* @ORM\OrderBy({"periode" = "ASC", "type_accueil" = "ASC", "lieu_accueil" = "ASC", "tranche_age" = "ASC", "tranche_horaire" = "ASC", "jour_semaine" = "ASC"})
*/
private $dispos_public;
/**
* Disponiblités prév de l'assistant maternel, utilisé pour l'offre d'accueil site grand public
* @ORM\OneToMany(targetEntity="App\Entity\OffreAccueil\DispoPrevAssmat", mappedBy="assmat")
* @ORM\OrderBy({"date_debut" = "ASC"})
*/
private $dispos_prev;
/**
* Disponiblités pendant les vacances de l'assistant maternel, utilisé pour l'offre d'accueil site grand public
* @ORM\OneToMany(targetEntity="App\Entity\OffreAccueil\DispoVacancesAssmat", mappedBy="assmat")
* @ORM\OrderBy({"semaine" = "ASC", "jour" = "ASC"})
*/
private $dispos_vacances;
/**
* @ORM\OneToMany(targetEntity="App\Entity\OffreAccueil\Photo", mappedBy="assmat")
*/
private $photos;
// </editor-fold>
// <editor-fold desc="Accesseurs">
/**
* Get id_fonctionnel
*
* @return string
*/
public function getIdFonctionnel()
{
return $this->id_fonctionnel;
}
/**
* Set secteurPmi
*
* @param SecteurPmi $secteurPmi
*
* @return AssistantMaternel
*/
public function setSecteurPmi(SecteurPmi $secteurPmi = null)
{
$this->secteur_pmi = $secteurPmi;
return $this;
}
/**
* Get secteurPmi
*
* @return SecteurPmi
*/
public function getSecteurPmi()
{
return $this->secteur_pmi;
}
/**
* Set commune
*
* @param Commune $commune
*
* @return AssistantMaternel
*/
public function setCommune(Commune $commune = null)
{
$this->commune = $commune;
return $this;
}
/**
* Get commune
*
* @return Commune
*/
public function getCommune()
{
return $this->commune;
}
/**
* Get commune fonctionnelle : celle de l'assmat ou celle de la MAM
*
* @return Commune
*/
public function getCommuneFonctionnelle()
{
if ($this->mam != null) {
return $this->mam->getCommune();
}
return $this->commune;
}
/**
* Set canton
*
* @param Canton $canton
*
* @return AssistantMaternel
*/
public function setCanton(Canton $canton = null)
{
$this->canton = $canton;
return $this;
}
/**
* Get canton
*
* @return Canton
*/
public function getCanton()
{
return $this->canton;
}
/**
* Set MAM
*
* @param MAM $mam
*
* @return AssistantMaternel
*/
public function setMAM(MAM $mam = null)
{
$this->mam = $mam;
return $this;
}
/**
* Get MAM
*
* @return MAM
*/
public function getMAM()
{
return $this->mam;
}
/**
* Get agrements
*
* @return array
*/
public function getAgrements()
{
return $this->agrements;
}
/**
* Get accueils
*
* @return array
*/
public function getAccueils(): \Doctrine\Common\Collections\Collection
{
return $this->accueils;
}
/**
* Get dispos
*
* @return array
*/
public function getDispos()
{
return $this->dispos;
}
/**
* Set dispos
*
* @param string $planning_dispos
*
* @return AssistantMaternel
*/
public function setDispos($planning_dispos)
{
$this->dispos = $planning_dispos;
return $this;
}
/**
* Get nomFamille
*
* @return string
*/
public function getNomFamille()
{
return $this->nom_famille;
}
/**
* Set nomFamille
*
* @param string $nomFamille
*
* @return AssistantMaternel
*/
public function setNomFamille($nomFamille)
{
$this->nom_famille = $nomFamille;
return $this;
}
/**
* Get nomNaissance
*
* @return string
*/
public function getNomNaissance()
{
return $this->nom_naissance;
}
/**
* Set nomNaissance
*
* @param string $nomNaissance
*
* @return AssistantMaternel
*/
public function setNomNaissance($nomNaissance)
{
$this->nom_naissance = $nomNaissance;
return $this;
}
/**
* Get prenom
*
* @return string
*/
public function getPrenom()
{
return $this->prenom;
}
/**
* Set prenom
*
* @param string $prenom
*
* @return AssistantMaternel
*/
public function setPrenom($prenom)
{
$this->prenom = $prenom;
return $this;
}
/**
* Set dateNaissance
*
* @param \DateTime $dateNaissance
*
* @return AssistantMaternel
*/
public function setDateNaissance($dateNaissance)
{
$this->date_naissance = $dateNaissance;
return $this;
}
/**
* Get dateNaissance
*
* @return \DateTime
*/
public function getDateNaissance()
{
return $this->date_naissance;
}
/**
* Get dateFinAgrementDomicile
*
* @return \DateTime
*/
public function getDateFinAgrementDomicile()
{
return $this->date_fin_agrement_domicile;
}
/**
* Get dateFinAgrementMAM
*
* @return \DateTime
*/
public function getDateFinAgrementMAM()
{
return $this->date_fin_agrement_mam;
}
/**
* Get dateFinAgrement by id Lieu Accueil
*
* @return boolean
*/
public function getDateFinAgrementByLieuAccueil($idLieuAccueil)
{
if ($idLieuAccueil == EnumLieuAccueil::MAM) {
return $this->date_fin_agrement_mam;
} elseif ($idLieuAccueil == EnumLieuAccueil::DOMICILE) {
return $this->date_fin_agrement_domicile;
}
}
/**
* Get dateDebutAgrementDomicile
*
* @return \DateTime
*/
public function getDateDebutAgrementDomicile()
{
return $this->date_debut_agrement_domicile;
}
/**
* Get dateDebutAgrementMAM
*
* @return \DateTime
*/
public function getDateDebutAgrementMAM()
{
return $this->date_debut_agrement_mam;
}
/**
* Get dateDebutAgrement by id Lieu Accueil
*
* @return boolean
*/
public function getDateDebutAgrementByLieuAccueil($idLieuAccueil)
{
if ($idLieuAccueil == EnumLieuAccueil::MAM) {
return $this->date_debut_agrement_mam;
} elseif ($idLieuAccueil == EnumLieuAccueil::DOMICILE) {
return $this->date_debut_agrement_domicile;
}
}
/**
* Get datePremierAgrementDomicile
*
* @return \DateTime
*/
public function getDatePremierAgrementDomicile()
{
return $this->date_premier_agrement_domicile;
}
/**
* Get datePremierAgrementMAM
*
* @return \DateTime
*/
public function getDatePremierAgrementMAM()
{
return $this->date_premier_agrement_mam;
}
/**
* Get datePremierAgrement by id Lieu Accueil
*
* @return boolean
*/
public function getDatePremierAgrementByLieuAccueil($idLieuAccueil)
{
if ($idLieuAccueil == EnumLieuAccueil::MAM) {
return $this->date_premier_agrement_mam;
} elseif ($idLieuAccueil == EnumLieuAccueil::DOMICILE) {
return $this->date_premier_agrement_domicile;
}
}
/**
* Indique si l'assmat a obtenu son 1er agrement après le 01/01/2007
* si obtenu avant, la notion de 2e partie de formation est caduque
*/
public function aPremierAgrementApres2007()
{
if ($this->date_premier_agrement_mam == null) {
$minPremierAgrement = $this->date_premier_agrement_domicile;
} elseif ($this->date_premier_agrement_domicile == null) {
$minPremierAgrement = $this->date_premier_agrement_mam;
} else {
$minPremierAgrement = min($this->date_premier_agrement_domicile, $this->date_premier_agrement_mam);
}
return $minPremierAgrement >= new \DateTime('2007-01-01');
}
/**
* Set adresse
*
* @param string $adresse
*
* @return AssistantMaternel
*/
public function setAdresse($adresse)
{
$this->adresse = $adresse;
return $this;
}
/**
* Get adresse
*
* @return string
*/
public function getAdresse()
{
return trim($this->adresse);
}
/**
* Set adresseComplement
*
* @param string $adresseComplement
*
* @return AssistantMaternel
*/
public function setAdresseComplement($adresseComplement)
{
$this->adresse_complement = $adresseComplement;
return $this;
}
/**
* Get adresseComplement
*
* @return string
*/
public function getAdresseComplement()
{
return trim($this->adresse_complement);
}
/**
* Set codePostal
*
* @param string $codePostal
*
* @return AssistantMaternel
*/
public function setCodePostal($codePostal)
{
$this->code_postal = $codePostal;
return $this;
}
/**
* Ajouter un accueil, s'il n'est pas déjà associé à l'assmat
* ATTENTION mise à jour de l'assmat uniquement - pour associer un accueil, l'important est $accueil->setAssmat
*
* @param Accueil $acc
*
* @return AssistantMaternel
*/
public function addAccueil(\App\Entity\GDA\Accueil $acc): AssistantMaternel
{
foreach ($this->accueils as $a) {
if ($a->getId() == $acc->getId()) {
// Accueil déjà présent dans la liste, rien à faire
return $this;
}
}
if ($acc->getAssmat()->getId() != $this->getId()) {
throw new \Exception("L'accueil n'est pas associé à l'assistant maternel");
}
$this->accueils->add($acc);
return $this;
}
/**
* Get codePostal
*
* @return string
*/
public function getCodePostal()
{
return $this->code_postal;
}
/**
* Set bureauDistributeur
*
* @param string $bureauDistributeur
*
* @return AssistantMaternel
*/
public function setBureauDistributeur($bureauDistributeur)
{
$this->bureau_distributeur = $bureauDistributeur;
return $this;
}
/**
* Get bureauDistributeur
*
* @return string
*/
public function getBureauDistributeur()
{
return $this->bureau_distributeur;
}
/**
* Set telFixe
*
* @param string $telFixe
*
* @return AssistantMaternel
*/
public function setTelFixe($telFixe)
{
$this->tel_fixe = $telFixe;
return $this;
}
/**
* Get telFixe
*
* @return string
*/
public function getTelFixe()
{
return trim($this->tel_fixe);
}
/**
* Get la préférences de publication du tel fixe ,
* à défaut indique si sur liste rouge ou oppose
* renvoie faux si l'assmat a déjà positionné ses préférences
* ou bien si elle est opposée ou bien si elle est sur liste rouge
*
* @return boolean
*/
public function getPublieTelFixeEtendu()
{
$publieTel = false;
if ($this->getPreferencesPublication()) {
$publieTel = $this->getPreferencesPublication()->getPubliTelFixe();
} else if (!$this->getOppose() && !$this->getListeRougeTelFixe()) {
$publieTel = true;
}
return $publieTel;
}
/**
* Set telPortable
*
* @param string $telPortable
*
* @return AssistantMaternel
*/
public function setTelPortable($telPortable)
{
$this->tel_portable = $telPortable;
return $this;
}
/**
* Get telPortable
*
* @return string
*/
public function getTelPortable()
{
return trim($this->tel_portable);
}
/**
* Get la préférences de publication du tel portable ,
* à défaut indique si sur liste rouge ou oppose
* renvoie faux si l'assmat a déjà positionné ses préférences
* ou bien si elle est opposée ou bien si elle est sur liste rouge
*
* @return boolean
*/
public function getPublieTelPortableEtendu()
{
$publieTel = false;
if ($this->getPreferencesPublication()) {
$publieTel = $this->getPreferencesPublication()->getPubliTelPortable();
} else if (!$this->getOppose() && !$this->getListeRougeTelPortable()) {
$publieTel = true;
}
return $publieTel;
}
/**
* Set listeRougeTelFixe
*
* @param string $listeRouge
*
* @return AssistantMaternel
*/
public function setListeRougeTelFixe($listeRouge)
{
$this->liste_rouge_tel_fixe = $listeRouge;
return $this;
}
/**
* Get listeRougeTelFixe
*
* @return string
*/
public function getListeRougeTelFixe()
{
return $this->liste_rouge_tel_fixe;
}
/**
* Set listeRougeTelPortable
*
* @param string $listeRouge
*
* @return AssistantMaternel
*/
public function setListeRougeTelPortable($listeRouge)
{
$this->liste_rouge_tel_portable = $listeRouge;
return $this;
}
/**
* Get listeRougeTelPortable
*
* @return string
*/
public function getListeRougeTelPortable()
{
if ($this->liste_rouge_tel_portable === null) {
// retrocompatibilité quand on n'a pas l'info pour la publication email
return $this->liste_rouge_tel_fixe;
} else {
return $this->liste_rouge_tel_portable;
}
}
/**
* Set listeRougeMail
*
* @param string $listeRouge
*
* @return AssistantMaternel
*/
public function setListeRougeMail($listeRouge)
{
$this->liste_rouge_mail = $listeRouge;
return $this;
}
/**
* Get listeRougeMail
*
* @return string
*/
public function getListeRougeMail()
{
if ($this->liste_rouge_mail === null) {
// retrocompatibilité quand on n'a pas l'info pour la publication email
return $this->liste_rouge_tel_fixe;
} else {
return $this->liste_rouge_mail;
}
}
/**
* Set email
*
* @param string $email
*
* @return AssistantMaternel
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get email
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Get la préférences de publication du mail ,
* à défaut indique si sur liste rouge ou oppose
* renvoie faux si l'assmat a déjà positionné ses préférences
* ou bien si elle est opposée ou bien si elle est sur liste rouge
*
* @return boolean
*/
public function getPublieMailEtendu()
{
$publieEmail = false;
if ($this->getPreferencesPublication()) {
$publieEmail = $this->getPreferencesPublication()->getPubliEmail();
} else if (!$this->getOppose() && !$this->getListeRougeMail()) {
$publieEmail = true;
}
return $publieEmail;
}
/**
* Set formation2
*
* @param string $formation2
*
* @return AssistantMaternel
*/
public function setFormation2($formation2)
{
$this->formation2_effectuee = $formation2;
return $this;
}
/**
* Get formation2
*
* @return string
*/
public function getFormation2()
{
return $this->formation2_effectuee;
}
/**
* Set dateMajAssmat
*
* @param string $dateMajAssmat
*
* @return AssistantMaternel
*/
public function setDateMajAssmat($dateMajAssmat)
{
$this->date_maj_assmat = $dateMajAssmat;
return $this;
}
/**
* Get dateMajAssmat
*
* @return string
*/
public function getDateMajAssmat()
{
return $this->date_maj_assmat;
}
/**
* Set date_modif_tel_fixe
*
* @param string $dateModifTelFixe
*
* @return AssistantMaternel
*/
public function setDateModifTelFixe($dateModifTelFixe)
{
$this->date_modif_tel_fixe = $dateModifTelFixe;
return $this;
}
/**
* Get date_modif_tel_fixe
*
* @return string
*/
public function getDateModifTelFixe()
{
return $this->date_modif_tel_fixe;
}
/**
* Set date_modif_tel_portable
*
* @param string $dateModifTelPortable
*
* @return AssistantMaternel
*/
public function setDateModifTelPortable($dateModifTelPortable)
{
$this->date_modif_tel_portable = $dateModifTelPortable;
return $this;
}
/**
* Get date_modif_tel_portable
*
* @return string
*/
public function getDateModifTelPortable()
{
return $this->date_modif_tel_portable;
}
/**
* Set date_modif_mail
*
* @param string $dateModifMail
*
* @return AssistantMaternel
*/
public function setDateModifMail($dateModifMail)
{
$this->date_modif_mail = $dateModifMail;
return $this;
}
/**
* Get date_modif_mail
*
* @return string
*/
public function getDateModifMail()
{
return $this->date_modif_mail;
}
/**
* Set archiveDomicile
*
* @param boolean $archiveDomicile
*
* @return AssistantMaternel
*/
public function setEstArchiveDomicile($archiveDomicile)
{
// https://stackoverflow.com/questions/4775294/parsing-a-string-into-a-boolean-value-in-php
$this->archive_domicile = filter_var($archiveDomicile, FILTER_VALIDATE_BOOLEAN);
return $this;
}
/**
* Get archiveDomicile
*
* @deprecated utiliser getArchiveCalculeDomicile
* @return boolean
*/
public function getEstArchiveDomicile()
{
return $this->archive_domicile;
}
/**
* Set archiveMam
*
* @param boolean $archiveMam
*
* @return AssistantMaternel
*/
public function setEstArchiveMam($archiveMam)
{
// https://stackoverflow.com/questions/4775294/parsing-a-string-into-a-boolean-value-in-php
$this->archive_mam = filter_var($archiveMam, FILTER_VALIDATE_BOOLEAN);
return $this;
}
/**
* Get archiveMam
* @deprecated utiliser getArchiveCalculeMam
*
* @return boolean
*/
public function getEstArchiveMam()
{
return $this->archive_mam;
}
/**
* Get archiveMam AND archiveDomicile
* @deprecated utiliser getArchiveCalcule
* @return boolean
*/
public function getEstArchive()
{
return $this->archive_mam && $this->archive_domicile;
}
/**
* Get archive agrégé pour lieu domicile
*
* @return boolean
*/
public function getArchiveCalculeDomicile()
{
return $this->archive_domicile || ($this->formation1_effectuee !== null && !$this->formation1_effectuee) || ($this->creche !== null && $this->creche) || ($this->cta_dom !== null && $this->cta_dom) || ($this->suspension_dom !== null && $this->suspension_dom);
}
/**
* Get archive agrégé pour lieu MAM
*
* @return boolean
*/
public function getArchiveCalculeMam()
{
return $this->archive_mam || ($this->formation1_effectuee !== null && !$this->formation1_effectuee) || ($this->creche !== null && $this->creche) || ($this->cta_mam !== null && $this->cta_mam) || ($this->suspension_mam !== null && $this->suspension_mam);
}
/**
* Get archive agrégé by id Lieu Accueil
*
* @return boolean
*/
public function getArchiveCalculeByLieuAccueil($idLieuAccueil)
{
if ($idLieuAccueil == EnumLieuAccueil::MAM) {
return $this->getArchiveCalculeMam();
} elseif ($idLieuAccueil == EnumLieuAccueil::DOMICILE) {
return $this->getArchiveCalculeDomicile();
}
}
/**
* Get suspension by id Lieu Accueil
*
* @return boolean
*/
public function getEstSuspensionByLieuAccueil($idLieuAccueil)
{
if ($idLieuAccueil == EnumLieuAccueil::MAM) {
return $this->suspension_mam;
} elseif ($idLieuAccueil == EnumLieuAccueil::DOMICILE) {
return $this->suspension_dom;
}
}
/**
* Get CTA by id Lieu Accueil
*
* @return boolean
*/
public function getEstCessationByLieuAccueil($idLieuAccueil)
{
if ($idLieuAccueil == EnumLieuAccueil::MAM) {
return $this->cta_mam;
} elseif ($idLieuAccueil == EnumLieuAccueil::DOMICILE) {
return $this->cta_dom;
}
}
/**
* Set formation1_effectuee
*
* @param boolean $formation1
*
* @return AssistantMaternel
*/
public function setEstFormation1Effecuee($formation1)
{
// https://stackoverflow.com/questions/4775294/parsing-a-string-into-a-boolean-value-in-php
$this->formation1_effectuee = filter_var($formation1, FILTER_VALIDATE_BOOLEAN);
return $this;
}
/**
* Get formation1_effectuee
*
* @return boolean
*/
public function getEstFormation1Effectuee()
{
return $this->formation1_effectuee;
}
/**
* Set creche
*
* @param boolean $creche
*
* @return AssistantMaternel
*/
public function setEstCreche($creche)
{
// https://stackoverflow.com/questions/4775294/parsing-a-string-into-a-boolean-value-in-php
$this->creche = filter_var($creche, FILTER_VALIDATE_BOOLEAN);
return $this;
}
/**
* Get creche
*
* @return boolean
*/
public function getEstCreche()
{
return $this->creche;
}
/**
* Set cessation_dom
*
* @param boolean $cta_dom
*
* @return AssistantMaternel
*/
public function setEstCessationDom($cta_dom)
{
// https://stackoverflow.com/questions/4775294/parsing-a-string-into-a-boolean-value-in-php
$this->cta_dom = filter_var($cta_dom, FILTER_VALIDATE_BOOLEAN);
return $this;
}
/**
* Get cessation_dom
*
* @return boolean
*/
public function getEstCessationDom()
{
return $this->cta_dom;
}
/**
* Set cta_mam
*
* @param boolean $cta_mam
*
* @return AssistantMaternel
*/
public function setEstCessationMam($cta_mam)
{
// https://stackoverflow.com/questions/4775294/parsing-a-string-into-a-boolean-value-in-php
$this->cta_mam = filter_var($cta_mam, FILTER_VALIDATE_BOOLEAN);
return $this;
}
/**
* Get cta_mam
*
* @return boolean
*/
public function getEstCessationMam()
{
return $this->cta_mam;
}
/**
* Set suspension_dom
*
* @param boolean $suspension_dom
*
* @return AssistantMaternel
*/
public function setEstSuspensionDom($suspension_dom)
{
// https://stackoverflow.com/questions/4775294/parsing-a-string-into-a-boolean-value-in-php
$this->suspension_dom = filter_var($suspension_dom, FILTER_VALIDATE_BOOLEAN);
return $this;
}
/**
* Get suspension_dom
*
* @return boolean
*/
public function getEstSuspensionDom()
{
return $this->suspension_dom;
}
/**
* Set suspension_mam
*
* @param boolean $suspension_mam
*
* @return AssistantMaternel
*/
public function setEstSuspensionMam($suspension_mam)
{
// https://stackoverflow.com/questions/4775294/parsing-a-string-into-a-boolean-value-in-php
$this->suspension_mam = filter_var($suspension_mam, FILTER_VALIDATE_BOOLEAN);
return $this;
}
/**
* Get suspension_mam
*
* @return boolean
*/
public function getEstSuspensionMam()
{
return $this->suspension_mam;
}
/**
* Statut Archive agrégat
* formation1 pas faite, en creche, archive (dom/mam), cessation (dom/mam), suspension (dom/mam)
* nécessite cta et suspension remis à null si lieu d'accueil pas agréé
*
* @return boolean
*/
public function getArchiveCalcule()
{
return ($this->archive_mam && $this->archive_domicile) || ($this->formation1_effectuee !== null && !$this->formation1_effectuee) || ($this->creche !== null && $this->creche) || ($this->cta_dom !== null && $this->cta_dom) || ($this->cta_mam !== null && $this->cta_mam) || ($this->suspension_dom !== null && $this->suspension_dom) || ($this->suspension_mam !== null && $this->suspension_mam)
;
}
/**
* Motif du statut archivé
* formation1 pas faite, en creche, archive (dom/mam), cessation (dom/mam), suspension (dom/mam)
* nécessite cta et suspension remis à null si lieu d'accueil pas agréé
*
* @return string
*/
public function getArchiveMotif()
{
if ($this->formation1_effectuee !== null && !$this->formation1_effectuee) {
return 'Formation 1 non effectuée';
}
if ($this->creche !== null && $this->creche) {
return 'Exerce en crèche';
}
if ($this->suspension_dom !== null && $this->suspension_dom) {
return 'Suspension Agrément Domicile';
}
if ($this->suspension_mam !== null && $this->suspension_mam) {
return 'Suspension Agrément MAM';
}
if ($this->cta_dom !== null && $this->cta_dom) {
return 'Cessation temporaire Agrément Domicile';
}
if ($this->cta_mam !== null && $this->cta_mam) {
return 'Cessation temporaire Agrément MAM';
}
if ($this->archive_mam && $this->archive_domicile) {
return 'Archivé';
}
return 'en activité';
}
/**
* Motif du statut archivé
* formation1 pas faite, en creche, archive (dom/mam), cessation (dom/mam), suspension (dom/mam)
* nécessite cta et suspension remis à null si lieu d'accueil pas agréé
*
* @return string
*/
public function getArchiveLabelBadge()
{
if ($this->formation1_effectuee !== null && !$this->formation1_effectuee) {
return 'Archivé : Formation';
}
if ($this->creche !== null && $this->creche) {
return 'Archivé : Crèche';
}
if ($this->suspension_dom !== null && $this->suspension_dom || $this->suspension_mam !== null && $this->suspension_mam) {
return 'Archivé : Suspension';
}
if ($this->cta_dom !== null && $this->cta_dom || $this->cta_mam !== null && $this->cta_mam) {
return 'Archivé : CTA';
}
if ($this->archive_mam && $this->archive_domicile) {
return 'Archivé';
}
return '';
}
/**
* Set supprime
*
* @param boolean $supprime
*
* @return AssistantMaternel
*/
public function setSupprime($supprime)
{
// https://stackoverflow.com/questions/4775294/parsing-a-string-into-a-boolean-value-in-php
$this->supprime = filter_var($supprime, FILTER_VALIDATE_BOOLEAN);
return $this;
}
/**
* Get supprime
*
* @return boolean
*/
public function getSupprime()
{
return $this->supprime;
}
/**
* Set supprime_domicile
*
* @param boolean $supprime_domicile
*
* @return AssistantMaternel
*/
public function setSupprimeDomicile($supprime_domicile)
{
$this->supprime_domicile = filter_var($supprime_domicile, FILTER_VALIDATE_BOOLEAN);
return $this;
}
/**
* Get supprime_domicile
*
* @return boolean
*/
public function getSupprimeDomicile()
{
return $this->supprime_domicile;
}
/**
* Set supprime_mam
*
* @param boolean $supprime_mam
*
* @return AssistantMaternel
*/
public function setSupprimeMAM($supprime_mam)
{
$this->supprime_mam = filter_var($supprime_mam, FILTER_VALIDATE_BOOLEAN);
return $this;
}
/**
* Get supprime_domicile
*
* @return boolean
*/
public function getSupprimeMAM()
{
return $this->supprime_mam;
}
/**
* Get supprime by id Lieu Accueil
*
* @return boolean
*/
public function getEstSupprimeByLieuAccueil($idLieuAccueil)
{
if ($idLieuAccueil == EnumLieuAccueil::MAM) {
return $this->supprime_mam;
} elseif ($idLieuAccueil == EnumLieuAccueil::DOMICILE) {
return $this->supprime_domicile;
}
}
/**
* Set utilisateur
*
* @param Utilisateur $utilisateur
*
* @return AssistantMaternel
*/
public function setUtilisateur($utilisateur)
{
$this->utilisateur = $utilisateur;
return $this;
}
/**
* Get utilisateur
*
* @return Utilisateur
*/
public function getUtilisateur()
{
return $this->utilisateur;
}
/**
* Get puericultrice
*
* @return Utilisateur
*/
public function getPuericultrice()
{
return $this->puericultrice;
}
/**
* Set puericultrice
*
* @param Utilisateur $puericultrice
*
* @return AssistantMaternel
*/
public function setPuericultrice($puericultrice)
{
$this->puericultrice = $puericultrice;
return $this;
}
/**
* Set participe
*
* @param boolean $participe
*
* @return AssistantMaternel
*/
public function setParticipe($participe)
{
$this->participe = filter_var($participe, FILTER_VALIDATE_BOOLEAN);
return $this;
}
/**
* Get participe
*
* @return boolean
*/
public function getParticipe()
{
return $this->participe;
}
/**
* Set oppose
*
* @param boolean $oppose
*
* @return AssistantMaternel
*/
public function setOppose($oppose)
{
$this->oppose = filter_var($oppose, FILTER_VALIDATE_BOOLEAN);
return $this;
}
/**
* Get oppose
*
* @return boolean
*/
public function getOppose()
{
return $this->oppose;
}
/**
* Set consent = !oppose
*
* @param boolean $consent
*
* @return AssistantMaternel
*/
public function setConsent($consent)
{
$this->oppose = !filter_var($consent, FILTER_VALIDATE_BOOLEAN);
return $this;
}
/**
* Get consent = !oppose
*
* @return boolean
*/
public function getConsent()
{
return !$this->oppose;
}
/**
* Has agrément en cours de validité by lieu d'accueil passé en paramètre
* @param integer $idLieuAccueil lieu de l'accueil EnumLieuAccueil
* @return boolean
*/
public function hasAgrementEnCoursByLieuAccueil($idLieuAccueil, $targetDate = null)
{
if (array_search($idLieuAccueil, EnumLieuAccueil::getAvailableLieuxAccueils()) === false) {
throw new \Exception("Lieu d'accueil non défini : $idLieuAccueil");
}
if ($targetDate == null) {
$targetDate = new \DateTime("tomorrow midnight");
}
foreach ($this->agrements as $agrement) {
if ($idLieuAccueil == $agrement->getIdLieuAccueil()) {
if (
$idLieuAccueil == EnumLieuAccueil::MAM && $this->date_fin_agrement_mam != null && $this->date_fin_agrement_mam >= $targetDate
) {
return true;
} elseif (
$idLieuAccueil == EnumLieuAccueil::DOMICILE && $this->date_fin_agrement_domicile != null && $this->date_fin_agrement_domicile >= $targetDate
) {
return true;
}
}
}
return false;
}
/**
* Has agrément en cours
* @return boolean
*/
public function hasAgrementEnCours()
{
return $this->hasAgrementEnCoursByLieuAccueil(EnumLieuAccueil::DOMICILE) || $this->hasAgrementEnCoursByLieuAccueil(EnumLieuAccueil::MAM);
}
/**
* Has agrément by lieu d'accueil passé en paramètre
* @param integer $lieuAccueil lieu de l'accueil EnumLieuAccueil
* @return boolean
*/
public function hasAgrementByLieuAccueil($lieuAccueil)
{
$lieuAccueilTrouve = false;
foreach ($this->agrements as $agrement) {
if ($lieuAccueil == $agrement->getIdLieuAccueil()) {
$lieuAccueilTrouve = true;
break;
}
}
return $lieuAccueilTrouve;
}
/**
* Has places by lieu d'accueil passé en paramètre
* @param integer $lieuAccueil lieu de l'accueil EnumLieuAccueil
* @return boolean
*/
public function hasPlacesByLieuAccueil($lieuAccueil)
{
$lieuAccueilTrouve = false;
foreach ($this->agrements as $agrement) {
if ($lieuAccueil == $agrement->getIdLieuAccueil()) {
$lieuAccueilTrouve = true;
break;
}
}
return $lieuAccueilTrouve;
}
/**
* Indique s'il existe au moins un accueil en cours pour un agrément échu
*/
public function hasAccueilEnCoursEtAgrementEchu($targetDate = null)
{
$lieuxAgrees = $this->getLieuxAccueilAgrees();
foreach ($lieuxAgrees as $idLieu => $lieu) {
$accEnCours = $this->getAccueilsByLieuAndActif($idLieu, true, $targetDate);
$agremEnCours = $this->hasAgrementEnCoursByLieuAccueil($idLieu, $targetDate);
if ($accEnCours && !$agremEnCours) {
return true;
}
}
return false;
}
/**
* Indique s'il existe au moins un accueil en cours pour un agrément échu
*/
public function hasAccueilEnCoursEtArchive()
{
$lieuxAgrees = $this->getLieuxAccueilAgrees();
foreach ($lieuxAgrees as $idLieu => $lieu) {
$accEnCours = $this->getAccueilsByLieuAndActif($idLieu, true);
$estArchiveLieu = $this->getArchiveCalculeByLieuAccueil($idLieu);
if ($accEnCours && $estArchiveLieu) {
return true;
}
}
return false;
}
/**
* Obtient la liste des agréments avec un nombre de places non nul
* @return array
*/
public function getAgrementsWithPlaces()
{
$agremWithPlaces = array();
foreach ($this->agrements as $agrement) {
if ($agrement->getNombrePlaces() > 0) {
$agremWithPlaces[] = $agrement;
}
}
return $agremWithPlaces;
}
/**
* Obtient le nombre total de places agréées
* @return array
*/
public function getNombrePlacesTotal()
{
$agremWithPlaces = 0;
foreach ($this->agrements as $agrement) {
$agremWithPlaces += $agrement->getNombrePlaces();
}
return $agremWithPlaces;
}
/**
* Obtient la liste des lieux d'accueil avec un nombre de places non nul
* @return array
*/
public function getLieuxAccueilAgrees()
{
$lieuxAccueilAgrees = array();
foreach ($this->agrements as $agrement) {
if ($agrement->getNombrePlaces() > 0) {
$lieuxAccueilAgrees[$agrement->getLieuAccueil()->getId()] = $agrement->getLieuAccueil();
}
}
return $lieuxAccueilAgrees;
}
/**
* Obtient la liste des types d'accueil avec un nombre de places non nul
* @return array
*/
public function getTypesAccueilAgrees()
{
$typesAccueilAgrees = array();
foreach ($this->agrements as $agrement) {
if ($agrement->getNombrePlaces() > 0) {
$typesAccueilAgrees[$agrement->getTypeAccueil()->getId()] = $agrement->getTypeAccueil();
}
}
return $typesAccueilAgrees;
}
/**
* Obtient la liste des tranches d'ages agréées : avec un nombre de places non nul pour l'agrément
* @return array
*/
public function getTranchesAgeAgrees()
{
$tranches = array();
foreach ($this->agrements as $agrement) {
if ($agrement->getNombrePlaces() > 0) {
$tranches[] = $agrement->getTrancheAge();
}
}
return $tranches;
}
/**
* Obtient la liste des agréments pour un lieu d'accueil (même sans place)
* @return array
*/
public function getAgrementsByLieu($lieuAccueil)
{
$agrems = array();
foreach ($this->agrements as $agrement) {
if ($lieuAccueil == $agrement->getIdLieuAccueil()) {
$agrems[] = $agrement;
}
}
return $agrems;
}
/* * *
* Fonction de tri par ordre croissant de tranche d'age
*/
function orderByTrancheAge($a, $b)
{
$dateMinA = date_sub(new \DateTime(), $a->getTrancheAge()->getAgeMin());
$dateMinB = date_sub(new \DateTime(), $b->getTrancheAge()->getAgeMin());
return $dateMinB <=> $dateMinA;
}
/**
* Obtient la liste des agréments avec un nombre de places non nul pour un lieu d'accueil
* @return array
*/
public function getAgrementsWithPlacesByLieu($lieuAccueil)
{
$agremWithPlaces = array();
foreach ($this->agrements as $agrement) {
if ($lieuAccueil == $agrement->getIdLieuAccueil() && $agrement->getNombrePlaces() > 0) {
$agremWithPlaces[] = $agrement;
}
}
uasort($agremWithPlaces, array($this, 'orderByTrancheAge')); //tri utilisé pour tous les écrans où on liste les tranches d'âge agrées
return $agremWithPlaces;
}
/**
* Obtient la liste des tranches d'ages agréées :
* avec un nombre de places non nul pour l'agrément correspondant un lieu d'accueil fourni
* @return array
*/
public function getTranchesAgeAgreesByIdLieu($idLieuAccueil)
{
$tranches = array();
foreach ($this->agrements as $agrement) {
if ($idLieuAccueil == $agrement->getIdLieuAccueil() && $agrement->getNombrePlaces() > 0) {
$tranches[] = $agrement->getTrancheAge();
}
}
return $tranches;
}
/**
* Obtient la liste des accueils pour un lieu d'accueil
* et selon s'il est actif ou non à l'éventuelle date fournie
* @param type $idLieuAccueil identifiant du lieu d'accueil
* @param type $actif indique si l'accueil doit être actif à la $targetDate ou non
* @param type $targetDate
* @return array
*/
public function getAccueilsByLieuAndActif($idLieuAccueil, $actif, $targetDate = null)
{
if ($targetDate == null) {
$targetDate = new \DateTime();
}
$accueilsByLieu = array();
foreach ($this->accueils as $accueil) {
if (
$idLieuAccueil == $accueil->getLieuAccueil()->getId() &&
!($actif xor ( $accueil->getDateFin() === null || $accueil->getDateFin() >= $targetDate))
) {
$accueilsByLieu[] = $accueil;
}
}
return $accueilsByLieu;
}
public function getAccueilsByLieu($idLieuAccueil)
{
$accueilsByLieu = array();
foreach ($this->accueils as $accueil) {
if ($idLieuAccueil == $accueil->getLieuAccueil()->getId()) {
$accueilsByLieu[] = $accueil;
}
}
return $accueilsByLieu;
}
public function getAccueilsByActif($actif, $targetDate = null)
{
if ($targetDate == null) {
$targetDate = new \DateTime();
}
$accueilsByActif = array();
foreach ($this->accueils as $accueil) {
if (!($actif xor ( $accueil->getDateFin() === null || $accueil->getDateFin() >= $targetDate))) {
$accueilsByActif[] = $accueil;
}
}
return $accueilsByActif;
}
/**
* Obtient la liste des enfants de moins de 3 ans à la date fournie (par défaut date du jour si absente)
* @param type $targetDate
* @return array
*/
public function getEnfantsAssmatMoins3Ans($targetDate = null)
{
$enfantsMoins3ans = array();
foreach ($this->enfantsAssmat as $enfant) {
if ($enfant->getAgeAnnees($targetDate) < 3) {
$enfantsMoins3ans[] = $enfant;
}
}
return $enfantsMoins3ans;
}
/**
* Obtient la liste des enfants agés entre 3 et 11 ans à la date fournie (par défaut date du jour si absente)
* @param type $targetDate
* @return array
*/
public function getEnfantsAssmatEntre3et11Ans($targetDate = null)
{
$enfants3a11ans = array();
foreach ($this->enfantsAssmat as $enfant) {
if ($enfant->getAgeAnnees($targetDate) >= 3 && $enfant->getAgeAnnees($targetDate) < 11) {
$enfants3a11ans[] = $enfant;
}
}
return $enfants3a11ans;
}
/**
* Obtient la liste des enfants de moins de 11 ans à la date fournie (par défaut date du jour si absente)
* @param type $targetDate
* @return array
*/
public function getEnfantsAssmatMoins11Ans($targetDate = null)
{
$enfantsMoins11ans = array();
foreach ($this->enfantsAssmat as $enfant) {
if ($enfant->getAgeAnnees($targetDate) < 11) {
$enfantsMoins11ans[] = $enfant;
}
}
return $enfantsMoins11ans;
}
/**
* Obtient la liste des enfants de moins de 3 ans à la date fournie (par défaut date du jour si absente)
* et qui ont été indiqués comme à prendre en compte pour le calcul de dépassement
* @param type $targetDate date à laquelle on calcule l'age de l'enfant
* @return array
*/
public function getEnfantsAssmatMoins3AnsGardes($targetDate = null)
{
$enfantsMoins3ans = array();
foreach ($this->enfantsAssmat as $enfant) {
if ($enfant->getEstGarde() && $enfant->getAgeAnnees($targetDate) < 3) {
$enfantsMoins3ans[] = $enfant;
}
}
return $enfantsMoins3ans;
}
/**
* Obtient la liste des enfants agés entre 3 et 11 ans à la date fournie (par défaut date du jour si absente)
* et qui ont été indiqués comme à prendre en compte pour le calcul de dépassement
* @param type $targetDate date à laquelle on calcule l'age de l'enfant
* @return array
*/
public function getEnfantsAssmatEntre3et11AnsGardes($targetDate = null)
{
$enfants3a11ans = array();
foreach ($this->enfantsAssmat as $enfant) {
if ($enfant->getEstGarde() && $enfant->getAgeAnnees($targetDate) >= 3 && $enfant->getAgeAnnees($targetDate) < 11) {
$enfants3a11ans[] = $enfant;
}
}
return $enfants3a11ans;
}
/**
* Obtient la liste des enfants de moins de 11 ans à la date fournie (par défaut date du jour si absente)
* et qui ont été indiqués comme à prendre en compte pour le calcul de dépassement
* @param type $targetDate date à laquelle on calcule l'age de l'enfant
* @return array
*/
public function getEnfantsAssmatMoins11AnsGardes($targetDate = null)
{
$enfantsMoins11ans = array();
foreach ($this->enfantsAssmat as $enfant) {
if ($enfant->getEstGarde() && $enfant->getAgeAnnees($targetDate) < 11) {
$enfantsMoins11ans[] = $enfant;
}
}
return $enfantsMoins11ans;
}
public function getDepassements()
{
return $this->depassements;
}
/**
* Indique s'il existe au moins un accueil de nuit en cours
*/
public function hasAccueilNuitEncours($targetDate = null)
{
if ($targetDate == null) {
$targetDate = new \DateTime();
}
foreach ($this->accueils as $accueil) {
if ($accueil->getEstNuit() && ($accueil->getDateFin() === null || $accueil->getDateFin() >= $targetDate)) {
return true;
}
}
return false;
}
/**
* Indique s'il existe au moins un accueil atypique en cours
*/
public function hasAccueilAtypiqueEncours($targetDate = null)
{
if ($targetDate == null) {
$targetDate = new \DateTime();
}
foreach ($this->accueils as $accueil) {
if ($accueil->getEstAtypique() && ($accueil->getDateFin() === null || $accueil->getDateFin() >= $targetDate)) {
return true;
}
}
return false;
}
/**
* Indique s'il existe au moins un accueil déclaré avec dérogation en cours
*/
public function hasAccueilDerogationEncours($targetDate = null)
{
if ($targetDate == null) {
$targetDate = new \DateTime();
}
foreach ($this->accueils as $accueil) {
if ($accueil->getEstDerogation() && ($accueil->getDateFin() === null || $accueil->getDateFin() >= $targetDate)) {
return true;
}
}
return false;
}
/*
* Libellé Indiquant si l'assmat a un unique accueil et qu'il s'agit d'un premier accueil :libellé
* @return string
*/
public function libelleEstPremierAccueil()
{
// Les accueils de l'assmat
// NB : penser au lazy loading si on utilise cette fonction dans une boucle
// (faire jointure sur assmat.accueils)
$accueilsAM = $this->getAccueils();
if (count($accueilsAM) == 1) {
if ($accueilsAM[0]->getEstPremierAccueil()) {
return '1er accueil';
} else {
return 'Unique accueil répertorié';
}
} else {
return '';
}
}
/**
* Set preferences_publication
*
* @param PreferencesPublication $preferences_publication
*
* @return AssistantMaternel
*/
public function setPreferencesPublication($preferences_publication)
{
$this->preferences_publication = $preferences_publication;
return $this;
}
/**
* Get preferences_publication
*
* @return PreferencesPublication
*/
public function getPreferencesPublication()
{
return $this->preferences_publication;
}
/**
* Set presentation_assmat
*
* @param PresentationAssmat $presentation_assmat
*
* @return AssistantMaternel
*/
public function setPresentationAssmat($presentation_assmat)
{
$this->presentation_assmat = $presentation_assmat;
return $this;
}
/**
* Get presentation_assmat
*
* @return PresentationAssmat
*/
public function getPresentationAssmat()
{
return $this->presentation_assmat;
}
/**
* Get dispos_public
*
* @return array
*/
public function getDisposPublic()
{
return $this->dispos_public;
}
/**
* Get dispos_public
* tri pour pouvoir afficher dans le bon ordre le planning de dispo juste après création
* @param LieuAccueil $lieuAccueil
* @return array
*/
public function getDisposPublicByLieuAccueil($lieuAccueil)
{
$criteria = Criteria::create()
->andWhere(Criteria::expr()->eq('lieu_accueil', $lieuAccueil))
->orderBy(array("tranche_horaire" => Criteria::ASC, "jour_semaine" => Criteria::ASC));
return $this->getDisposPublic()->matching($criteria);
}
/**
* Get Nombre de places disponibles au pire
* Calculé sur la base des dispos_public
*
* @param LieuAccueil $lieuAccueil
* @param TrancheAge $trancheAge
* @return integer
*/
public function getNombrePlacesDispoByLieuEtTrancheAge($lieuAccueil, $trancheAge)
{
$criteria = Criteria::create()
->andWhere(Criteria::expr()->eq('lieu_accueil', $lieuAccueil))
->andWhere(Criteria::expr()->eq('tranche_age', $trancheAge))
->andWhere(Criteria::expr()->neq('nombre_places_libres', null))
->orderBy(['nombre_places_libres' => Criteria::ASC])
->setFirstResult(0);
$minimum = $this->getDisposPublic()->matching($criteria)[0];
return $minimum === null ? 0 : $minimum->getNombrePlacesLibres();
}
/**
* Générer toutes les dispos public manquantes, avec 0 places dispo
* en fonction de periode, type, lieu accuail et de la liste de tranches d'ages, jours et plages horaires fournies
*
* @param Periode $periode periode
* @param TypeAccueil $typeAccueil type d'accueil
* @param LieuAccueil $lieuAccueil lieu d'accueil agréé pour l'assmat
* @param array $tranchesAge tranches d'age
* @param array $jours jours de la semaine (lundi-dimanche)
* @param array $horaires plages horaires actives
* @param FrequenceDispo $frequenceOccupe objt pour la frequence occupé
* @return AssistantMaternel
*/
public function genererDisposPublic(
Periode $periode, TypeAccueil $typeAccueil, LieuAccueil $lieuAccueil, array $tranchesAge, array $jours, array $horaires, FrequenceDispo $frequenceOccupe
)
{
foreach ($tranchesAge as $t) {
foreach ($horaires as $h) {
foreach ($jours as $j) {
// Rechercher si la dispo pour ce jour/semaine existe déjà dans la liste des dispos
$dispo_existe = $this->dispos_public->filter(function (DispoPublicAssmat $dispo) use ($periode, $typeAccueil, $lieuAccueil, $t, $h, $j) {
return $dispo->getPeriode()->getId() === $periode->getId() &&
$dispo->getTypeAccueil()->getId() === $typeAccueil->getId() &&
$dispo->getLieuAccueil()->getId() === $lieuAccueil->getId() &&
$dispo->getTrancheAge()->getId() === $t->getId() &&
$dispo->getTrancheHoraire()->getId() === $h->getId() &&
$dispo->getJourSemaine()->getId() === $j->getId();
});
// Si aucune dispo saisie pour ce jour/semaine, on la génère
if (!count($dispo_existe)) {
$this->dispos_public->add(new DispoPublicAssmat($this, $periode, $typeAccueil, $lieuAccueil, $t, $h, $j, $frequenceOccupe));
}
// La persistence des nouvelles données se fait en dehors de la classe de l'entité
}
}
}
return $this;
}
/**
* renvoie le tableau des dispos publiques telles que définies par les déclarations d'accueil
*
* @return array
*/
public function getSyncedDisposPublic($frequenceOccupe)
{
foreach ($this->dispos as $dg) {
// Rechercher si la dispo $dg (issue gda) pour ce jour/semaine existe déjà dans la liste des dispos publiques
$dispo_existe = $this->dispos_public->filter(function (DispoPublicAssmat $dispo) use ($dg) {
return $dispo->getPeriode()->getId() === $dg->getPeriode()->getId() &&
$dispo->getIdTypeAccueil() === $dg->getIdTypeAccueil() &&
$dispo->getIdLieuAccueil() === $dg->getIdLieuAccueil() &&
$dispo->getTrancheAge()->getId() === $dg->getTrancheAge()->getId() &&
$dispo->getTrancheHoraire()->getId() === $dg->getTrancheHoraire()->getId() &&
$dispo->getJourSemaine()->getId() === $dg->getJourSemaine()->getId();
});
if ($dispo_existe != null && !$dispo_existe->isEmpty()) {
if ($dispo_existe->first()->getNombrePlacesLibres() !== null) {
//on change le nombre de places libres seulement si l'assmat n'avait pas indiqué le créneau comme non travaillé
$dispo_existe->first()->setNombrePlacesLibres($dg->getNombrePlacesLibres());
}
} else {
// Si aucune dispo saisie pour ce periode/type/lieu/age/jour/horaire, on la génère
$newDispo = new DispoPublicAssmat(
$this, $dg->getPeriode(), $dg->getTypeAccueil(), $dg->getLieuAccueil(), $dg->getTrancheAge(), $dg->getTrancheHoraire(), $dg->getJourSemaine(), $frequenceOccupe
);
$newDispo->setNombrePlacesLibres($dg->getNombrePlacesLibres());
$this->dispos_public->add($newDispo);
}
}
// La persistence des nouvelles données se fait en dehors de la classe de l'entité
return $this->dispos_public;
}
/**
* Get dispos_prev
*
* @return array
*/
public function getDisposPrev()
{
return $this->dispos_prev;
}
/**
* Get dispos_prev
*
* @return array
*/
public function getDisposPrevByLieuAccueil($idLieuAccueil)
{
return $this->dispos_prev->filter(function ($dispo_prev) use ($idLieuAccueil) {
return $dispo_prev->getLieuAccueil()->getId() == $idLieuAccueil;
});
}
/**
* Get dispos_vacances
*
* @return array
*/
public function getDisposVacances()
{
return $this->dispos_vacances;
}
/**
* Générer toutes les dispos vacances manquantes, avec 0 places dispos
* en fonction de la liste de semaines et de jours fournies
*
* @param $semaines Les SemaineVacances pour lesquelles générer les dispos
* @param $jours Enum des jours de la semaine (lundi-dimanche)
* @return AssistantMaternel
*/
public function genererDisposVacances(array $semaines, array $jours)
{
// On parcourt chaque semaine et chaque jour
foreach ($semaines as $s) {
foreach ($jours as $j) {
// Rechercher si la dispo pour ce jour/semaine existe déjà dans la liste des dispos
$dispo_existe = $this->dispos_vacances->filter(function (DispoVacancesAssmat $dispo) use ($s, $j) {
return $dispo->getSemaine()->getId() === $s->getId() && $dispo->getJour() === $j;
});
// Si aucune dispo saisie pour ce jour/semaine, on la génère
if (!count($dispo_existe)) {
$this->dispos_vacances->add(new DispoVacancesAssmat($this, $s, $j));
}
// La persistence des nouvelles données se fait en dehors de la classe de l'entité
}
}
return $this;
}
/**
* isElligiblePremierAccueil
*
* Indique si l'assmat est dans une situation permettant de déclarer un accueil comme étant le premier
* C'est le cas si l'assmat n'a jamais déclaré d'accueil
* Ou si tous ses accueils existants ont été déclarés avant sa date de premier agément [EVO 24 08/2022]
*
* @return boolean
*/
public function isElligiblePremierAccueil()
{
$accueilsAM = $this->getAccueils();
$arrayAccueils = array();
foreach ($accueilsAM as $accueil) {
$arrayAccueils[] = $accueil;
}
if (!count($accueilsAM)) {
//aucun accueil
return true;
}
$accueils_dom_posterieur = false; // vrai si est aggréé à domicile et qu'il existe au moins un accueil ayant débuté après
$accueils_mam_posterieur = false; // vrai si est aggréé en mam et qu'il existe au moins un accueil ayant débuté après
if ($this->date_debut_agrement_domicile) {
$accueils_dom_posterieur = count(array_filter($arrayAccueils, function ($acc) {
return $acc->getDateDebut() > $this->date_debut_agrement_domicile && $acc->getLieuAccueil()->getId() == EnumLieuAccueil::DOMICILE;
}));
}
if ($this->date_debut_agrement_mam) {
$accueils_mam_posterieur = count(array_filter($arrayAccueils, function ($acc) {
return $acc->getDateDebut() > $this->date_debut_agrement_mam && $acc->getLieuAccueil()->getId() == EnumLieuAccueil::MAM;
}));
}
if (!$accueils_dom_posterieur && !$accueils_mam_posterieur) {
//aucun accueil posterieur à la date de re-agrément ni à domicile ni en mam
return true;
}
return false;
}
// </editor-fold>
// <editor-fold desc="Méthodes publiques">
/**
* Constructor
*/
public function __construct()
{
}
public function __toString()
{
return json_encode($this->jsonSerialize());
}
/*
* Implémentation de JsonSerializable
* Ne liste que les champs modifiables par les utilisateurs
*/
public function jsonSerialize()
{
return [
'id' => $this->id,
'email' => $this->email,
'archive_domicile' => $this->archive_domicile,
'archive_mam' => $this->archive_mam,
'supprime' => $this->supprime,
'oppose' => $this->oppose,
'puericultrice' => $this->puericultrice === null ? null : $this->puericultrice->jsonSerialize(),
'enfantsAssmat' => array_map(function ($e) {
return $e->jsonSerialize();
}, is_null($this->enfantsAssmat) ? [] : $this->enfantsAssmat->toArray())
];
}
/**
* Obtient une nouvelle instance d'AssistantMaternel, initialisée à partir du tableau associatif fourni en paramètre
*
* @param array $data
* @return AssistantMaternel
*/
public static function createFromArray(array $data)
{
$newInstance = new AssistantMaternel();
return $newInstance->initFromArray($data);
}
/**
* mappe les propriétés sur l'instance à partir d'un tableau associatif
*
* @param array $data
* @return void
*/
public function initFromArray(array $data)
{
foreach ($data as $prop => $value) {
$this->{$prop} = $value;
}
return $this;
}
// </editor-fold>
}