src/Entity/Lesson.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\LessonRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use Symfony\Component\Validator\Context\ExecutionContextInterface;
  10. /**
  11. * @ORM\Entity(repositoryClass=LessonRepository::class)
  12. * @ORM\Table(name="lesson",indexes={
  13. * @ORM\Index(name="start_time_idx", columns={"start_time"}),
  14. * @ORM\Index(name="end_time_idx", columns={"end_time"}),
  15. * @ORM\Index(name="status_idx", columns={"status"}),
  16. * @ORM\Index(name="teacher_idx", columns={"teacher_id"}),
  17. * @ORM\Index(name="teacher_missed_flags_start_end_idx", columns={"teacher_id", "child_missed", "teacher_missed", "start_time", "end_time"}),
  18. * @ORM\Index(name="teacher_start_end_idx", columns={"teacher_id", "start_time", "end_time"})
  19. * })
  20. */
  21. class Lesson
  22. {
  23. const TYPE_INDIVIDUAL = 'INDIVIDUAL';
  24. const TYPE_PAIR = 'PAIR';
  25. const TYPE_INDIVIDUAL_TEXT = 'Individualiai';
  26. const TYPE_PAIR_TEXT = 'Poroje';
  27. const STATUS_REGULAR = [
  28. 'value' => "REGULAR",
  29. 'text' => 'Įprastas užsiėmimas',
  30. 'color' => '#fff',
  31. 'description' => 'Užsiėmimas, kuris vyko įprastu, numatytu laiku.'
  32. ];
  33. const STATUS_REGULAR_MOVED = [
  34. 'value' => "REGULAR_MOVED",
  35. 'text' => 'Įprastas perkeltas užsiėmimas',
  36. 'color' => '#C1C1C1',
  37. 'description' => 'Užsiėmimas, kuris vyko nauju laiku, buvo perkeltas iš vienos dienos į kita, korepetitoriaus ir tėvų ar mokinio bendru sutarimu.'
  38. ];
  39. const STATUS_ADDITIONAL = [
  40. 'value' => "ADDITIONAL",
  41. 'text' => 'Papildomas užsiėmimas',
  42. 'color' => '#F2C11D',
  43. 'description' => 'Užsiėmimas, kuris yra papildomai pridėtas, korepetitoriaus ir tėvų ar mokinio bendru sutarimu.'
  44. ];
  45. const STATUS_MISSED = [
  46. 'value' => "MISSED",
  47. 'text' => 'Praleistas užsiėmimas',
  48. 'color' => '#fc6565',
  49. 'description' => ''
  50. ];
  51. const STATUS_INFORMED_MISSED = [
  52. 'value' => "INFORMED_MISSED",
  53. 'text' => 'Informuotai praleistas užsiėmimas',
  54. 'color' => '#fcb365',
  55. 'description' => ''
  56. ];
  57. const STATUS_UNINFORMED_MISSED = [
  58. 'value' => "UNINFORMED_MISSED",
  59. 'text' => 'Neinformuotai praleistas užsiėmimas',
  60. 'color' => '#bd75ff',
  61. 'description' => ''
  62. ];
  63. const STATUS_TUTOR_UNINFORMED_MISSED = [
  64. 'value' => "TUTOR_UNINFORMED_MISSED",
  65. 'text' => 'Korepetitoriaus neinformuotai praleistas užsiėmimas',
  66. 'color' => '#FF8200',
  67. 'description' => 'Užsiėmimas į kurį korepetitorius neprisijungė ar vėlavo 5 min.'
  68. ];
  69. const STATUS_CHILD_UNINFORMED_MISSED = [
  70. 'value' => "CHILD_UNINFORMED_MISSED",
  71. 'text' => 'Mokinio neinformuotai praleistas užsiėmimas',
  72. 'color' => '#F74F64',
  73. 'description' => 'Užsiėmimas į kurį mokinys neprisijungė ar pavėlavo 15 min. Taip pat, mokinio neinformuotai praleistas užsiėmimas yra laikomas jeigu likus mažiau nei 60 min. iki pamokos pradžios buvo pranešta, jog į užsiėmimą mokinys neprisijungs.'
  74. ];
  75. const STATUS_GIFT = [
  76. 'value' => "GIFT",
  77. 'text' => 'Kompensuojamas užsiėmimas',
  78. 'color' => '#58D68D',
  79. 'description' => 'Užsiėmimas, kuriuo liko nepatenkintas klientas ir mes atlikę atvejo analizę įsitikiname, kad jis buvo pravestas nekokybiškai. Tokiu atveju už užsiėmimą klientas mokėti neturi.'
  80. ];
  81. const STATUS_FREE = [
  82. 'value' => "FREE",
  83. 'text' => 'Nemokamas užsiėmimas',
  84. 'color' => '#00A9FE',
  85. 'description' => 'Tai mūsų, kaip įmonės, dovana klientui.'
  86. ];
  87. const STATUS_REWORK = [
  88. 'value' => "REWORK",
  89. 'text' => 'Atidirbimas',
  90. 'color' => '#54c44f',
  91. 'description' => ''
  92. ];
  93. const STATUS_WAITING_PAYMENT = [
  94. 'value' => "WAITING_PAYMENT",
  95. 'text' => 'Laukiama apmokėjimo',
  96. 'color' => '#FF0000',
  97. 'description' => ''
  98. ];
  99. const STATUS_LATE_CANCEL = [
  100. 'value' => "LATE_CANCEL",
  101. 'text' => 'Vėlyvas atšaukimas (50%)',
  102. 'color' => '#FF0000',
  103. 'description' => ''
  104. ];
  105. const STATUS_UNPAID_LESSON_TUTOR = [
  106. 'value' => "UNPAID_LESSON_TUTOR",
  107. 'text' => 'Neapmokamas užsiėmimas',
  108. 'color' => '#FF0000',
  109. 'description' => ''
  110. ];
  111. // const STATUS_TUTOR_CANCELLED = [
  112. // 'value' => "TUTOR_CANCELLED",
  113. // 'text' => 'Korepetitoriaus anuliuotas užsiėmimas',
  114. // 'color' => '#3438b9',
  115. // 'description' => ''
  116. // ];
  117. //
  118. // const STATUS_ADMIN_CANCELLED = [
  119. // 'value' => "ADMIN_CANCELLED",
  120. // 'text' => 'Administracijos anuliuotas užsiėmimas',
  121. // 'color' => '#3438b9',
  122. // 'description' => ''
  123. // ];
  124. const STATUSES = [
  125. self::STATUS_REGULAR,
  126. self::STATUS_REGULAR_MOVED,
  127. self::STATUS_ADDITIONAL,
  128. self::STATUS_TUTOR_UNINFORMED_MISSED,
  129. self::STATUS_CHILD_UNINFORMED_MISSED,
  130. self::STATUS_GIFT,
  131. self::STATUS_FREE,
  132. self::STATUS_INFORMED_MISSED,
  133. self::STATUS_WAITING_PAYMENT,
  134. self::STATUS_LATE_CANCEL,
  135. self::STATUS_UNPAID_LESSON_TUTOR,
  136. // self::STATUS_TUTOR_CANCELLED,
  137. // self::STATUS_ADMIN_CANCELLED,
  138. ];
  139. const ALL_STATUSES = [
  140. self::STATUS_REGULAR,
  141. self::STATUS_REGULAR_MOVED,
  142. self::STATUS_ADDITIONAL,
  143. self::STATUS_MISSED,
  144. self::STATUS_INFORMED_MISSED,
  145. self::STATUS_UNINFORMED_MISSED,
  146. self::STATUS_TUTOR_UNINFORMED_MISSED,
  147. self::STATUS_CHILD_UNINFORMED_MISSED,
  148. self::STATUS_GIFT,
  149. self::STATUS_FREE,
  150. self::STATUS_REWORK,
  151. self::STATUS_WAITING_PAYMENT,
  152. self::STATUS_LATE_CANCEL,
  153. self::STATUS_UNPAID_LESSON_TUTOR,
  154. // self::STATUS_TUTOR_CANCELLED,
  155. // self::STATUS_ADMIN_CANCELLED,
  156. ];
  157. /**
  158. * @ORM\Id
  159. * @ORM\GeneratedValue
  160. * @ORM\Column(type="integer")
  161. * @Groups({"LessonList", "ChildLessonReviewList"})
  162. */
  163. private $id;
  164. /**
  165. * @ORM\Column(type="string", length=255, nullable=true)
  166. * @Groups({"LessonList"})
  167. */
  168. private $type = self::TYPE_INDIVIDUAL;
  169. /**
  170. * @ORM\Column(type="integer", nullable=true)
  171. * @Groups({"LessonList"})
  172. */
  173. private $class;
  174. /**
  175. * @ORM\ManyToOne(targetEntity=Discipline::class, inversedBy="lessons")
  176. * @Groups({"LessonList", "ChildLessonReviewList"})
  177. */
  178. private $discipline;
  179. /**
  180. * @ORM\ManyToOne(targetEntity=Teacher::class, inversedBy="lessons")
  181. * @Groups({"LessonList"})
  182. */
  183. private $teacher;
  184. /**
  185. * @ORM\Column(type="datetime", nullable=true)
  186. * @Groups({"LessonList", "ChildLessonReviewList"})
  187. */
  188. private $startTime;
  189. /**
  190. * @ORM\Column(type="datetime", nullable=true)
  191. */
  192. private $endTime;
  193. /**
  194. * @ORM\Column(type="integer", nullable=true)
  195. * @Groups({"LessonList"})
  196. */
  197. private $duration;
  198. /**
  199. * @ORM\Column(type="string", length=255, nullable=true)
  200. * @Groups({"LessonList"})
  201. */
  202. private $comment;
  203. /**
  204. * @ORM\Column(type="string", length=255, nullable=true)
  205. * @Groups({"LessonList"})
  206. */
  207. private $status;
  208. private $statusColor;
  209. /**
  210. * @ORM\ManyToMany(targetEntity=Child::class, inversedBy="lessons")
  211. * @Groups({"LessonList"})
  212. */
  213. private $children;
  214. /**
  215. * @ORM\Column(type="string", length=255, nullable=true)
  216. * @Groups({"LessonList"})
  217. */
  218. private $adminComment;
  219. /**
  220. * @ORM\OneToMany(targetEntity=PaymentLog::class, mappedBy="lesson", orphanRemoval=false)
  221. */
  222. private $paymentLogs;
  223. /**
  224. * @ORM\OneToMany(targetEntity=TeacherPaymentLog::class, mappedBy="lesson", orphanRemoval=false)
  225. */
  226. private $teacherPaymentLogs;
  227. /**
  228. * @ORM\OneToMany(targetEntity=LessonChangeLog::class, mappedBy="lesson", orphanRemoval=false)
  229. */
  230. private $lessonChangeLogs;
  231. /**
  232. * @ORM\Column(type="boolean", nullable=true)
  233. */
  234. private $statusTeacher = 0;
  235. /**
  236. * @ORM\Column(type="boolean", nullable=true)
  237. */
  238. private $statusChild = 0;
  239. /**
  240. * @ORM\Column(type="string", length=255, nullable=true)
  241. */
  242. private $learncubeUUID;
  243. /**
  244. * @ORM\Column(type="datetime", nullable=true)
  245. */
  246. private $attendedAtTeacher;
  247. /**
  248. * @ORM\Column(type="datetime", nullable=true)
  249. */
  250. private $attendedAtChild;
  251. private $lessonJoin;
  252. /**
  253. * @ORM\Column(type="boolean", nullable=true)
  254. * @Groups({"LessonList"})
  255. */
  256. private $childIsLate = 0;
  257. /**
  258. * @ORM\Column(type="boolean", nullable=true)
  259. * @Groups({"LessonList"})
  260. */
  261. private $childMissed = 0;
  262. /**
  263. * @ORM\Column(type="boolean", nullable=true)
  264. * @Groups({"LessonList"})
  265. */
  266. private $teacherMissed = 0;
  267. /**
  268. * @ORM\Column(type="datetime", nullable=true)
  269. */
  270. private $learncubeEndAt;
  271. /**
  272. * @ORM\Column(type="integer", nullable=true,options={"default" : "0"})
  273. * @Groups({"LessonList"})
  274. */
  275. private $learncubeDuration = 0;
  276. /**
  277. * @ORM\Column(type="string", length=255, nullable=true)
  278. * @Groups({"LessonList"})
  279. */
  280. private $freeReason;
  281. /**
  282. * @ORM\OneToMany(targetEntity=LessonLearncubeLog::class, mappedBy="lesson", orphanRemoval=true)
  283. */
  284. private $lessonLearncubeLogs;
  285. /**
  286. * @ORM\Column(type="integer", nullable=true)
  287. * @Groups({"LessonList"})
  288. */
  289. private $learncubeChildDuration = 0;
  290. /**
  291. * @ORM\Column(type="integer", nullable=true)
  292. * @Groups({"LessonList"})
  293. */
  294. private $learncubeTeacherDuration = 0;
  295. /**
  296. * @ORM\Column(type="datetime", nullable=true)
  297. */
  298. private $movedAt;
  299. /**
  300. * @ORM\Column(type="string", length=255, nullable=true)
  301. */
  302. private $wasMissedBy;
  303. /**
  304. * @ORM\Column(type="datetime", nullable=true)
  305. */
  306. private $dateAdd;
  307. /**
  308. * @ORM\Column(type="string", length=255, nullable=true)
  309. */
  310. private $childMissReason;
  311. /**
  312. * @ORM\Column(type="datetime", nullable=true)
  313. */
  314. private $childMissedAt;
  315. /**
  316. * @ORM\Column(type="text", nullable=true)
  317. */
  318. private $technicalDifficultyComment;
  319. /**
  320. * @ORM\Column(type="text", nullable=true)
  321. */
  322. private $learncubeReview;
  323. /**
  324. * @ORM\Column(type="string", length=255, nullable=true)
  325. */
  326. private $learncubeRating;
  327. /**
  328. * @ORM\Column(type="string", length=255, nullable=true)
  329. */
  330. private $googleCalendarIdTeacher;
  331. /**
  332. * @ORM\Column(type="string", length=255, nullable=true)
  333. */
  334. private $googleCalendarIdChild;
  335. /**
  336. * @ORM\Column(type="string", length=255, nullable=true)
  337. */
  338. private $googleCalendarIdGuardian;
  339. /**
  340. * @ORM\Column(type="string", length=255, nullable=true)
  341. */
  342. private $publicToken;
  343. /**
  344. * @ORM\Column(type="string", length=255, nullable=true)
  345. */
  346. private $movedBy;
  347. /**
  348. * @ORM\Column(type="float", nullable=true)
  349. */
  350. private $paid;
  351. /**
  352. * @ORM\Column(type="datetime", nullable=true)
  353. */
  354. private $originalStartTime;
  355. /**
  356. * @ORM\Column(type="datetime", nullable=true)
  357. */
  358. private $originalEndTime;
  359. /**
  360. * @ORM\OneToMany(targetEntity=ChildLessonReview::class, mappedBy="lesson")
  361. */
  362. private $childLessonReviews;
  363. /**
  364. * @ORM\Column(type="boolean", nullable=true, options={"default": 0})
  365. */
  366. private $childDismissedReview = false;
  367. public function __construct()
  368. {
  369. $this->children = new ArrayCollection();
  370. $this->paymentLogs = new ArrayCollection();
  371. $this->teacherPaymentLogs = new ArrayCollection();
  372. $this->lessonChangeLogs = new ArrayCollection();
  373. $this->lessonLearncubeLogs = new ArrayCollection();
  374. $this->dateAdd = new \DateTime();
  375. $this->childLessonReviews = new ArrayCollection();
  376. }
  377. public function __toString()
  378. {
  379. return "{$this->id}";
  380. }
  381. public function getId(): ?int
  382. {
  383. return $this->id;
  384. }
  385. public function getType(): ?string
  386. {
  387. return $this->type;
  388. }
  389. public function setType(?string $type): self
  390. {
  391. $this->type = $type;
  392. return $this;
  393. }
  394. public function getClass(): ?int
  395. {
  396. return $this->class;
  397. }
  398. public function setClass(?int $class): self
  399. {
  400. $this->class = $class;
  401. return $this;
  402. }
  403. public function getDiscipline(): ?Discipline
  404. {
  405. return $this->discipline;
  406. }
  407. public function setDiscipline(?Discipline $discipline): self
  408. {
  409. $this->discipline = $discipline;
  410. return $this;
  411. }
  412. public function getTeacher(): ?Teacher
  413. {
  414. return $this->teacher;
  415. }
  416. public function setTeacher(?Teacher $teacher): self
  417. {
  418. $this->teacher = $teacher;
  419. return $this;
  420. }
  421. public function getStartTime(): ?\DateTimeInterface
  422. {
  423. return $this->startTime;
  424. }
  425. public function setStartTime(?\DateTimeInterface $startTime): self
  426. {
  427. $this->startTime = $startTime;
  428. return $this;
  429. }
  430. public function getEndTime(): ?\DateTimeInterface
  431. {
  432. return $this->endTime;
  433. }
  434. public function setEndTime(?\DateTimeInterface $endTime): self
  435. {
  436. $this->endTime = $endTime;
  437. return $this;
  438. }
  439. public function getDuration(): ?int
  440. {
  441. return $this->duration;
  442. }
  443. public function setDuration(?int $duration): self
  444. {
  445. $this->duration = $duration;
  446. return $this;
  447. }
  448. public function getComment(): ?string
  449. {
  450. return $this->comment;
  451. }
  452. public function setComment(?string $comment): self
  453. {
  454. $this->comment = $comment;
  455. return $this;
  456. }
  457. public function getStatus(): ?string
  458. {
  459. $text = $this->status;
  460. foreach (self::ALL_STATUSES as $STATUS)
  461. {
  462. if($STATUS['value'] == $this->status)
  463. {
  464. $text = $STATUS['text'];
  465. }
  466. }
  467. return $text;
  468. }
  469. public function getStatusDescription(): ?string
  470. {
  471. $text = $this->status;
  472. foreach (self::ALL_STATUSES as $STATUS)
  473. {
  474. if($STATUS['value'] == $this->status)
  475. {
  476. $text = $STATUS['description'];
  477. }
  478. }
  479. return $text;
  480. }
  481. public function getStatusValue(): ?string
  482. {
  483. return $this->status;
  484. }
  485. public function setStatus(?string $status): self
  486. {
  487. foreach (self::ALL_STATUSES as $STATUS)
  488. {
  489. if($STATUS['text'] == $status)
  490. {
  491. $status = $STATUS['value'];
  492. }
  493. }
  494. $this->status = $status;
  495. return $this;
  496. }
  497. public function getStatusColor(): ?string
  498. {
  499. $color = "";
  500. foreach (self::ALL_STATUSES as $STATUS)
  501. {
  502. if($STATUS['value'] == $this->status)
  503. {
  504. $color = $STATUS['color'];
  505. }
  506. }
  507. return $color;
  508. }
  509. /**
  510. * @return Collection|Child[]
  511. */
  512. public function getChildren(): Collection
  513. {
  514. return $this->children;
  515. }
  516. public function getChild(): ?Child
  517. {
  518. return $this->children ? $this->children[0] : null;
  519. }
  520. public function addChild(Child $child): self
  521. {
  522. if (!$this->children->contains($child)) {
  523. $this->children[] = $child;
  524. }
  525. return $this;
  526. }
  527. public function removeChild(Child $child): self
  528. {
  529. $this->children->removeElement($child);
  530. return $this;
  531. }
  532. public function getAdminComment(): ?string
  533. {
  534. return $this->adminComment;
  535. }
  536. public function setAdminComment(?string $adminComment): self
  537. {
  538. $this->adminComment = $adminComment;
  539. return $this;
  540. }
  541. /**
  542. * @return Collection|PaymentLog[]
  543. */
  544. public function getPaymentLogs(): Collection
  545. {
  546. return $this->paymentLogs;
  547. }
  548. public function addPaymentLog(PaymentLog $paymentLog): self
  549. {
  550. if (!$this->paymentLogs->contains($paymentLog)) {
  551. $this->paymentLogs[] = $paymentLog;
  552. $paymentLog->setLesson($this);
  553. }
  554. return $this;
  555. }
  556. public function removePaymentLog(PaymentLog $paymentLog): self
  557. {
  558. if ($this->paymentLogs->removeElement($paymentLog)) {
  559. // set the owning side to null (unless already changed)
  560. if ($paymentLog->getLesson() === $this) {
  561. $paymentLog->setLesson(null);
  562. }
  563. }
  564. return $this;
  565. }
  566. /**
  567. * @return Collection|TeacherPaymentLog[]
  568. */
  569. public function getTeacherPaymentLogs(): Collection
  570. {
  571. return $this->teacherPaymentLogs;
  572. }
  573. public function addTeacherPaymentLog(TeacherPaymentLog $teacherPaymentLog): self
  574. {
  575. if (!$this->teacherPaymentLogs->contains($teacherPaymentLog)) {
  576. $this->teacherPaymentLogs[] = $teacherPaymentLog;
  577. $teacherPaymentLog->setLesson($this);
  578. }
  579. return $this;
  580. }
  581. public function removeTeacherPaymentLog(TeacherPaymentLog $teacherPaymentLog): self
  582. {
  583. if ($this->teacherPaymentLogs->removeElement($teacherPaymentLog)) {
  584. // set the owning side to null (unless already changed)
  585. if ($teacherPaymentLog->getLesson() === $this) {
  586. $teacherPaymentLog->setLesson(null);
  587. }
  588. }
  589. return $this;
  590. }
  591. /**
  592. * @Assert\Callback
  593. */
  594. public function validate(ExecutionContextInterface $context, $payload)
  595. {
  596. $startTime = $this->getStartTime();
  597. $endTime = $this->getEndTime();
  598. $durationDiff = date_diff($startTime, $endTime);
  599. $duration = (int)$durationDiff->i + (int)$durationDiff->h * 60;
  600. if ($duration > 120) {
  601. $context->buildViolation('Maksimalus pamokos laikas yra 2h.')
  602. ->atPath('endTime')
  603. ->addViolation();
  604. }
  605. }
  606. /**
  607. * @return Collection|LessonChangeLog[]
  608. */
  609. public function getLessonChangeLogs(): Collection
  610. {
  611. return $this->lessonChangeLogs;
  612. }
  613. public function addLessonChangeLog(LessonChangeLog $lessonChangeLog): self
  614. {
  615. if (!$this->lessonChangeLogs->contains($lessonChangeLog)) {
  616. $this->lessonChangeLogs[] = $lessonChangeLog;
  617. $lessonChangeLog->setLesson($this);
  618. }
  619. return $this;
  620. }
  621. public function removeLessonChangeLog(LessonChangeLog $lessonChangeLog): self
  622. {
  623. if ($this->lessonChangeLogs->removeElement($lessonChangeLog)) {
  624. // set the owning side to null (unless already changed)
  625. if ($lessonChangeLog->getLesson() === $this) {
  626. $lessonChangeLog->setLesson(null);
  627. }
  628. }
  629. return $this;
  630. }
  631. public function isStatusTeacher(): ?bool
  632. {
  633. return $this->statusTeacher;
  634. }
  635. public function setStatusTeacher(?bool $statusTeacher): self
  636. {
  637. $this->statusTeacher = $statusTeacher;
  638. return $this;
  639. }
  640. public function isStatusChild(): ?bool
  641. {
  642. return $this->statusChild;
  643. }
  644. public function setStatusChild(?bool $statusChild): self
  645. {
  646. $this->statusChild = $statusChild;
  647. return $this;
  648. }
  649. public function getLearncubeUUID(): ?string
  650. {
  651. return $this->learncubeUUID;
  652. }
  653. public function setLearncubeUUID(?string $learncubeUUID): self
  654. {
  655. $this->learncubeUUID = $learncubeUUID;
  656. return $this;
  657. }
  658. public function getAttendedAtTeacher(): ?\DateTimeInterface
  659. {
  660. return $this->attendedAtTeacher;
  661. }
  662. public function setAttendedAtTeacher(?\DateTimeInterface $attendedAtTeacher): self
  663. {
  664. $this->attendedAtTeacher = $attendedAtTeacher;
  665. return $this;
  666. }
  667. public function getAttendedAtChild(): ?\DateTimeInterface
  668. {
  669. return $this->attendedAtChild;
  670. }
  671. public function setAttendedAtChild(?\DateTimeInterface $attendedAtChild): self
  672. {
  673. $this->attendedAtChild = $attendedAtChild;
  674. return $this;
  675. }
  676. public function getLessonJoin()
  677. {
  678. $lessonJoin = true;
  679. $endTime = new \DateTime();
  680. $endTime->modify('-5 minutes');
  681. if($this->endTime < $endTime)
  682. {
  683. $lessonJoin = false;
  684. }
  685. $startTime = new \DateTime();
  686. $startTime->modify('+5 minutes');
  687. if($this->startTime > $startTime)
  688. {
  689. $lessonJoin = false;
  690. }
  691. if($this->childMissed || $this->teacherMissed)
  692. {
  693. return false;
  694. }
  695. return $lessonJoin;
  696. }
  697. public function isMovable()
  698. {
  699. $dateNow = new \DateTime();
  700. if(in_array($this->status, [Lesson::STATUS_TUTOR_UNINFORMED_MISSED['value'], Lesson::STATUS_CHILD_UNINFORMED_MISSED['value']]) && $dateNow->format('Y-m-d') == $this->startTime->format('Y-m-d'))
  701. {
  702. return true;
  703. }
  704. if($dateNow < $this->endTime && $dateNow->format('Y-m') == $this->startTime->format('Y-m'))
  705. {
  706. return true;
  707. }
  708. return false;
  709. }
  710. public function getChildIsLate(): ?bool
  711. {
  712. return $this->childIsLate;
  713. }
  714. public function setChildIsLate(?bool $childIsLate): self
  715. {
  716. $this->childIsLate = $childIsLate;
  717. return $this;
  718. }
  719. public function getChildMissed(): ?bool
  720. {
  721. return $this->childMissed;
  722. }
  723. public function setChildMissed(?bool $childMissed): self
  724. {
  725. $this->childMissed = $childMissed;
  726. return $this;
  727. }
  728. public function getTeacherMissed(): ?bool
  729. {
  730. return $this->teacherMissed;
  731. }
  732. public function setTeacherMissed(?bool $teacherMissed): self
  733. {
  734. $this->teacherMissed = $teacherMissed;
  735. return $this;
  736. }
  737. public function getLearncubeEndAt(): ?\DateTimeInterface
  738. {
  739. return $this->learncubeEndAt;
  740. }
  741. public function setLearncubeEndAt(?\DateTimeInterface $learncubeEndAt): self
  742. {
  743. $this->learncubeEndAt = $learncubeEndAt;
  744. return $this;
  745. }
  746. public function getLearncubeDuration(): ?int
  747. {
  748. return $this->learncubeDuration;
  749. }
  750. public function setLearncubeDuration(?int $learncubeDuration): self
  751. {
  752. $this->learncubeDuration = $learncubeDuration;
  753. return $this;
  754. }
  755. public function getFreeReason(): ?string
  756. {
  757. return $this->freeReason;
  758. }
  759. public function setFreeReason(?string $freeReason): self
  760. {
  761. $this->freeReason = $freeReason;
  762. return $this;
  763. }
  764. /**
  765. * @return Collection<int, LessonLearncubeLog>
  766. */
  767. public function getLessonLearncubeLogs(): Collection
  768. {
  769. return $this->lessonLearncubeLogs;
  770. }
  771. public function addLessonLearncubeLog(LessonLearncubeLog $lessonLearncubeLog): self
  772. {
  773. if (!$this->lessonLearncubeLogs->contains($lessonLearncubeLog)) {
  774. $this->lessonLearncubeLogs[] = $lessonLearncubeLog;
  775. $lessonLearncubeLog->setLesson($this);
  776. }
  777. return $this;
  778. }
  779. public function removeLessonLearncubeLog(LessonLearncubeLog $lessonLearncubeLog): self
  780. {
  781. if ($this->lessonLearncubeLogs->removeElement($lessonLearncubeLog)) {
  782. // set the owning side to null (unless already changed)
  783. if ($lessonLearncubeLog->getLesson() === $this) {
  784. $lessonLearncubeLog->setLesson(null);
  785. }
  786. }
  787. return $this;
  788. }
  789. public function getLearncubeChildDuration(): ?int
  790. {
  791. return $this->learncubeChildDuration;
  792. }
  793. public function setLearncubeChildDuration(?int $learncubeChildDuration): self
  794. {
  795. $this->learncubeChildDuration = $learncubeChildDuration;
  796. return $this;
  797. }
  798. public function getLearncubeTeacherDuration(): ?int
  799. {
  800. return $this->learncubeTeacherDuration;
  801. }
  802. public function setLearncubeTeacherDuration(?int $learncubeTeacherDuration): self
  803. {
  804. $this->learncubeTeacherDuration = $learncubeTeacherDuration;
  805. return $this;
  806. }
  807. public function getMovedAt(): ?\DateTimeInterface
  808. {
  809. return $this->movedAt;
  810. }
  811. public function setMovedAt(?\DateTimeInterface $movedAt): self
  812. {
  813. $this->movedAt = $movedAt;
  814. return $this;
  815. }
  816. public function getWasMissedBy(): ?string
  817. {
  818. return $this->wasMissedBy;
  819. }
  820. public function setWasMissedBy(?string $wasMissedBy): self
  821. {
  822. $this->wasMissedBy = $wasMissedBy;
  823. return $this;
  824. }
  825. public function getDateAdd(): ?\DateTimeInterface
  826. {
  827. return $this->dateAdd;
  828. }
  829. public function setDateAdd(?\DateTimeInterface $dateAdd): self
  830. {
  831. $this->dateAdd = $dateAdd;
  832. return $this;
  833. }
  834. public function getChildMissReason(): ?string
  835. {
  836. return $this->childMissReason;
  837. }
  838. public function setChildMissReason(?string $childMissReason): self
  839. {
  840. $this->childMissReason = $childMissReason;
  841. return $this;
  842. }
  843. public function getChildMissedAt(): ?\DateTimeInterface
  844. {
  845. return $this->childMissedAt;
  846. }
  847. public function setChildMissedAt(?\DateTimeInterface $childMissedAt): self
  848. {
  849. $this->childMissedAt = $childMissedAt;
  850. return $this;
  851. }
  852. public function getTechnicalDifficultyComment(): ?string
  853. {
  854. return $this->technicalDifficultyComment;
  855. }
  856. public function setTechnicalDifficultyComment(?string $technicalDifficultyComment): self
  857. {
  858. $this->technicalDifficultyComment = $technicalDifficultyComment;
  859. return $this;
  860. }
  861. public function getLearncubeReview(): ?string
  862. {
  863. return $this->learncubeReview;
  864. }
  865. public function setLearncubeReview(?string $learncubeReview): self
  866. {
  867. $this->learncubeReview = $learncubeReview;
  868. return $this;
  869. }
  870. public function getLearncubeRating(): ?string
  871. {
  872. return $this->learncubeRating;
  873. }
  874. public function setLearncubeRating(?string $learncubeRating): self
  875. {
  876. $this->learncubeRating = $learncubeRating;
  877. return $this;
  878. }
  879. public function getGoogleCalendarIdTeacher(): ?string
  880. {
  881. return $this->googleCalendarIdTeacher;
  882. }
  883. public function setGoogleCalendarIdTeacher(?string $googleCalendarIdTeacher): self
  884. {
  885. $this->googleCalendarIdTeacher = $googleCalendarIdTeacher;
  886. return $this;
  887. }
  888. public function getGoogleCalendarIdChild(): ?string
  889. {
  890. return $this->googleCalendarIdChild;
  891. }
  892. public function setGoogleCalendarIdChild(?string $googleCalendarIdChild): self
  893. {
  894. $this->googleCalendarIdChild = $googleCalendarIdChild;
  895. return $this;
  896. }
  897. public function getGoogleCalendarIdGuardian(): ?string
  898. {
  899. return $this->googleCalendarIdGuardian;
  900. }
  901. public function setGoogleCalendarIdGuardian(?string $googleCalendarIdGuardian): self
  902. {
  903. $this->googleCalendarIdGuardian = $googleCalendarIdGuardian;
  904. return $this;
  905. }
  906. public function getPublicToken(): ?string
  907. {
  908. return $this->publicToken;
  909. }
  910. public function setPublicToken(?string $publicToken): self
  911. {
  912. $this->publicToken = $publicToken;
  913. return $this;
  914. }
  915. public function getMovedBy(): ?string
  916. {
  917. return $this->movedBy;
  918. }
  919. public function setMovedBy(?string $movedBy): self
  920. {
  921. $this->movedBy = $movedBy;
  922. return $this;
  923. }
  924. public function getPaid(): ?float
  925. {
  926. return $this->paid;
  927. }
  928. public function setPaid(?float $paid): self
  929. {
  930. $this->paid = $paid;
  931. return $this;
  932. }
  933. public function getOriginalStartTime(): ?\DateTimeInterface
  934. {
  935. return $this->originalStartTime;
  936. }
  937. public function setOriginalStartTime(?\DateTimeInterface $originalStartTime): self
  938. {
  939. $this->originalStartTime = $originalStartTime;
  940. return $this;
  941. }
  942. public function getOriginalEndTime(): ?\DateTimeInterface
  943. {
  944. return $this->originalEndTime;
  945. }
  946. public function setOriginalEndTime(?\DateTimeInterface $originalEndTime): self
  947. {
  948. $this->originalEndTime = $originalEndTime;
  949. return $this;
  950. }
  951. /**
  952. * @return Collection<int, ChildLessonReview>
  953. */
  954. public function getChildLessonReviews(): Collection
  955. {
  956. return $this->childLessonReviews;
  957. }
  958. public function addChildLessonReview(ChildLessonReview $childLessonReview): self
  959. {
  960. if (!$this->childLessonReviews->contains($childLessonReview)) {
  961. $this->childLessonReviews[] = $childLessonReview;
  962. $childLessonReview->setLesson($this);
  963. }
  964. return $this;
  965. }
  966. public function removeChildLessonReview(ChildLessonReview $childLessonReview): self
  967. {
  968. if ($this->childLessonReviews->removeElement($childLessonReview)) {
  969. // set the owning side to null (unless already changed)
  970. if ($childLessonReview->getLesson() === $this) {
  971. $childLessonReview->setLesson(null);
  972. }
  973. }
  974. return $this;
  975. }
  976. public function getChildDismissedReview(): bool
  977. {
  978. return (bool) $this->childDismissedReview;
  979. }
  980. public function setChildDismissedReview(?bool $childDismissedReview): self
  981. {
  982. $this->childDismissedReview = (bool) $childDismissedReview;
  983. return $this;
  984. }
  985. }