<?php
namespace App\Entity;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\Collection;
use App\Repository\SchoolReportCardRepository;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity(repositoryClass=SchoolReportCardRepository::class)
*/
class SchoolReportCard
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=60, unique=true)
*/
private $code;
/**
* @ORM\Column(type="string", length=128)
*/
private $label;
/**
* @ORM\Column(type="float")
*/
private $note_on;
/**
* @ORM\ManyToOne(targetEntity=Establishment::class, inversedBy="schoolReportCards")
* @ORM\JoinColumn(nullable=false)
*/
private $establishment;
/**
* @ORM\ManyToOne(targetEntity=SchoolYear::class, inversedBy="schoolReportCards")
* @ORM\JoinColumn(nullable=false)
*/
private $schoolYear;
/**
* @ORM\ManyToOne(targetEntity=SchoolYearPeriode::class, inversedBy="schoolReportCards")
* @ORM\JoinColumn(nullable=false)
*/
private $schoolYearPeriode;
/**
* @ORM\ManyToOne(targetEntity=RegistrationStudentRegistration::class, inversedBy="schoolReportCards")
* @ORM\JoinColumn(nullable=false)
*/
private $studentRegistration;
/**
* @ORM\ManyToOne(targetEntity=SettingClassroom::class, inversedBy="schoolReportCards")
* @ORM\JoinColumn(nullable=false)
*/
private $classroom;
/**
* @ORM\Column(type="float")
*/
private $coefficient;
/**
* @ORM\Column(type="integer")
*/
private $order_num;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $created_at;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $updated_at;
/**
* @ORM\Column(type="integer")
*/
private $created_by;
/**
* @ORM\Column(type="integer")
*/
private $updated_by;
/**
* @ORM\OneToMany(targetEntity=SchoolAverageReportCard::class, mappedBy="reportCard")
* @ORM\OrderBy({"order_num" = "ASC"})
*/
private $schoolAverageReportCards;
/**
* @ORM\OneToMany(targetEntity=SchoolAssessmentByClass::class, mappedBy="reportCard")
*/
private $schoolAssessmentByClasses;
/**
* @ORM\OneToMany(targetEntity=SchoolAssessmentByLevel::class, mappedBy="reportCard")
*/
private $schoolAssessmentByLevels;
/**
* @ORM\OneToMany(targetEntity=SchoolAssessmentByClassByMatter::class, mappedBy="reportCard")
*/
private $schoolAssessmentByClassByMatters;
/**
* @ORM\OneToMany(targetEntity=SchoolAssessmentByLevelByMatter::class, mappedBy="reportCard")
*/
private $schoolAssessmentByLevelByMatters;
/**
* @ORM\ManyToOne(targetEntity=ReportCard::class, inversedBy="schoolReportCards")
* @ORM\JoinColumn(nullable=false)
*/
private $reportCard;
/**
* @ORM\Column(type="string", length=128)
*/
private $type;
/**
* @ORM\Column(type="boolean")
*/
private $is_validated;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $report_card_average;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $class_average;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $smallest_average;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $sstrongest_average;
/**
* @ORM\Column(type="string", length=60, nullable=true)
*/
private $rank;
/**
* @ORM\Column(type="string", length=60, nullable=true)
*/
private $level_rank;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $total_average;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $total_coefficient;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $justified_absence;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $unjustified_absence;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $annual_average;
/**
* @ORM\Column(type="string", length=60, nullable=true)
*/
private $annual_rank;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $class_annual_average;
/**
* @ORM\Column(type="boolean")
*/
private $is_unclassified;
/**
* @ORM\ManyToOne(targetEntity=SchoolReportCardAbsence::class, inversedBy="schoolReportCards")
*/
private $schoolReportCardAbsence;
public function __construct()
{
$this->total_average = 0;
$this->total_coefficient = 0;
$this->is_validated = false;
$this->is_unclassified = false;
$this->schoolAverageReportCards = new ArrayCollection();
$this->schoolAssessmentByClasses = new ArrayCollection();
$this->schoolAssessmentByLevels = new ArrayCollection();
$this->schoolAssessmentByClassByMatters = new ArrayCollection();
$this->schoolAssessmentByLevelByMatters = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getEstablishment(): ?Establishment
{
return $this->establishment;
}
public function setEstablishment(?Establishment $establishment): self
{
$this->establishment = $establishment;
return $this;
}
public function getSchoolYear(): ?SchoolYear
{
return $this->schoolYear;
}
public function setSchoolYear(?SchoolYear $schoolYear): self
{
$this->schoolYear = $schoolYear;
return $this;
}
public function getSchoolYearPeriode(): ?SchoolYearPeriode
{
return $this->schoolYearPeriode;
}
public function setSchoolYearPeriode(?SchoolYearPeriode $schoolYearPeriode): self
{
$this->schoolYearPeriode = $schoolYearPeriode;
return $this;
}
public function getStudentRegistration(): ?RegistrationStudentRegistration
{
return $this->studentRegistration;
}
public function setStudentRegistration(?RegistrationStudentRegistration $studentRegistration): self
{
$this->studentRegistration = $studentRegistration;
return $this;
}
public function getClassroom(): ?SettingClassroom
{
return $this->classroom;
}
public function setClassroom(?SettingClassroom $classroom): self
{
$this->classroom = $classroom;
return $this;
}
public function getCoefficient(): ?float
{
return $this->coefficient;
}
public function setCoefficient(float $coefficient): self
{
$this->coefficient = $coefficient;
return $this;
}
public function getOrderNum(): ?int
{
return $this->order_num;
}
public function setOrderNum(int $order_num): self
{
$this->order_num = $order_num;
return $this;
}
/**
* @return Collection|SchoolAverageReportCard[]
*/
public function getSchoolAverageReportCards(): Collection
{
return $this->schoolAverageReportCards;
}
public function addSchoolAverageReportCard(SchoolAverageReportCard $schoolAverageReportCard): self
{
if (!$this->schoolAverageReportCards->contains($schoolAverageReportCard)) {
$this->schoolAverageReportCards[] = $schoolAverageReportCard;
$schoolAverageReportCard->setReportCard($this);
}
return $this;
}
public function removeSchoolAverageReportCard(SchoolAverageReportCard $schoolAverageReportCard): self
{
if ($this->schoolAverageReportCards->removeElement($schoolAverageReportCard)) {
// set the owning side to null (unless already changed)
if ($schoolAverageReportCard->getReportCard() === $this) {
$schoolAverageReportCard->setReportCard(null);
}
}
return $this;
}
/**
* @return Collection|SchoolAssessmentByClass[]
*/
public function getSchoolAssessmentByClasses(): Collection
{
return $this->schoolAssessmentByClasses;
}
public function addSchoolAssessmentByClass(SchoolAssessmentByClass $schoolAssessmentByClass): self
{
if (!$this->schoolAssessmentByClasses->contains($schoolAssessmentByClass)) {
$this->schoolAssessmentByClasses[] = $schoolAssessmentByClass;
$schoolAssessmentByClass->setReportCard($this);
}
return $this;
}
public function removeSchoolAssessmentByClass(SchoolAssessmentByClass $schoolAssessmentByClass): self
{
if ($this->schoolAssessmentByClasses->removeElement($schoolAssessmentByClass)) {
// set the owning side to null (unless already changed)
if ($schoolAssessmentByClass->getReportCard() === $this) {
$schoolAssessmentByClass->setReportCard(null);
}
}
return $this;
}
/**
* @return Collection|SchoolAssessmentByLevel[]
*/
public function getSchoolAssessmentByLevels(): Collection
{
return $this->schoolAssessmentByLevels;
}
public function addSchoolAssessmentByLevel(SchoolAssessmentByLevel $schoolAssessmentByLevel): self
{
if (!$this->schoolAssessmentByLevels->contains($schoolAssessmentByLevel)) {
$this->schoolAssessmentByLevels[] = $schoolAssessmentByLevel;
$schoolAssessmentByLevel->setReportCard($this);
}
return $this;
}
public function removeSchoolAssessmentByLevel(SchoolAssessmentByLevel $schoolAssessmentByLevel): self
{
if ($this->schoolAssessmentByLevels->removeElement($schoolAssessmentByLevel)) {
// set the owning side to null (unless already changed)
if ($schoolAssessmentByLevel->getReportCard() === $this) {
$schoolAssessmentByLevel->setReportCard(null);
}
}
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeImmutable $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updated_at;
}
public function setUpdatedAt(\DateTimeImmutable $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}
public function getCreatedBy(): ?int
{
return $this->created_by;
}
public function setCreatedBy(int $created_by): self
{
$this->created_by = $created_by;
return $this;
}
public function getUpdatedBy(): ?int
{
return $this->updated_by;
}
public function setUpdatedBy(int $updated_by): self
{
$this->updated_by = $updated_by;
return $this;
}
/**
* @return Collection|SchoolAssessmentByClassByMatter[]
*/
public function getSchoolAssessmentByClassByMatters(): Collection
{
return $this->schoolAssessmentByClassByMatters;
}
public function addSchoolAssessmentByClassByMatter(SchoolAssessmentByClassByMatter $schoolAssessmentByClassByMatter): self
{
if (!$this->schoolAssessmentByClassByMatters->contains($schoolAssessmentByClassByMatter)) {
$this->schoolAssessmentByClassByMatters[] = $schoolAssessmentByClassByMatter;
$schoolAssessmentByClassByMatter->setReportCard($this);
}
return $this;
}
public function removeSchoolAssessmentByClassByMatter(SchoolAssessmentByClassByMatter $schoolAssessmentByClassByMatter): self
{
if ($this->schoolAssessmentByClassByMatters->removeElement($schoolAssessmentByClassByMatter)) {
// set the owning side to null (unless already changed)
if ($schoolAssessmentByClassByMatter->getReportCard() === $this) {
$schoolAssessmentByClassByMatter->setReportCard(null);
}
}
return $this;
}
/**
* @return Collection|SchoolAssessmentByLevelByMatter[]
*/
public function getSchoolAssessmentByLevelByMatters(): Collection
{
return $this->schoolAssessmentByLevelByMatters;
}
public function addSchoolAssessmentByLevelByMatter(SchoolAssessmentByLevelByMatter $schoolAssessmentByLevelByMatter): self
{
if (!$this->schoolAssessmentByLevelByMatters->contains($schoolAssessmentByLevelByMatter)) {
$this->schoolAssessmentByLevelByMatters[] = $schoolAssessmentByLevelByMatter;
$schoolAssessmentByLevelByMatter->setReportCard($this);
}
return $this;
}
public function removeSchoolAssessmentByLevelByMatter(SchoolAssessmentByLevelByMatter $schoolAssessmentByLevelByMatter): self
{
if ($this->schoolAssessmentByLevelByMatters->removeElement($schoolAssessmentByLevelByMatter)) {
// set the owning side to null (unless already changed)
if ($schoolAssessmentByLevelByMatter->getReportCard() === $this) {
$schoolAssessmentByLevelByMatter->setReportCard(null);
}
}
return $this;
}
public function getReportCard(): ?ReportCard
{
return $this->reportCard;
}
public function setReportCard(?ReportCard $reportCard): self
{
$this->reportCard = $reportCard;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getIsValidated(): ?bool
{
return $this->is_validated;
}
public function setIsValidated(bool $is_validated): self
{
$this->is_validated = $is_validated;
return $this;
}
public function getTotaleNote(){
$note = 0;
foreach ($this->getSchoolAverageReportCards() as $key => $schoolAverageReportCard) {
$note += $schoolAverageReportCard->getCoefficientXAverage();
}
return $note;
}
public function getTotaleCoefficient(){
$coefficient = 0;
foreach ($this->getSchoolAverageReportCards() as $key => $schoolAverageReportCard) {
$coefficient += $schoolAverageReportCard->getCoefficient();
}
return $coefficient;
}
public function getAverage(){
if ($this->getTotaleCoefficient() > 0) {
return $this->getTotaleNote()/$this->getTotaleCoefficient();
}
return 0;
}
public function getNoteOn(): ?float
{
return $this->note_on;
}
public function setNoteOn(float $note_on): self
{
$this->note_on = $note_on;
return $this;
}
public function getReportCardAverage(): ?float
{
return $this->report_card_average;
}
public function setReportCardAverage(?float $report_card_average): self
{
$this->report_card_average = $report_card_average;
return $this;
}
public function getRank(): ?string
{
return $this->rank;
}
public function setRank(?string $rank): self
{
$this->rank = $rank;
return $this;
}
public function getClassAverage(): ?float
{
return $this->class_average;
}
public function setClassAverage(?float $class_average): self
{
$this->class_average = $class_average;
return $this;
}
public function getSmallestAverage(): ?float
{
return $this->smallest_average;
}
public function setSmallestAverage(?float $smallest_average): self
{
$this->smallest_average = $smallest_average;
return $this;
}
public function getSstrongestAverage(): ?float
{
return $this->sstrongest_average;
}
public function setSstrongestAverage(?float $sstrongest_average): self
{
$this->sstrongest_average = $sstrongest_average;
return $this;
}
public function getLevelRank(): ?string
{
return $this->level_rank;
}
public function setLevelRank(?string $level_rank): self
{
$this->level_rank = $level_rank;
return $this;
}
public function getTotalAverage(): ?float
{
return $this->total_average;
}
public function setTotalAverage(?float $total_average): self
{
$this->total_average = $total_average;
return $this;
}
public function getTotalCoefficient(): ?float
{
return $this->total_coefficient;
}
public function setTotalCoefficient(?float $total_coefficient): self
{
$this->total_coefficient = $total_coefficient;
return $this;
}
public function getJustifiedAbsence(): ?float
{
return $this->justified_absence;
}
public function setJustifiedAbsence(?float $justified_absence): self
{
$this->justified_absence = $justified_absence;
return $this;
}
public function getUnjustifiedAbsence(): ?float
{
return $this->unjustified_absence;
}
public function setUnjustifiedAbsence(?float $unjustified_absence): self
{
$this->unjustified_absence = $unjustified_absence;
return $this;
}
public function getAnnualAverage(): ?float
{
return $this->annual_average;
}
public function setAnnualAverage(?float $annual_average): self
{
$this->annual_average = $annual_average;
return $this;
}
public function getAnnualRank(): ?string
{
return $this->annual_rank;
}
public function setAnnualRank(?string $annual_rank): self
{
$this->annual_rank = $annual_rank;
return $this;
}
public function getClassAnnualAverage(): ?float
{
return $this->class_annual_average;
}
public function setClassAnnualAverage(?float $class_annual_average): self
{
$this->class_annual_average = $class_annual_average;
return $this;
}
public function isUnclassified(){
$count_nc = 0;
foreach ($this->getSchoolAverageReportCards() as $key => $schoolAverageReportCard) {
if ($schoolAverageReportCard->getAverage() >= 999) {
$count_nc++;
}
}
return $count_nc == count($this->getSchoolAverageReportCards());
}
public function isConduiteBlame(){
foreach ($this->getSchoolAverageReportCards() as $key => $schoolAverageReportCard) {
if (!$schoolAverageReportCard->getMatter()->getIsMatterConduct()) {
if ($schoolAverageReportCard->getMatter()->getIsMatterConduct() && $schoolAverageReportCard->getAverage() < 10) {
return true;
}
}
}
return false;
}
public function getIsUnclassified(): ?bool
{
return $this->is_unclassified;
}
public function setIsUnclassified(bool $is_unclassified): self
{
$this->is_unclassified = $is_unclassified;
return $this;
}
public function getNbHAbsence(DateTimeImmutable $startDate, DateTimeImmutable $endDate){
$nbh = 0;
foreach ($this->getStudentRegistration()->getSchoolTeacherCallSheetLines() as $key => $schoolTeacherCallSheetLine) {
if ($schoolTeacherCallSheetLine->getCreateDate()->format('Y-m-d') >= $startDate->format('Y-m-d') && $schoolTeacherCallSheetLine->getCreateDate()->format('Y-m-d') <= $endDate->format('Y-m-d')) {
if ($schoolTeacherCallSheetLine->getIsAbsent() && $schoolTeacherCallSheetLine->getSchoolTeacherCallSheet()->getIsAproved()) {
if ($schoolTeacherCallSheetLine->getSchoolTeacherCallSheet()->getSettingTimeTable()->getDefautDuration() > 0) {
$nbh += $schoolTeacherCallSheetLine->getSchoolTeacherCallSheet()->getSettingTimeTable()->getDefautDuration();
}else {
$nbh += 1;
}
}
}
}
return $nbh;
}
public function getUserUpdatedBy(UserRepository $userRepository){
return $userRepository->findOneBy(['id' => $this->getUpdatedBy()], []);
}
public function getSchoolReportCardAbsence(): ?SchoolReportCardAbsence
{
return $this->schoolReportCardAbsence;
}
public function setSchoolReportCardAbsence(?SchoolReportCardAbsence $schoolReportCardAbsence): self
{
$this->schoolReportCardAbsence = $schoolReportCardAbsence;
return $this;
}
}