src/Entity/TblPersonnel.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TblPersonnelRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use App\Entity\Traits\TimestampableTrait;
  7. use DateTime;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  12. /**
  13.  * @ORM\Entity(repositoryClass=TblPersonnelRepository::class)
  14.  * @Gedmo\Loggable
  15.  * @UniqueEntity(
  16.  *     fields={"nom", "prenom"},
  17.  *     errorPath="nom"
  18.  * )
  19.  */
  20. class TblPersonnel
  21. {
  22.     /**
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue
  25.      * @ORM\Column(type="integer")
  26.      */
  27.     private $id;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      * @Gedmo\Versioned
  31.      */
  32.     private $codeRh;
  33.     /**
  34.      * @ORM\ManyToOne(targetEntity=RefGenre::class)
  35.      * @ORM\JoinColumn(nullable=false)
  36.      * @Gedmo\Versioned
  37.      */
  38.     private $genre;
  39.     /**
  40.      * @ORM\ManyToOne(targetEntity=RefTypePersonnel::class)
  41.      * @ORM\JoinColumn(nullable=true)
  42.      * @Gedmo\Versioned
  43.      */
  44.     private $type;
  45.     /**
  46.      * @ORM\Column(type="boolean", nullable=true)
  47.      * @Gedmo\Versioned
  48.      */
  49.     private $salarie;
  50.     /**
  51.      * @ORM\Column(type="string", length=255, nullable=true)
  52.      * @Gedmo\Versioned
  53.      */
  54.     private $statut;
  55.     /**
  56.      * @ORM\ManyToOne(targetEntity=RefTypeContrat::class)
  57.      * @ORM\JoinColumn(nullable=true)
  58.      * @Gedmo\Versioned
  59.      */
  60.     private $typeContrat;
  61.     /**
  62.      * @ORM\ManyToOne(targetEntity=User::class)
  63.      * @ORM\JoinColumns({
  64.      *   @ORM\JoinColumn(name="user_id", referencedColumnName="user_id", nullable=true)
  65.      * })
  66.      * @Gedmo\Versioned
  67.      */
  68.     private $responsable;
  69.     /**
  70.      * @ORM\Column(type="float", nullable=true)
  71.      * @Gedmo\Versioned
  72.      */
  73.     private $nbrHeureParSemaine;
  74.     /**
  75.      * @ORM\Column(type="float", nullable=true)
  76.      * @Gedmo\Versioned
  77.      */
  78.     private $tarifHeure;
  79.     /**
  80.      * @ORM\Column(type="datetime", nullable=true)
  81.      * @Gedmo\Versioned
  82.      */
  83.     private $dateEmbauche;
  84.     /**
  85.      * @ORM\Column(type="datetime", nullable=true)
  86.      * @Gedmo\Versioned
  87.      */
  88.     private $dateFinEmbauche;
  89.     /**
  90.      * @ORM\ManyToOne(targetEntity=RefVille::class)
  91.      * @ORM\JoinColumn(nullable=true)
  92.      * @Gedmo\Versioned
  93.      */
  94.     private $ville;
  95.     /**
  96.      * @ORM\ManyToOne(targetEntity=RefPays::class)
  97.      * @ORM\JoinColumn(nullable=true)
  98.      * @Gedmo\Versioned
  99.      */
  100.     private $pays;
  101.     /**
  102.      * @ORM\Column(type="datetime", nullable=true)
  103.      * @Gedmo\Versioned
  104.      */
  105.     private $emploi;
  106.     /**
  107.      * @ORM\Column(type="text", nullable=true)
  108.      * @Gedmo\Versioned
  109.      */
  110.     private $adresse;
  111.     /**
  112.      * @ORM\Column(type="text", nullable=true)
  113.      * @Gedmo\Versioned
  114.      */
  115.     private $note;
  116.     /**
  117.      * @ORM\Column(type="string", length=255)
  118.      * @Gedmo\Versioned
  119.      */
  120.     private $nom;
  121.     /**
  122.      * @ORM\Column(type="string", length=255)
  123.      * @Gedmo\Versioned
  124.      */
  125.     private $prenom;
  126.     /**
  127.      * @ORM\Column(type="string", length=25)
  128.      * @Assert\Regex("/[0-9]{10}$/")
  129.      * @Gedmo\Versioned
  130.      */
  131.     private $numTel;
  132.     /**
  133.      * @ORM\Column(type="string", length=255, nullable=true)
  134.      * @Gedmo\Versioned
  135.      */
  136.     private $email;
  137.     /**
  138.      * @ORM\Column(type="date", nullable=true)
  139.      * @Gedmo\Versioned
  140.      */
  141.     private $dateNaissance;
  142.     /**
  143.      * @ORM\ManyToOne(targetEntity=RefFonction::class)
  144.      * @Gedmo\Versioned
  145.      */
  146.     private $fonction;
  147.     /**
  148.      * @ORM\Column(type="string", length=10, nullable=true)
  149.      * @Gedmo\Versioned
  150.      */
  151.     private $cin;
  152.     /**
  153.      * @ORM\Column(type="float", nullable=true)
  154.      */
  155.     private $tarifJours;
  156.     /**
  157.      * @ORM\Column(type="float", nullable=true)
  158.      */
  159.     private $tarifSalaire;
  160.     /**
  161.      * @ORM\ManyToOne(targetEntity=RefGroupe::class)
  162.      */
  163.     private $groupe;
  164.     
  165.     /**
  166.      * @ORM\ManyToMany(targetEntity=TblOperations::class, mappedBy="personnel")
  167.      */
  168.     private $tblOperations;
  169.     /**
  170.      * @ORM\OneToMany(targetEntity=TblMission::class, mappedBy="personnel")
  171.      */
  172.     private $missions;
  173.     /**
  174.      * @ORM\OneToMany(targetEntity=TblOperationTravail::class, mappedBy="personnel")
  175.      */
  176.     private $tblOperationsTravail;
  177.     /**
  178.      * @ORM\OneToMany(targetEntity=TblOperationPaie::class, mappedBy="personnel")
  179.      */
  180.     private $tblOperationPaie;
  181.     /**
  182.      * @ORM\ManyToMany(targetEntity=TblFile::class,cascade={"persist"})
  183.      * @ORM\JoinTable(name="lnk_tbl_tblPersonnel_tbl_file",
  184.      *   joinColumns={
  185.      *     @ORM\JoinColumn(name="tbl_tblPersonnel_id", referencedColumnName="id")
  186.      *   },
  187.      *   inverseJoinColumns={
  188.      *     @ORM\JoinColumn(name="tbl_file_id", referencedColumnName="id", nullable=false)
  189.      *   }
  190.      * )
  191.      */
  192.     private $files;
  193.     /**
  194.      * @ORM\OneToMany(targetEntity=TblMouvement::class, mappedBy="personnel")
  195.      */
  196.     private $tblMouvements;
  197.     use TimestampableTrait;
  198.     public function __construct()
  199.     {
  200.         $this->dateEmbauche = new \DateTime();
  201.         $this->createdAt = new \DateTime();
  202.         $this->mouvements = new ArrayCollection();
  203.         $this->tblOperations = new ArrayCollection();
  204.         $this->missions = new ArrayCollection();
  205.         $this->tblOperationsTravail = new ArrayCollection();
  206.         $this->tblOperationPaie = new ArrayCollection();
  207.         $this->files = new ArrayCollection();
  208.         $this->tblMouvements = new ArrayCollection();
  209.     }
  210.     public function getId(): ?int
  211.     {
  212.         return $this->id;
  213.     }
  214.     public function getCodeRh(): ?string
  215.     {
  216.         return $this->codeRh;
  217.     }
  218.     public function setCodeRh(string $codeRh): self
  219.     {
  220.         $this->codeRh $codeRh;
  221.         return $this;
  222.     }
  223.     public function getGenre(): ?RefGenre
  224.     {
  225.         return $this->genre;
  226.     }
  227.     public function setGenre(?RefGenre $genre): self
  228.     {
  229.         $this->genre $genre;
  230.         return $this;
  231.     }
  232.     public function getType(): ?RefTypePersonnel
  233.     {
  234.         return $this->type;
  235.     }
  236.     public function setType(?RefTypePersonnel $type): self
  237.     {
  238.         $this->type $type;
  239.         return $this;
  240.     }
  241.     public function isSalarie(): ?bool
  242.     {
  243.         return $this->salarie;
  244.     }
  245.     public function setSalarie(bool $salarie): self
  246.     {
  247.         $this->salarie $salarie;
  248.         return $this;
  249.     }
  250.     public function getStatut(): ?string
  251.     {
  252.         return $this->statut;
  253.     }
  254.     public function setStatut(string $statut): self
  255.     {
  256.         $this->statut $statut;
  257.         return $this;
  258.     }
  259.     public function getTypeContrat(): ?RefTypeContrat
  260.     {
  261.         return $this->typeContrat;
  262.     }
  263.     public function setTypeContrat(?RefTypeContrat $typeContrat): self
  264.     {
  265.         $this->typeContrat $typeContrat;
  266.         return $this;
  267.     }
  268.     public function getResponsable(): ?User
  269.     {
  270.         return $this->responsable;
  271.     }
  272.     public function setResponsable(?User $responsable): self
  273.     {
  274.         $this->responsable $responsable;
  275.         return $this;
  276.     }
  277.     public function getNbrHeureParSemaine(): ?float
  278.     {
  279.         return $this->nbrHeureParSemaine;
  280.     }
  281.     public function setNbrHeureParSemaine(float $nbrHeureParSemaine): self
  282.     {
  283.         $this->nbrHeureParSemaine $nbrHeureParSemaine;
  284.         return $this;
  285.     }
  286.     public function getTarifHeure(): ?float
  287.     {
  288.         return $this->tarifHeure;
  289.     }
  290.     public function setTarifHeure(float $tarifHeure): self
  291.     {
  292.         $this->tarifHeure $tarifHeure;
  293.         return $this;
  294.     }
  295.     public function getDateEmbauche(): ?\DateTimeInterface
  296.     {
  297.         return $this->dateEmbauche;
  298.     }
  299.     public function setDateEmbauche(\DateTimeInterface $dateEmbauche): self
  300.     {
  301.         $this->dateEmbauche $dateEmbauche;
  302.         return $this;
  303.     }
  304.     public function getDateFinEmbauche(): ?\DateTimeInterface
  305.     {
  306.         return $this->dateFinEmbauche;
  307.     }
  308.     public function setDateFinEmbauche(?\DateTimeInterface $dateFinEmbauche): self
  309.     {
  310.         $this->dateFinEmbauche $dateFinEmbauche;
  311.         return $this;
  312.     }
  313.     public function getVille(): ?RefVille
  314.     {
  315.         return $this->ville;
  316.     }
  317.     public function setVille(?RefVille $ville): self
  318.     {
  319.         $this->ville $ville;
  320.         return $this;
  321.     }
  322.     public function getPays(): ?RefPays
  323.     {
  324.         return $this->pays;
  325.     }
  326.     public function setPays(?RefPays $pays): self
  327.     {
  328.         $this->pays $pays;
  329.         return $this;
  330.     }
  331.     public function getEmploi(): ?\DateTimeInterface
  332.     {
  333.         return $this->emploi;
  334.     }
  335.     public function setEmploi(\DateTimeInterface $emploi): self
  336.     {
  337.         $this->emploi $emploi;
  338.         return $this;
  339.     }
  340.     public function getAdresse(): ?string
  341.     {
  342.         return $this->adresse;
  343.     }
  344.     public function setAdresse(string $adresse): self
  345.     {
  346.         $this->adresse $adresse;
  347.         return $this;
  348.     }
  349.     public function getNote(): ?string
  350.     {
  351.         return $this->note;
  352.     }
  353.     public function setNote(?string $note): self
  354.     {
  355.         $this->note $note;
  356.         return $this;
  357.     }
  358.     public function getNom(): ?string
  359.     {
  360.         return $this->nom;
  361.     }
  362.     public function setNom(string $nom): self
  363.     {
  364.         $this->nom $nom;
  365.         return $this;
  366.     }
  367.     public function getPrenom(): ?string
  368.     {
  369.         return $this->prenom;
  370.     }
  371.     public function setPrenom(string $prenom): self
  372.     {
  373.         $this->prenom $prenom;
  374.         return $this;
  375.     }
  376.     public function getNumTel(): ?string
  377.     {
  378.         return $this->numTel;
  379.     }
  380.     public function setNumTel(string $numTel): self
  381.     {
  382.         $this->numTel $numTel;
  383.         return $this;
  384.     }
  385.     public function getEmail(): ?string
  386.     {
  387.         return $this->email;
  388.     }
  389.     public function setEmail(?string $email): self
  390.     {
  391.         $this->email $email;
  392.         return $this;
  393.     }
  394.     public function getDateNaissance(): ?\DateTimeInterface
  395.     {
  396.         return $this->dateNaissance;
  397.     }
  398.     public function setDateNaissance(?\DateTimeInterface $dateNaissance): self
  399.     {
  400.         $this->dateNaissance $dateNaissance;
  401.         return $this;
  402.     }
  403.     public function getFonction(): ?RefFonction
  404.     {
  405.         return $this->fonction;
  406.     }
  407.     public function setFonction(?RefFonction $fonction): self
  408.     {
  409.         $this->fonction $fonction;
  410.         return $this;
  411.     }
  412.     public function generateCodeRH()
  413.     {
  414.         $firstNom strtoupper(substr($this->getNom(),0,1));
  415.         $firstPrenom strtoupper(substr($this->getPrenom(),0,1));
  416.         $codeTH $firstNom $firstPrenom . ((new DateTime())->format('ymdis'));
  417.         $this->setCodeRh($codeTH);
  418.     }
  419.     public function __toString()
  420.     {
  421.         return $this->getNom() . ' ' $this->getPrenom();
  422.     }
  423.     public function toArrayDatatable($urlEdit$urlShow$resteApaye$totalTravail)
  424.     {
  425.         return [
  426.             "",
  427.             $this->__toString(),
  428.             $resteApaye,
  429.             $totalTravail,
  430.             !$this->getGroupe() ? '--' $this->getGroupe()->getLibelle(),
  431.             $this->getNumTel(),
  432.             $this->getCin(),
  433.             $this->getFonction()->getFonctionLib(),
  434.             $this->getCodeRh(),
  435.             '<a class="btn btn-primary" title="Modifier" href=' $urlEdit '><i class="ti ti-edit"></i></a>
  436.              <a class="btn btn-success" data-id='.$this->getId().' data-action = "click->form-paie#openModalPersonnel" title="paiement" ><i class="ti ti-cash"></i></a>',
  437.         ];
  438.     } 
  439.     public function getNumTelForWhtsp()
  440.     {
  441.         return '212'.ltrim($this->getNumTel(), $this->getNumTel()[0]);
  442.     }
  443.     public function getCin(): ?string
  444.     {
  445.         return $this->cin;
  446.     }
  447.     public function setCin(string $cin): self
  448.     {
  449.         $this->cin $cin;
  450.         return $this;
  451.     }
  452.     public function getTarifJours(): ?float
  453.     {
  454.         return $this->tarifJours;
  455.     }
  456.     public function setTarifJours(?float $tarifJours): self
  457.     {
  458.         $this->tarifJours $tarifJours;
  459.         return $this;
  460.     }
  461.     public function getTarifSalaire(): ?float
  462.     {
  463.         return $this->tarifSalaire;
  464.     }
  465.     public function setTarifSalaire(?float $tarifSalaire): self
  466.     {
  467.         $this->tarifSalaire $tarifSalaire;
  468.         return $this;
  469.     }
  470.     public function getGroupe(): ?RefGroupe
  471.     {
  472.         return $this->groupe;
  473.     }
  474.     public function setGroupe(?RefGroupe $groupe): self
  475.     {
  476.         $this->groupe $groupe;
  477.         
  478.         return $this;
  479.     }
  480.     /**
  481.      * @return Collection<int, TblOperations>
  482.      */
  483.     public function getTblOperations(): Collection
  484.     {
  485.         return $this->tblOperations;
  486.     }
  487.     public function addTblOperation(TblOperations $tblOperation): self
  488.     {
  489.         if (!$this->tblOperations->contains($tblOperation)) {
  490.             $this->tblOperations[] = $tblOperation;
  491.             $tblOperation->addPersonnel($this);
  492.         }
  493.         return $this;
  494.     }
  495.     public function removeTblOperation(TblOperations $tblOperation): self
  496.     {
  497.         if ($this->tblOperations->removeElement($tblOperation)) {
  498.             $tblOperation->removePersonnel($this);
  499.         }
  500.         return $this;
  501.     }
  502.     /**
  503.      * @return Collection<int, TblMission>
  504.      */
  505.     public function getMissions(): Collection
  506.     {
  507.         return $this->missions;
  508.     }
  509.     public function addMission(TblMission $mission): self
  510.     {
  511.         if (!$this->missions->contains($mission)) {
  512.             $this->missions[] = $mission;
  513.             $mission->setPersonnel($this);
  514.         }
  515.         return $this;
  516.     }
  517.     public function removeMission(TblMission $mission): self
  518.     {
  519.         if ($this->missions->removeElement($mission)) {
  520.             // set the owning side to null (unless already changed)
  521.             if ($mission->getPersonnel() === $this) {
  522.                 $mission->setPersonnel(null);
  523.             }
  524.         }
  525.         return $this;
  526.     }
  527.     /**
  528.      * @return Collection<int, TblOperationTravail>
  529.      */
  530.     public function getTblOperationsTravail(): Collection
  531.     {
  532.         return $this->tblOperationsTravail;
  533.     }
  534.     public function addTblOperationsTravail(TblOperationTravail $tblOperationsTravail): self
  535.     {
  536.         if (!$this->tblOperationsTravail->contains($tblOperationsTravail)) {
  537.             $this->tblOperationsTravail[] = $tblOperationsTravail;
  538.             $tblOperationsTravail->setPersonnel($this);
  539.         }
  540.         return $this;
  541.     }
  542.     public function removeTblOperationsTravail(TblOperationTravail $tblOperationsTravail): self
  543.     {
  544.         if ($this->tblOperationsTravail->removeElement($tblOperationsTravail)) {
  545.             // set the owning side to null (unless already changed)
  546.             if ($tblOperationsTravail->getPersonnel() === $this) {
  547.                 $tblOperationsTravail->setPersonnel(null);
  548.             }
  549.         }
  550.         return $this;
  551.     }
  552.     /**
  553.      * @return Collection<int, TblOperationPaie>
  554.      */
  555.     public function getTblOperationPaie(): Collection
  556.     {
  557.         return $this->tblOperationPaie;
  558.     }
  559.     public function addTblOperationPaie(TblOperationPaie $tblOperationPaie): self
  560.     {
  561.         if (!$this->tblOperationPaie->contains($tblOperationPaie)) {
  562.             $this->tblOperationPaie[] = $tblOperationPaie;
  563.             $tblOperationPaie->setPersonnel($this);
  564.         }
  565.         return $this;
  566.     }
  567.     public function removeTblOperationPaie(TblOperationPaie $tblOperationPaie): self
  568.     {
  569.         if ($this->tblOperationPaie->removeElement($tblOperationPaie)) {
  570.             // set the owning side to null (unless already changed)
  571.             if ($tblOperationPaie->getPersonnel() === $this) {
  572.                 $tblOperationPaie->setPersonnel(null);
  573.             }
  574.         }
  575.         return $this;
  576.     }
  577.     /**
  578.      * @return Collection<int, TblFile>
  579.      */
  580.     public function getFiles(): Collection
  581.     {
  582.         return $this->files;
  583.     }
  584.     public function addFile(TblFile $file): self
  585.     {
  586.         if (!$this->files->contains($file)) {
  587.             $this->files[] = $file;
  588.         }
  589.         return $this;
  590.     }
  591.     public function removeFile(TblFile $file): self
  592.     {
  593.         $this->files->removeElement($file);
  594.         return $this;
  595.     }
  596.     /**
  597.      * @return Collection<int, TblMouvement>
  598.      */
  599.     public function getTblMouvements(): Collection
  600.     {
  601.         return $this->tblMouvements;
  602.     }
  603.     public function addTblMouvement(TblMouvement $tblMouvement): self
  604.     {
  605.         if (!$this->tblMouvements->contains($tblMouvement)) {
  606.             $this->tblMouvements[] = $tblMouvement;
  607.             $tblMouvement->setPersonnel($this);
  608.         }
  609.         return $this;
  610.     }
  611.     public function removeTblMouvement(TblMouvement $tblMouvement): self
  612.     {
  613.         if ($this->tblMouvements->removeElement($tblMouvement)) {
  614.             // set the owning side to null (unless already changed)
  615.             if ($tblMouvement->getPersonnel() === $this) {
  616.                 $tblMouvement->setPersonnel(null);
  617.             }
  618.         }
  619.         return $this;
  620.     }
  621.     }