src/Entity/TeacherSchedule.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Doctrine\ORM\Mapping\JoinColumn;
  7. /**
  8.  * @ORM\Entity(repositoryClass="App\Repository\TeacherScheduleRepository")
  9.  */
  10. class TeacherSchedule
  11. {
  12.     /**
  13.      * @ORM\Id()
  14.      * @ORM\GeneratedValue()
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="datetime")
  20.      */
  21.     private $freeDate;
  22.     /**
  23.      * @ORM\Column(type="boolean")
  24.      */
  25.     private $isFree;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity="App\Entity\Teacher", inversedBy="schedules")
  28.      */
  29.     private $teacher;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity="App\Entity\ScheduleInstitute", inversedBy="teacherSchedule")
  32.      */
  33.     private $scheduleInstitute;
  34.     /**
  35.      * @ORM\ManyToOne(targetEntity="App\Entity\Session", inversedBy="TeacherSchedule")
  36.      */
  37.     private $sessionCourse;
  38.     /**
  39.      * @ORM\ManyToOne(targetEntity="App\Entity\Session", inversedBy="nextTeacherSchedule")
  40.      */
  41.     private $nextSessionCourse;
  42.     /**
  43.      * @ORM\ManyToOne(targetEntity="App\Entity\SubscriptionOrder", inversedBy="schedules")
  44.      */
  45.     private $subscriptionOrder;
  46.     /**
  47.      * @ORM\Column(type="datetime", nullable=true)
  48.      */
  49.     private $occupiedUntil;
  50.     /**
  51.      * @ORM\ManyToOne(targetEntity="App\Entity\Room", inversedBy="teacherSchedules")
  52.      */
  53.     private $room;
  54.     /**
  55.      * @ORM\OneToMany(targetEntity="App\Entity\PaidCourseList", mappedBy="teacherSchedule")
  56.      */
  57.     private $courseList;
  58.     /*
  59.     /**
  60.      * @ORM\OneToOne(targetEntity="App\Entity\AbsenceLog", mappedBy="catchUpSchedule", cascade={"persist", "remove"})
  61.      */
  62.     //private $absenceLog;
  63.     /**
  64.      * @ORM\Column(type="boolean")
  65.      */
  66.     private $forCatchUp;
  67.     /**
  68.      * @ORM\Column(type="boolean")
  69.      */
  70.     private $isBlocked;
  71.     /**
  72.      * @ORM\Column(type="datetime", nullable=true)
  73.      */
  74.     private $updateAt;
  75.     /**
  76.      * @ORM\Column(type="string", length=100, nullable=true)
  77.      */
  78.     private $updateBy;
  79.     /**
  80.      * @ORM\Column(type="boolean", nullable=true)
  81.      */
  82.     private $forVideo;
  83.     /**
  84.      * @ORM\Column(type="string", length=255, nullable=true)
  85.      */
  86.     private $comments;
  87.     /**
  88.      * @ORM\OneToMany(targetEntity="App\Entity\AbsenceLog", mappedBy="catchUpSchedule")
  89.      */
  90.     private $absenceLogs;
  91.     /**
  92.      * @ORM\Column(type="boolean", nullable=true)
  93.      */
  94.     private $forRamadan;
  95.     /**
  96.      * @ORM\Column(type="boolean", nullable=true)
  97.      */
  98.     private $isForLevelTest;
  99.     public function __construct()
  100.     {
  101.         $this->courseList  = new ArrayCollection();
  102.         $this->absenceLogs = new ArrayCollection();
  103.     }
  104.     public function getId(): ?int
  105.     {
  106.         return $this->id;
  107.     }
  108.     public function getFreeDate(): ?\DateTimeInterface
  109.     {
  110.         return $this->freeDate;
  111.     }
  112.     public function setFreeDate(\DateTimeInterface $freeDate): self
  113.     {
  114.         $this->freeDate $freeDate;
  115.         return $this;
  116.     }
  117.     public function getIsFree(): ?bool
  118.     {
  119.         return $this->isFree;
  120.     }
  121.     public function setIsFree(bool $isFree): self
  122.     {
  123.         $this->isFree $isFree;
  124.         return $this;
  125.     }
  126.     public function getTeacher(): ?Teacher
  127.     {
  128.         return $this->teacher;
  129.     }
  130.     public function setTeacher(?Teacher $teacher): self
  131.     {
  132.         $this->teacher $teacher;
  133.         return $this;
  134.     }
  135.     public function getScheduleInstitute(): ?ScheduleInstitute
  136.     {
  137.         return $this->scheduleInstitute;
  138.     }
  139.     public function setScheduleInstitute(?ScheduleInstitute $scheduleInstitute): self
  140.     {
  141.         $this->scheduleInstitute $scheduleInstitute;
  142.         return $this;
  143.     }
  144.     public function getSessionCourse(): ?Session
  145.     {
  146.         return $this->sessionCourse;
  147.     }
  148.     public function setSessionCourse(?Session $sessionCourse): self
  149.     {
  150.         $this->sessionCourse $sessionCourse;
  151.         return $this;
  152.     }
  153.     public function getNextSessionCourse(): ?Session
  154.     {
  155.         return $this->nextSessionCourse;
  156.     }
  157.     public function setNextSessionCourse(?Session $nextSessionCourse): self
  158.     {
  159.         $this->nextSessionCourse $nextSessionCourse;
  160.         return $this;
  161.     }
  162.     public function getSubscriptionOrder(): ?SubscriptionOrder
  163.     {
  164.         return $this->subscriptionOrder;
  165.     }
  166.     public function setSubscriptionOrder(?SubscriptionOrder $subscriptionOrder): self
  167.     {
  168.         $this->subscriptionOrder $subscriptionOrder;
  169.         return $this;
  170.     }
  171.     public function getOccupiedUntil(): ?\DateTimeInterface
  172.     {
  173.         return $this->occupiedUntil;
  174.     }
  175.     public function setOccupiedUntil(?\DateTimeInterface $occupiedUntil): self
  176.     {
  177.         $this->occupiedUntil $occupiedUntil;
  178.         return $this;
  179.     }
  180.     public function getRoom(): ?Room
  181.     {
  182.         return $this->room;
  183.     }
  184.     public function setRoom(?Room $room): self
  185.     {
  186.         $this->room $room;
  187.         return $this;
  188.     }
  189.     public function __toString()
  190.     {
  191.         return $this->getScheduleInstitute()->getDisplayName();
  192.     }
  193.     /**
  194.      * @return Collection|PaidCourseList[]
  195.      */
  196.     public function getCourseList(): Collection
  197.     {
  198.         return $this->courseList;
  199.     }
  200.     public function addCourseList(PaidCourseList $courseList): self
  201.     {
  202.         if ( ! $this->courseList->contains($courseList)) {
  203.             $this->courseList[] = $courseList;
  204.             $courseList->setTeacherSchedule($this);
  205.         }
  206.         return $this;
  207.     }
  208.     public function removeCourseList(PaidCourseList $courseList): self
  209.     {
  210.         if ($this->courseList->contains($courseList)) {
  211.             $this->courseList->removeElement($courseList);
  212.             // set the owning side to null (unless already changed)
  213.             if ($courseList->getTeacherSchedule() === $this) {
  214.                 $courseList->setTeacherSchedule(null);
  215.             }
  216.         }
  217.         return $this;
  218.     }
  219.     /*
  220.     public function getAbsenceLog(): ?AbsenceLog
  221.     {
  222.         return $this->absenceLog;
  223.     }
  224.     public function setAbsenceLog(?AbsenceLog $absenceLog): self
  225.     {
  226.         $this->absenceLog = $absenceLog;
  227.         // set (or unset) the owning side of the relation if necessary
  228.         $newCatchUpDate = $absenceLog === null ? null : $this;
  229.         if ($newCatchUpDate !== $absenceLog->getCatchUpSchedule()) {
  230.             $absenceLog->setCatchUpSchedule($newCatchUpDate);
  231.         }
  232.         return $this;
  233.     }
  234.     */
  235.     public function getForCatchUp(): ?bool
  236.     {
  237.         return $this->forCatchUp;
  238.     }
  239.     public function setForCatchUp(bool $forCatchUp): self
  240.     {
  241.         $this->forCatchUp $forCatchUp;
  242.         return $this;
  243.     }
  244.     public function getIsBlocked(): ?bool
  245.     {
  246.         return $this->isBlocked;
  247.     }
  248.     public function setIsBlocked(bool $isBlocked): self
  249.     {
  250.         $this->isBlocked $isBlocked;
  251.         return $this;
  252.     }
  253.     public function getUpdateAt(): ?\DateTimeInterface
  254.     {
  255.         return $this->updateAt;
  256.     }
  257.     public function setUpdateAt(?\DateTimeInterface $updateAt): self
  258.     {
  259.         $this->updateAt $updateAt;
  260.         return $this;
  261.     }
  262.     public function getUpdateBy(): ?string
  263.     {
  264.         return $this->updateBy;
  265.     }
  266.     public function setUpdateBy(?string $updateBy): self
  267.     {
  268.         $this->updateBy $updateBy;
  269.         return $this;
  270.     }
  271.     public function getForVideo(): ?bool
  272.     {
  273.         return $this->forVideo;
  274.     }
  275.     public function setForVideo(?bool $forVideo): self
  276.     {
  277.         $this->forVideo $forVideo;
  278.         return $this;
  279.     }
  280.     public function getComments(): ?string
  281.     {
  282.         return $this->comments;
  283.     }
  284.     public function setComments(?string $comments): self
  285.     {
  286.         $this->comments $comments;
  287.         return $this;
  288.     }
  289.     /**
  290.      * @return Collection<int, AbsenceLog>
  291.      */
  292.     public function getAbsenceLogs(): Collection
  293.     {
  294.         return $this->absenceLogs;
  295.     }
  296.     public function addAbsenceLog(AbsenceLog $absenceLog): self
  297.     {
  298.         if ( ! $this->absenceLogs->contains($absenceLog)) {
  299.             $this->absenceLogs[] = $absenceLog;
  300.             $absenceLog->setCatchUpSchedule($this);
  301.         }
  302.         return $this;
  303.     }
  304.     public function removeAbsenceLog(AbsenceLog $absenceLog): self
  305.     {
  306.         if ($this->absenceLogs->removeElement($absenceLog)) {
  307.             // set the owning side to null (unless already changed)
  308.             if ($absenceLog->getCatchUpSchedule() === $this) {
  309.                 $absenceLog->setCatchUpSchedule(null);
  310.             }
  311.         }
  312.         return $this;
  313.     }
  314.     public function getForRamadan(): ?bool
  315.     {
  316.         return $this->forRamadan;
  317.     }
  318.     public function setForRamadan(?bool $forRamadan): self
  319.     {
  320.         $this->forRamadan $forRamadan;
  321.         return $this;
  322.     }
  323.     public function getIsForLevelTest(): ?bool
  324.     {
  325.         return $this->isForLevelTest;
  326.     }
  327.     public function setIsForLevelTest(?bool $isForLevelTest): self
  328.     {
  329.         $this->isForLevelTest $isForLevelTest;
  330.         return $this;
  331.     }
  332.     public function getNextCourseAfterDate(?\DateTime $date null): \DateTime
  333.     {
  334.         if ($date === null) {
  335.             $date = new \DateTime('now', new \DateTimeZone('Africa/Cairo'));
  336.         }
  337.         $freeDate         = new \DateTime('now', new \DateTimeZone('Africa/Cairo'));
  338.         /** @var ScheduleInstitute $scheduleInstitue */
  339.         $scheduleInstitue $this->getScheduleInstitute();
  340.         if ($scheduleInstitue->getDayNb() <= $date->format('N')) {
  341.             $modifyDay = ($date->format('N')) + $scheduleInstitue->getDayNb();
  342.             $freeDate->modify('+'.$modifyDay.' days')->setTime(0,0,0)->add(New \DateInterval('PT'.$scheduleInstitue->getStartTime().'S'));
  343.         } else {
  344.             $modifyDay $scheduleInstitue->getDayNb() - $date->format('N');
  345.             $freeDate->modify('+'.$modifyDay.' days')->setTime(0,0,0)->add(New \DateInterval('PT'.$scheduleInstitue->getStartTime().'S'));
  346.         }
  347.         return $freeDate;
  348.     }
  349. }