<?php
namespace App\Entity;
use App\Repository\TblPersonnelRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use App\Entity\Traits\TimestampableTrait;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass=TblPersonnelRepository::class)
* @Gedmo\Loggable
* @UniqueEntity(
* fields={"nom", "prenom"},
* errorPath="nom"
* )
*/
class TblPersonnel
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Gedmo\Versioned
*/
private $codeRh;
/**
* @ORM\ManyToOne(targetEntity=RefGenre::class)
* @ORM\JoinColumn(nullable=false)
* @Gedmo\Versioned
*/
private $genre;
/**
* @ORM\ManyToOne(targetEntity=RefTypePersonnel::class)
* @ORM\JoinColumn(nullable=true)
* @Gedmo\Versioned
*/
private $type;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Gedmo\Versioned
*/
private $salarie;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Gedmo\Versioned
*/
private $statut;
/**
* @ORM\ManyToOne(targetEntity=RefTypeContrat::class)
* @ORM\JoinColumn(nullable=true)
* @Gedmo\Versioned
*/
private $typeContrat;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="user_id", referencedColumnName="user_id", nullable=true)
* })
* @Gedmo\Versioned
*/
private $responsable;
/**
* @ORM\Column(type="float", nullable=true)
* @Gedmo\Versioned
*/
private $nbrHeureParSemaine;
/**
* @ORM\Column(type="float", nullable=true)
* @Gedmo\Versioned
*/
private $tarifHeure;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Gedmo\Versioned
*/
private $dateEmbauche;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Gedmo\Versioned
*/
private $dateFinEmbauche;
/**
* @ORM\ManyToOne(targetEntity=RefVille::class)
* @ORM\JoinColumn(nullable=true)
* @Gedmo\Versioned
*/
private $ville;
/**
* @ORM\ManyToOne(targetEntity=RefPays::class)
* @ORM\JoinColumn(nullable=true)
* @Gedmo\Versioned
*/
private $pays;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Gedmo\Versioned
*/
private $emploi;
/**
* @ORM\Column(type="text", nullable=true)
* @Gedmo\Versioned
*/
private $adresse;
/**
* @ORM\Column(type="text", nullable=true)
* @Gedmo\Versioned
*/
private $note;
/**
* @ORM\Column(type="string", length=255)
* @Gedmo\Versioned
*/
private $nom;
/**
* @ORM\Column(type="string", length=255)
* @Gedmo\Versioned
*/
private $prenom;
/**
* @ORM\Column(type="string", length=25)
* @Assert\Regex("/[0-9]{10}$/")
* @Gedmo\Versioned
*/
private $numTel;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Gedmo\Versioned
*/
private $email;
/**
* @ORM\Column(type="date", nullable=true)
* @Gedmo\Versioned
*/
private $dateNaissance;
/**
* @ORM\ManyToOne(targetEntity=RefFonction::class)
* @Gedmo\Versioned
*/
private $fonction;
/**
* @ORM\Column(type="string", length=10, nullable=true)
* @Gedmo\Versioned
*/
private $cin;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $tarifJours;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $tarifSalaire;
/**
* @ORM\ManyToOne(targetEntity=RefGroupe::class)
*/
private $groupe;
/**
* @ORM\ManyToMany(targetEntity=TblOperations::class, mappedBy="personnel")
*/
private $tblOperations;
/**
* @ORM\OneToMany(targetEntity=TblMission::class, mappedBy="personnel")
*/
private $missions;
/**
* @ORM\OneToMany(targetEntity=TblOperationTravail::class, mappedBy="personnel")
*/
private $tblOperationsTravail;
/**
* @ORM\OneToMany(targetEntity=TblOperationPaie::class, mappedBy="personnel")
*/
private $tblOperationPaie;
/**
* @ORM\ManyToMany(targetEntity=TblFile::class,cascade={"persist"})
* @ORM\JoinTable(name="lnk_tbl_tblPersonnel_tbl_file",
* joinColumns={
* @ORM\JoinColumn(name="tbl_tblPersonnel_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="tbl_file_id", referencedColumnName="id", nullable=false)
* }
* )
*/
private $files;
/**
* @ORM\OneToMany(targetEntity=TblMouvement::class, mappedBy="personnel")
*/
private $tblMouvements;
use TimestampableTrait;
public function __construct()
{
$this->dateEmbauche = new \DateTime();
$this->createdAt = new \DateTime();
$this->mouvements = new ArrayCollection();
$this->tblOperations = new ArrayCollection();
$this->missions = new ArrayCollection();
$this->tblOperationsTravail = new ArrayCollection();
$this->tblOperationPaie = new ArrayCollection();
$this->files = new ArrayCollection();
$this->tblMouvements = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCodeRh(): ?string
{
return $this->codeRh;
}
public function setCodeRh(string $codeRh): self
{
$this->codeRh = $codeRh;
return $this;
}
public function getGenre(): ?RefGenre
{
return $this->genre;
}
public function setGenre(?RefGenre $genre): self
{
$this->genre = $genre;
return $this;
}
public function getType(): ?RefTypePersonnel
{
return $this->type;
}
public function setType(?RefTypePersonnel $type): self
{
$this->type = $type;
return $this;
}
public function isSalarie(): ?bool
{
return $this->salarie;
}
public function setSalarie(bool $salarie): self
{
$this->salarie = $salarie;
return $this;
}
public function getStatut(): ?string
{
return $this->statut;
}
public function setStatut(string $statut): self
{
$this->statut = $statut;
return $this;
}
public function getTypeContrat(): ?RefTypeContrat
{
return $this->typeContrat;
}
public function setTypeContrat(?RefTypeContrat $typeContrat): self
{
$this->typeContrat = $typeContrat;
return $this;
}
public function getResponsable(): ?User
{
return $this->responsable;
}
public function setResponsable(?User $responsable): self
{
$this->responsable = $responsable;
return $this;
}
public function getNbrHeureParSemaine(): ?float
{
return $this->nbrHeureParSemaine;
}
public function setNbrHeureParSemaine(float $nbrHeureParSemaine): self
{
$this->nbrHeureParSemaine = $nbrHeureParSemaine;
return $this;
}
public function getTarifHeure(): ?float
{
return $this->tarifHeure;
}
public function setTarifHeure(float $tarifHeure): self
{
$this->tarifHeure = $tarifHeure;
return $this;
}
public function getDateEmbauche(): ?\DateTimeInterface
{
return $this->dateEmbauche;
}
public function setDateEmbauche(\DateTimeInterface $dateEmbauche): self
{
$this->dateEmbauche = $dateEmbauche;
return $this;
}
public function getDateFinEmbauche(): ?\DateTimeInterface
{
return $this->dateFinEmbauche;
}
public function setDateFinEmbauche(?\DateTimeInterface $dateFinEmbauche): self
{
$this->dateFinEmbauche = $dateFinEmbauche;
return $this;
}
public function getVille(): ?RefVille
{
return $this->ville;
}
public function setVille(?RefVille $ville): self
{
$this->ville = $ville;
return $this;
}
public function getPays(): ?RefPays
{
return $this->pays;
}
public function setPays(?RefPays $pays): self
{
$this->pays = $pays;
return $this;
}
public function getEmploi(): ?\DateTimeInterface
{
return $this->emploi;
}
public function setEmploi(\DateTimeInterface $emploi): self
{
$this->emploi = $emploi;
return $this;
}
public function getAdresse(): ?string
{
return $this->adresse;
}
public function setAdresse(string $adresse): self
{
$this->adresse = $adresse;
return $this;
}
public function getNote(): ?string
{
return $this->note;
}
public function setNote(?string $note): self
{
$this->note = $note;
return $this;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(string $nom): self
{
$this->nom = $nom;
return $this;
}
public function getPrenom(): ?string
{
return $this->prenom;
}
public function setPrenom(string $prenom): self
{
$this->prenom = $prenom;
return $this;
}
public function getNumTel(): ?string
{
return $this->numTel;
}
public function setNumTel(string $numTel): self
{
$this->numTel = $numTel;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getDateNaissance(): ?\DateTimeInterface
{
return $this->dateNaissance;
}
public function setDateNaissance(?\DateTimeInterface $dateNaissance): self
{
$this->dateNaissance = $dateNaissance;
return $this;
}
public function getFonction(): ?RefFonction
{
return $this->fonction;
}
public function setFonction(?RefFonction $fonction): self
{
$this->fonction = $fonction;
return $this;
}
public function generateCodeRH()
{
$firstNom = strtoupper(substr($this->getNom(),0,1));
$firstPrenom = strtoupper(substr($this->getPrenom(),0,1));
$codeTH = $firstNom . $firstPrenom . ((new DateTime())->format('ymdis'));
$this->setCodeRh($codeTH);
}
public function __toString()
{
return $this->getNom() . ' ' . $this->getPrenom();
}
public function toArrayDatatable($urlEdit, $urlShow, $resteApaye, $totalTravail)
{
return [
"",
$this->__toString(),
$resteApaye,
$totalTravail,
!$this->getGroupe() ? '--' : $this->getGroupe()->getLibelle(),
$this->getNumTel(),
$this->getCin(),
$this->getFonction()->getFonctionLib(),
$this->getCodeRh(),
'<a class="btn btn-primary" title="Modifier" href=' . $urlEdit . '><i class="ti ti-edit"></i></a>
<a class="btn btn-success" data-id='.$this->getId().' data-action = "click->form-paie#openModalPersonnel" title="paiement" ><i class="ti ti-cash"></i></a>',
];
}
public function getNumTelForWhtsp()
{
return '212'.ltrim($this->getNumTel(), $this->getNumTel()[0]);
}
public function getCin(): ?string
{
return $this->cin;
}
public function setCin(string $cin): self
{
$this->cin = $cin;
return $this;
}
public function getTarifJours(): ?float
{
return $this->tarifJours;
}
public function setTarifJours(?float $tarifJours): self
{
$this->tarifJours = $tarifJours;
return $this;
}
public function getTarifSalaire(): ?float
{
return $this->tarifSalaire;
}
public function setTarifSalaire(?float $tarifSalaire): self
{
$this->tarifSalaire = $tarifSalaire;
return $this;
}
public function getGroupe(): ?RefGroupe
{
return $this->groupe;
}
public function setGroupe(?RefGroupe $groupe): self
{
$this->groupe = $groupe;
return $this;
}
/**
* @return Collection<int, TblOperations>
*/
public function getTblOperations(): Collection
{
return $this->tblOperations;
}
public function addTblOperation(TblOperations $tblOperation): self
{
if (!$this->tblOperations->contains($tblOperation)) {
$this->tblOperations[] = $tblOperation;
$tblOperation->addPersonnel($this);
}
return $this;
}
public function removeTblOperation(TblOperations $tblOperation): self
{
if ($this->tblOperations->removeElement($tblOperation)) {
$tblOperation->removePersonnel($this);
}
return $this;
}
/**
* @return Collection<int, TblMission>
*/
public function getMissions(): Collection
{
return $this->missions;
}
public function addMission(TblMission $mission): self
{
if (!$this->missions->contains($mission)) {
$this->missions[] = $mission;
$mission->setPersonnel($this);
}
return $this;
}
public function removeMission(TblMission $mission): self
{
if ($this->missions->removeElement($mission)) {
// set the owning side to null (unless already changed)
if ($mission->getPersonnel() === $this) {
$mission->setPersonnel(null);
}
}
return $this;
}
/**
* @return Collection<int, TblOperationTravail>
*/
public function getTblOperationsTravail(): Collection
{
return $this->tblOperationsTravail;
}
public function addTblOperationsTravail(TblOperationTravail $tblOperationsTravail): self
{
if (!$this->tblOperationsTravail->contains($tblOperationsTravail)) {
$this->tblOperationsTravail[] = $tblOperationsTravail;
$tblOperationsTravail->setPersonnel($this);
}
return $this;
}
public function removeTblOperationsTravail(TblOperationTravail $tblOperationsTravail): self
{
if ($this->tblOperationsTravail->removeElement($tblOperationsTravail)) {
// set the owning side to null (unless already changed)
if ($tblOperationsTravail->getPersonnel() === $this) {
$tblOperationsTravail->setPersonnel(null);
}
}
return $this;
}
/**
* @return Collection<int, TblOperationPaie>
*/
public function getTblOperationPaie(): Collection
{
return $this->tblOperationPaie;
}
public function addTblOperationPaie(TblOperationPaie $tblOperationPaie): self
{
if (!$this->tblOperationPaie->contains($tblOperationPaie)) {
$this->tblOperationPaie[] = $tblOperationPaie;
$tblOperationPaie->setPersonnel($this);
}
return $this;
}
public function removeTblOperationPaie(TblOperationPaie $tblOperationPaie): self
{
if ($this->tblOperationPaie->removeElement($tblOperationPaie)) {
// set the owning side to null (unless already changed)
if ($tblOperationPaie->getPersonnel() === $this) {
$tblOperationPaie->setPersonnel(null);
}
}
return $this;
}
/**
* @return Collection<int, TblFile>
*/
public function getFiles(): Collection
{
return $this->files;
}
public function addFile(TblFile $file): self
{
if (!$this->files->contains($file)) {
$this->files[] = $file;
}
return $this;
}
public function removeFile(TblFile $file): self
{
$this->files->removeElement($file);
return $this;
}
/**
* @return Collection<int, TblMouvement>
*/
public function getTblMouvements(): Collection
{
return $this->tblMouvements;
}
public function addTblMouvement(TblMouvement $tblMouvement): self
{
if (!$this->tblMouvements->contains($tblMouvement)) {
$this->tblMouvements[] = $tblMouvement;
$tblMouvement->setPersonnel($this);
}
return $this;
}
public function removeTblMouvement(TblMouvement $tblMouvement): self
{
if ($this->tblMouvements->removeElement($tblMouvement)) {
// set the owning side to null (unless already changed)
if ($tblMouvement->getPersonnel() === $this) {
$tblMouvement->setPersonnel(null);
}
}
return $this;
}
}