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. const EARLY_PAYMENT_BILLABLE_STATUS_VALUES = [
  158. self::STATUS_REGULAR['value'],
  159. self::STATUS_REGULAR_MOVED['value'],
  160. self::STATUS_ADDITIONAL['value'],
  161. self::STATUS_WAITING_PAYMENT['value'],
  162. ];
  163. /**
  164. * @ORM\Id
  165. * @ORM\GeneratedValue
  166. * @ORM\Column(type="integer")
  167. * @Groups({"LessonList", "ChildLessonReviewList"})
  168. */
  169. private $id;
  170. /**
  171. * @ORM\Column(type="string", length=255, nullable=true)
  172. * @Groups({"LessonList"})
  173. */
  174. private $type = self::TYPE_INDIVIDUAL;
  175. /**
  176. * @ORM\Column(type="integer", nullable=true)
  177. * @Groups({"LessonList"})
  178. */
  179. private $class;
  180. /**
  181. * @ORM\ManyToOne(targetEntity=Discipline::class, inversedBy="lessons")
  182. * @Groups({"LessonList", "ChildLessonReviewList"})
  183. */
  184. private $discipline;
  185. /**
  186. * @ORM\ManyToOne(targetEntity=Teacher::class, inversedBy="lessons")
  187. * @Groups({"LessonList"})
  188. */
  189. private $teacher;
  190. /**
  191. * @ORM\Column(type="datetime", nullable=true)
  192. * @Groups({"LessonList", "ChildLessonReviewList"})
  193. */
  194. private $startTime;
  195. /**
  196. * @ORM\Column(type="datetime", nullable=true)
  197. */
  198. private $endTime;
  199. /**
  200. * @ORM\Column(type="integer", nullable=true)
  201. * @Groups({"LessonList"})
  202. */
  203. private $duration;
  204. /**
  205. * @ORM\Column(type="string", length=255, nullable=true)
  206. * @Groups({"LessonList"})
  207. */
  208. private $comment;
  209. /**
  210. * @ORM\Column(type="string", length=255, nullable=true)
  211. * @Groups({"LessonList"})
  212. */
  213. private $status;
  214. private $statusColor;
  215. /**
  216. * @ORM\ManyToMany(targetEntity=Child::class, inversedBy="lessons")
  217. * @Groups({"LessonList"})
  218. */
  219. private $children;
  220. /**
  221. * @ORM\Column(type="string", length=255, nullable=true)
  222. * @Groups({"LessonList"})
  223. */
  224. private $adminComment;
  225. /**
  226. * @ORM\OneToMany(targetEntity=PaymentLog::class, mappedBy="lesson", orphanRemoval=false)
  227. */
  228. private $paymentLogs;
  229. /**
  230. * @ORM\OneToMany(targetEntity=TeacherPaymentLog::class, mappedBy="lesson", orphanRemoval=false)
  231. */
  232. private $teacherPaymentLogs;
  233. /**
  234. * @ORM\OneToMany(targetEntity=LessonChangeLog::class, mappedBy="lesson", orphanRemoval=false)
  235. */
  236. private $lessonChangeLogs;
  237. /**
  238. * @ORM\Column(type="boolean", nullable=true)
  239. */
  240. private $statusTeacher = 0;
  241. /**
  242. * @ORM\Column(type="boolean", nullable=true)
  243. */
  244. private $statusChild = 0;
  245. /**
  246. * @ORM\Column(type="string", length=255, nullable=true)
  247. */
  248. private $learncubeUUID;
  249. /**
  250. * @ORM\Column(type="datetime", nullable=true)
  251. */
  252. private $attendedAtTeacher;
  253. /**
  254. * @ORM\Column(type="datetime", nullable=true)
  255. */
  256. private $attendedAtChild;
  257. private $lessonJoin;
  258. /**
  259. * @ORM\Column(type="boolean", nullable=true)
  260. * @Groups({"LessonList"})
  261. */
  262. private $childIsLate = 0;
  263. /**
  264. * @ORM\Column(type="boolean", nullable=true)
  265. * @Groups({"LessonList"})
  266. */
  267. private $childMissed = 0;
  268. /**
  269. * @ORM\Column(type="boolean", nullable=true)
  270. * @Groups({"LessonList"})
  271. */
  272. private $teacherMissed = 0;
  273. /**
  274. * @ORM\Column(type="datetime", nullable=true)
  275. */
  276. private $learncubeEndAt;
  277. /**
  278. * @ORM\Column(type="integer", nullable=true,options={"default" : "0"})
  279. * @Groups({"LessonList"})
  280. */
  281. private $learncubeDuration = 0;
  282. /**
  283. * @ORM\Column(type="string", length=255, nullable=true)
  284. * @Groups({"LessonList"})
  285. */
  286. private $freeReason;
  287. /**
  288. * @ORM\OneToMany(targetEntity=LessonLearncubeLog::class, mappedBy="lesson", orphanRemoval=true)
  289. */
  290. private $lessonLearncubeLogs;
  291. /**
  292. * @ORM\Column(type="integer", nullable=true)
  293. * @Groups({"LessonList"})
  294. */
  295. private $learncubeChildDuration = 0;
  296. /**
  297. * @ORM\Column(type="integer", nullable=true)
  298. * @Groups({"LessonList"})
  299. */
  300. private $learncubeTeacherDuration = 0;
  301. /**
  302. * @ORM\Column(type="datetime", nullable=true)
  303. */
  304. private $movedAt;
  305. /**
  306. * @ORM\Column(type="string", length=255, nullable=true)
  307. */
  308. private $wasMissedBy;
  309. /**
  310. * @ORM\Column(type="datetime", nullable=true)
  311. */
  312. private $dateAdd;
  313. /**
  314. * @ORM\Column(type="string", length=255, nullable=true)
  315. */
  316. private $childMissReason;
  317. /**
  318. * @ORM\Column(type="datetime", nullable=true)
  319. */
  320. private $childMissedAt;
  321. /**
  322. * @ORM\Column(type="text", nullable=true)
  323. */
  324. private $technicalDifficultyComment;
  325. /**
  326. * @ORM\Column(type="text", nullable=true)
  327. */
  328. private $learncubeReview;
  329. /**
  330. * @ORM\Column(type="string", length=255, nullable=true)
  331. */
  332. private $learncubeRating;
  333. /**
  334. * @ORM\Column(type="string", length=255, nullable=true)
  335. */
  336. private $googleCalendarIdTeacher;
  337. /**
  338. * @ORM\Column(type="string", length=255, nullable=true)
  339. */
  340. private $googleCalendarIdChild;
  341. /**
  342. * @ORM\Column(type="string", length=255, nullable=true)
  343. */
  344. private $googleCalendarIdGuardian;
  345. /**
  346. * @ORM\Column(type="string", length=255, nullable=true)
  347. */
  348. private $publicToken;
  349. /**
  350. * @ORM\Column(type="string", length=255, nullable=true)
  351. */
  352. private $movedBy;
  353. /**
  354. * @ORM\Column(type="float", nullable=true)
  355. */
  356. private $paid;
  357. /**
  358. * @ORM\Column(type="datetime", nullable=true)
  359. */
  360. private $originalStartTime;
  361. /**
  362. * @ORM\Column(type="datetime", nullable=true)
  363. */
  364. private $originalEndTime;
  365. /**
  366. * @ORM\OneToMany(targetEntity=ChildLessonReview::class, mappedBy="lesson")
  367. */
  368. private $childLessonReviews;
  369. /**
  370. * @ORM\Column(type="boolean", nullable=true, options={"default": 0})
  371. */
  372. private $childDismissedReview = false;
  373. public function __construct()
  374. {
  375. $this->children = new ArrayCollection();
  376. $this->paymentLogs = new ArrayCollection();
  377. $this->teacherPaymentLogs = new ArrayCollection();
  378. $this->lessonChangeLogs = new ArrayCollection();
  379. $this->lessonLearncubeLogs = new ArrayCollection();
  380. $this->dateAdd = new \DateTime();
  381. $this->childLessonReviews = new ArrayCollection();
  382. }
  383. public function __toString()
  384. {
  385. return "{$this->id}";
  386. }
  387. public function getId(): ?int
  388. {
  389. return $this->id;
  390. }
  391. public function getType(): ?string
  392. {
  393. return $this->type;
  394. }
  395. public function setType(?string $type): self
  396. {
  397. $this->type = $type;
  398. return $this;
  399. }
  400. public function getClass(): ?int
  401. {
  402. return $this->class;
  403. }
  404. public function setClass(?int $class): self
  405. {
  406. $this->class = $class;
  407. return $this;
  408. }
  409. public function getDiscipline(): ?Discipline
  410. {
  411. return $this->discipline;
  412. }
  413. public function setDiscipline(?Discipline $discipline): self
  414. {
  415. $this->discipline = $discipline;
  416. return $this;
  417. }
  418. public function getTeacher(): ?Teacher
  419. {
  420. return $this->teacher;
  421. }
  422. public function setTeacher(?Teacher $teacher): self
  423. {
  424. $this->teacher = $teacher;
  425. return $this;
  426. }
  427. public function getStartTime(): ?\DateTimeInterface
  428. {
  429. return $this->startTime;
  430. }
  431. public function setStartTime(?\DateTimeInterface $startTime): self
  432. {
  433. $this->startTime = $startTime;
  434. return $this;
  435. }
  436. public function getEndTime(): ?\DateTimeInterface
  437. {
  438. return $this->endTime;
  439. }
  440. public function setEndTime(?\DateTimeInterface $endTime): self
  441. {
  442. $this->endTime = $endTime;
  443. return $this;
  444. }
  445. public function getDuration(): ?int
  446. {
  447. return $this->duration;
  448. }
  449. public function setDuration(?int $duration): self
  450. {
  451. $this->duration = $duration;
  452. return $this;
  453. }
  454. public function getComment(): ?string
  455. {
  456. return $this->comment;
  457. }
  458. public function setComment(?string $comment): self
  459. {
  460. $this->comment = $comment;
  461. return $this;
  462. }
  463. public function getStatus(): ?string
  464. {
  465. $text = $this->status;
  466. foreach (self::ALL_STATUSES as $STATUS)
  467. {
  468. if($STATUS['value'] == $this->status)
  469. {
  470. $text = $STATUS['text'];
  471. }
  472. }
  473. return $text;
  474. }
  475. public function getStatusDescription(): ?string
  476. {
  477. $text = $this->status;
  478. foreach (self::ALL_STATUSES as $STATUS)
  479. {
  480. if($STATUS['value'] == $this->status)
  481. {
  482. $text = $STATUS['description'];
  483. }
  484. }
  485. return $text;
  486. }
  487. public function getStatusValue(): ?string
  488. {
  489. return $this->status;
  490. }
  491. public function setStatus(?string $status): self
  492. {
  493. foreach (self::ALL_STATUSES as $STATUS)
  494. {
  495. if($STATUS['text'] == $status)
  496. {
  497. $status = $STATUS['value'];
  498. }
  499. }
  500. $this->status = $status;
  501. return $this;
  502. }
  503. public function getStatusColor(): ?string
  504. {
  505. $color = "";
  506. foreach (self::ALL_STATUSES as $STATUS)
  507. {
  508. if($STATUS['value'] == $this->status)
  509. {
  510. $color = $STATUS['color'];
  511. }
  512. }
  513. return $color;
  514. }
  515. /**
  516. * @return Collection|Child[]
  517. */
  518. public function getChildren(): Collection
  519. {
  520. return $this->children;
  521. }
  522. public function getChild(): ?Child
  523. {
  524. return $this->children ? $this->children[0] : null;
  525. }
  526. public function addChild(Child $child): self
  527. {
  528. if (!$this->children->contains($child)) {
  529. $this->children[] = $child;
  530. }
  531. return $this;
  532. }
  533. public function removeChild(Child $child): self
  534. {
  535. $this->children->removeElement($child);
  536. return $this;
  537. }
  538. public function getAdminComment(): ?string
  539. {
  540. return $this->adminComment;
  541. }
  542. public function setAdminComment(?string $adminComment): self
  543. {
  544. $this->adminComment = $adminComment;
  545. return $this;
  546. }
  547. /**
  548. * @return Collection|PaymentLog[]
  549. */
  550. public function getPaymentLogs(): Collection
  551. {
  552. return $this->paymentLogs;
  553. }
  554. public function addPaymentLog(PaymentLog $paymentLog): self
  555. {
  556. if (!$this->paymentLogs->contains($paymentLog)) {
  557. $this->paymentLogs[] = $paymentLog;
  558. $paymentLog->setLesson($this);
  559. }
  560. return $this;
  561. }
  562. public function removePaymentLog(PaymentLog $paymentLog): self
  563. {
  564. if ($this->paymentLogs->removeElement($paymentLog)) {
  565. // set the owning side to null (unless already changed)
  566. if ($paymentLog->getLesson() === $this) {
  567. $paymentLog->setLesson(null);
  568. }
  569. }
  570. return $this;
  571. }
  572. /**
  573. * @return Collection|TeacherPaymentLog[]
  574. */
  575. public function getTeacherPaymentLogs(): Collection
  576. {
  577. return $this->teacherPaymentLogs;
  578. }
  579. public function addTeacherPaymentLog(TeacherPaymentLog $teacherPaymentLog): self
  580. {
  581. if (!$this->teacherPaymentLogs->contains($teacherPaymentLog)) {
  582. $this->teacherPaymentLogs[] = $teacherPaymentLog;
  583. $teacherPaymentLog->setLesson($this);
  584. }
  585. return $this;
  586. }
  587. public function removeTeacherPaymentLog(TeacherPaymentLog $teacherPaymentLog): self
  588. {
  589. if ($this->teacherPaymentLogs->removeElement($teacherPaymentLog)) {
  590. // set the owning side to null (unless already changed)
  591. if ($teacherPaymentLog->getLesson() === $this) {
  592. $teacherPaymentLog->setLesson(null);
  593. }
  594. }
  595. return $this;
  596. }
  597. /**
  598. * @Assert\Callback
  599. */
  600. public function validate(ExecutionContextInterface $context, $payload)
  601. {
  602. $startTime = $this->getStartTime();
  603. $endTime = $this->getEndTime();
  604. $durationDiff = date_diff($startTime, $endTime);
  605. $duration = (int)$durationDiff->i + (int)$durationDiff->h * 60;
  606. if ($duration > 120) {
  607. $context->buildViolation('Maksimalus pamokos laikas yra 2h.')
  608. ->atPath('endTime')
  609. ->addViolation();
  610. }
  611. }
  612. /**
  613. * @return Collection|LessonChangeLog[]
  614. */
  615. public function getLessonChangeLogs(): Collection
  616. {
  617. return $this->lessonChangeLogs;
  618. }
  619. public function addLessonChangeLog(LessonChangeLog $lessonChangeLog): self
  620. {
  621. if (!$this->lessonChangeLogs->contains($lessonChangeLog)) {
  622. $this->lessonChangeLogs[] = $lessonChangeLog;
  623. $lessonChangeLog->setLesson($this);
  624. }
  625. return $this;
  626. }
  627. public function removeLessonChangeLog(LessonChangeLog $lessonChangeLog): self
  628. {
  629. if ($this->lessonChangeLogs->removeElement($lessonChangeLog)) {
  630. // set the owning side to null (unless already changed)
  631. if ($lessonChangeLog->getLesson() === $this) {
  632. $lessonChangeLog->setLesson(null);
  633. }
  634. }
  635. return $this;
  636. }
  637. public function isStatusTeacher(): ?bool
  638. {
  639. return $this->statusTeacher;
  640. }
  641. public function setStatusTeacher(?bool $statusTeacher): self
  642. {
  643. $this->statusTeacher = $statusTeacher;
  644. return $this;
  645. }
  646. public function isStatusChild(): ?bool
  647. {
  648. return $this->statusChild;
  649. }
  650. public function setStatusChild(?bool $statusChild): self
  651. {
  652. $this->statusChild = $statusChild;
  653. return $this;
  654. }
  655. public function getLearncubeUUID(): ?string
  656. {
  657. return $this->learncubeUUID;
  658. }
  659. public function setLearncubeUUID(?string $learncubeUUID): self
  660. {
  661. $this->learncubeUUID = $learncubeUUID;
  662. return $this;
  663. }
  664. public function getAttendedAtTeacher(): ?\DateTimeInterface
  665. {
  666. return $this->attendedAtTeacher;
  667. }
  668. public function setAttendedAtTeacher(?\DateTimeInterface $attendedAtTeacher): self
  669. {
  670. $this->attendedAtTeacher = $attendedAtTeacher;
  671. return $this;
  672. }
  673. public function getAttendedAtChild(): ?\DateTimeInterface
  674. {
  675. return $this->attendedAtChild;
  676. }
  677. public function setAttendedAtChild(?\DateTimeInterface $attendedAtChild): self
  678. {
  679. $this->attendedAtChild = $attendedAtChild;
  680. return $this;
  681. }
  682. public function getLessonJoin()
  683. {
  684. $lessonJoin = true;
  685. $endTime = new \DateTime();
  686. $endTime->modify('-5 minutes');
  687. if($this->endTime < $endTime)
  688. {
  689. $lessonJoin = false;
  690. }
  691. $startTime = new \DateTime();
  692. $startTime->modify('+5 minutes');
  693. if($this->startTime > $startTime)
  694. {
  695. $lessonJoin = false;
  696. }
  697. if($this->childMissed || $this->teacherMissed)
  698. {
  699. return false;
  700. }
  701. return $lessonJoin;
  702. }
  703. public function isMovable()
  704. {
  705. $dateNow = new \DateTime();
  706. 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'))
  707. {
  708. return true;
  709. }
  710. if($dateNow < $this->endTime && $dateNow->format('Y-m') == $this->startTime->format('Y-m'))
  711. {
  712. return true;
  713. }
  714. return false;
  715. }
  716. public function getChildIsLate(): ?bool
  717. {
  718. return $this->childIsLate;
  719. }
  720. public function setChildIsLate(?bool $childIsLate): self
  721. {
  722. $this->childIsLate = $childIsLate;
  723. return $this;
  724. }
  725. public function getChildMissed(): ?bool
  726. {
  727. return $this->childMissed;
  728. }
  729. public function setChildMissed(?bool $childMissed): self
  730. {
  731. $this->childMissed = $childMissed;
  732. return $this;
  733. }
  734. public function getTeacherMissed(): ?bool
  735. {
  736. return $this->teacherMissed;
  737. }
  738. public function setTeacherMissed(?bool $teacherMissed): self
  739. {
  740. $this->teacherMissed = $teacherMissed;
  741. return $this;
  742. }
  743. public function getLearncubeEndAt(): ?\DateTimeInterface
  744. {
  745. return $this->learncubeEndAt;
  746. }
  747. public function setLearncubeEndAt(?\DateTimeInterface $learncubeEndAt): self
  748. {
  749. $this->learncubeEndAt = $learncubeEndAt;
  750. return $this;
  751. }
  752. public function getLearncubeDuration(): ?int
  753. {
  754. return $this->learncubeDuration;
  755. }
  756. public function setLearncubeDuration(?int $learncubeDuration): self
  757. {
  758. $this->learncubeDuration = $learncubeDuration;
  759. return $this;
  760. }
  761. public function getFreeReason(): ?string
  762. {
  763. return $this->freeReason;
  764. }
  765. public function setFreeReason(?string $freeReason): self
  766. {
  767. $this->freeReason = $freeReason;
  768. return $this;
  769. }
  770. /**
  771. * @return Collection<int, LessonLearncubeLog>
  772. */
  773. public function getLessonLearncubeLogs(): Collection
  774. {
  775. return $this->lessonLearncubeLogs;
  776. }
  777. public function addLessonLearncubeLog(LessonLearncubeLog $lessonLearncubeLog): self
  778. {
  779. if (!$this->lessonLearncubeLogs->contains($lessonLearncubeLog)) {
  780. $this->lessonLearncubeLogs[] = $lessonLearncubeLog;
  781. $lessonLearncubeLog->setLesson($this);
  782. }
  783. return $this;
  784. }
  785. public function removeLessonLearncubeLog(LessonLearncubeLog $lessonLearncubeLog): self
  786. {
  787. if ($this->lessonLearncubeLogs->removeElement($lessonLearncubeLog)) {
  788. // set the owning side to null (unless already changed)
  789. if ($lessonLearncubeLog->getLesson() === $this) {
  790. $lessonLearncubeLog->setLesson(null);
  791. }
  792. }
  793. return $this;
  794. }
  795. public function getLearncubeChildDuration(): ?int
  796. {
  797. return $this->learncubeChildDuration;
  798. }
  799. public function setLearncubeChildDuration(?int $learncubeChildDuration): self
  800. {
  801. $this->learncubeChildDuration = $learncubeChildDuration;
  802. return $this;
  803. }
  804. public function getLearncubeTeacherDuration(): ?int
  805. {
  806. return $this->learncubeTeacherDuration;
  807. }
  808. public function setLearncubeTeacherDuration(?int $learncubeTeacherDuration): self
  809. {
  810. $this->learncubeTeacherDuration = $learncubeTeacherDuration;
  811. return $this;
  812. }
  813. public function getMovedAt(): ?\DateTimeInterface
  814. {
  815. return $this->movedAt;
  816. }
  817. public function setMovedAt(?\DateTimeInterface $movedAt): self
  818. {
  819. $this->movedAt = $movedAt;
  820. return $this;
  821. }
  822. public function getWasMissedBy(): ?string
  823. {
  824. return $this->wasMissedBy;
  825. }
  826. public function setWasMissedBy(?string $wasMissedBy): self
  827. {
  828. $this->wasMissedBy = $wasMissedBy;
  829. return $this;
  830. }
  831. public function getDateAdd(): ?\DateTimeInterface
  832. {
  833. return $this->dateAdd;
  834. }
  835. public function setDateAdd(?\DateTimeInterface $dateAdd): self
  836. {
  837. $this->dateAdd = $dateAdd;
  838. return $this;
  839. }
  840. public function getChildMissReason(): ?string
  841. {
  842. return $this->childMissReason;
  843. }
  844. public function setChildMissReason(?string $childMissReason): self
  845. {
  846. $this->childMissReason = $childMissReason;
  847. return $this;
  848. }
  849. public function getChildMissedAt(): ?\DateTimeInterface
  850. {
  851. return $this->childMissedAt;
  852. }
  853. public function setChildMissedAt(?\DateTimeInterface $childMissedAt): self
  854. {
  855. $this->childMissedAt = $childMissedAt;
  856. return $this;
  857. }
  858. public function getTechnicalDifficultyComment(): ?string
  859. {
  860. return $this->technicalDifficultyComment;
  861. }
  862. public function setTechnicalDifficultyComment(?string $technicalDifficultyComment): self
  863. {
  864. $this->technicalDifficultyComment = $technicalDifficultyComment;
  865. return $this;
  866. }
  867. public function getLearncubeReview(): ?string
  868. {
  869. return $this->learncubeReview;
  870. }
  871. public function setLearncubeReview(?string $learncubeReview): self
  872. {
  873. $this->learncubeReview = $learncubeReview;
  874. return $this;
  875. }
  876. public function getLearncubeRating(): ?string
  877. {
  878. return $this->learncubeRating;
  879. }
  880. public function setLearncubeRating(?string $learncubeRating): self
  881. {
  882. $this->learncubeRating = $learncubeRating;
  883. return $this;
  884. }
  885. public function getGoogleCalendarIdTeacher(): ?string
  886. {
  887. return $this->googleCalendarIdTeacher;
  888. }
  889. public function setGoogleCalendarIdTeacher(?string $googleCalendarIdTeacher): self
  890. {
  891. $this->googleCalendarIdTeacher = $googleCalendarIdTeacher;
  892. return $this;
  893. }
  894. public function getGoogleCalendarIdChild(): ?string
  895. {
  896. return $this->googleCalendarIdChild;
  897. }
  898. public function setGoogleCalendarIdChild(?string $googleCalendarIdChild): self
  899. {
  900. $this->googleCalendarIdChild = $googleCalendarIdChild;
  901. return $this;
  902. }
  903. public function getGoogleCalendarIdGuardian(): ?string
  904. {
  905. return $this->googleCalendarIdGuardian;
  906. }
  907. public function setGoogleCalendarIdGuardian(?string $googleCalendarIdGuardian): self
  908. {
  909. $this->googleCalendarIdGuardian = $googleCalendarIdGuardian;
  910. return $this;
  911. }
  912. public function getPublicToken(): ?string
  913. {
  914. return $this->publicToken;
  915. }
  916. public function setPublicToken(?string $publicToken): self
  917. {
  918. $this->publicToken = $publicToken;
  919. return $this;
  920. }
  921. public function getMovedBy(): ?string
  922. {
  923. return $this->movedBy;
  924. }
  925. public function setMovedBy(?string $movedBy): self
  926. {
  927. $this->movedBy = $movedBy;
  928. return $this;
  929. }
  930. public function getPaid(): ?float
  931. {
  932. return $this->paid;
  933. }
  934. public function setPaid(?float $paid): self
  935. {
  936. $this->paid = $paid;
  937. return $this;
  938. }
  939. public function getOriginalStartTime(): ?\DateTimeInterface
  940. {
  941. return $this->originalStartTime;
  942. }
  943. public function setOriginalStartTime(?\DateTimeInterface $originalStartTime): self
  944. {
  945. $this->originalStartTime = $originalStartTime;
  946. return $this;
  947. }
  948. public function getOriginalEndTime(): ?\DateTimeInterface
  949. {
  950. return $this->originalEndTime;
  951. }
  952. public function setOriginalEndTime(?\DateTimeInterface $originalEndTime): self
  953. {
  954. $this->originalEndTime = $originalEndTime;
  955. return $this;
  956. }
  957. /**
  958. * @return Collection<int, ChildLessonReview>
  959. */
  960. public function getChildLessonReviews(): Collection
  961. {
  962. return $this->childLessonReviews;
  963. }
  964. public function addChildLessonReview(ChildLessonReview $childLessonReview): self
  965. {
  966. if (!$this->childLessonReviews->contains($childLessonReview)) {
  967. $this->childLessonReviews[] = $childLessonReview;
  968. $childLessonReview->setLesson($this);
  969. }
  970. return $this;
  971. }
  972. public function removeChildLessonReview(ChildLessonReview $childLessonReview): self
  973. {
  974. if ($this->childLessonReviews->removeElement($childLessonReview)) {
  975. // set the owning side to null (unless already changed)
  976. if ($childLessonReview->getLesson() === $this) {
  977. $childLessonReview->setLesson(null);
  978. }
  979. }
  980. return $this;
  981. }
  982. public function getChildDismissedReview(): bool
  983. {
  984. return (bool) $this->childDismissedReview;
  985. }
  986. public function setChildDismissedReview(?bool $childDismissedReview): self
  987. {
  988. $this->childDismissedReview = (bool) $childDismissedReview;
  989. return $this;
  990. }
  991. }