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

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