src/Entity/AssistantMaternel/AssistantMaternel.php line 2459

Open in your IDE?
  1. <?php
  2. namespace App\Entity\AssistantMaternel;
  3. use \JsonSerializable;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\Common\Collections\Criteria;
  6. use App\Entity\MAM\MAM;
  7. use App\Entity\Commun\Utilisateur;
  8. use App\Entity\Referentiel\SecteurPmi;
  9. use App\Entity\Referentiel\Commune;
  10. use App\Entity\Referentiel\Canton;
  11. use App\Entity\Referentiel\EnumLieuAccueil;
  12. use App\Entity\Referentiel\Periode;
  13. use App\Entity\Referentiel\LieuAccueil;
  14. use App\Entity\Referentiel\TypeAccueil;
  15. use \App\Entity\Referentiel\FrequenceDispo;
  16. use App\Entity\OffreAccueil\DispoPublicAssmat;
  17. use App\Entity\OffreAccueil\DispoVacancesAssmat;
  18. use App\Entity\OffreAccueil\PreferencesPublication;
  19. use Symfony\Component\Validator\Constraints as Assert;
  20. /**
  21.  * @ORM\Entity(repositoryClass="App\Repository\AssistantMaternel\AssistantMaternelRepository")
  22.  * @ORM\Table(
  23.  *      name="efc.assistant_maternel",
  24.  *      uniqueConstraints={@ORM\UniqueConstraint(name="assistant_maternel_un",columns={"id_fonctionnel"})},
  25.  *      indexes={@ORM\Index(name="id_fonc_idx", columns={"id_fonctionnel"}),@ORM\Index(name="assmat_email_idx", columns={"email"})}
  26.  * )
  27.  */
  28. class AssistantMaternel implements JsonSerializable
  29. {
  30.     // <editor-fold defaultstate="collapsed" desc="Champs privés">
  31.     // use App\Entity\Commun\PersonneTrait;
  32.     use \App\Entity\Commun\IdTrait;
  33.     use \App\Entity\Commun\DateNaissanceTrait;
  34.     use \App\Entity\Commun\PhotosTrait;
  35.     /**
  36.      * @ORM\Column(type="string", length=70)
  37.      */
  38.     private $id_fonctionnel;
  39.     /**
  40.      * @ORM\Column(type="string", length=50)
  41.      */
  42.     private $nom_famille;
  43.     /**
  44.      * @ORM\Column(type="string", length=50, nullable=true)
  45.      */
  46.     private $nom_naissance;
  47.     /**
  48.      * @ORM\Column(type="string", length=50)
  49.      */
  50.     private $prenom;
  51.     /**
  52.      * @ORM\Column(type="date", nullable=true)
  53.      */
  54.     private $date_naissance;
  55.     /**
  56.      * @ORM\Column(type="string", length=100)
  57.      */
  58.     private $adresse;
  59.     /**
  60.      * @ORM\Column(type="string", length=100, nullable=true)
  61.      */
  62.     private $adresse_complement;
  63.     /**
  64.      * @ORM\Column(type="string", length=5)
  65.      */
  66.     private $code_postal;
  67.     /**
  68.      * @ORM\Column(type="string", length=100, nullable=true)
  69.      */
  70.     private $bureau_distributeur;
  71.     /**
  72.      * @ORM\Column(type="string", length=10, nullable=true)
  73.      */
  74.     private $tel_fixe;
  75.     /**
  76.      * @ORM\Column(type="string", length=10, nullable=true)
  77.      */
  78.     private $tel_portable;
  79.     /**
  80.      * @ORM\Column(type="datetime", nullable=true)
  81.      */
  82.     private $date_modif_tel_fixe;
  83.     /**
  84.      * @ORM\Column(type="datetime", nullable=true)
  85.      */
  86.     private $date_modif_tel_portable;
  87.     /**
  88.      * @ORM\Column(type="datetime", nullable=true)
  89.      */
  90.     private $date_modif_mail;
  91.     /**
  92.      * @ORM\Column(type="boolean")
  93.      */
  94.     private $liste_rouge_tel_fixe;
  95.     /**
  96.      * @ORM\Column(type="boolean")
  97.      */
  98.     private $liste_rouge_tel_portable;
  99.     /**
  100.      * @ORM\Column(type="boolean")
  101.      */
  102.     private $liste_rouge_mail;
  103.     /**
  104.      * @ORM\Column(type="date", nullable=true)
  105.      */
  106.     private $date_premier_agrement_domicile;
  107.     /**
  108.      * @ORM\Column(type="date", nullable=true)
  109.      */
  110.     private $date_debut_agrement_domicile;
  111.     /**
  112.      * @ORM\Column(type="date", nullable=true)
  113.      */
  114.     private $date_fin_agrement_domicile;
  115.     /**
  116.      * @ORM\Column(type="date", nullable=true)
  117.      */
  118.     private $date_premier_agrement_mam;
  119.     /**
  120.      * @ORM\Column(type="date", nullable=true)
  121.      */
  122.     private $date_debut_agrement_mam;
  123.     /**
  124.      * @ORM\Column(type="date", nullable=true)
  125.      */
  126.     private $date_fin_agrement_mam;
  127.     /**
  128.      * @ORM\Column(type="boolean")
  129.      */
  130.     private $participe;
  131.     /**
  132.      * @ORM\Column(type="boolean")
  133.      */
  134.     private $archive_domicile;
  135.     /**
  136.      * @ORM\Column(type="boolean")
  137.      */
  138.     private $archive_mam;
  139.     /**
  140.      * @ORM\Column(type="boolean", nullable=false)
  141.      */
  142.     private $oppose;
  143.     /**
  144.      * @ORM\Column(type="boolean")
  145.      */
  146.     private $supprime;
  147.     /**
  148.      * @ORM\Column(type="boolean")
  149.      */
  150.     private $supprime_domicile;
  151.     /**
  152.      * @ORM\Column(type="boolean")
  153.      */
  154.     private $supprime_mam;
  155.     /**
  156.      * 
  157.      * @var string
  158.      * 
  159.      * @Assert\Email(
  160.      *     message = "L'adresse mail '{{ value }}' n'est pas valide.",
  161.      * )
  162.      * 
  163.      * La regex permet de transmettre une contrainte de validation avec un format plus strict au niveau du navigateur
  164.      * @Assert\Regex(
  165.      *     pattern="/^([a-zA-Z0-9'_\-\.\+]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/",
  166.      *     match=true,
  167.      *     message="L'adresse mail '{{ value }}' n'est pas valide."
  168.      * )
  169.      * @ORM\Column(type="string", length=250, nullable=true)
  170.      */
  171.     private $email;
  172.     /**
  173.      * @ORM\Column(type="boolean", nullable=true)
  174.      */
  175.     private $formation2_effectuee;
  176.     /**
  177.      * @ORM\Column(type="boolean", nullable=true)
  178.      */
  179.     private $formation1_effectuee;
  180.     /**
  181.      * @ORM\Column(type="boolean", nullable=true)
  182.      */
  183.     private $suspension_dom;
  184.     /**
  185.      * @ORM\Column(type="boolean", nullable=true)
  186.      */
  187.     private $suspension_mam;
  188.     /**
  189.      * @ORM\Column(type="boolean", nullable=true)
  190.      */
  191.     private $cta_dom;
  192.     /**
  193.      * @ORM\Column(type="boolean", nullable=true)
  194.      */
  195.     private $cta_mam;
  196.     /**
  197.      * @ORM\Column(type="boolean", nullable=true)
  198.      */
  199.     private $creche;
  200.     /**
  201.      * @ORM\Column(type="boolean", nullable=true)
  202.      */
  203.     private $assistant_familial;
  204.     /**
  205.      * @ORM\Column(type="datetime")
  206.      */
  207.     private $date_maj_departement;
  208.     /**
  209.      * @ORM\Column(type="datetime", nullable=true)
  210.      */
  211.     private $date_maj_assmat;
  212.     /**
  213.      * Le secteur de PMI est nullable car certains départements n'ont pas de secteurs de PMI
  214.      * @ORM\ManyToOne(targetEntity="App\Entity\Referentiel\SecteurPmi", inversedBy="assmats")
  215.      * @ORM\JoinColumn(name="id_secteur_pmi", referencedColumnName="id", nullable=true)
  216.      */
  217.     private $secteur_pmi;
  218.     /**
  219.      * @ORM\ManyToOne(targetEntity="App\Entity\Referentiel\Commune", inversedBy="assmats")
  220.      * @ORM\JoinColumn(name="id_commune", referencedColumnName="id")
  221.      */
  222.     private $commune;
  223.     /**
  224.      * @ORM\ManyToOne(targetEntity="App\Entity\Referentiel\Canton", inversedBy="assmats")
  225.      * @ORM\JoinColumn(name="id_canton", referencedColumnName="id")
  226.      */
  227.     private $canton;
  228.     /**
  229.      * @ORM\ManyToOne(targetEntity="App\Entity\MAM\MAM", inversedBy="assmats")
  230.      * @ORM\JoinColumn(name="id_mam", referencedColumnName="id", nullable=true)
  231.      */
  232.     private $mam;
  233.     /**
  234.      * @ORM\OneToMany(targetEntity="App\Entity\AssistantMaternel\Agrement", mappedBy="assmat")
  235.      */
  236.     private $agrements;
  237.     /**
  238.      * @ORM\OneToMany(targetEntity="App\Entity\GDA\Accueil", mappedBy="assmat")
  239.      * @ORM\OrderBy({"date_debut" = "DESC","date_fin" = "DESC"})
  240.      */
  241.     private $accueils;
  242.     /**
  243.      * Disponiblités issues des déclarations d'accueil du GDA
  244.      * @ORM\OneToMany(targetEntity="App\Entity\GDA\PlanningDispo", mappedBy="assmat")
  245.      */
  246.     private $dispos;
  247.     /**
  248.      * Identifiants de connexion de l'assmat
  249.      * @ORM\OneToOne(targetEntity="App\Entity\Commun\Utilisateur", inversedBy="assistant_maternel")
  250.      * @ORM\JoinColumn(name="id_utilisateur", referencedColumnName="id")
  251.      */
  252.     private $utilisateur;
  253.     /**
  254.      * @ORM\ManyToOne(targetEntity="App\Entity\Commun\Utilisateur")
  255.      * @ORM\JoinColumn(name="id_puericultrice", referencedColumnName="id")
  256.      */
  257.     private $puericultrice;
  258.     /**
  259.      * Propres enfants de l'assistant maternel, utilisé pour le calcul des dépassement pour ses enfants de moins de 11 ans
  260.      * @ORM\OneToMany(targetEntity="App\Entity\AssistantMaternel\EnfantAssmat", mappedBy="assmat")
  261.      * @ORM\OrderBy({"date_naissance" = "DESC"})
  262.      */
  263.     private $enfantsAssmat;
  264.     /**
  265.      * @ORM\OneToMany(targetEntity="App\Entity\GDA\DepassementAssmat", mappedBy="assmat")
  266.      */
  267.     private $depassements;
  268.     /**
  269.      * Préférences de publication site grand public
  270.      * @ORM\OneToOne(targetEntity="App\Entity\OffreAccueil\PreferencesPublication", mappedBy="assmat")
  271.      */
  272.     private $preferences_publication;
  273.     /**
  274.      * Présentation offre d'accueil site grand public
  275.      * @ORM\OneToOne(targetEntity="App\Entity\OffreAccueil\PresentationAssmat", mappedBy="assmat")
  276.      */
  277.     private $presentation_assmat;
  278.     /**
  279.      * Disponiblités publiques de l'assistant maternel, utilisé pour le planning de dispo offre d'accueil site grand public
  280.      * @ORM\OneToMany(targetEntity="App\Entity\OffreAccueil\DispoPublicAssmat", mappedBy="assmat")
  281.      * @ORM\OrderBy({"periode" = "ASC", "type_accueil" = "ASC", "lieu_accueil" = "ASC", "tranche_age" = "ASC", "tranche_horaire" = "ASC", "jour_semaine" = "ASC"})
  282.      */
  283.     private $dispos_public;
  284.     /**
  285.      * Disponiblités prév de l'assistant maternel, utilisé pour l'offre d'accueil site grand public
  286.      * @ORM\OneToMany(targetEntity="App\Entity\OffreAccueil\DispoPrevAssmat", mappedBy="assmat")
  287.      * @ORM\OrderBy({"date_debut" = "ASC"})
  288.      */
  289.     private $dispos_prev;
  290.     /**
  291.      * Disponiblités pendant les vacances de l'assistant maternel, utilisé pour l'offre d'accueil site grand public
  292.      * @ORM\OneToMany(targetEntity="App\Entity\OffreAccueil\DispoVacancesAssmat", mappedBy="assmat")
  293.      * @ORM\OrderBy({"semaine" = "ASC", "jour" = "ASC"})
  294.      */
  295.     private $dispos_vacances;
  296.     /**
  297.      * @ORM\OneToMany(targetEntity="App\Entity\OffreAccueil\Photo", mappedBy="assmat")
  298.      */
  299.     private $photos;
  300.     // </editor-fold>
  301.     // <editor-fold desc="Accesseurs">
  302.     /**
  303.      * Get id_fonctionnel
  304.      *
  305.      * @return string
  306.      */
  307.     public function getIdFonctionnel()
  308.     {
  309.         return $this->id_fonctionnel;
  310.     }
  311.     /**
  312.      * Set secteurPmi
  313.      *
  314.      * @param SecteurPmi $secteurPmi
  315.      *
  316.      * @return AssistantMaternel
  317.      */
  318.     public function setSecteurPmi(SecteurPmi $secteurPmi null)
  319.     {
  320.         $this->secteur_pmi $secteurPmi;
  321.         return $this;
  322.     }
  323.     /**
  324.      * Get secteurPmi
  325.      *
  326.      * @return SecteurPmi
  327.      */
  328.     public function getSecteurPmi()
  329.     {
  330.         return $this->secteur_pmi;
  331.     }
  332.     /**
  333.      * Set commune
  334.      *
  335.      * @param Commune $commune
  336.      *
  337.      * @return AssistantMaternel
  338.      */
  339.     public function setCommune(Commune $commune null)
  340.     {
  341.         $this->commune $commune;
  342.         return $this;
  343.     }
  344.     /**
  345.      * Get commune
  346.      *
  347.      * @return Commune
  348.      */
  349.     public function getCommune()
  350.     {
  351.         return $this->commune;
  352.     }
  353.     /**
  354.      * Get commune fonctionnelle : celle de l'assmat ou celle de la MAM
  355.      *
  356.      * @return Commune
  357.      */
  358.     public function getCommuneFonctionnelle()
  359.     {
  360.         if ($this->mam != null) {
  361.             return $this->mam->getCommune();
  362.         }
  363.         return $this->commune;
  364.     }
  365.     /**
  366.      * Set canton
  367.      *
  368.      * @param Canton $canton
  369.      *
  370.      * @return AssistantMaternel
  371.      */
  372.     public function setCanton(Canton $canton null)
  373.     {
  374.         $this->canton $canton;
  375.         return $this;
  376.     }
  377.     /**
  378.      * Get canton
  379.      *
  380.      * @return Canton
  381.      */
  382.     public function getCanton()
  383.     {
  384.         return $this->canton;
  385.     }
  386.     /**
  387.      * Set MAM
  388.      *
  389.      * @param MAM $mam
  390.      *
  391.      * @return AssistantMaternel
  392.      */
  393.     public function setMAM(MAM $mam null)
  394.     {
  395.         $this->mam $mam;
  396.         return $this;
  397.     }
  398.     /**
  399.      * Get MAM
  400.      *
  401.      * @return MAM
  402.      */
  403.     public function getMAM()
  404.     {
  405.         return $this->mam;
  406.     }
  407.     /**
  408.      * Get agrements
  409.      *
  410.      * @return array
  411.      */
  412.     public function getAgrements()
  413.     {
  414.         return $this->agrements;
  415.     }
  416.     /**
  417.      * Get accueils
  418.      *
  419.      * @return array
  420.      */
  421.     public function getAccueils(): \Doctrine\Common\Collections\Collection
  422.     {
  423.         return $this->accueils;
  424.     }
  425.     /**
  426.      * Get dispos
  427.      *
  428.      * @return array
  429.      */
  430.     public function getDispos()
  431.     {
  432.         return $this->dispos;
  433.     }
  434.     /**
  435.      * Set dispos
  436.      *
  437.      * @param string $planning_dispos
  438.      *
  439.      * @return AssistantMaternel
  440.      */
  441.     public function setDispos($planning_dispos)
  442.     {
  443.         $this->dispos $planning_dispos;
  444.         return $this;
  445.     }
  446.     /**
  447.      * Get nomFamille
  448.      *
  449.      * @return string
  450.      */
  451.     public function getNomFamille()
  452.     {
  453.         return $this->nom_famille;
  454.     }
  455.     /**
  456.      * Set nomFamille
  457.      *
  458.      * @param string $nomFamille
  459.      *
  460.      * @return AssistantMaternel
  461.      */
  462.     public function setNomFamille($nomFamille)
  463.     {
  464.         $this->nom_famille $nomFamille;
  465.         return $this;
  466.     }
  467.     /**
  468.      * Get nomNaissance
  469.      *
  470.      * @return string
  471.      */
  472.     public function getNomNaissance()
  473.     {
  474.         return $this->nom_naissance;
  475.     }
  476.     /**
  477.      * Set nomNaissance
  478.      *
  479.      * @param string $nomNaissance
  480.      *
  481.      * @return AssistantMaternel
  482.      */
  483.     public function setNomNaissance($nomNaissance)
  484.     {
  485.         $this->nom_naissance $nomNaissance;
  486.         return $this;
  487.     }
  488.     /**
  489.      * Get prenom
  490.      *
  491.      * @return string
  492.      */
  493.     public function getPrenom()
  494.     {
  495.         return $this->prenom;
  496.     }
  497.     /**
  498.      * Set prenom
  499.      *
  500.      * @param string $prenom
  501.      *
  502.      * @return AssistantMaternel
  503.      */
  504.     public function setPrenom($prenom)
  505.     {
  506.         $this->prenom $prenom;
  507.         return $this;
  508.     }
  509.     /**
  510.      * Set dateNaissance
  511.      *
  512.      * @param \DateTime $dateNaissance
  513.      *
  514.      * @return AssistantMaternel
  515.      */
  516.     public function setDateNaissance($dateNaissance)
  517.     {
  518.         $this->date_naissance $dateNaissance;
  519.         return $this;
  520.     }
  521.     /**
  522.      * Get dateNaissance
  523.      *
  524.      * @return \DateTime
  525.      */
  526.     public function getDateNaissance()
  527.     {
  528.         return $this->date_naissance;
  529.     }
  530.     /**
  531.      * Get dateFinAgrementDomicile
  532.      *
  533.      * @return \DateTime
  534.      */
  535.     public function getDateFinAgrementDomicile()
  536.     {
  537.         return $this->date_fin_agrement_domicile;
  538.     }
  539.     /**
  540.      * Get dateFinAgrementMAM
  541.      *
  542.      * @return \DateTime
  543.      */
  544.     public function getDateFinAgrementMAM()
  545.     {
  546.         return $this->date_fin_agrement_mam;
  547.     }
  548.     /**
  549.      * Get dateFinAgrement by id Lieu Accueil
  550.      *
  551.      * @return boolean
  552.      */
  553.     public function getDateFinAgrementByLieuAccueil($idLieuAccueil)
  554.     {
  555.         if ($idLieuAccueil == EnumLieuAccueil::MAM) {
  556.             return $this->date_fin_agrement_mam;
  557.         } elseif ($idLieuAccueil == EnumLieuAccueil::DOMICILE) {
  558.             return $this->date_fin_agrement_domicile;
  559.         }
  560.     }
  561.     /**
  562.      * Get dateDebutAgrementDomicile
  563.      *
  564.      * @return \DateTime
  565.      */
  566.     public function getDateDebutAgrementDomicile()
  567.     {
  568.         return $this->date_debut_agrement_domicile;
  569.     }
  570.     /**
  571.      * Get dateDebutAgrementMAM
  572.      *
  573.      * @return \DateTime
  574.      */
  575.     public function getDateDebutAgrementMAM()
  576.     {
  577.         return $this->date_debut_agrement_mam;
  578.     }
  579.     /**
  580.      * Get dateDebutAgrement by id Lieu Accueil
  581.      *
  582.      * @return boolean
  583.      */
  584.     public function getDateDebutAgrementByLieuAccueil($idLieuAccueil)
  585.     {
  586.         if ($idLieuAccueil == EnumLieuAccueil::MAM) {
  587.             return $this->date_debut_agrement_mam;
  588.         } elseif ($idLieuAccueil == EnumLieuAccueil::DOMICILE) {
  589.             return $this->date_debut_agrement_domicile;
  590.         }
  591.     }
  592.     /**
  593.      * Get datePremierAgrementDomicile
  594.      *
  595.      * @return \DateTime
  596.      */
  597.     public function getDatePremierAgrementDomicile()
  598.     {
  599.         return $this->date_premier_agrement_domicile;
  600.     }
  601.     /**
  602.      * Get datePremierAgrementMAM
  603.      *
  604.      * @return \DateTime
  605.      */
  606.     public function getDatePremierAgrementMAM()
  607.     {
  608.         return $this->date_premier_agrement_mam;
  609.     }
  610.     /**
  611.      * Get datePremierAgrement by id Lieu Accueil
  612.      *
  613.      * @return boolean
  614.      */
  615.     public function getDatePremierAgrementByLieuAccueil($idLieuAccueil)
  616.     {
  617.         if ($idLieuAccueil == EnumLieuAccueil::MAM) {
  618.             return $this->date_premier_agrement_mam;
  619.         } elseif ($idLieuAccueil == EnumLieuAccueil::DOMICILE) {
  620.             return $this->date_premier_agrement_domicile;
  621.         }
  622.     }
  623.     /**
  624.      * Indique si l'assmat a obtenu son 1er agrement après le 01/01/2007
  625.      * si obtenu avant, la notion de 2e partie de formation est caduque
  626.      */
  627.     public function aPremierAgrementApres2007()
  628.     {
  629.         if ($this->date_premier_agrement_mam == null) {
  630.             $minPremierAgrement $this->date_premier_agrement_domicile;
  631.         } elseif ($this->date_premier_agrement_domicile == null) {
  632.             $minPremierAgrement $this->date_premier_agrement_mam;
  633.         } else {
  634.             $minPremierAgrement min($this->date_premier_agrement_domicile$this->date_premier_agrement_mam);
  635.         }
  636.         return $minPremierAgrement >= new \DateTime('2007-01-01');
  637.     }
  638.     /**
  639.      * Set adresse
  640.      *
  641.      * @param string $adresse
  642.      *
  643.      * @return AssistantMaternel
  644.      */
  645.     public function setAdresse($adresse)
  646.     {
  647.         $this->adresse $adresse;
  648.         return $this;
  649.     }
  650.     /**
  651.      * Get adresse
  652.      *
  653.      * @return string
  654.      */
  655.     public function getAdresse()
  656.     {
  657.         return trim($this->adresse);
  658.     }
  659.     /**
  660.      * Set adresseComplement
  661.      *
  662.      * @param string $adresseComplement
  663.      *
  664.      * @return AssistantMaternel
  665.      */
  666.     public function setAdresseComplement($adresseComplement)
  667.     {
  668.         $this->adresse_complement $adresseComplement;
  669.         return $this;
  670.     }
  671.     /**
  672.      * Get adresseComplement
  673.      *
  674.      * @return string
  675.      */
  676.     public function getAdresseComplement()
  677.     {
  678.         return trim($this->adresse_complement);
  679.     }
  680.     /**
  681.      * Set codePostal
  682.      *
  683.      * @param string $codePostal
  684.      *
  685.      * @return AssistantMaternel
  686.      */
  687.     public function setCodePostal($codePostal)
  688.     {
  689.         $this->code_postal $codePostal;
  690.         return $this;
  691.     }
  692.     /**
  693.      * Ajouter un accueil, s'il n'est pas déjà associé à l'assmat
  694.      * ATTENTION mise à jour de l'assmat uniquement - pour associer un accueil, l'important est $accueil->setAssmat
  695.      *
  696.      * @param Accueil $acc
  697.      *
  698.      * @return AssistantMaternel
  699.      */
  700.     public function addAccueil(\App\Entity\GDA\Accueil $acc): AssistantMaternel
  701.     {
  702.         foreach ($this->accueils as $a) {
  703.             if ($a->getId() == $acc->getId()) {
  704.                 // Accueil déjà présent dans la liste, rien à faire
  705.                 return $this;
  706.             }
  707.         }
  708.         if ($acc->getAssmat()->getId() != $this->getId()) {
  709.             throw new \Exception("L'accueil n'est pas associé à l'assistant maternel");
  710.         }
  711.         $this->accueils->add($acc);
  712.         return $this;
  713.     }
  714.     /**
  715.      * Get codePostal
  716.      *
  717.      * @return string
  718.      */
  719.     public function getCodePostal()
  720.     {
  721.         return $this->code_postal;
  722.     }
  723.     /**
  724.      * Set bureauDistributeur
  725.      *
  726.      * @param string $bureauDistributeur
  727.      *
  728.      * @return AssistantMaternel
  729.      */
  730.     public function setBureauDistributeur($bureauDistributeur)
  731.     {
  732.         $this->bureau_distributeur $bureauDistributeur;
  733.         return $this;
  734.     }
  735.     /**
  736.      * Get bureauDistributeur
  737.      *
  738.      * @return string
  739.      */
  740.     public function getBureauDistributeur()
  741.     {
  742.         return $this->bureau_distributeur;
  743.     }
  744.     /**
  745.      * Set telFixe
  746.      *
  747.      * @param string $telFixe
  748.      *
  749.      * @return AssistantMaternel
  750.      */
  751.     public function setTelFixe($telFixe)
  752.     {
  753.         $this->tel_fixe $telFixe;
  754.         return $this;
  755.     }
  756.     /**
  757.      * Get telFixe
  758.      *
  759.      * @return string
  760.      */
  761.     public function getTelFixe()
  762.     {
  763.         return trim($this->tel_fixe);
  764.     }
  765.     /**
  766.      * Get la préférences de publication du tel fixe ,
  767.      * à défaut indique si sur liste rouge ou oppose
  768.      * renvoie faux si l'assmat a déjà positionné ses préférences 
  769.      * ou bien si elle est opposée ou bien si elle est sur liste rouge
  770.      *
  771.      * @return boolean
  772.      */
  773.     public function getPublieTelFixeEtendu()
  774.     {
  775.         $publieTel false;
  776.         if ($this->getPreferencesPublication()) {
  777.             $publieTel $this->getPreferencesPublication()->getPubliTelFixe();
  778.         } else if (!$this->getOppose() && !$this->getListeRougeTelFixe()) {
  779.             $publieTel true;
  780.         }
  781.         return $publieTel;
  782.     }
  783.     /**
  784.      * Set telPortable
  785.      *
  786.      * @param string $telPortable
  787.      *
  788.      * @return AssistantMaternel
  789.      */
  790.     public function setTelPortable($telPortable)
  791.     {
  792.         $this->tel_portable $telPortable;
  793.         return $this;
  794.     }
  795.     /**
  796.      * Get telPortable
  797.      *
  798.      * @return string
  799.      */
  800.     public function getTelPortable()
  801.     {
  802.         return trim($this->tel_portable);
  803.     }
  804.     /**
  805.      * Get la préférences de publication du tel portable ,
  806.      * à défaut indique si sur liste rouge ou oppose
  807.      * renvoie faux si l'assmat a déjà positionné ses préférences
  808.      * ou bien si elle est opposée ou bien si elle est sur liste rouge
  809.      *
  810.      * @return boolean
  811.      */
  812.     public function getPublieTelPortableEtendu()
  813.     {
  814.         $publieTel false;
  815.         if ($this->getPreferencesPublication()) {
  816.             $publieTel $this->getPreferencesPublication()->getPubliTelPortable();
  817.         } else if (!$this->getOppose() && !$this->getListeRougeTelPortable()) {
  818.             $publieTel true;
  819.         }
  820.         return $publieTel;
  821.     }
  822.     /**
  823.      * Set listeRougeTelFixe
  824.      *
  825.      * @param string $listeRouge
  826.      *
  827.      * @return AssistantMaternel
  828.      */
  829.     public function setListeRougeTelFixe($listeRouge)
  830.     {
  831.         $this->liste_rouge_tel_fixe $listeRouge;
  832.         return $this;
  833.     }
  834.     /**
  835.      * Get listeRougeTelFixe
  836.      *
  837.      * @return string
  838.      */
  839.     public function getListeRougeTelFixe()
  840.     {
  841.         return $this->liste_rouge_tel_fixe;
  842.     }
  843.     /**
  844.      * Set listeRougeTelPortable
  845.      *
  846.      * @param string $listeRouge
  847.      *
  848.      * @return AssistantMaternel
  849.      */
  850.     public function setListeRougeTelPortable($listeRouge)
  851.     {
  852.         $this->liste_rouge_tel_portable $listeRouge;
  853.         return $this;
  854.     }
  855.     /**
  856.      * Get listeRougeTelPortable
  857.      *
  858.      * @return string
  859.      */
  860.     public function getListeRougeTelPortable()
  861.     {
  862.         if ($this->liste_rouge_tel_portable === null) {
  863.             // retrocompatibilité quand on n'a pas l'info pour la publication email
  864.             return $this->liste_rouge_tel_fixe;
  865.         } else {
  866.             return $this->liste_rouge_tel_portable;
  867.         }
  868.     }
  869.     /**
  870.      * Set listeRougeMail
  871.      *
  872.      * @param string $listeRouge
  873.      *
  874.      * @return AssistantMaternel
  875.      */
  876.     public function setListeRougeMail($listeRouge)
  877.     {
  878.         $this->liste_rouge_mail $listeRouge;
  879.         return $this;
  880.     }
  881.     /**
  882.      * Get listeRougeMail
  883.      *
  884.      * @return string
  885.      */
  886.     public function getListeRougeMail()
  887.     {
  888.         if ($this->liste_rouge_mail === null) {
  889.             // retrocompatibilité quand on n'a pas l'info pour la publication email
  890.             return $this->liste_rouge_tel_fixe;
  891.         } else {
  892.             return $this->liste_rouge_mail;
  893.         }
  894.     }
  895.     /**
  896.      * Set email
  897.      *
  898.      * @param string $email
  899.      *
  900.      * @return AssistantMaternel
  901.      */
  902.     public function setEmail($email)
  903.     {
  904.         $this->email $email;
  905.         return $this;
  906.     }
  907.     /**
  908.      * Get email
  909.      *
  910.      * @return string
  911.      */
  912.     public function getEmail()
  913.     {
  914.         return $this->email;
  915.     }
  916.     /**
  917.      * Get la préférences de publication du mail ,
  918.      * à défaut indique si sur liste rouge ou oppose
  919.      * renvoie faux si l'assmat a déjà positionné ses préférences
  920.      * ou bien si elle est opposée ou bien si elle est sur liste rouge
  921.      *
  922.      * @return boolean
  923.      */
  924.     public function getPublieMailEtendu()
  925.     {
  926.         $publieEmail false;
  927.         if ($this->getPreferencesPublication()) {
  928.             $publieEmail $this->getPreferencesPublication()->getPubliEmail();
  929.         } else if (!$this->getOppose() && !$this->getListeRougeMail()) {
  930.             $publieEmail true;
  931.         }
  932.         return $publieEmail;
  933.     }
  934.     /**
  935.      * Set formation2
  936.      *
  937.      * @param string $formation2
  938.      *
  939.      * @return AssistantMaternel
  940.      */
  941.     public function setFormation2($formation2)
  942.     {
  943.         $this->formation2_effectuee $formation2;
  944.         return $this;
  945.     }
  946.     /**
  947.      * Get formation2
  948.      *
  949.      * @return string
  950.      */
  951.     public function getFormation2()
  952.     {
  953.         return $this->formation2_effectuee;
  954.     }
  955.     /**
  956.      * Set dateMajAssmat
  957.      *
  958.      * @param string $dateMajAssmat
  959.      *
  960.      * @return AssistantMaternel
  961.      */
  962.     public function setDateMajAssmat($dateMajAssmat)
  963.     {
  964.         $this->date_maj_assmat $dateMajAssmat;
  965.         return $this;
  966.     }
  967.     /**
  968.      * Get dateMajAssmat
  969.      *
  970.      * @return string
  971.      */
  972.     public function getDateMajAssmat()
  973.     {
  974.         return $this->date_maj_assmat;
  975.     }
  976.     /**
  977.      * Set date_modif_tel_fixe
  978.      *
  979.      * @param string $dateModifTelFixe
  980.      *
  981.      * @return AssistantMaternel
  982.      */
  983.     public function setDateModifTelFixe($dateModifTelFixe)
  984.     {
  985.         $this->date_modif_tel_fixe $dateModifTelFixe;
  986.         return $this;
  987.     }
  988.     /**
  989.      * Get date_modif_tel_fixe
  990.      *
  991.      * @return string
  992.      */
  993.     public function getDateModifTelFixe()
  994.     {
  995.         return $this->date_modif_tel_fixe;
  996.     }
  997.     /**
  998.      * Set date_modif_tel_portable
  999.      *
  1000.      * @param string $dateModifTelPortable
  1001.      *
  1002.      * @return AssistantMaternel
  1003.      */
  1004.     public function setDateModifTelPortable($dateModifTelPortable)
  1005.     {
  1006.         $this->date_modif_tel_portable $dateModifTelPortable;
  1007.         return $this;
  1008.     }
  1009.     /**
  1010.      * Get date_modif_tel_portable
  1011.      *
  1012.      * @return string
  1013.      */
  1014.     public function getDateModifTelPortable()
  1015.     {
  1016.         return $this->date_modif_tel_portable;
  1017.     }
  1018.     /**
  1019.      * Set date_modif_mail
  1020.      *
  1021.      * @param string $dateModifMail
  1022.      *
  1023.      * @return AssistantMaternel
  1024.      */
  1025.     public function setDateModifMail($dateModifMail)
  1026.     {
  1027.         $this->date_modif_mail $dateModifMail;
  1028.         return $this;
  1029.     }
  1030.     /**
  1031.      * Get date_modif_mail
  1032.      *
  1033.      * @return string
  1034.      */
  1035.     public function getDateModifMail()
  1036.     {
  1037.         return $this->date_modif_mail;
  1038.     }
  1039.     /**
  1040.      * Set archiveDomicile
  1041.      *
  1042.      * @param boolean $archiveDomicile
  1043.      *
  1044.      * @return AssistantMaternel
  1045.      */
  1046.     public function setEstArchiveDomicile($archiveDomicile)
  1047.     {
  1048.         // https://stackoverflow.com/questions/4775294/parsing-a-string-into-a-boolean-value-in-php
  1049.         $this->archive_domicile filter_var($archiveDomicileFILTER_VALIDATE_BOOLEAN);
  1050.         return $this;
  1051.     }
  1052.     /**
  1053.      * Get archiveDomicile
  1054.      *
  1055.      * @deprecated utiliser getArchiveCalculeDomicile
  1056.      * @return boolean
  1057.      */
  1058.     public function getEstArchiveDomicile()
  1059.     {
  1060.         return $this->archive_domicile;
  1061.     }
  1062.     /**
  1063.      * Set archiveMam
  1064.      *
  1065.      * @param boolean $archiveMam
  1066.      *
  1067.      * @return AssistantMaternel
  1068.      */
  1069.     public function setEstArchiveMam($archiveMam)
  1070.     {
  1071.         // https://stackoverflow.com/questions/4775294/parsing-a-string-into-a-boolean-value-in-php
  1072.         $this->archive_mam filter_var($archiveMamFILTER_VALIDATE_BOOLEAN);
  1073.         return $this;
  1074.     }
  1075.     /**
  1076.      * Get archiveMam
  1077.      * @deprecated utiliser getArchiveCalculeMam
  1078.      *
  1079.      * @return boolean
  1080.      */
  1081.     public function getEstArchiveMam()
  1082.     {
  1083.         return $this->archive_mam;
  1084.     }
  1085.     /**
  1086.      * Get archiveMam AND archiveDomicile
  1087.      * @deprecated utiliser getArchiveCalcule
  1088.      * @return boolean
  1089.      */
  1090.     public function getEstArchive()
  1091.     {
  1092.         return $this->archive_mam && $this->archive_domicile;
  1093.     }
  1094.     /**
  1095.      * Get archive agrégé pour lieu domicile
  1096.      *
  1097.      * @return boolean
  1098.      */
  1099.     public function getArchiveCalculeDomicile()
  1100.     {
  1101.         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);
  1102.     }
  1103.     /**
  1104.      * Get archive agrégé pour lieu MAM
  1105.      *
  1106.      * @return boolean
  1107.      */
  1108.     public function getArchiveCalculeMam()
  1109.     {
  1110.         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);
  1111.     }
  1112.     /**
  1113.      * Get archive agrégé by id Lieu Accueil
  1114.      *
  1115.      * @return boolean
  1116.      */
  1117.     public function getArchiveCalculeByLieuAccueil($idLieuAccueil)
  1118.     {
  1119.         if ($idLieuAccueil == EnumLieuAccueil::MAM) {
  1120.             return $this->getArchiveCalculeMam();
  1121.         } elseif ($idLieuAccueil == EnumLieuAccueil::DOMICILE) {
  1122.             return $this->getArchiveCalculeDomicile();
  1123.         }
  1124.     }
  1125.     /**
  1126.      * Get suspension by id Lieu Accueil
  1127.      *
  1128.      * @return boolean
  1129.      */
  1130.     public function getEstSuspensionByLieuAccueil($idLieuAccueil)
  1131.     {
  1132.         if ($idLieuAccueil == EnumLieuAccueil::MAM) {
  1133.             return $this->suspension_mam;
  1134.         } elseif ($idLieuAccueil == EnumLieuAccueil::DOMICILE) {
  1135.             return $this->suspension_dom;
  1136.         }
  1137.     }
  1138.     /**
  1139.      * Get CTA by id Lieu Accueil
  1140.      *
  1141.      * @return boolean
  1142.      */
  1143.     public function getEstCessationByLieuAccueil($idLieuAccueil)
  1144.     {
  1145.         if ($idLieuAccueil == EnumLieuAccueil::MAM) {
  1146.             return $this->cta_mam;
  1147.         } elseif ($idLieuAccueil == EnumLieuAccueil::DOMICILE) {
  1148.             return $this->cta_dom;
  1149.         }
  1150.     }
  1151.     /**
  1152.      * Set formation1_effectuee
  1153.      *
  1154.      * @param boolean $formation1
  1155.      *
  1156.      * @return AssistantMaternel
  1157.      */
  1158.     public function setEstFormation1Effecuee($formation1)
  1159.     {
  1160.         // https://stackoverflow.com/questions/4775294/parsing-a-string-into-a-boolean-value-in-php
  1161.         $this->formation1_effectuee filter_var($formation1FILTER_VALIDATE_BOOLEAN);
  1162.         return $this;
  1163.     }
  1164.     /**
  1165.      * Get formation1_effectuee
  1166.      *
  1167.      * @return boolean
  1168.      */
  1169.     public function getEstFormation1Effectuee()
  1170.     {
  1171.         return $this->formation1_effectuee;
  1172.     }
  1173.     /**
  1174.      * Set creche
  1175.      *
  1176.      * @param boolean $creche
  1177.      *
  1178.      * @return AssistantMaternel
  1179.      */
  1180.     public function setEstCreche($creche)
  1181.     {
  1182.         // https://stackoverflow.com/questions/4775294/parsing-a-string-into-a-boolean-value-in-php
  1183.         $this->creche filter_var($crecheFILTER_VALIDATE_BOOLEAN);
  1184.         return $this;
  1185.     }
  1186.     /**
  1187.      * Get creche
  1188.      *
  1189.      * @return boolean
  1190.      */
  1191.     public function getEstCreche()
  1192.     {
  1193.         return $this->creche;
  1194.     }
  1195.     /**
  1196.      * Set cessation_dom
  1197.      *
  1198.      * @param boolean $cta_dom
  1199.      *
  1200.      * @return AssistantMaternel
  1201.      */
  1202.     public function setEstCessationDom($cta_dom)
  1203.     {
  1204.         // https://stackoverflow.com/questions/4775294/parsing-a-string-into-a-boolean-value-in-php
  1205.         $this->cta_dom filter_var($cta_domFILTER_VALIDATE_BOOLEAN);
  1206.         return $this;
  1207.     }
  1208.     /**
  1209.      * Get cessation_dom
  1210.      *
  1211.      * @return boolean
  1212.      */
  1213.     public function getEstCessationDom()
  1214.     {
  1215.         return $this->cta_dom;
  1216.     }
  1217.     /**
  1218.      * Set cta_mam
  1219.      *
  1220.      * @param boolean $cta_mam
  1221.      *
  1222.      * @return AssistantMaternel
  1223.      */
  1224.     public function setEstCessationMam($cta_mam)
  1225.     {
  1226.         // https://stackoverflow.com/questions/4775294/parsing-a-string-into-a-boolean-value-in-php
  1227.         $this->cta_mam filter_var($cta_mamFILTER_VALIDATE_BOOLEAN);
  1228.         return $this;
  1229.     }
  1230.     /**
  1231.      * Get cta_mam
  1232.      *
  1233.      * @return boolean
  1234.      */
  1235.     public function getEstCessationMam()
  1236.     {
  1237.         return $this->cta_mam;
  1238.     }
  1239.     /**
  1240.      * Set suspension_dom
  1241.      *
  1242.      * @param boolean $suspension_dom
  1243.      *
  1244.      * @return AssistantMaternel
  1245.      */
  1246.     public function setEstSuspensionDom($suspension_dom)
  1247.     {
  1248.         // https://stackoverflow.com/questions/4775294/parsing-a-string-into-a-boolean-value-in-php
  1249.         $this->suspension_dom filter_var($suspension_domFILTER_VALIDATE_BOOLEAN);
  1250.         return $this;
  1251.     }
  1252.     /**
  1253.      * Get suspension_dom
  1254.      *
  1255.      * @return boolean
  1256.      */
  1257.     public function getEstSuspensionDom()
  1258.     {
  1259.         return $this->suspension_dom;
  1260.     }
  1261.     /**
  1262.      * Set suspension_mam
  1263.      *
  1264.      * @param boolean $suspension_mam
  1265.      *
  1266.      * @return AssistantMaternel
  1267.      */
  1268.     public function setEstSuspensionMam($suspension_mam)
  1269.     {
  1270.         // https://stackoverflow.com/questions/4775294/parsing-a-string-into-a-boolean-value-in-php
  1271.         $this->suspension_mam filter_var($suspension_mamFILTER_VALIDATE_BOOLEAN);
  1272.         return $this;
  1273.     }
  1274.     /**
  1275.      * Get suspension_mam
  1276.      *
  1277.      * @return boolean
  1278.      */
  1279.     public function getEstSuspensionMam()
  1280.     {
  1281.         return $this->suspension_mam;
  1282.     }
  1283.     /**
  1284.      * Statut Archive agrégat
  1285.      * formation1 pas faite, en creche, archive (dom/mam), cessation (dom/mam), suspension (dom/mam)
  1286.      * nécessite cta et suspension remis à null si lieu d'accueil pas agréé
  1287.      *
  1288.      * @return boolean
  1289.      */
  1290.     public function getArchiveCalcule()
  1291.     {
  1292.         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)
  1293.         ;
  1294.     }
  1295.     /**
  1296.      * Motif du statut archivé
  1297.      * formation1 pas faite, en creche, archive (dom/mam), cessation (dom/mam), suspension (dom/mam)
  1298.      * nécessite cta et suspension remis à null si lieu d'accueil pas agréé
  1299.      *
  1300.      * @return string
  1301.      */
  1302.     public function getArchiveMotif()
  1303.     {
  1304.         if ($this->formation1_effectuee !== null && !$this->formation1_effectuee) {
  1305.             return 'Formation 1 non effectuée';
  1306.         }
  1307.         if ($this->creche !== null && $this->creche) {
  1308.             return 'Exerce en crèche';
  1309.         }
  1310.         if ($this->suspension_dom !== null && $this->suspension_dom) {
  1311.             return 'Suspension Agrément Domicile';
  1312.         }
  1313.         if ($this->suspension_mam !== null && $this->suspension_mam) {
  1314.             return 'Suspension Agrément MAM';
  1315.         }
  1316.         if ($this->cta_dom !== null && $this->cta_dom) {
  1317.             return 'Cessation temporaire Agrément Domicile';
  1318.         }
  1319.         if ($this->cta_mam !== null && $this->cta_mam) {
  1320.             return 'Cessation temporaire Agrément MAM';
  1321.         }
  1322.         if ($this->archive_mam && $this->archive_domicile) {
  1323.             return 'Archivé';
  1324.         }
  1325.         return 'en activité';
  1326.     }
  1327.     /**
  1328.      * Motif du statut archivé
  1329.      * formation1 pas faite, en creche, archive (dom/mam), cessation (dom/mam), suspension (dom/mam)
  1330.      * nécessite cta et suspension remis à null si lieu d'accueil pas agréé
  1331.      *
  1332.      * @return string
  1333.      */
  1334.     public function getArchiveLabelBadge()
  1335.     {
  1336.         if ($this->formation1_effectuee !== null && !$this->formation1_effectuee) {
  1337.             return 'Archivé : Formation';
  1338.         }
  1339.         if ($this->creche !== null && $this->creche) {
  1340.             return 'Archivé : Crèche';
  1341.         }
  1342.         if ($this->suspension_dom !== null && $this->suspension_dom || $this->suspension_mam !== null && $this->suspension_mam) {
  1343.             return 'Archivé : Suspension';
  1344.         }
  1345.         if ($this->cta_dom !== null && $this->cta_dom || $this->cta_mam !== null && $this->cta_mam) {
  1346.             return 'Archivé : CTA';
  1347.         }
  1348.         if ($this->archive_mam && $this->archive_domicile) {
  1349.             return 'Archivé';
  1350.         }
  1351.         return '';
  1352.     }
  1353.     /**
  1354.      * Set supprime
  1355.      *
  1356.      * @param boolean $supprime
  1357.      *
  1358.      * @return AssistantMaternel
  1359.      */
  1360.     public function setSupprime($supprime)
  1361.     {
  1362.         // https://stackoverflow.com/questions/4775294/parsing-a-string-into-a-boolean-value-in-php
  1363.         $this->supprime filter_var($supprimeFILTER_VALIDATE_BOOLEAN);
  1364.         return $this;
  1365.     }
  1366.     /**
  1367.      * Get supprime
  1368.      *
  1369.      * @return boolean
  1370.      */
  1371.     public function getSupprime()
  1372.     {
  1373.         return $this->supprime;
  1374.     }
  1375.     /**
  1376.      * Set supprime_domicile
  1377.      *
  1378.      * @param boolean $supprime_domicile
  1379.      *
  1380.      * @return AssistantMaternel
  1381.      */
  1382.     public function setSupprimeDomicile($supprime_domicile)
  1383.     {
  1384.         $this->supprime_domicile filter_var($supprime_domicileFILTER_VALIDATE_BOOLEAN);
  1385.         return $this;
  1386.     }
  1387.     /**
  1388.      * Get supprime_domicile
  1389.      *
  1390.      * @return boolean
  1391.      */
  1392.     public function getSupprimeDomicile()
  1393.     {
  1394.         return $this->supprime_domicile;
  1395.     }
  1396.     /**
  1397.      * Set supprime_mam
  1398.      *
  1399.      * @param boolean $supprime_mam
  1400.      *
  1401.      * @return AssistantMaternel
  1402.      */
  1403.     public function setSupprimeMAM($supprime_mam)
  1404.     {
  1405.         $this->supprime_mam filter_var($supprime_mamFILTER_VALIDATE_BOOLEAN);
  1406.         return $this;
  1407.     }
  1408.     /**
  1409.      * Get supprime_domicile
  1410.      *
  1411.      * @return boolean
  1412.      */
  1413.     public function getSupprimeMAM()
  1414.     {
  1415.         return $this->supprime_mam;
  1416.     }
  1417.     /**
  1418.      * Get supprime by id Lieu Accueil
  1419.      *
  1420.      * @return boolean
  1421.      */
  1422.     public function getEstSupprimeByLieuAccueil($idLieuAccueil)
  1423.     {
  1424.         if ($idLieuAccueil == EnumLieuAccueil::MAM) {
  1425.             return $this->supprime_mam;
  1426.         } elseif ($idLieuAccueil == EnumLieuAccueil::DOMICILE) {
  1427.             return $this->supprime_domicile;
  1428.         }
  1429.     }
  1430.     /**
  1431.      * Set utilisateur
  1432.      *
  1433.      * @param Utilisateur $utilisateur
  1434.      *
  1435.      * @return AssistantMaternel
  1436.      */
  1437.     public function setUtilisateur($utilisateur)
  1438.     {
  1439.         $this->utilisateur $utilisateur;
  1440.         return $this;
  1441.     }
  1442.     /**
  1443.      * Get utilisateur
  1444.      *
  1445.      * @return Utilisateur
  1446.      */
  1447.     public function getUtilisateur()
  1448.     {
  1449.         return $this->utilisateur;
  1450.     }
  1451.     /**
  1452.      * Get puericultrice
  1453.      *
  1454.      * @return Utilisateur
  1455.      */
  1456.     public function getPuericultrice()
  1457.     {
  1458.         return $this->puericultrice;
  1459.     }
  1460.     /**
  1461.      * Set puericultrice
  1462.      *
  1463.      * @param Utilisateur $puericultrice
  1464.      *
  1465.      * @return AssistantMaternel
  1466.      */
  1467.     public function setPuericultrice($puericultrice)
  1468.     {
  1469.         $this->puericultrice $puericultrice;
  1470.         return $this;
  1471.     }
  1472.     /**
  1473.      * Set participe
  1474.      *
  1475.      * @param boolean $participe
  1476.      *
  1477.      * @return AssistantMaternel
  1478.      */
  1479.     public function setParticipe($participe)
  1480.     {
  1481.         $this->participe filter_var($participeFILTER_VALIDATE_BOOLEAN);
  1482.         return $this;
  1483.     }
  1484.     /**
  1485.      * Get participe
  1486.      *
  1487.      * @return boolean
  1488.      */
  1489.     public function getParticipe()
  1490.     {
  1491.         return $this->participe;
  1492.     }
  1493.     /**
  1494.      * Set oppose
  1495.      *
  1496.      * @param boolean $oppose
  1497.      *
  1498.      * @return AssistantMaternel
  1499.      */
  1500.     public function setOppose($oppose)
  1501.     {
  1502.         $this->oppose filter_var($opposeFILTER_VALIDATE_BOOLEAN);
  1503.         return $this;
  1504.     }
  1505.     /**
  1506.      * Get oppose
  1507.      *
  1508.      * @return boolean
  1509.      */
  1510.     public function getOppose()
  1511.     {
  1512.         return $this->oppose;
  1513.     }
  1514.     /**
  1515.      * Set consent = !oppose
  1516.      *
  1517.      * @param boolean $consent
  1518.      *
  1519.      * @return AssistantMaternel
  1520.      */
  1521.     public function setConsent($consent)
  1522.     {
  1523.         $this->oppose = !filter_var($consentFILTER_VALIDATE_BOOLEAN);
  1524.         return $this;
  1525.     }
  1526.     /**
  1527.      * Get consent = !oppose
  1528.      *
  1529.      * @return boolean
  1530.      */
  1531.     public function getConsent()
  1532.     {
  1533.         return !$this->oppose;
  1534.     }
  1535.     /**
  1536.      * Has agrément en cours de validité by lieu d'accueil passé en paramètre
  1537.      * @param integer $idLieuAccueil lieu de l'accueil EnumLieuAccueil
  1538.      * @return boolean
  1539.      */
  1540.     public function hasAgrementEnCoursByLieuAccueil($idLieuAccueil$targetDate null)
  1541.     {
  1542.         if (array_search($idLieuAccueilEnumLieuAccueil::getAvailableLieuxAccueils()) === false) {
  1543.             throw new \Exception("Lieu d'accueil non défini : $idLieuAccueil");
  1544.         }
  1545.         if ($targetDate == null) {
  1546.             $targetDate = new \DateTime("tomorrow midnight");
  1547.         }
  1548.         foreach ($this->agrements as $agrement) {
  1549.             if ($idLieuAccueil == $agrement->getIdLieuAccueil()) {
  1550.                 if (
  1551.                         $idLieuAccueil == EnumLieuAccueil::MAM && $this->date_fin_agrement_mam != null && $this->date_fin_agrement_mam >= $targetDate
  1552.                 ) {
  1553.                     return true;
  1554.                 } elseif (
  1555.                         $idLieuAccueil == EnumLieuAccueil::DOMICILE && $this->date_fin_agrement_domicile != null && $this->date_fin_agrement_domicile >= $targetDate
  1556.                 ) {
  1557.                     return true;
  1558.                 }
  1559.             }
  1560.         }
  1561.         return false;
  1562.     }
  1563.     /**
  1564.      * Has agrément en cours
  1565.      * @return boolean
  1566.      */
  1567.     public function hasAgrementEnCours()
  1568.     {
  1569.         return $this->hasAgrementEnCoursByLieuAccueil(EnumLieuAccueil::DOMICILE) || $this->hasAgrementEnCoursByLieuAccueil(EnumLieuAccueil::MAM);
  1570.     }
  1571.     /**
  1572.      * Has agrément by lieu d'accueil passé en paramètre
  1573.      * @param integer $lieuAccueil lieu de l'accueil EnumLieuAccueil
  1574.      * @return boolean
  1575.      */
  1576.     public function hasAgrementByLieuAccueil($lieuAccueil)
  1577.     {
  1578.         $lieuAccueilTrouve false;
  1579.         foreach ($this->agrements as $agrement) {
  1580.             if ($lieuAccueil == $agrement->getIdLieuAccueil()) {
  1581.                 $lieuAccueilTrouve true;
  1582.                 break;
  1583.             }
  1584.         }
  1585.         return $lieuAccueilTrouve;
  1586.     }
  1587.     /**
  1588.      * Has places by lieu d'accueil passé en paramètre
  1589.      * @param integer $lieuAccueil lieu de l'accueil EnumLieuAccueil
  1590.      * @return boolean
  1591.      */
  1592.     public function hasPlacesByLieuAccueil($lieuAccueil)
  1593.     {
  1594.         $lieuAccueilTrouve false;
  1595.         foreach ($this->agrements as $agrement) {
  1596.             if ($lieuAccueil == $agrement->getIdLieuAccueil()) {
  1597.                 $lieuAccueilTrouve true;
  1598.                 break;
  1599.             }
  1600.         }
  1601.         return $lieuAccueilTrouve;
  1602.     }
  1603.     /**
  1604.      * Indique s'il existe au moins un accueil en cours pour un agrément échu
  1605.      */
  1606.     public function hasAccueilEnCoursEtAgrementEchu($targetDate null)
  1607.     {
  1608.         $lieuxAgrees $this->getLieuxAccueilAgrees();
  1609.         foreach ($lieuxAgrees as $idLieu => $lieu) {
  1610.             $accEnCours $this->getAccueilsByLieuAndActif($idLieutrue$targetDate);
  1611.             $agremEnCours $this->hasAgrementEnCoursByLieuAccueil($idLieu$targetDate);
  1612.             if ($accEnCours && !$agremEnCours) {
  1613.                 return true;
  1614.             }
  1615.         }
  1616.         return false;
  1617.     }
  1618.     /**
  1619.      * Indique s'il existe au moins un accueil en cours pour un agrément échu
  1620.      */
  1621.     public function hasAccueilEnCoursEtArchive()
  1622.     {
  1623.         $lieuxAgrees $this->getLieuxAccueilAgrees();
  1624.         foreach ($lieuxAgrees as $idLieu => $lieu) {
  1625.             $accEnCours $this->getAccueilsByLieuAndActif($idLieutrue);
  1626.             $estArchiveLieu $this->getArchiveCalculeByLieuAccueil($idLieu);
  1627.             if ($accEnCours && $estArchiveLieu) {
  1628.                 return true;
  1629.             }
  1630.         }
  1631.         return false;
  1632.     }
  1633.     /**
  1634.      * Obtient la liste des agréments avec un nombre de places non nul
  1635.      * @return array
  1636.      */
  1637.     public function getAgrementsWithPlaces()
  1638.     {
  1639.         $agremWithPlaces = array();
  1640.         foreach ($this->agrements as $agrement) {
  1641.             if ($agrement->getNombrePlaces() > 0) {
  1642.                 $agremWithPlaces[] = $agrement;
  1643.             }
  1644.         }
  1645.         return $agremWithPlaces;
  1646.     }
  1647.     /**
  1648.      * Obtient le nombre total de places agréées
  1649.      * @return array
  1650.      */
  1651.     public function getNombrePlacesTotal()
  1652.     {
  1653.         $agremWithPlaces 0;
  1654.         foreach ($this->agrements as $agrement) {
  1655.             $agremWithPlaces += $agrement->getNombrePlaces();
  1656.         }
  1657.         return $agremWithPlaces;
  1658.     }
  1659.     /**
  1660.      * Obtient la liste des lieux d'accueil avec un nombre de places non nul
  1661.      * @return array
  1662.      */
  1663.     public function getLieuxAccueilAgrees()
  1664.     {
  1665.         $lieuxAccueilAgrees = array();
  1666.         foreach ($this->agrements as $agrement) {
  1667.             if ($agrement->getNombrePlaces() > 0) {
  1668.                 $lieuxAccueilAgrees[$agrement->getLieuAccueil()->getId()] = $agrement->getLieuAccueil();
  1669.             }
  1670.         }
  1671.         return $lieuxAccueilAgrees;
  1672.     }
  1673.     /**
  1674.      * Obtient la liste des types d'accueil avec un nombre de places non nul
  1675.      * @return array
  1676.      */
  1677.     public function getTypesAccueilAgrees()
  1678.     {
  1679.         $typesAccueilAgrees = array();
  1680.         foreach ($this->agrements as $agrement) {
  1681.             if ($agrement->getNombrePlaces() > 0) {
  1682.                 $typesAccueilAgrees[$agrement->getTypeAccueil()->getId()] = $agrement->getTypeAccueil();
  1683.             }
  1684.         }
  1685.         return $typesAccueilAgrees;
  1686.     }
  1687.     /**
  1688.      * Obtient la liste des tranches d'ages agréées : avec un nombre de places non nul pour l'agrément
  1689.      * @return array
  1690.      */
  1691.     public function getTranchesAgeAgrees()
  1692.     {
  1693.         $tranches = array();
  1694.         foreach ($this->agrements as $agrement) {
  1695.             if ($agrement->getNombrePlaces() > 0) {
  1696.                 $tranches[] = $agrement->getTrancheAge();
  1697.             }
  1698.         }
  1699.         return $tranches;
  1700.     }
  1701.     /**
  1702.      * Obtient la liste des agréments pour un lieu d'accueil (même sans place)
  1703.      * @return array
  1704.      */
  1705.     public function getAgrementsByLieu($lieuAccueil)
  1706.     {
  1707.         $agrems = array();
  1708.         foreach ($this->agrements as $agrement) {
  1709.             if ($lieuAccueil == $agrement->getIdLieuAccueil()) {
  1710.                 $agrems[] = $agrement;
  1711.             }
  1712.         }
  1713.         return $agrems;
  1714.     }
  1715.     /*     * *
  1716.      * Fonction de tri par ordre croissant de tranche d'age
  1717.      */
  1718.     function orderByTrancheAge($a$b)
  1719.     {
  1720.         $dateMinA date_sub(new \DateTime(), $a->getTrancheAge()->getAgeMin());
  1721.         $dateMinB date_sub(new \DateTime(), $b->getTrancheAge()->getAgeMin());
  1722.         return $dateMinB <=> $dateMinA;
  1723.     }
  1724.     /**
  1725.      * Obtient la liste des agréments avec un nombre de places non nul pour un lieu d'accueil
  1726.      * @return array
  1727.      */
  1728.     public function getAgrementsWithPlacesByLieu($lieuAccueil)
  1729.     {
  1730.         $agremWithPlaces = array();
  1731.         foreach ($this->agrements as $agrement) {
  1732.             if ($lieuAccueil == $agrement->getIdLieuAccueil() && $agrement->getNombrePlaces() > 0) {
  1733.                 $agremWithPlaces[] = $agrement;
  1734.             }
  1735.         }
  1736.         uasort($agremWithPlaces, array($this'orderByTrancheAge')); //tri utilisé pour tous les écrans où on liste les tranches d'âge agrées
  1737.         return $agremWithPlaces;
  1738.     }
  1739.     /**
  1740.      * Obtient la liste des tranches d'ages agréées :
  1741.      * avec un nombre de places non nul pour l'agrément correspondant un lieu d'accueil fourni
  1742.      * @return array
  1743.      */
  1744.     public function getTranchesAgeAgreesByIdLieu($idLieuAccueil)
  1745.     {
  1746.         $tranches = array();
  1747.         foreach ($this->agrements as $agrement) {
  1748.             if ($idLieuAccueil == $agrement->getIdLieuAccueil() && $agrement->getNombrePlaces() > 0) {
  1749.                 $tranches[] = $agrement->getTrancheAge();
  1750.             }
  1751.         }
  1752.         return $tranches;
  1753.     }
  1754.     /**
  1755.      * Obtient la liste des accueils pour un lieu d'accueil
  1756.      *  et selon s'il est actif ou non à l'éventuelle date fournie
  1757.      * @param type $idLieuAccueil identifiant du lieu d'accueil
  1758.      * @param type $actif indique si l'accueil doit être actif à la $targetDate ou non
  1759.      * @param type $targetDate
  1760.      * @return array
  1761.      */
  1762.     public function getAccueilsByLieuAndActif($idLieuAccueil$actif$targetDate null)
  1763.     {
  1764.         if ($targetDate == null) {
  1765.             $targetDate = new \DateTime();
  1766.         }
  1767.         $accueilsByLieu = array();
  1768.         foreach ($this->accueils as $accueil) {
  1769.             if (
  1770.                     $idLieuAccueil == $accueil->getLieuAccueil()->getId() &&
  1771.                     !($actif xor ( $accueil->getDateFin() === null || $accueil->getDateFin() >= $targetDate))
  1772.             ) {
  1773.                 $accueilsByLieu[] = $accueil;
  1774.             }
  1775.         }
  1776.         return $accueilsByLieu;
  1777.     }
  1778.     public function getAccueilsByLieu($idLieuAccueil)
  1779.     {
  1780.         $accueilsByLieu = array();
  1781.         foreach ($this->accueils as $accueil) {
  1782.             if ($idLieuAccueil == $accueil->getLieuAccueil()->getId()) {
  1783.                 $accueilsByLieu[] = $accueil;
  1784.             }
  1785.         }
  1786.         return $accueilsByLieu;
  1787.     }
  1788.     public function getAccueilsByActif($actif$targetDate null)
  1789.     {
  1790.         if ($targetDate == null) {
  1791.             $targetDate = new \DateTime();
  1792.         }
  1793.         $accueilsByActif = array();
  1794.         foreach ($this->accueils as $accueil) {
  1795.             if (!($actif xor ( $accueil->getDateFin() === null || $accueil->getDateFin() >= $targetDate))) {
  1796.                 $accueilsByActif[] = $accueil;
  1797.             }
  1798.         }
  1799.         return $accueilsByActif;
  1800.     }
  1801.     /**
  1802.      * Obtient la liste des enfants de moins de 3 ans à la date fournie (par défaut date du jour si absente)
  1803.      * @param type $targetDate
  1804.      * @return array
  1805.      */
  1806.     public function getEnfantsAssmatMoins3Ans($targetDate null)
  1807.     {
  1808.         $enfantsMoins3ans = array();
  1809.         foreach ($this->enfantsAssmat as $enfant) {
  1810.             if ($enfant->getAgeAnnees($targetDate) < 3) {
  1811.                 $enfantsMoins3ans[] = $enfant;
  1812.             }
  1813.         }
  1814.         return $enfantsMoins3ans;
  1815.     }
  1816.     /**
  1817.      * Obtient la liste des enfants agés entre 3 et 11 ans à la date fournie (par défaut date du jour si absente)
  1818.      * @param type $targetDate
  1819.      * @return array
  1820.      */
  1821.     public function getEnfantsAssmatEntre3et11Ans($targetDate null)
  1822.     {
  1823.         $enfants3a11ans = array();
  1824.         foreach ($this->enfantsAssmat as $enfant) {
  1825.             if ($enfant->getAgeAnnees($targetDate) >= && $enfant->getAgeAnnees($targetDate) < 11) {
  1826.                 $enfants3a11ans[] = $enfant;
  1827.             }
  1828.         }
  1829.         return $enfants3a11ans;
  1830.     }
  1831.     /**
  1832.      * Obtient la liste des enfants de moins de 11 ans à la date fournie (par défaut date du jour si absente)
  1833.      * @param type $targetDate
  1834.      * @return array
  1835.      */
  1836.     public function getEnfantsAssmatMoins11Ans($targetDate null)
  1837.     {
  1838.         $enfantsMoins11ans = array();
  1839.         foreach ($this->enfantsAssmat as $enfant) {
  1840.             if ($enfant->getAgeAnnees($targetDate) < 11) {
  1841.                 $enfantsMoins11ans[] = $enfant;
  1842.             }
  1843.         }
  1844.         return $enfantsMoins11ans;
  1845.     }
  1846.     /**
  1847.      * Obtient la liste des enfants de moins de 3 ans à la date fournie (par défaut date du jour si absente)
  1848.      * et qui ont été indiqués comme à prendre en compte pour le calcul de dépassement
  1849.      * @param type $targetDate date à laquelle on calcule l'age de l'enfant
  1850.      * @return array
  1851.      */
  1852.     public function getEnfantsAssmatMoins3AnsGardes($targetDate null)
  1853.     {
  1854.         $enfantsMoins3ans = array();
  1855.         foreach ($this->enfantsAssmat as $enfant) {
  1856.             if ($enfant->getEstGarde() && $enfant->getAgeAnnees($targetDate) < 3) {
  1857.                 $enfantsMoins3ans[] = $enfant;
  1858.             }
  1859.         }
  1860.         return $enfantsMoins3ans;
  1861.     }
  1862.     /**
  1863.      * Obtient la liste des enfants agés entre 3 et 11 ans à la date fournie (par défaut date du jour si absente)
  1864.      * et qui ont été indiqués comme à prendre en compte pour le calcul de dépassement
  1865.      * @param type $targetDate date à laquelle on calcule l'age de l'enfant
  1866.      * @return array
  1867.      */
  1868.     public function getEnfantsAssmatEntre3et11AnsGardes($targetDate null)
  1869.     {
  1870.         $enfants3a11ans = array();
  1871.         foreach ($this->enfantsAssmat as $enfant) {
  1872.             if ($enfant->getEstGarde() && $enfant->getAgeAnnees($targetDate) >= && $enfant->getAgeAnnees($targetDate) < 11) {
  1873.                 $enfants3a11ans[] = $enfant;
  1874.             }
  1875.         }
  1876.         return $enfants3a11ans;
  1877.     }
  1878.     /**
  1879.      * Obtient la liste des enfants de moins de 11 ans à la date fournie (par défaut date du jour si absente)
  1880.      * et qui ont été indiqués comme à prendre en compte pour le calcul de dépassement
  1881.      * @param type $targetDate date à laquelle on calcule l'age de l'enfant
  1882.      * @return array
  1883.      */
  1884.     public function getEnfantsAssmatMoins11AnsGardes($targetDate null)
  1885.     {
  1886.         $enfantsMoins11ans = array();
  1887.         foreach ($this->enfantsAssmat as $enfant) {
  1888.             if ($enfant->getEstGarde() && $enfant->getAgeAnnees($targetDate) < 11) {
  1889.                 $enfantsMoins11ans[] = $enfant;
  1890.             }
  1891.         }
  1892.         return $enfantsMoins11ans;
  1893.     }
  1894.     public function getDepassements()
  1895.     {
  1896.         return $this->depassements;
  1897.     }
  1898.     /**
  1899.      * Indique s'il existe au moins un accueil de nuit en cours
  1900.      */
  1901.     public function hasAccueilNuitEncours($targetDate null)
  1902.     {
  1903.         if ($targetDate == null) {
  1904.             $targetDate = new \DateTime();
  1905.         }
  1906.         foreach ($this->accueils as $accueil) {
  1907.             if ($accueil->getEstNuit() && ($accueil->getDateFin() === null || $accueil->getDateFin() >= $targetDate)) {
  1908.                 return true;
  1909.             }
  1910.         }
  1911.         return false;
  1912.     }
  1913.     /**
  1914.      * Indique s'il existe au moins un accueil atypique en cours
  1915.      */
  1916.     public function hasAccueilAtypiqueEncours($targetDate null)
  1917.     {
  1918.         if ($targetDate == null) {
  1919.             $targetDate = new \DateTime();
  1920.         }
  1921.         foreach ($this->accueils as $accueil) {
  1922.             if ($accueil->getEstAtypique() && ($accueil->getDateFin() === null || $accueil->getDateFin() >= $targetDate)) {
  1923.                 return true;
  1924.             }
  1925.         }
  1926.         return false;
  1927.     }
  1928.     /**
  1929.      * Indique s'il existe au moins un accueil déclaré avec dérogation en cours
  1930.      */
  1931.     public function hasAccueilDerogationEncours($targetDate null)
  1932.     {
  1933.         if ($targetDate == null) {
  1934.             $targetDate = new \DateTime();
  1935.         }
  1936.         foreach ($this->accueils as $accueil) {
  1937.             if ($accueil->getEstDerogation() && ($accueil->getDateFin() === null || $accueil->getDateFin() >= $targetDate)) {
  1938.                 return true;
  1939.             }
  1940.         }
  1941.         return false;
  1942.     }
  1943.     /*
  1944.      * Libellé Indiquant si l'assmat a un unique accueil et qu'il s'agit d'un premier accueil :libellé
  1945.      * @return string
  1946.      */
  1947.     public function libelleEstPremierAccueil()
  1948.     {
  1949.         // Les accueils de l'assmat
  1950.         // NB : penser au lazy loading si on utilise cette fonction dans une boucle
  1951.         // (faire jointure sur assmat.accueils)
  1952.         $accueilsAM $this->getAccueils();
  1953.         if (count($accueilsAM) == 1) {
  1954.             if ($accueilsAM[0]->getEstPremierAccueil()) {
  1955.                 return '1er accueil';
  1956.             } else {
  1957.                 return 'Unique accueil répertorié';
  1958.             }
  1959.         } else {
  1960.             return '';
  1961.         }
  1962.     }
  1963.     /**
  1964.      * Set preferences_publication
  1965.      *
  1966.      * @param PreferencesPublication $preferences_publication
  1967.      *
  1968.      * @return AssistantMaternel
  1969.      */
  1970.     public function setPreferencesPublication($preferences_publication)
  1971.     {
  1972.         $this->preferences_publication $preferences_publication;
  1973.         return $this;
  1974.     }
  1975.     /**
  1976.      * Get preferences_publication
  1977.      *
  1978.      * @return PreferencesPublication
  1979.      */
  1980.     public function getPreferencesPublication()
  1981.     {
  1982.         return $this->preferences_publication;
  1983.     }
  1984.     /**
  1985.      * Set presentation_assmat
  1986.      *
  1987.      * @param PresentationAssmat $presentation_assmat
  1988.      *
  1989.      * @return AssistantMaternel
  1990.      */
  1991.     public function setPresentationAssmat($presentation_assmat)
  1992.     {
  1993.         $this->presentation_assmat $presentation_assmat;
  1994.         return $this;
  1995.     }
  1996.     /**
  1997.      * Get presentation_assmat
  1998.      *
  1999.      * @return PresentationAssmat
  2000.      */
  2001.     public function getPresentationAssmat()
  2002.     {
  2003.         return $this->presentation_assmat;
  2004.     }
  2005.     /**
  2006.      * Get dispos_public
  2007.      *
  2008.      * @return array
  2009.      */
  2010.     public function getDisposPublic()
  2011.     {
  2012.         return $this->dispos_public;
  2013.     }
  2014.     /**
  2015.      * Get dispos_public
  2016.      * tri pour pouvoir afficher dans le bon ordre le planning de dispo juste après création
  2017.      * @param LieuAccueil $lieuAccueil
  2018.      * @return array
  2019.      */
  2020.     public function getDisposPublicByLieuAccueil($lieuAccueil)
  2021.     {
  2022.         $criteria Criteria::create()
  2023.                 ->andWhere(Criteria::expr()->eq('lieu_accueil'$lieuAccueil))
  2024.                 ->orderBy(array("tranche_horaire" => Criteria::ASC"jour_semaine" => Criteria::ASC));
  2025.         return $this->getDisposPublic()->matching($criteria);
  2026.     }
  2027.     /**
  2028.      * Get Nombre de places disponibles au pire
  2029.      * Calculé sur la base des dispos_public
  2030.      * 
  2031.      * @param LieuAccueil $lieuAccueil
  2032.      * @param TrancheAge $trancheAge
  2033.      * @return integer
  2034.      */
  2035.     public function getNombrePlacesDispoByLieuEtTrancheAge($lieuAccueil$trancheAge)
  2036.     {
  2037.         $criteria Criteria::create()
  2038.                 ->andWhere(Criteria::expr()->eq('lieu_accueil'$lieuAccueil))
  2039.                 ->andWhere(Criteria::expr()->eq('tranche_age'$trancheAge))
  2040.                 ->andWhere(Criteria::expr()->neq('nombre_places_libres'null))
  2041.                 ->orderBy(['nombre_places_libres' => Criteria::ASC])
  2042.                 ->setFirstResult(0);
  2043.         $minimum $this->getDisposPublic()->matching($criteria)[0];
  2044.         return $minimum === null $minimum->getNombrePlacesLibres();
  2045.     }
  2046.     /**
  2047.      * Générer toutes les dispos public manquantes, avec 0 places dispo
  2048.      * en fonction de periode, type, lieu accuail et de la liste de tranches d'ages, jours et plages horaires fournies
  2049.      *
  2050.      * @param Periode $periode  periode
  2051.      * @param TypeAccueil $typeAccueil type d'accueil
  2052.      * @param LieuAccueil $lieuAccueil lieu d'accueil agréé pour l'assmat
  2053.      * @param array $tranchesAge  tranches d'age
  2054.      * @param array $jours  jours de la semaine (lundi-dimanche)
  2055.      * @param array $horaires  plages horaires actives
  2056.      * @param FrequenceDispo $frequenceOccupe objt pour la frequence occupé
  2057.      * @return AssistantMaternel
  2058.      */
  2059.     public function genererDisposPublic(
  2060.             Periode $periodeTypeAccueil $typeAccueilLieuAccueil $lieuAccueil, array $tranchesAge, array $jours, array $horairesFrequenceDispo $frequenceOccupe
  2061.     )
  2062.     {
  2063.         foreach ($tranchesAge as $t) {
  2064.             foreach ($horaires as $h) {
  2065.                 foreach ($jours as $j) {
  2066.                     // Rechercher si la dispo pour ce jour/semaine existe déjà dans la liste des dispos
  2067.                     $dispo_existe $this->dispos_public->filter(function (DispoPublicAssmat $dispo) use ($periode$typeAccueil$lieuAccueil$t$h$j) {
  2068.                         return $dispo->getPeriode()->getId() === $periode->getId() &&
  2069.                                 $dispo->getTypeAccueil()->getId() === $typeAccueil->getId() &&
  2070.                                 $dispo->getLieuAccueil()->getId() === $lieuAccueil->getId() &&
  2071.                                 $dispo->getTrancheAge()->getId() === $t->getId() &&
  2072.                                 $dispo->getTrancheHoraire()->getId() === $h->getId() &&
  2073.                                 $dispo->getJourSemaine()->getId() === $j->getId();
  2074.                     });
  2075.                     // Si aucune dispo saisie pour ce jour/semaine, on la génère
  2076.                     if (!count($dispo_existe)) {
  2077.                         $this->dispos_public->add(new DispoPublicAssmat($this$periode$typeAccueil$lieuAccueil$t$h$j$frequenceOccupe));
  2078.                     }
  2079.                     // La persistence des nouvelles données se fait en dehors de la classe de l'entité
  2080.                 }
  2081.             }
  2082.         }
  2083.         return $this;
  2084.     }
  2085.     /**
  2086.      * renvoie le tableau des dispos publiques telles que définies par les déclarations d'accueil
  2087.      *
  2088.      * @return array
  2089.      */
  2090.     public function getSyncedDisposPublic($frequenceOccupe)
  2091.     {
  2092.         foreach ($this->dispos as $dg) {
  2093.             // Rechercher si la dispo $dg (issue gda) pour ce jour/semaine existe déjà dans la liste des dispos publiques
  2094.             $dispo_existe $this->dispos_public->filter(function (DispoPublicAssmat $dispo) use ($dg) {
  2095.                 return $dispo->getPeriode()->getId() === $dg->getPeriode()->getId() &&
  2096.                         $dispo->getIdTypeAccueil() === $dg->getIdTypeAccueil() &&
  2097.                         $dispo->getIdLieuAccueil() === $dg->getIdLieuAccueil() &&
  2098.                         $dispo->getTrancheAge()->getId() === $dg->getTrancheAge()->getId() &&
  2099.                         $dispo->getTrancheHoraire()->getId() === $dg->getTrancheHoraire()->getId() &&
  2100.                         $dispo->getJourSemaine()->getId() === $dg->getJourSemaine()->getId();
  2101.             });
  2102.             if ($dispo_existe != null && !$dispo_existe->isEmpty()) {
  2103.                 if ($dispo_existe->first()->getNombrePlacesLibres() !== null) {
  2104.                     //on change le nombre de places libres seulement si l'assmat n'avait pas indiqué le créneau comme non travaillé
  2105.                     $dispo_existe->first()->setNombrePlacesLibres($dg->getNombrePlacesLibres());
  2106.                 }
  2107.             } else {
  2108.                 // Si aucune dispo saisie pour ce periode/type/lieu/age/jour/horaire, on la génère
  2109.                 $newDispo = new DispoPublicAssmat(
  2110.                         $this$dg->getPeriode(), $dg->getTypeAccueil(), $dg->getLieuAccueil(), $dg->getTrancheAge(), $dg->getTrancheHoraire(), $dg->getJourSemaine(), $frequenceOccupe
  2111.                 );
  2112.                 $newDispo->setNombrePlacesLibres($dg->getNombrePlacesLibres());
  2113.                 $this->dispos_public->add($newDispo);
  2114.             }
  2115.         }
  2116.         // La persistence des nouvelles données se fait en dehors de la classe de l'entité
  2117.         return $this->dispos_public;
  2118.     }
  2119.     /**
  2120.      * Get dispos_prev
  2121.      *
  2122.      * @return array
  2123.      */
  2124.     public function getDisposPrev()
  2125.     {
  2126.         return $this->dispos_prev;
  2127.     }
  2128.     /**
  2129.      * Get dispos_prev
  2130.      *
  2131.      * @return array
  2132.      */
  2133.     public function getDisposPrevByLieuAccueil($idLieuAccueil)
  2134.     {
  2135.         return $this->dispos_prev->filter(function ($dispo_prev) use ($idLieuAccueil) {
  2136.                     return $dispo_prev->getLieuAccueil()->getId() == $idLieuAccueil;
  2137.                 });
  2138.     }
  2139.     /**
  2140.      * Get dispos_vacances
  2141.      *
  2142.      * @return array
  2143.      */
  2144.     public function getDisposVacances()
  2145.     {
  2146.         return $this->dispos_vacances;
  2147.     }
  2148.     /**
  2149.      * Générer toutes les dispos vacances manquantes, avec 0 places dispos
  2150.      * en fonction de la liste de semaines et de jours fournies
  2151.      *
  2152.      * @param $semaines Les SemaineVacances pour lesquelles générer les dispos
  2153.      * @param $jours Enum des jours de la semaine (lundi-dimanche)
  2154.      * @return AssistantMaternel
  2155.      */
  2156.     public function genererDisposVacances(array $semaines, array $jours)
  2157.     {
  2158.         // On parcourt chaque semaine et chaque jour
  2159.         foreach ($semaines as $s) {
  2160.             foreach ($jours as $j) {
  2161.                 // Rechercher si la dispo pour ce jour/semaine existe déjà dans la liste des dispos
  2162.                 $dispo_existe $this->dispos_vacances->filter(function (DispoVacancesAssmat $dispo) use ($s$j) {
  2163.                     return $dispo->getSemaine()->getId() === $s->getId() && $dispo->getJour() === $j;
  2164.                 });
  2165.                 // Si aucune dispo saisie pour ce jour/semaine, on la génère
  2166.                 if (!count($dispo_existe)) {
  2167.                     $this->dispos_vacances->add(new DispoVacancesAssmat($this$s$j));
  2168.                 }
  2169.                 // La persistence des nouvelles données se fait en dehors de la classe de l'entité
  2170.             }
  2171.         }
  2172.         return $this;
  2173.     }
  2174.     /**
  2175.      * isElligiblePremierAccueil
  2176.      * 
  2177.      * Indique si l'assmat est dans une situation permettant de déclarer un accueil comme étant le premier
  2178.      * C'est le cas si l'assmat n'a jamais déclaré d'accueil
  2179.      *           Ou si tous ses accueils existants ont été déclarés avant sa date de premier agément [EVO 24 08/2022]
  2180.      *
  2181.      * @return boolean
  2182.      */
  2183.     public function isElligiblePremierAccueil()
  2184.     {
  2185.         $accueilsAM $this->getAccueils();
  2186.         $arrayAccueils = array();
  2187.         foreach ($accueilsAM as $accueil) {
  2188.             $arrayAccueils[] = $accueil;
  2189.         }
  2190.         if (!count($accueilsAM)) {
  2191.             //aucun accueil
  2192.             return true;
  2193.         }
  2194.         $accueils_dom_posterieur false// vrai si est aggréé à domicile et qu'il existe au moins un accueil ayant débuté après
  2195.         $accueils_mam_posterieur false// vrai si est aggréé en mam et qu'il existe au moins un accueil ayant débuté après
  2196.         if ($this->date_debut_agrement_domicile) {
  2197.             $accueils_dom_posterieur count(array_filter($arrayAccueils, function ($acc) {
  2198.                         return $acc->getDateDebut() > $this->date_debut_agrement_domicile && $acc->getLieuAccueil()->getId() == EnumLieuAccueil::DOMICILE;
  2199.                     }));
  2200.         }
  2201.         if ($this->date_debut_agrement_mam) {
  2202.             $accueils_mam_posterieur count(array_filter($arrayAccueils, function ($acc) {
  2203.                         return $acc->getDateDebut() > $this->date_debut_agrement_mam && $acc->getLieuAccueil()->getId() == EnumLieuAccueil::MAM;
  2204.                     }));
  2205.         }
  2206.         if (!$accueils_dom_posterieur && !$accueils_mam_posterieur) {
  2207.             //aucun accueil posterieur à la date de re-agrément ni à domicile ni en mam
  2208.             return true;
  2209.         }
  2210.         return false;
  2211.     }
  2212.     // </editor-fold>
  2213.     // <editor-fold desc="Méthodes publiques">
  2214.     /**
  2215.      * Constructor
  2216.      */
  2217.     public function __construct()
  2218.     {
  2219.         
  2220.     }
  2221.     public function __toString()
  2222.     {
  2223.         return json_encode($this->jsonSerialize());
  2224.     }
  2225.     /*
  2226.      * Implémentation de JsonSerializable
  2227.      * Ne liste que les champs modifiables par les utilisateurs
  2228.      */
  2229.     public function jsonSerialize()
  2230.     {
  2231.         return [
  2232.             'id' => $this->id,
  2233.             'email' => $this->email,
  2234.             'archive_domicile' => $this->archive_domicile,
  2235.             'archive_mam' => $this->archive_mam,
  2236.             'supprime' => $this->supprime,
  2237.             'oppose' => $this->oppose,
  2238.             'puericultrice' => $this->puericultrice === null null $this->puericultrice->jsonSerialize(),
  2239.             'enfantsAssmat' => array_map(function ($e) {
  2240.                         return $e->jsonSerialize();
  2241.                     }, is_null($this->enfantsAssmat) ? [] : $this->enfantsAssmat->toArray())
  2242.         ];
  2243.     }
  2244.     /**
  2245.      * Obtient une nouvelle instance d'AssistantMaternel, initialisée à partir du tableau associatif fourni en paramètre
  2246.      *
  2247.      * @param array $data
  2248.      * @return AssistantMaternel
  2249.      */
  2250.     public static function createFromArray(array $data)
  2251.     {
  2252.         $newInstance = new AssistantMaternel();
  2253.         return $newInstance->initFromArray($data);
  2254.     }
  2255.     /**
  2256.      * mappe les propriétés sur l'instance à partir d'un tableau associatif
  2257.      *
  2258.      * @param array $data
  2259.      * @return void
  2260.      */
  2261.     public function initFromArray(array $data)
  2262.     {
  2263.         foreach ($data as $prop => $value) {
  2264.             $this->{$prop} = $value;
  2265.         }
  2266.         return $this;
  2267.     }
  2268.     // </editor-fold>
  2269. }