<?php
namespace App\Entity;
use App\Repository\StudentRepository;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
/**
* @ORM\Entity(repositoryClass=StudentRepository::class)
*/
class Student
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $firstName;
/**
* @ORM\Column(type="string", length=255)
*/
private $lastName;
/**
* @ORM\Column(type="boolean")
*/
private $gender;
/**
* @ORM\Column(type="date")
*/
private $birthDate;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $address;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $phone;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $fatherName;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $fatherPhone;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $motherName;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $motherPhone;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $guardianName;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $guardianPhone;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $guardianLegalRelationship;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $postName;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $birthPlace;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $nationality;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $languages;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $addressNumber;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $addressAvenue;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $addressDistrict;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $addressCommune;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $previousSchool;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $previousClass;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $previousSchoolContact;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $originDistrict;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $originTerritory;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $originSector;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $originProvince;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $healthInfo;
/**
* @ORM\ManyToOne(targetEntity=School::class, inversedBy="students")
* @ORM\JoinColumn(nullable=false)
*/
private $school;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private $updatedAt;
/**
* @ORM\ManyToOne(targetEntity=Promotion::class, inversedBy="students")
* @ORM\JoinColumn(nullable=true)
*/
private $promotion;
/**
* @ORM\OneToMany(targetEntity=Payment::class, mappedBy="student")
*/
private $payments;
/**
* @ORM\OneToMany(targetEntity=Attendance::class, mappedBy="student")
*/
private $attendances;
public function __construct()
{
$this->payments = new ArrayCollection();
}
public function __toString(): string
{
return $this->firstName . ' ' . $this->lastName;
}
public function getId(): ?int
{
return $this->id;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
public function getGender(): ?bool
{
return $this->gender;
}
public function setGender(bool $gender): self
{
$this->gender = $gender;
return $this;
}
public function getBirthDate(): ?\DateTimeInterface
{
return $this->birthDate;
}
public function setBirthDate(\DateTimeInterface $birthDate): self
{
$this->birthDate = $birthDate;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getFatherName(): ?string
{
return $this->fatherName;
}
public function setFatherName(?string $fatherName): self
{
$this->fatherName = $fatherName;
return $this;
}
public function getFatherPhone(): ?string
{
return $this->fatherPhone;
}
public function setFatherPhone(?string $fatherPhone): self
{
$this->fatherPhone = $fatherPhone;
return $this;
}
public function getMotherName(): ?string
{
return $this->motherName;
}
public function setMotherName(?string $motherName): self
{
$this->motherName = $motherName;
return $this;
}
public function getMotherPhone(): ?string
{
return $this->motherPhone;
}
public function setMotherPhone(?string $motherPhone): self
{
$this->motherPhone = $motherPhone;
return $this;
}
public function getGuardianName(): ?string
{
return $this->guardianName;
}
public function setGuardianName(?string $guardianName): self
{
$this->guardianName = $guardianName;
return $this;
}
public function getGuardianPhone(): ?string
{
return $this->guardianPhone;
}
public function setGuardianPhone(?string $guardianPhone): self
{
$this->guardianPhone = $guardianPhone;
return $this;
}
public function getGuardianLegalRelationship(): ?string
{
return $this->guardianLegalRelationship;
}
public function setGuardianLegalRelationship(?string $guardianLegalRelationship): self
{
$this->guardianLegalRelationship = $guardianLegalRelationship;
return $this;
}
public function getPostName(): ?string
{
return $this->postName;
}
public function setPostName(?string $postName): self
{
$this->postName = $postName;
return $this;
}
public function getBirthPlace(): ?string
{
return $this->birthPlace;
}
public function setBirthPlace(?string $birthPlace): self
{
$this->birthPlace = $birthPlace;
return $this;
}
public function getNationality(): ?string
{
return $this->nationality;
}
public function setNationality(?string $nationality): self
{
$this->nationality = $nationality;
return $this;
}
public function getLanguages(): ?string
{
return $this->languages;
}
public function setLanguages(?string $languages): self
{
$this->languages = $languages;
return $this;
}
public function getAddressNumber(): ?string
{
return $this->addressNumber;
}
public function setAddressNumber(?string $addressNumber): self
{
$this->addressNumber = $addressNumber;
return $this;
}
public function getAddressAvenue(): ?string
{
return $this->addressAvenue;
}
public function setAddressAvenue(?string $addressAvenue): self
{
$this->addressAvenue = $addressAvenue;
return $this;
}
public function getAddressDistrict(): ?string
{
return $this->addressDistrict;
}
public function setAddressDistrict(?string $addressDistrict): self
{
$this->addressDistrict = $addressDistrict;
return $this;
}
public function getAddressCommune(): ?string
{
return $this->addressCommune;
}
public function setAddressCommune(?string $addressCommune): self
{
$this->addressCommune = $addressCommune;
return $this;
}
public function getPreviousSchool(): ?string
{
return $this->previousSchool;
}
public function setPreviousSchool(?string $previousSchool): self
{
$this->previousSchool = $previousSchool;
return $this;
}
public function getPreviousClass(): ?string
{
return $this->previousClass;
}
public function setPreviousClass(?string $previousClass): self
{
$this->previousClass = $previousClass;
return $this;
}
public function getPreviousSchoolContact(): ?string
{
return $this->previousSchoolContact;
}
public function setPreviousSchoolContact(?string $previousSchoolContact): self
{
$this->previousSchoolContact = $previousSchoolContact;
return $this;
}
public function getOriginDistrict(): ?string
{
return $this->originDistrict;
}
public function setOriginDistrict(?string $originDistrict): self
{
$this->originDistrict = $originDistrict;
return $this;
}
public function getOriginTerritory(): ?string
{
return $this->originTerritory;
}
public function setOriginTerritory(?string $originTerritory): self
{
$this->originTerritory = $originTerritory;
return $this;
}
public function getOriginSector(): ?string
{
return $this->originSector;
}
public function setOriginSector(?string $originSector): self
{
$this->originSector = $originSector;
return $this;
}
public function getOriginProvince(): ?string
{
return $this->originProvince;
}
public function setOriginProvince(?string $originProvince): self
{
$this->originProvince = $originProvince;
return $this;
}
public function getHealthInfo(): ?string
{
return $this->healthInfo;
}
public function setHealthInfo(?string $healthInfo): self
{
$this->healthInfo = $healthInfo;
return $this;
}
public function getSchool(): ?School
{
return $this->school;
}
public function setSchool(?School $school): self
{
$this->school = $school;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getPromotion(): ?Promotion
{
return $this->promotion;
}
public function setPromotion(?Promotion $promotion): self
{
$this->promotion = $promotion;
return $this;
}
/**
* @return Collection<int, Payment>
*/
public function getPayments(): Collection
{
return $this->payments;
}
public function addPayment(Payment $payment): self
{
if (!$this->payments->contains($payment)) {
$this->payments->add($payment);
$payment->setStudent($this);
}
return $this;
}
public function removePayment(Payment $payment): self
{
if ($this->payments->removeElement($payment)) {
// set the owning side to null (unless already changed)
if ($payment->getStudent() === $this) {
$payment->setStudent(null);
}
}
return $this;
}
/**
* @return Collection<int, Attendance>
*/
public function getAttendances(): Collection
{
return $this->attendances;
}
public function addAttendance(Attendance $attendance): self
{
if (!$this->attendances->contains($attendance)) {
$this->attendances->add($attendance);
$attendance->setStudent($this);
}
return $this;
}
public function removeAttendance(Attendance $attendance): self
{
if ($this->attendances->removeElement($attendance)) {
// set the owning side to null (unless already changed)
if ($attendance->getStudent() === $this) {
$attendance->setStudent(null);
}
}
return $this;
}
/**
* Vérifie si l'élève est en ordre de paiement
*/
public function isPaymentInOrder(): bool
{
foreach ($this->payments as $payment) {
$fee = $payment->getFee();
if ($fee && !$fee->isFullyPaid()) {
return false;
}
}
return true;
}
/**
* Calcule le montant total dû par l'élève
*/
public function getTotalAmountDue(): float
{
$total = 0;
foreach ($this->payments as $payment) {
$fee = $payment->getFee();
if ($fee) {
$total += $fee->getRemainingAmount();
}
}
return $total;
}
/**
* Calcule le montant total payé par l'élève
*/
public function getTotalAmountPaid(): float
{
$total = 0;
foreach ($this->payments as $payment) {
$total += (float) $payment->getAmountPaid();
}
return $total;
}
/**
* Récupère les frais impayés de l'élève
*/
public function getUnpaidFees(): array
{
$unpaidFees = [];
foreach ($this->payments as $payment) {
$fee = $payment->getFee();
if ($fee && !$fee->isFullyPaid()) {
$unpaidFees[] = $fee;
}
}
return $unpaidFees;
}
}