<?php
namespace App\Entity;
use App\Repository\SchoolTeacherCallSheetRepository;
use App\Repository\UserRepository;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=SchoolTeacherCallSheetRepository::class)
* SchoolTeacherTimeSheet
*/
class SchoolTeacherCallSheet
{
const STATUS_BROUILLON = 'Brouillon';
const STATUS_VALIDE = 'Validé';
const STATUS_REJETE = 'Rejeté';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Establishment::class, inversedBy="schoolTeacherCallSheets")
* @ORM\JoinColumn(nullable=false)
*/
private $establishment;
/**
* @ORM\ManyToOne(targetEntity=SchoolYear::class, inversedBy="schoolTeacherCallSheets")
* @ORM\JoinColumn(nullable=false)
*/
private $schoolYear;
/**
* @ORM\ManyToOne(targetEntity=SettingClassroom::class, inversedBy="schoolTeacherCallSheets")
* @ORM\JoinColumn(nullable=false)
*/
private $settingClassroom;
/**
* @ORM\ManyToOne(targetEntity=SchoolWorkingTime::class, inversedBy="schoolTeacherCallSheets")
*/
private $schoolWorkingTime;
/**
* @ORM\ManyToOne(targetEntity=SettingTimeTable::class, inversedBy="schoolTeacherCallSheets")
*/
private $settingTimeTable;
/**
* @ORM\ManyToOne(targetEntity=SchoolMatter::class, inversedBy="schoolTeacherCallSheets")
*/
private $schoolMatter;
/**
* @ORM\ManyToOne(targetEntity=SchoolTeacher::class, inversedBy="schoolTeacherCallSheets")
*/
private $schoolTeacher;
/**
* @ORM\Column(type="string", length=60)
*/
private $day;
/**
* @ORM\Column(type="date_immutable")
*/
private $create_date;
/**
* @ORM\Column(type="string", length=60)
*/
private $create_time;
/**
* @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=SchoolTeacherCallSheetLine::class, mappedBy="schoolTeacherCallSheet")
*/
private $schoolTeacherCallSheetLines;
/**
* @ORM\Column(type="boolean")
*/
private $is_validated;
/**
* @ORM\Column(type="boolean")
*/
private $is_aproved;
/**
* @ORM\OneToMany(targetEntity=SchoolTeacherTimeSheet::class, mappedBy="schoolTeacherCallSheet")
*/
private $schoolTeacherTimeSheets;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $defaut_duration;
/**
* @ORM\Column(type="string", length=50)
*/
private $status;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $rejectionReason;
public function __construct()
{
$this->schoolTeacherCallSheetLines = new ArrayCollection();
$this->create_date = new DateTimeImmutable();
$this->is_validated = false;
$this->is_aproved = false;
$this->schoolTeacherTimeSheets = new ArrayCollection();
$this->status = self::STATUS_BROUILLON;
}
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 getSettingClassroom(): ?SettingClassroom
{
return $this->settingClassroom;
}
public function setSettingClassroom(?SettingClassroom $settingClassroom): self
{
$this->settingClassroom = $settingClassroom;
return $this;
}
public function getSchoolWorkingTime(): ?SchoolWorkingTime
{
return $this->schoolWorkingTime;
}
public function setSchoolWorkingTime(?SchoolWorkingTime $schoolWorkingTime): self
{
$this->schoolWorkingTime = $schoolWorkingTime;
return $this;
}
public function getSettingTimeTable(): ?SettingTimeTable
{
return $this->settingTimeTable;
}
public function setSettingTimeTable(?SettingTimeTable $settingTimeTable): self
{
$this->settingTimeTable = $settingTimeTable;
return $this;
}
public function getSchoolMatter(): ?SchoolMatter
{
return $this->schoolMatter;
}
public function setSchoolMatter(?SchoolMatter $schoolMatter): self
{
$this->schoolMatter = $schoolMatter;
return $this;
}
public function getSchoolTeacher(): ?SchoolTeacher
{
return $this->schoolTeacher;
}
public function setSchoolTeacher(?SchoolTeacher $schoolTeacher): self
{
$this->schoolTeacher = $schoolTeacher;
return $this;
}
public function getDay(): ?string
{
return $this->day;
}
public function setDay(string $day): self
{
$this->day = $day;
return $this;
}
public function getCreateDate(): ?\DateTimeImmutable
{
return $this->create_date;
}
public function setCreateDate(\DateTimeImmutable $create_date): self
{
$this->create_date = $create_date;
return $this;
}
public function getCreateTime(): ?string
{
return $this->create_time;
}
public function setCreateTime(string $create_time): self
{
$this->create_time = $create_time;
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|SchoolTeacherCallSheetLine[]
*/
public function getSchoolTeacherCallSheetLines(): Collection
{
return $this->schoolTeacherCallSheetLines;
}
public function addSchoolTeacherCallSheetLine(SchoolTeacherCallSheetLine $schoolTeacherCallSheetLine): self
{
if (!$this->schoolTeacherCallSheetLines->contains($schoolTeacherCallSheetLine)) {
$this->schoolTeacherCallSheetLines[] = $schoolTeacherCallSheetLine;
$schoolTeacherCallSheetLine->setSchoolTeacherCallSheet($this);
}
return $this;
}
public function removeSchoolTeacherCallSheetLine(SchoolTeacherCallSheetLine $schoolTeacherCallSheetLine): self
{
if ($this->schoolTeacherCallSheetLines->removeElement($schoolTeacherCallSheetLine)) {
// set the owning side to null (unless already changed)
if ($schoolTeacherCallSheetLine->getSchoolTeacherCallSheet() === $this) {
$schoolTeacherCallSheetLine->setSchoolTeacherCallSheet(null);
}
}
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 isCanBeSaved(){
foreach ($this->getSchoolTeacherCallSheetLines() as $key => $schoolTeacherCallSheetLine) {
if (!$schoolTeacherCallSheetLine->getIsAbsent() && !$schoolTeacherCallSheetLine->getIsPresente()) {
return false;
}
}
return true;
}
public function getIsAproved(): ?bool
{
return $this->is_aproved;
}
public function setIsAproved(bool $is_aproved): self
{
$this->is_aproved = $is_aproved;
return $this;
}
/**
* @return Collection|SchoolTeacherTimeSheet[]
*/
public function getSchoolTeacherTimeSheets(): Collection
{
return $this->schoolTeacherTimeSheets;
}
public function addSchoolTeacherTimeSheet(SchoolTeacherTimeSheet $schoolTeacherTimeSheet): self
{
if (!$this->schoolTeacherTimeSheets->contains($schoolTeacherTimeSheet)) {
$this->schoolTeacherTimeSheets[] = $schoolTeacherTimeSheet;
$schoolTeacherTimeSheet->setSchoolTeacherCallSheet($this);
}
return $this;
}
public function removeSchoolTeacherTimeSheet(SchoolTeacherTimeSheet $schoolTeacherTimeSheet): self
{
if ($this->schoolTeacherTimeSheets->removeElement($schoolTeacherTimeSheet)) {
// set the owning side to null (unless already changed)
if ($schoolTeacherTimeSheet->getSchoolTeacherCallSheet() === $this) {
$schoolTeacherTimeSheet->setSchoolTeacherCallSheet(null);
}
}
return $this;
}
public function getDefautDuration(): ?float
{
return $this->defaut_duration;
}
public function setDefautDuration(?float $defaut_duration): self
{
$this->defaut_duration = $defaut_duration;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
public function getRejectionReason(): ?string
{
return $this->rejectionReason;
}
public function setRejectionReason(?string $rejectionReason): self
{
$this->rejectionReason = $rejectionReason;
return $this;
}
public function getUser(UserRepository $userRepository){
return $userRepository->findOneBy(['id' => $this->getCreatedBy()], []);
}
public function getCreatedByUsername(UserRepository $userRepository): ?string
{
return $userRepository->findOneBy(['id' => $this->getCreatedBy()], []) ? $userRepository->findOneBy(['id' => $this->getCreatedBy()], [])->getUserIdentifier() : null;
}
public function getUpdatedByUsername(UserRepository $userRepository): ?string
{
return $userRepository->findOneBy(['id' => $this->getUpdatedBy()], []) ? $userRepository->findOneBy(['id' => $this->getUpdatedBy()], [])->getUserIdentifier() : null;
}
}