<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\JoinColumn;
/**
* @ORM\Entity(repositoryClass="App\Repository\TeacherScheduleRepository")
*/
class TeacherSchedule
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="datetime")
*/
private $freeDate;
/**
* @ORM\Column(type="boolean")
*/
private $isFree;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Teacher", inversedBy="schedules")
*/
private $teacher;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\ScheduleInstitute", inversedBy="teacherSchedule")
*/
private $scheduleInstitute;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Session", inversedBy="TeacherSchedule")
*/
private $sessionCourse;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Session", inversedBy="nextTeacherSchedule")
*/
private $nextSessionCourse;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\SubscriptionOrder", inversedBy="schedules")
*/
private $subscriptionOrder;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $occupiedUntil;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Room", inversedBy="teacherSchedules")
*/
private $room;
/**
* @ORM\OneToMany(targetEntity="App\Entity\PaidCourseList", mappedBy="teacherSchedule")
*/
private $courseList;
/*
/**
* @ORM\OneToOne(targetEntity="App\Entity\AbsenceLog", mappedBy="catchUpSchedule", cascade={"persist", "remove"})
*/
//private $absenceLog;
/**
* @ORM\Column(type="boolean")
*/
private $forCatchUp;
/**
* @ORM\Column(type="boolean")
*/
private $isBlocked;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updateAt;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $updateBy;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $forVideo;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $comments;
/**
* @ORM\OneToMany(targetEntity="App\Entity\AbsenceLog", mappedBy="catchUpSchedule")
*/
private $absenceLogs;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $forRamadan;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isForLevelTest;
public function __construct()
{
$this->courseList = new ArrayCollection();
$this->absenceLogs = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getFreeDate(): ?\DateTimeInterface
{
return $this->freeDate;
}
public function setFreeDate(\DateTimeInterface $freeDate): self
{
$this->freeDate = $freeDate;
return $this;
}
public function getIsFree(): ?bool
{
return $this->isFree;
}
public function setIsFree(bool $isFree): self
{
$this->isFree = $isFree;
return $this;
}
public function getTeacher(): ?Teacher
{
return $this->teacher;
}
public function setTeacher(?Teacher $teacher): self
{
$this->teacher = $teacher;
return $this;
}
public function getScheduleInstitute(): ?ScheduleInstitute
{
return $this->scheduleInstitute;
}
public function setScheduleInstitute(?ScheduleInstitute $scheduleInstitute): self
{
$this->scheduleInstitute = $scheduleInstitute;
return $this;
}
public function getSessionCourse(): ?Session
{
return $this->sessionCourse;
}
public function setSessionCourse(?Session $sessionCourse): self
{
$this->sessionCourse = $sessionCourse;
return $this;
}
public function getNextSessionCourse(): ?Session
{
return $this->nextSessionCourse;
}
public function setNextSessionCourse(?Session $nextSessionCourse): self
{
$this->nextSessionCourse = $nextSessionCourse;
return $this;
}
public function getSubscriptionOrder(): ?SubscriptionOrder
{
return $this->subscriptionOrder;
}
public function setSubscriptionOrder(?SubscriptionOrder $subscriptionOrder): self
{
$this->subscriptionOrder = $subscriptionOrder;
return $this;
}
public function getOccupiedUntil(): ?\DateTimeInterface
{
return $this->occupiedUntil;
}
public function setOccupiedUntil(?\DateTimeInterface $occupiedUntil): self
{
$this->occupiedUntil = $occupiedUntil;
return $this;
}
public function getRoom(): ?Room
{
return $this->room;
}
public function setRoom(?Room $room): self
{
$this->room = $room;
return $this;
}
public function __toString()
{
return $this->getScheduleInstitute()->getDisplayName();
}
/**
* @return Collection|PaidCourseList[]
*/
public function getCourseList(): Collection
{
return $this->courseList;
}
public function addCourseList(PaidCourseList $courseList): self
{
if ( ! $this->courseList->contains($courseList)) {
$this->courseList[] = $courseList;
$courseList->setTeacherSchedule($this);
}
return $this;
}
public function removeCourseList(PaidCourseList $courseList): self
{
if ($this->courseList->contains($courseList)) {
$this->courseList->removeElement($courseList);
// set the owning side to null (unless already changed)
if ($courseList->getTeacherSchedule() === $this) {
$courseList->setTeacherSchedule(null);
}
}
return $this;
}
/*
public function getAbsenceLog(): ?AbsenceLog
{
return $this->absenceLog;
}
public function setAbsenceLog(?AbsenceLog $absenceLog): self
{
$this->absenceLog = $absenceLog;
// set (or unset) the owning side of the relation if necessary
$newCatchUpDate = $absenceLog === null ? null : $this;
if ($newCatchUpDate !== $absenceLog->getCatchUpSchedule()) {
$absenceLog->setCatchUpSchedule($newCatchUpDate);
}
return $this;
}
*/
public function getForCatchUp(): ?bool
{
return $this->forCatchUp;
}
public function setForCatchUp(bool $forCatchUp): self
{
$this->forCatchUp = $forCatchUp;
return $this;
}
public function getIsBlocked(): ?bool
{
return $this->isBlocked;
}
public function setIsBlocked(bool $isBlocked): self
{
$this->isBlocked = $isBlocked;
return $this;
}
public function getUpdateAt(): ?\DateTimeInterface
{
return $this->updateAt;
}
public function setUpdateAt(?\DateTimeInterface $updateAt): self
{
$this->updateAt = $updateAt;
return $this;
}
public function getUpdateBy(): ?string
{
return $this->updateBy;
}
public function setUpdateBy(?string $updateBy): self
{
$this->updateBy = $updateBy;
return $this;
}
public function getForVideo(): ?bool
{
return $this->forVideo;
}
public function setForVideo(?bool $forVideo): self
{
$this->forVideo = $forVideo;
return $this;
}
public function getComments(): ?string
{
return $this->comments;
}
public function setComments(?string $comments): self
{
$this->comments = $comments;
return $this;
}
/**
* @return Collection<int, AbsenceLog>
*/
public function getAbsenceLogs(): Collection
{
return $this->absenceLogs;
}
public function addAbsenceLog(AbsenceLog $absenceLog): self
{
if ( ! $this->absenceLogs->contains($absenceLog)) {
$this->absenceLogs[] = $absenceLog;
$absenceLog->setCatchUpSchedule($this);
}
return $this;
}
public function removeAbsenceLog(AbsenceLog $absenceLog): self
{
if ($this->absenceLogs->removeElement($absenceLog)) {
// set the owning side to null (unless already changed)
if ($absenceLog->getCatchUpSchedule() === $this) {
$absenceLog->setCatchUpSchedule(null);
}
}
return $this;
}
public function getForRamadan(): ?bool
{
return $this->forRamadan;
}
public function setForRamadan(?bool $forRamadan): self
{
$this->forRamadan = $forRamadan;
return $this;
}
public function getIsForLevelTest(): ?bool
{
return $this->isForLevelTest;
}
public function setIsForLevelTest(?bool $isForLevelTest): self
{
$this->isForLevelTest = $isForLevelTest;
return $this;
}
public function getNextCourseAfterDate(?\DateTime $date = null): \DateTime
{
if ($date === null) {
$date = new \DateTime('now', new \DateTimeZone('Africa/Cairo'));
}
$freeDate = new \DateTime('now', new \DateTimeZone('Africa/Cairo'));
/** @var ScheduleInstitute $scheduleInstitue */
$scheduleInstitue = $this->getScheduleInstitute();
if ($scheduleInstitue->getDayNb() <= $date->format('N')) {
$modifyDay = (7 - $date->format('N')) + $scheduleInstitue->getDayNb();
$freeDate->modify('+'.$modifyDay.' days')->setTime(0,0,0)->add(New \DateInterval('PT'.$scheduleInstitue->getStartTime().'S'));
} else {
$modifyDay = $scheduleInstitue->getDayNb() - $date->format('N');
$freeDate->modify('+'.$modifyDay.' days')->setTime(0,0,0)->add(New \DateInterval('PT'.$scheduleInstitue->getStartTime().'S'));
}
return $freeDate;
}
}