src/Entity/Employe.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\EmployeRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * Employe = fiche personnelle d'un salarié de l'entreprise.
  7.  * L'affectation (magasin, direction, poste...) est gérée par EmployeAffectation.
  8.  *
  9.  * @ORM\Entity(repositoryClass=EmployeRepository::class)
  10.  * @ORM\Table(name="hr_employe")
  11.  */
  12. class Employe
  13. {
  14.     public const STATUT_ACTIF       'actif';
  15.     public const STATUT_SUSPENDU    'suspendu';
  16.     public const STATUT_PARTI       'parti';
  17.     public const STATUT_RETRAITE    'retraite';
  18.     public const STATUT_DECEDE      'decede';
  19.     public const SEXE_M 'M';
  20.     public const SEXE_F 'F';
  21.     public const SITUATION_CELIBATAIRE 'celibataire';
  22.     public const SITUATION_MARIE       'marie';
  23.     public const SITUATION_DIVORCE     'divorce';
  24.     public const SITUATION_VEUF        'veuf';
  25.     /** @ORM\Id @ORM\GeneratedValue @ORM\Column(type="integer") */
  26.     private $id;
  27.     /** @ORM\Column(type="string", length=30, unique=true) */
  28.     private $matricule;
  29.     /** @ORM\Column(type="string", length=80) */
  30.     private $nom;
  31.     /** @ORM\Column(type="string", length=80) */
  32.     private $prenom;
  33.     /** @ORM\Column(type="string", length=80, nullable=true, name="nom_jeune_fille") */
  34.     private $nomJeuneFille;
  35.     /** @ORM\Column(type="string", length=1, nullable=true) */
  36.     private $sexe;
  37.     /** @ORM\Column(type="date", nullable=true, name="date_naissance") */
  38.     private $dateNaissance;
  39.     /** @ORM\Column(type="string", length=120, nullable=true, name="lieu_naissance") */
  40.     private $lieuNaissance;
  41.     /** @ORM\Column(type="string", length=80, nullable=true) */
  42.     private $nationalite 'Togolaise';
  43.     /** @ORM\Column(type="string", length=30, nullable=true, name="situation_familiale") */
  44.     private $situationFamiliale;
  45.     /** @ORM\Column(type="integer", options={"default":0}, name="nb_enfants") */
  46.     private $nbEnfants 0;
  47.     /** @ORM\Column(type="integer", options={"default":0}, name="nb_enfants_a_charge") */
  48.     private $nbEnfantsACharge 0;
  49.     /** @ORM\Column(type="string", length=30, nullable=true, name="cni_numero") */
  50.     private $cniNumero;
  51.     /** @ORM\Column(type="date", nullable=true, name="cni_date_emission") */
  52.     private $cniDateEmission;
  53.     /** @ORM\Column(type="string", length=30, nullable=true, name="nif_numero") */
  54.     private $nifNumero;
  55.     /** @ORM\Column(type="string", length=30, nullable=true, name="cnss_numero") */
  56.     private $cnssNumero;
  57.     /** @ORM\Column(type="string", length=30, nullable=true, name="inam_numero") */
  58.     private $inamNumero;
  59.     /** @ORM\Column(type="string", length=120, nullable=true) */
  60.     private $email;
  61.     /** @ORM\Column(type="string", length=20, nullable=true) */
  62.     private $telephone;
  63.     /** @ORM\Column(type="string", length=20, nullable=true, name="telephone_urgence") */
  64.     private $telephoneUrgence;
  65.     /** @ORM\Column(type="string", length=120, nullable=true, name="contact_urgence") */
  66.     private $contactUrgence;
  67.     /** @ORM\Column(type="text", nullable=true) */
  68.     private $adresse;
  69.     /** @ORM\Column(type="string", length=80, nullable=true) */
  70.     private $ville;
  71.     /** @ORM\Column(type="string", length=80, nullable=true) */
  72.     private $pays 'Togo';
  73.     /** @ORM\Column(type="string", length=200, nullable=true) */
  74.     private $photo;
  75.     /** @ORM\Column(type="date", nullable=true, name="date_embauche") */
  76.     private $dateEmbauche;
  77.     /** @ORM\Column(type="date", nullable=true, name="date_fin_contrat") */
  78.     private $dateFinContrat;
  79.     /** @ORM\Column(type="date", nullable=true, name="date_depart") */
  80.     private $dateDepart;
  81.     /** @ORM\Column(type="string", length=20, options={"default":"actif"}) */
  82.     private $statut self::STATUT_ACTIF;
  83.     /** @ORM\Column(type="string", length=80, nullable=true, name="banque_nom") */
  84.     private $banqueNom;
  85.     /** @ORM\Column(type="string", length=50, nullable=true, name="banque_rib") */
  86.     private $banqueRib;
  87.     /** @ORM\Column(type="string", length=30, nullable=true, name="mode_paiement") */
  88.     private $modePaiement 'virement';
  89.     /** @ORM\Column(type="decimal", precision=14, scale=2, nullable=true, name="salaire_base") */
  90.     private $salaireBase;
  91.     /**
  92.      * @ORM\ManyToOne(targetEntity="User")
  93.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=true)
  94.      */
  95.     private $user;
  96.     /**
  97.      * @ORM\ManyToOne(targetEntity="Employe")
  98.      * @ORM\JoinColumn(name="manager_id", referencedColumnName="id", nullable=true)
  99.      */
  100.     private $manager;
  101.     /** @ORM\Column(type="text", nullable=true) */
  102.     private $notes;
  103.     /** @ORM\Column(type="datetime", name="date_creation") */
  104.     private $dateCreation;
  105.     /** @ORM\Column(type="datetime", nullable=true, name="date_suppression") */
  106.     private $dateSuppression;
  107.     /** @ORM\Column(type="text", nullable=true) */
  108.     private $journal;
  109.     /**
  110.      * Entité juridique d'appartenance (Phase GES, multi-société).
  111.      *
  112.      * @ORM\ManyToOne(targetEntity="Entite")
  113.      * @ORM\JoinColumn(name="entite_id", referencedColumnName="id", nullable=true)
  114.      */
  115.     private $entite;
  116.     public function __construct() { $this->dateCreation = new \DateTime(); }
  117.     public function getId(): ?int { return $this->id; }
  118.     public function getMatricule(): ?string { return $this->matricule; }
  119.     public function setMatricule(string $m): self $this->matricule $m; return $this; }
  120.     public function getNom(): ?string { return $this->nom; }
  121.     public function setNom(string $n): self $this->nom $n; return $this; }
  122.     public function getPrenom(): ?string { return $this->prenom; }
  123.     public function setPrenom(string $p): self $this->prenom $p; return $this; }
  124.     public function getNomJeuneFille(): ?string { return $this->nomJeuneFille; }
  125.     public function setNomJeuneFille(?string $n): self $this->nomJeuneFille $n; return $this; }
  126.     public function getSexe(): ?string { return $this->sexe; }
  127.     public function setSexe(?string $s): self $this->sexe $s; return $this; }
  128.     public function getDateNaissance(): ?\DateTimeInterface { return $this->dateNaissance; }
  129.     public function setDateNaissance(?\DateTimeInterface $d): self $this->dateNaissance $d; return $this; }
  130.     public function getLieuNaissance(): ?string { return $this->lieuNaissance; }
  131.     public function setLieuNaissance(?string $l): self $this->lieuNaissance $l; return $this; }
  132.     public function getNationalite(): ?string { return $this->nationalite; }
  133.     public function setNationalite(?string $n): self $this->nationalite $n; return $this; }
  134.     public function getSituationFamiliale(): ?string { return $this->situationFamiliale; }
  135.     public function setSituationFamiliale(?string $s): self $this->situationFamiliale $s; return $this; }
  136.     public function getNbEnfants(): int { return (int)$this->nbEnfants; }
  137.     public function setNbEnfants(int $n): self $this->nbEnfants $n; return $this; }
  138.     public function getNbEnfantsACharge(): int { return (int)$this->nbEnfantsACharge; }
  139.     public function setNbEnfantsACharge(int $n): self $this->nbEnfantsACharge $n; return $this; }
  140.     public function getCniNumero(): ?string { return $this->cniNumero; }
  141.     public function setCniNumero(?string $c): self $this->cniNumero $c; return $this; }
  142.     public function getCniDateEmission(): ?\DateTimeInterface { return $this->cniDateEmission; }
  143.     public function setCniDateEmission(?\DateTimeInterface $d): self $this->cniDateEmission $d; return $this; }
  144.     public function getNifNumero(): ?string { return $this->nifNumero; }
  145.     public function setNifNumero(?string $n): self $this->nifNumero $n; return $this; }
  146.     public function getCnssNumero(): ?string { return $this->cnssNumero; }
  147.     public function setCnssNumero(?string $n): self $this->cnssNumero $n; return $this; }
  148.     public function getInamNumero(): ?string { return $this->inamNumero; }
  149.     public function setInamNumero(?string $n): self $this->inamNumero $n; return $this; }
  150.     public function getEmail(): ?string { return $this->email; }
  151.     public function setEmail(?string $e): self $this->email $e; return $this; }
  152.     public function getTelephone(): ?string { return $this->telephone; }
  153.     public function setTelephone(?string $t): self $this->telephone $t; return $this; }
  154.     public function getTelephoneUrgence(): ?string { return $this->telephoneUrgence; }
  155.     public function setTelephoneUrgence(?string $t): self $this->telephoneUrgence $t; return $this; }
  156.     public function getContactUrgence(): ?string { return $this->contactUrgence; }
  157.     public function setContactUrgence(?string $c): self $this->contactUrgence $c; return $this; }
  158.     public function getAdresse(): ?string { return $this->adresse; }
  159.     public function setAdresse(?string $a): self $this->adresse $a; return $this; }
  160.     public function getVille(): ?string { return $this->ville; }
  161.     public function setVille(?string $v): self $this->ville $v; return $this; }
  162.     public function getPays(): ?string { return $this->pays; }
  163.     public function setPays(?string $p): self $this->pays $p; return $this; }
  164.     public function getPhoto(): ?string { return $this->photo; }
  165.     public function setPhoto(?string $p): self $this->photo $p; return $this; }
  166.     public function getDateEmbauche(): ?\DateTimeInterface { return $this->dateEmbauche; }
  167.     public function setDateEmbauche(?\DateTimeInterface $d): self $this->dateEmbauche $d; return $this; }
  168.     public function getDateFinContrat(): ?\DateTimeInterface { return $this->dateFinContrat; }
  169.     public function setDateFinContrat(?\DateTimeInterface $d): self $this->dateFinContrat $d; return $this; }
  170.     public function getDateDepart(): ?\DateTimeInterface { return $this->dateDepart; }
  171.     public function setDateDepart(?\DateTimeInterface $d): self $this->dateDepart $d; return $this; }
  172.     public function getStatut(): string { return $this->statut; }
  173.     public function setStatut(string $s): self $this->statut $s; return $this; }
  174.     public function getBanqueNom(): ?string { return $this->banqueNom; }
  175.     public function setBanqueNom(?string $b): self $this->banqueNom $b; return $this; }
  176.     public function getBanqueRib(): ?string { return $this->banqueRib; }
  177.     public function setBanqueRib(?string $r): self $this->banqueRib $r; return $this; }
  178.     public function getModePaiement(): ?string { return $this->modePaiement; }
  179.     public function setModePaiement(?string $m): self $this->modePaiement $m; return $this; }
  180.     public function getSalaireBase() { return $this->salaireBase; }
  181.     public function setSalaireBase($s): self $this->salaireBase $s; return $this; }
  182.     public function getUser(): ?User { return $this->user; }
  183.     public function setUser(?User $u): self $this->user $u; return $this; }
  184.     public function getManager(): ?Employe { return $this->manager; }
  185.     public function setManager(?Employe $m): self $this->manager $m; return $this; }
  186.     public function getNotes(): ?string { return $this->notes; }
  187.     public function setNotes(?string $n): self $this->notes $n; return $this; }
  188.     public function getDateCreation(): ?\DateTimeInterface { return $this->dateCreation; }
  189.     public function setDateCreation(\DateTimeInterface $d): self $this->dateCreation $d; return $this; }
  190.     public function getDateSuppression(): ?\DateTimeInterface { return $this->dateSuppression; }
  191.     public function setDateSuppression(?\DateTimeInterface $d): self $this->dateSuppression $d; return $this; }
  192.     public function getJournal(): ?string { return $this->journal; }
  193.     public function setJournal(?string $j): self $this->journal $j; return $this; }
  194.     public function getEntite(): ?Entite { return $this->entite; }
  195.     public function setEntite(?Entite $e): self $this->entite $e; return $this; }
  196.     public function getNomComplet(): string
  197.     {
  198.         return trim(($this->prenom ?? '').' '.($this->nom ?? ''));
  199.     }
  200.     public function getAge(): ?int
  201.     {
  202.         if (!$this->dateNaissance) return null;
  203.         return (int)$this->dateNaissance->diff(new \DateTime())->y;
  204.     }
  205.     public function getAncienneteAnnees(): ?int
  206.     {
  207.         if (!$this->dateEmbauche) return null;
  208.         $end $this->dateDepart ?: new \DateTime();
  209.         return (int)$this->dateEmbauche->diff($end)->y;
  210.     }
  211.     public function __toString(): string { return $this->getNomComplet() ?: 'Employe#'.$this->id; }
  212.     public function toArray(): array
  213.     {
  214.         return [
  215.             'id'        => $this->id,
  216.             'matricule' => $this->matricule,
  217.             'nom'       => $this->nom,
  218.             'prenom'    => $this->prenom,
  219.             'sexe'      => $this->sexe,
  220.             'date_naissance' => $this->dateNaissance?->format('Y-m-d'),
  221.             'lieu_naissance' => $this->lieuNaissance,
  222.             'nationalite'    => $this->nationalite,
  223.             'situation_familiale' => $this->situationFamiliale,
  224.             'nb_enfants'     => $this->nbEnfants,
  225.             'nb_enfants_a_charge' => $this->nbEnfantsACharge,
  226.             'cni_numero' => $this->cniNumero,
  227.             'nif_numero' => $this->nifNumero,
  228.             'cnss_numero'=> $this->cnssNumero,
  229.             'inam_numero'=> $this->inamNumero,
  230.             'email'      => $this->email,
  231.             'telephone'  => $this->telephone,
  232.             'adresse'    => $this->adresse,
  233.             'ville'      => $this->ville,
  234.             'pays'       => $this->pays,
  235.             'date_embauche' => $this->dateEmbauche?->format('Y-m-d'),
  236.             'date_fin_contrat' => $this->dateFinContrat?->format('Y-m-d'),
  237.             'date_depart' => $this->dateDepart?->format('Y-m-d'),
  238.             'statut'    => $this->statut,
  239.             'banque_nom'=> $this->banqueNom,
  240.             'banque_rib'=> $this->banqueRib,
  241.             'mode_paiement' => $this->modePaiement,
  242.             'salaire_base'  => $this->salaireBase,
  243.             'user_id'    => $this->user?->getId(),
  244.             'manager_id' => $this->manager?->getId(),
  245.             'entite_id'  => $this->entite?->getId(),
  246.         ];
  247.     }
  248. }