src/Entity/DailyAbsence.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\Timestampable;
  4. use App\Repository\DailyAbsenceRepository;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. // Absence journalière — écoles primaires/maternelles uniquement. L'appel s'y
  8. // fait une fois par jour pour toute la classe (pas par matière/période comme
  9. // au secondaire, voir Absence.php qui reste lié à AgendaElement/Exams et
  10. // n'est pas touché). startAt/endAt sont des DATETIME (pas juste une heure ou
  11. // une date) pour permettre un intervalle explicite sur plusieurs jours (ex:
  12. // absent de mardi 14h à jeudi 10h), en plus du cas simple d'appel : "heure de
  13. // l'absence" connue immédiatement (startAt), "heure de retour" (endAt)
  14. // inconnue au moment de la saisie et complétée plus tard quand l'élève
  15. // revient — endAt est donc nullable, contrairement à une déclaration
  16. // d'intervalle où les deux bornes sont toujours connues d'avance. Entité
  17. // neuve et isolée : aucun rapport avec Absence/AgendaElement/Exams existants.
  18. #[ORM\HasLifecycleCallbacks]
  19. #[ORM\Entity(repositoryClassDailyAbsenceRepository::class)]
  20. class DailyAbsence
  21. {
  22.     use Timestampable;
  23.     #[ORM\Id]
  24.     #[ORM\GeneratedValue]
  25.     #[ORM\Column]
  26.     private ?int $id null;
  27.     #[ORM\ManyToOne]
  28.     #[ORM\JoinColumn(nullablefalse)]
  29.     private ?Student $student null;
  30.     #[ORM\ManyToOne]
  31.     #[ORM\JoinColumn(nullablefalse)]
  32.     private ?TheClass $classe null;
  33.     // Primaire/maternelle : absence rattachée à l'évaluation mensuelle (pas de
  34.     // séquence dans ce système), choisie explicitement par l'utilisateur au
  35.     // même titre que pour la saisie des notes (voir PrimaryComponentNote et
  36.     // PrimaryEvaluation). Le trimestre est accessible via getQuarter().
  37.     #[ORM\ManyToOne]
  38.     #[ORM\JoinColumn(nullablefalse)]
  39.     private ?PrimaryEvaluation $evaluation null;
  40.     // "type" explicite requis (comme Absence/Late::$startTime) : sans lui
  41.     // Doctrine mappe la colonne en "string" par défaut, et l'insertion plante
  42.     // avec "Object of class DateTime could not be converted to string" dès
  43.     // qu'on persiste un DateTime brut ici.
  44.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  45.     private ?\DateTimeInterface $startAt null;
  46.     // Nullable : null = élève toujours absent, heure de retour pas encore
  47.     // connue/saisie (cas normal juste après l'appel). Voir isReturned().
  48.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  49.     private ?\DateTimeInterface $endAt null;
  50.     #[ORM\Column]
  51.     private bool $justified false;
  52.     #[ORM\Column(length255nullabletrue)]
  53.     private ?string $motif null;
  54.     #[ORM\ManyToOne]
  55.     #[ORM\JoinColumn(nullablefalse)]
  56.     private ?School $school null;
  57.     #[ORM\ManyToOne]
  58.     #[ORM\JoinColumn(nullablefalse)]
  59.     private ?SchoolYear $year null;
  60.     #[ORM\ManyToOne]
  61.     #[ORM\JoinColumn(nullablefalse)]
  62.     private ?User $author null;
  63.     public function getId(): ?int
  64.     {
  65.         return $this->id;
  66.     }
  67.     public function getStudent(): ?Student
  68.     {
  69.         return $this->student;
  70.     }
  71.     public function setStudent(?Student $student): static
  72.     {
  73.         $this->student $student;
  74.         return $this;
  75.     }
  76.     public function getClasse(): ?TheClass
  77.     {
  78.         return $this->classe;
  79.     }
  80.     public function setClasse(?TheClass $classe): static
  81.     {
  82.         $this->classe $classe;
  83.         return $this;
  84.     }
  85.     public function getEvaluation(): ?PrimaryEvaluation
  86.     {
  87.         return $this->evaluation;
  88.     }
  89.     public function setEvaluation(?PrimaryEvaluation $evaluation): static
  90.     {
  91.         $this->evaluation $evaluation;
  92.         return $this;
  93.     }
  94.     public function getQuarter(): ?Quarter
  95.     {
  96.         return $this->evaluation?->getQuarter();
  97.     }
  98.     public function getStartAt(): ?\DateTimeInterface
  99.     {
  100.         return $this->startAt;
  101.     }
  102.     public function setStartAt(\DateTimeInterface $startAt): static
  103.     {
  104.         $this->startAt $startAt;
  105.         return $this;
  106.     }
  107.     public function getEndAt(): ?\DateTimeInterface
  108.     {
  109.         return $this->endAt;
  110.     }
  111.     public function setEndAt(?\DateTimeInterface $endAt): static
  112.     {
  113.         $this->endAt $endAt;
  114.         return $this;
  115.     }
  116.     /** Heure de retour déjà saisie ? Sinon l'élève est toujours compté absent. */
  117.     public function isReturned(): bool
  118.     {
  119.         return $this->endAt !== null;
  120.     }
  121.     public function isJustified(): bool
  122.     {
  123.         return $this->justified;
  124.     }
  125.     public function setJustified(bool $justified): static
  126.     {
  127.         $this->justified $justified;
  128.         return $this;
  129.     }
  130.     public function getMotif(): ?string
  131.     {
  132.         return $this->motif;
  133.     }
  134.     public function setMotif(?string $motif): static
  135.     {
  136.         $this->motif $motif;
  137.         return $this;
  138.     }
  139.     public function getSchool(): ?School
  140.     {
  141.         return $this->school;
  142.     }
  143.     public function setSchool(?School $school): static
  144.     {
  145.         $this->school $school;
  146.         return $this;
  147.     }
  148.     public function getYear(): ?SchoolYear
  149.     {
  150.         return $this->year;
  151.     }
  152.     public function setYear(?SchoolYear $year): static
  153.     {
  154.         $this->year $year;
  155.         return $this;
  156.     }
  157.     public function getAuthor(): ?User
  158.     {
  159.         return $this->author;
  160.     }
  161.     public function setAuthor(?User $author): static
  162.     {
  163.         $this->author $author;
  164.         return $this;
  165.     }
  166. }