src/Entity/Gestiform/Formations/Emargement/Emargement.php line 14

  1. <?php
  2. namespace App\Entity\Gestiform\Formations\Emargement;
  3. use DateTime;
  4. use DateTimeInterface;
  5. use App\Entity\AbstractEntity;
  6. use App\Entity\Gestiform\Admin\MasterListe\Masterlistelg;
  7. use App\Entity\Gestiform\Formations\Session\Planning\Event;
  8. use App\Repository\Gestiform\Formations\Emargement\EmargementRepository;
  9. use Doctrine\ORM\Mapping as ORM;
  10. #[ORM\Entity(repositoryClassEmargementRepository::class)]
  11. class Emargement extends AbstractEntity
  12. {
  13.     #[ORM\Column(type'datetime'nullabletrue)]
  14.     private ?DateTime $start null;
  15.     #[ORM\Column(type'datetime'nullabletrue)]
  16.     private ?DateTime $end null;
  17.     #[ORM\ManyToOne(targetEntityEvent::class, cascade: ['persist'], inversedBy'emargements')]
  18.     private ?Event $event;
  19.     #[ORM\Column(type'text'nullabletrue)]
  20.     private ?string $presence null;
  21.     #[ORM\Column(type'text'nullabletrue)]
  22.     private ?string $absence null;
  23.     #[ORM\ManyToOne(targetEntityMasterlistelg::class)]
  24.     private ?Masterlistelg $ampm null;
  25.     #[ORM\ManyToOne(targetEntityMasterlistelg::class)]
  26.     private ?Masterlistelg $declarationnull;
  27.     public function getStart(): ?DateTimeInterface
  28.     {
  29.         return $this->start;
  30.     }
  31.     public function setStart(?DateTimeInterface $start): static
  32.     {
  33.         $this->start $start;
  34.         return $this;
  35.     }
  36.     public function getEnd(): ?DateTimeInterface
  37.     {
  38.         return $this->end;
  39.     }
  40.     public function setEnd(?DateTimeInterface $end): static
  41.     {
  42.         $this->end $end;
  43.         return $this;
  44.     }
  45.     public function getEvent(): ?Event
  46.     {
  47.         return $this->event;
  48.     }
  49.     public function setEvent(?Event $event): static
  50.     {
  51.         $this->event $event;
  52.         return $this;
  53.     }
  54.     public function removeDataAbsence(string $idDossier): self
  55.     {
  56.         $absence json_decode($this->absence ?? '{}'true);
  57.         if (isset($absence[$idDossier])) {
  58.             unset($absence[$idDossier]);
  59.         }
  60.         $this->absence json_encode($absence);
  61.         return $this;
  62.     }
  63.     public function removeDataPresence(string $idDossier): self
  64.     {
  65.         $presence json_decode($this->presence ?? '{}'true);
  66.         if (isset($presence[$idDossier])) {
  67.             unset($presence[$idDossier]);
  68.         }
  69.         $this->presence json_encode($presence);
  70.         return $this;
  71.     }
  72.     public function addJustificatif(string $idDossierbool $justifierstring $piecestring $startJustificatifstring $endJustificatif,string $commentaireJustificatif): self
  73.     {
  74.         $dataAbsence json_decode($this->getAbsence() ?? '{}'true);
  75.         if (isset($dataAbsence[$idDossier])) {
  76.             $dataAbsence[$idDossier]['justifier'] = $justifier;
  77.             $dataAbsence[$idDossier]['piece'] = $piece;
  78.             $dataAbsence[$idDossier]['startJustificatif'] = $startJustificatif;
  79.             $dataAbsence[$idDossier]['endJustificatif'] = $endJustificatif;
  80.             $dataAbsence[$idDossier]['commentaireJustificatif'] = $commentaireJustificatif;
  81.         }
  82.         $this->absence json_encode($dataAbsence);
  83.         return $this;
  84.     }
  85.     public function getAbsence(): ?string
  86.     {
  87.         return $this->absence;
  88.     }
  89.     public function setAbsence(?string $absence): Emargement
  90.     {
  91.         $this->absence $absence;
  92.         return $this;
  93.     }
  94.     public function addAbsent(string $idDossier$motifAbsencestring $nomstring $prenomstring $commentaire ''bool $justifier falsestring $piece ''string $startJustificatif ''string $endJustificatif ''string $commentaireJustificatif ''): self
  95.     {
  96.         $dataAbsence json_decode($this->getAbsence() ?? '{}'true);
  97.         $dataAbsence[$idDossier] = [
  98.             'idDossier' => $idDossier,
  99.             'motifAbsence' => $motifAbsence,
  100.             'nom' => $nom,
  101.             'prenom' => $prenom,
  102.             'commentaire' => $commentaire,
  103.             'justifier' => $justifier,
  104.             'piece' => $piece,
  105.             'startJustificatif' => $startJustificatif,
  106.             'endJustificatif' => $endJustificatif,
  107.             'commentaireJustificatif' => $commentaireJustificatif
  108.         ];
  109.         $this->absence json_encode($dataAbsence);
  110.         return $this;
  111.     }
  112.     public function getDataPresence()
  113.     {
  114.         if ($this->presence === null || $this->presence === "") {
  115.             return [];
  116.         }
  117.         return json_decode($this->presencetrue);
  118.     }
  119.     public function getByIdDossier(string $idDossier): ?array
  120.     {
  121.         $dataAbsence $this->getDataAbsence() ?? [];
  122.         if (isset($dataAbsence[$idDossier])) {
  123.             return $dataAbsence[$idDossier];
  124.         }
  125.         return null;
  126.     }
  127.     public function getDataAbsence()
  128.     {
  129.         if ($this->absence === null || $this->absence === "") {
  130.             return [];
  131.         }
  132.         return json_decode($this->absencetrue);
  133.     }
  134.     public function addPresence(string $idDossier$motifRetardbool $retardstring $nomstring $prenomstring $commentaire): self
  135.     {
  136.         $dataPresence json_decode($this->getPresence() ?? '{}'true);
  137.         $dataPresence[$idDossier] = [
  138.             'idDossier' => $idDossier,
  139.             'nom' => $nom,
  140.             'prenom' => $prenom,
  141.             'retard' => $retard,
  142.             'motifRetard' => $motifRetard,
  143.             'commentaire' => $commentaire
  144.         ];
  145.         $this->presence json_encode($dataPresence);
  146.         return $this;
  147.     }
  148.     public function getPresence(): ?string
  149.     {
  150.         return $this->presence;
  151.     }
  152.     public function setPresence(?string $presence): Emargement
  153.     {
  154.         $this->presence $presence;
  155.         return $this;
  156.     }
  157.     public function getAmpm(): ?Masterlistelg
  158.     {
  159.         return $this->ampm;
  160.     }
  161.     public function setAmpm(?Masterlistelg $ampm): self
  162.     {
  163.         $this->ampm $ampm;
  164.         return $this;
  165.     }
  166.     public function getDeclaration(): ?Masterlistelg
  167.     {
  168.         return $this->declaration;
  169.     }
  170.     public function setDeclaration(?Masterlistelg $declaration): Emargement
  171.     {
  172.         $this->declaration $declaration;
  173.         return $this;
  174.     }
  175. }