src/Entity/Presence.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PresenceRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClassPresenceRepository::class)]
  7. class Presence
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column]
  12.     private ?int $id null;
  13.     #[ORM\ManyToOne(inversedBy'presences')]
  14.     #[ORM\JoinColumn(nullablefalse)]
  15.     private ?Employe $employe null;
  16.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  17.     private ?\DateTimeInterface $date null;
  18.     #[ORM\Column(typeTypes::TIME_MUTABLEnullabletrue)]
  19.     private ?\DateTimeInterface $heureArrivee null;
  20.     #[ORM\Column(typeTypes::TIME_MUTABLEnullabletrue)]
  21.     private ?\DateTimeInterface $heureDepart null;
  22.     #[ORM\Column(length50)]
  23.     private ?string $statut 'present'// present, absent, retard, conge, maladie
  24.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  25.     private ?string $notes null;
  26.     #[ORM\Column(typeTypes::DECIMALprecision5scale2nullabletrue)]
  27.     private ?string $heuresTravaillees null;
  28.     #[ORM\Column]
  29.     private ?\DateTimeImmutable $createdAt null;
  30.     #[ORM\Column(nullabletrue)]
  31.     private ?\DateTimeImmutable $updatedAt null;
  32.     public function __construct()
  33.     {
  34.         $this->createdAt = new \DateTimeImmutable();
  35.     }
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getEmploye(): ?Employe
  41.     {
  42.         return $this->employe;
  43.     }
  44.     public function setEmploye(?Employe $employe): static
  45.     {
  46.         $this->employe $employe;
  47.         return $this;
  48.     }
  49.     public function getDate(): ?\DateTimeInterface
  50.     {
  51.         return $this->date;
  52.     }
  53.     public function setDate(\DateTimeInterface $date): static
  54.     {
  55.         $this->date $date;
  56.         return $this;
  57.     }
  58.     public function getHeureArrivee(): ?\DateTimeInterface
  59.     {
  60.         return $this->heureArrivee;
  61.     }
  62.     public function setHeureArrivee(?\DateTimeInterface $heureArrivee): static
  63.     {
  64.         $this->heureArrivee $heureArrivee;
  65.         return $this;
  66.     }
  67.     public function getHeureDepart(): ?\DateTimeInterface
  68.     {
  69.         return $this->heureDepart;
  70.     }
  71.     public function setHeureDepart(?\DateTimeInterface $heureDepart): static
  72.     {
  73.         $this->heureDepart $heureDepart;
  74.         return $this;
  75.     }
  76.     public function getStatut(): ?string
  77.     {
  78.         return $this->statut;
  79.     }
  80.     public function setStatut(string $statut): static
  81.     {
  82.         $this->statut $statut;
  83.         return $this;
  84.     }
  85.     public function getNotes(): ?string
  86.     {
  87.         return $this->notes;
  88.     }
  89.     public function setNotes(?string $notes): static
  90.     {
  91.         $this->notes $notes;
  92.         return $this;
  93.     }
  94.     public function getHeuresTravaillees(): ?string
  95.     {
  96.         return $this->heuresTravaillees;
  97.     }
  98.     public function setHeuresTravaillees(?string $heuresTravaillees): static
  99.     {
  100.         $this->heuresTravaillees $heuresTravaillees;
  101.         return $this;
  102.     }
  103.     public function getCreatedAt(): ?\DateTimeImmutable
  104.     {
  105.         return $this->createdAt;
  106.     }
  107.     public function setCreatedAt(\DateTimeImmutable $createdAt): static
  108.     {
  109.         $this->createdAt $createdAt;
  110.         return $this;
  111.     }
  112.     public function getUpdatedAt(): ?\DateTimeImmutable
  113.     {
  114.         return $this->updatedAt;
  115.     }
  116.     public function setUpdatedAt(?\DateTimeImmutable $updatedAt): static
  117.     {
  118.         $this->updatedAt $updatedAt;
  119.         return $this;
  120.     }
  121.     public function calculerHeuresTravaillees(): void
  122.     {
  123.         if ($this->heureArrivee && $this->heureDepart) {
  124.             $diff $this->heureArrivee->diff($this->heureDepart);
  125.             $heures $diff->+ ($diff->60);
  126.             $this->heuresTravaillees number_format($heures2);
  127.         }
  128.     }
  129.     public function __toString(): string
  130.     {
  131.         return ($this->employe $this->employe->getNomComplet() : '') . ' - ' . ($this->date $this->date->format('d/m/Y') : '');
  132.     }
  133. }