src/Entity/ChildPreference.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ChildPreferenceRepository;
  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. /**
  9. * @ORM\Entity(repositoryClass=ChildPreferenceRepository::class)
  10. * @ORM\Table(name="child_preference", indexes={
  11. * @ORM\Index(name="cp_assigned_from_status_created_at_idx", columns={"assigned_from", "status", "created_at"}),
  12. * @ORM\Index(name="cp_assigned_at_idx", columns={"assigned_at"}),
  13. * @ORM\Index(name="cp_todo_at_idx", columns={"todo_at"})
  14. * })
  15. */
  16. class ChildPreference
  17. {
  18. const STATUS_TO_ASSIGN = [
  19. 'value' => "TO_ASSIGN",
  20. 'text' => 'Priskirti',
  21. 'color' => '#f8d7da'
  22. ];
  23. const STATUS_ASSIGNED = [
  24. 'value' => "ASSIGNED",
  25. 'text' => 'Priskirta',
  26. 'color' => '#d4edda'
  27. ];
  28. const STATUS_ACCEPTED = [
  29. 'value' => "ACCEPTED",
  30. 'text' => 'Priimta',
  31. 'color' => '#0cb535'
  32. ];
  33. const STATUS_CANCELLED = [
  34. 'value' => "CANCELLED",
  35. 'text' => 'Atmesta',
  36. 'color' => '#ffa600'
  37. ];
  38. const STATUS_TERMINATING = [
  39. 'value' => "TERMINATING",
  40. 'text' => 'Nutraukia',
  41. 'color' => '#45C6F6'
  42. ];
  43. const STATUS_NOT_FOUND = [
  44. 'value' => "NOT_FOUND",
  45. 'text' => 'Nerandama',
  46. 'color' => '#f8d7da'
  47. ];
  48. const STATUS_AUTOMATIC_ASSIGNMENT = [
  49. 'value' => "AUTOMATIC_ASSIGNMENT",
  50. 'text' => 'Automatinis priskyrimas',
  51. 'color' => '#f8d7da'
  52. ];
  53. const STATUSES = [self::STATUS_TO_ASSIGN, self::STATUS_ASSIGNED, self::STATUS_ACCEPTED, self::STATUS_CANCELLED, self::STATUS_TERMINATING, self::STATUS_NOT_FOUND, self::STATUS_AUTOMATIC_ASSIGNMENT];
  54. const PENDING_ADMIN_STATUSES = [
  55. self::STATUS_TO_ASSIGN['value'],
  56. self::STATUS_NOT_FOUND['value'],
  57. self::STATUS_CANCELLED['value'],
  58. ];
  59. const LIST_ASSIGNMENT_SOURCES = ['Keitimas', 'Naujas', 'Anketa'];
  60. /**
  61. * @ORM\Id
  62. * @ORM\GeneratedValue
  63. * @ORM\Column(type="integer")
  64. * @Groups({"ChildPreferenceList", "ChildPreferenceAssignmentList"})
  65. */
  66. private $id;
  67. /**
  68. * @ORM\ManyToOne(targetEntity=Discipline::class, inversedBy="childPreferences")
  69. * @ORM\JoinColumn(nullable=true)
  70. * @Groups({"ChildPreferenceList", "ChildPreferenceAssignmentList"})
  71. */
  72. private $discipline;
  73. /**
  74. * @Groups({"ChildPreferenceList", "ChildPreferenceAssignmentList"})
  75. */
  76. private $amount;
  77. /**
  78. * @Groups({"ChildPreferenceList", "ChildPreferenceAssignmentList"})
  79. */
  80. private $duration;
  81. /**
  82. * @ORM\Column(type="string", length=255, nullable=true)
  83. * @Groups({"ChildPreferenceList"})
  84. */
  85. private $type = Lesson::TYPE_INDIVIDUAL;
  86. /**
  87. * @ORM\ManyToOne(targetEntity=Teacher::class, inversedBy="childPreferences")
  88. * @Groups({"ChildPreferenceList", "ChildPreferenceAssignmentList"})
  89. */
  90. private $teacher;
  91. /**
  92. * @ORM\Column(type="text", nullable=true)
  93. * @Groups({"ChildPreferenceList", "ChildPreferenceAssignmentList"})
  94. */
  95. private $comment;
  96. /**
  97. * @ORM\ManyToOne(targetEntity=Child::class, inversedBy="childPreferences")
  98. * @Groups({"ChildPreferenceAssignmentList","ChildPreferenceList"})
  99. */
  100. private $child;
  101. /**
  102. * @ORM\OneToMany(targetEntity=ChildPreferenceTime::class, mappedBy="childPreference", cascade={"all"})
  103. * @Groups({"ChildPreferenceList", "ChildPreferenceAssignmentList"})
  104. */
  105. private $childPreferenceTimes;
  106. /**
  107. * @ORM\Column(type="text", nullable=true)
  108. */
  109. private $fittingTimes;
  110. /**
  111. * @ORM\Column(type="text", nullable=true)
  112. */
  113. private $fittingTimesPriority;
  114. /**
  115. * @ORM\Column(type="integer", nullable=true)
  116. */
  117. private $emailDuration = 120;
  118. /**
  119. * @ORM\Column(type="integer", nullable=true)
  120. */
  121. private $singleEmailDuration = 60;
  122. /**
  123. * @ORM\Column(type="datetime", nullable=true)
  124. */
  125. private $startTime;
  126. /**
  127. * @ORM\Column(type="datetime", nullable=true)
  128. * @Groups({"ChildPreferenceAssignmentList","ChildPreferenceList"})
  129. */
  130. private $endTime;
  131. /**
  132. * @ORM\Column(type="datetime", nullable=true)
  133. * @Groups({"ChildPreferenceAssignmentList"})
  134. */
  135. private $createdAt;
  136. /**
  137. * @ORM\Column(type="string", length=255, nullable=true)
  138. * @Groups({"ChildPreferenceAssignmentList"})
  139. */
  140. private $status = self::STATUS_TO_ASSIGN['value'];
  141. /**
  142. * @ORM\Column(type="datetime", nullable=true)
  143. * @Groups({"ChildPreferenceAssignmentList"})
  144. */
  145. private $assignedAt;
  146. /**
  147. * @ORM\Column(type="text", nullable=true)
  148. * @Groups({"ChildPreferenceAssignmentList"})
  149. */
  150. private $declineReason;
  151. /**
  152. * @ORM\Column(type="string", length=255, nullable=true)
  153. */
  154. private $teacherChange;
  155. /**
  156. * @ORM\Column(type="text", nullable=true)
  157. */
  158. private $terminateReason;
  159. /**
  160. * @ORM\Column(type="integer", nullable=true)
  161. */
  162. private $teacherAssignRemindCount = 0;
  163. /**
  164. * @ORM\Column(type="datetime", nullable=true)
  165. */
  166. private $acceptedAt;
  167. /**
  168. * @ORM\Column(type="datetime", nullable=true)
  169. * @Groups({"ChildPreferenceAssignmentList"})
  170. */
  171. private $todoAt;
  172. /**
  173. * @ORM\Column(type="text", nullable=true)
  174. * @Groups({"ChildPreferenceAssignmentList"})
  175. */
  176. private $adminComment;
  177. /**
  178. * @ORM\ManyToOne(targetEntity=Admin::class, inversedBy="childPreferences")
  179. * @Groups({"ChildPreferenceAssignmentList"})
  180. */
  181. private $adminUser;
  182. private $ignoreNotifications;
  183. private $regenerateLessonsFrom;
  184. private $regenerateAllLessons;
  185. /**
  186. * @ORM\Column(type="string", length=255, nullable=true)
  187. * @Groups({"ChildPreferenceAssignmentList"})
  188. */
  189. private $assignedFrom = "Senas";
  190. /**
  191. * @ORM\Column(type="boolean", nullable=true)
  192. * @Groups({"ChildPreferenceList"})
  193. */
  194. private $markedEndingByTeacher;
  195. /**
  196. * @ORM\Column(type="datetime", nullable=true)
  197. * @Groups({"ChildPreferenceList"})
  198. */
  199. private $markedEndingByTeacherDate;
  200. /**
  201. * @ORM\Column(type="datetime", nullable=true)
  202. */
  203. private $editedByTeacherAt;
  204. /**
  205. * @ORM\Column(type="string", length=255, nullable=true)
  206. */
  207. private $tutorTerminateComment;
  208. /**
  209. * @ORM\Column(type="string", length=255, nullable=true)
  210. */
  211. private $action;
  212. /**
  213. * @ORM\Column(type="string", length=255, nullable=true)
  214. */
  215. private $subAction;
  216. /**
  217. * @ORM\Column(type="datetime", nullable=true)
  218. */
  219. private $actionAt;
  220. /**
  221. * @ORM\Column(type="boolean", nullable=true)
  222. */
  223. private $keepPreviousTutor;
  224. /**
  225. * @ORM\Column(type="datetime", nullable=true)
  226. */
  227. private $assignedAutomaticly;
  228. /**
  229. * @ORM\Column(type="boolean", nullable=true)
  230. */
  231. private $flagManualAssignment;
  232. public function __construct()
  233. {
  234. $this->childPreferenceTimes = new ArrayCollection();
  235. $this->createdAt = new \Datetime();
  236. }
  237. public function getId(): ?int
  238. {
  239. return $this->id;
  240. }
  241. public function getDiscipline(): ?Discipline
  242. {
  243. return $this->discipline;
  244. }
  245. public function setDiscipline(?Discipline $discipline): self
  246. {
  247. $this->discipline = $discipline;
  248. return $this;
  249. }
  250. public function getAmount(): ?int
  251. {
  252. return count($this->childPreferenceTimes);
  253. // return $this->amount;
  254. }
  255. // public function setAmount(?int $amount): self
  256. // {
  257. // $this->amount = $amount;
  258. //
  259. // return $this;
  260. // }
  261. public function getDuration(): ?int
  262. {
  263. $duration = 0;
  264. /**
  265. * @var $childPreferenceTime ChildPreferenceTime
  266. */
  267. foreach ($this->childPreferenceTimes as $childPreferenceTime)
  268. {
  269. $startTime = $childPreferenceTime->getStartTime();
  270. $endTime = $childPreferenceTime->getEndTime();
  271. $durationDiff = date_diff($startTime, $endTime);
  272. $duration += (int)$durationDiff->i + (int)$durationDiff->h * 60;
  273. }
  274. return $duration;
  275. }
  276. // public function setDuration(?int $duration): self
  277. // {
  278. // $this->duration = $duration;
  279. //
  280. // return $this;
  281. // }
  282. public function getType(): ?string
  283. {
  284. return $this->type;
  285. }
  286. public function setType(?string $type): self
  287. {
  288. $this->type = $type;
  289. return $this;
  290. }
  291. public function getTeacher(): ?Teacher
  292. {
  293. return $this->teacher;
  294. }
  295. public function setTeacher(?Teacher $teacher): self
  296. {
  297. $this->teacher = $teacher;
  298. return $this;
  299. }
  300. public function getComment(): ?string
  301. {
  302. return $this->comment;
  303. }
  304. public function setComment(?string $comment): self
  305. {
  306. $this->comment = $comment;
  307. return $this;
  308. }
  309. public function getChild(): ?Child
  310. {
  311. return $this->child;
  312. }
  313. public function setChild(?Child $child): self
  314. {
  315. $this->child = $child;
  316. return $this;
  317. }
  318. /**
  319. * @return Collection|ChildPreferenceTime[]
  320. */
  321. public function getChildPreferenceTimes(): Collection
  322. {
  323. return $this->childPreferenceTimes;
  324. }
  325. public function addChildPreferenceTime(ChildPreferenceTime $childPreferenceTime): self
  326. {
  327. if (!$this->childPreferenceTimes->contains($childPreferenceTime)) {
  328. $this->childPreferenceTimes[] = $childPreferenceTime;
  329. $childPreferenceTime->setChildPreference($this);
  330. }
  331. return $this;
  332. }
  333. public function removeChildPreferenceTime(ChildPreferenceTime $childPreferenceTime): self
  334. {
  335. if ($this->childPreferenceTimes->removeElement($childPreferenceTime)) {
  336. // set the owning side to null (unless already changed)
  337. if ($childPreferenceTime->getChildPreference() === $this) {
  338. $childPreferenceTime->setChildPreference(null);
  339. }
  340. }
  341. return $this;
  342. }
  343. public function __toString()
  344. {
  345. return "{$this->child} {$this->id} {$this->discipline}";
  346. }
  347. public function getFittingTimes(): ?string
  348. {
  349. if($this->fittingTimes)
  350. {
  351. return $this->fittingTimes;
  352. }
  353. return $this->child->getFittingTimes();
  354. }
  355. public function setFittingTimes(?string $fittingTimes): self
  356. {
  357. $this->child->setFittingTimes($fittingTimes);
  358. $this->fittingTimes = $fittingTimes;
  359. return $this;
  360. }
  361. public function getEmailDuration(): ?int
  362. {
  363. return $this->emailDuration;
  364. }
  365. public function setEmailDuration(?int $emailDuration): self
  366. {
  367. $this->emailDuration = $emailDuration;
  368. return $this;
  369. }
  370. public function getSingleEmailDuration(): ?int
  371. {
  372. return $this->singleEmailDuration;
  373. }
  374. public function setSingleEmailDuration(?int $singleEmailDuration): self
  375. {
  376. $this->singleEmailDuration = $singleEmailDuration;
  377. return $this;
  378. }
  379. public function getStartTime(): ?\DateTimeInterface
  380. {
  381. return $this->startTime;
  382. }
  383. public function setStartTime(?\DateTimeInterface $startTime): self
  384. {
  385. $this->startTime = $startTime;
  386. return $this;
  387. }
  388. public function getEndTime(): ?\DateTimeInterface
  389. {
  390. return $this->endTime;
  391. }
  392. public function setEndTime(?\DateTimeInterface $endTime): self
  393. {
  394. $this->endTime = $endTime;
  395. return $this;
  396. }
  397. public function getCreatedAt(): ?\DateTimeInterface
  398. {
  399. return $this->createdAt;
  400. }
  401. public function setCreatedAt(?\DateTimeInterface $createdAt): self
  402. {
  403. $this->createdAt = $createdAt;
  404. return $this;
  405. }
  406. public function getStatus(): ?string
  407. {
  408. return $this->status;
  409. }
  410. public function getStatusLabel(): ?string
  411. {
  412. foreach (self::STATUSES as $STATUS)
  413. {
  414. if($STATUS['value'] == $this->status)
  415. {
  416. return $STATUS['text'];
  417. }
  418. }
  419. return '';
  420. }
  421. public function setStatus(?string $status): self
  422. {
  423. $this->status = $status;
  424. return $this;
  425. }
  426. public function getAssignedAt(): ?\DateTimeInterface
  427. {
  428. return $this->assignedAt;
  429. }
  430. public function setAssignedAt(?\DateTimeInterface $assignedAt): self
  431. {
  432. $this->assignedAt = $assignedAt;
  433. return $this;
  434. }
  435. public function getDeclineReason(): ?string
  436. {
  437. return $this->declineReason;
  438. }
  439. public function setDeclineReason(?string $declineReason): self
  440. {
  441. $this->declineReason = $declineReason;
  442. return $this;
  443. }
  444. public function getTeacherChange(): ?string
  445. {
  446. return $this->teacherChange;
  447. }
  448. public function setTeacherChange(?string $teacherChange): self
  449. {
  450. $this->teacherChange = $teacherChange;
  451. return $this;
  452. }
  453. public function getTerminateReason(): ?string
  454. {
  455. return $this->terminateReason;
  456. }
  457. public function setTerminateReason(?string $terminateReason): self
  458. {
  459. $this->terminateReason = $terminateReason;
  460. return $this;
  461. }
  462. public function getTeacherAssignRemindCount(): ?int
  463. {
  464. return $this->teacherAssignRemindCount;
  465. }
  466. public function setTeacherAssignRemindCount(?int $teacherAssignRemindCount): self
  467. {
  468. $this->teacherAssignRemindCount = $teacherAssignRemindCount;
  469. return $this;
  470. }
  471. public function getAcceptedAt(): ?\DateTimeInterface
  472. {
  473. return $this->acceptedAt;
  474. }
  475. public function setAcceptedAt(?\DateTimeInterface $acceptedAt): self
  476. {
  477. $this->acceptedAt = $acceptedAt;
  478. return $this;
  479. }
  480. public function getTodoAt(): ?\DateTimeInterface
  481. {
  482. return $this->todoAt;
  483. }
  484. public function setTodoAt(?\DateTimeInterface $todoAt): self
  485. {
  486. $this->todoAt = $todoAt;
  487. return $this;
  488. }
  489. public function getAdminComment(): ?string
  490. {
  491. return $this->adminComment;
  492. }
  493. public function setAdminComment(?string $adminComment): self
  494. {
  495. $this->adminComment = $adminComment;
  496. return $this;
  497. }
  498. public function getAdminUser(): ?Admin
  499. {
  500. return $this->adminUser;
  501. }
  502. public function setAdminUser(?Admin $adminUser): self
  503. {
  504. $this->adminUser = $adminUser;
  505. return $this;
  506. }
  507. public function getIgnoreNotifications()
  508. {
  509. return $this->ignoreNotifications;
  510. }
  511. public function setIgnoreNotifications($ignoreNotifications): self
  512. {
  513. $this->ignoreNotifications = $ignoreNotifications;
  514. return $this;
  515. }
  516. public function getRegenerateAllLessons()
  517. {
  518. return $this->regenerateAllLessons;
  519. }
  520. public function setRegenerateAllLessons($regenerateAllLessons): self
  521. {
  522. $this->regenerateAllLessons = $regenerateAllLessons;
  523. return $this;
  524. }
  525. public function getRegenerateLessonsFrom()
  526. {
  527. return $this->regenerateLessonsFrom;
  528. }
  529. public function setRegenerateLessonsFrom($regenerateLessonsFrom): self
  530. {
  531. $this->regenerateLessonsFrom = $regenerateLessonsFrom;
  532. return $this;
  533. }
  534. public function getAssignedFrom(): ?string
  535. {
  536. return $this->assignedFrom;
  537. }
  538. public function setAssignedFrom(?string $assignedFrom): self
  539. {
  540. $this->assignedFrom = $assignedFrom;
  541. return $this;
  542. }
  543. public function isMarkedEndingByTeacher(): ?bool
  544. {
  545. return $this->markedEndingByTeacher;
  546. }
  547. public function setMarkedEndingByTeacher(?bool $markedEndingByTeacher): self
  548. {
  549. $this->markedEndingByTeacher = $markedEndingByTeacher;
  550. return $this;
  551. }
  552. public function getMarkedEndingByTeacherDate(): ?\DateTimeInterface
  553. {
  554. return $this->markedEndingByTeacherDate;
  555. }
  556. public function setMarkedEndingByTeacherDate(?\DateTimeInterface $markedEndingByTeacherDate): self
  557. {
  558. $this->markedEndingByTeacherDate = $markedEndingByTeacherDate;
  559. return $this;
  560. }
  561. public function getEditedByTeacherAt(): ?\DateTimeInterface
  562. {
  563. return $this->editedByTeacherAt;
  564. }
  565. public function setEditedByTeacherAt(?\DateTimeInterface $editedByTeacherAt): self
  566. {
  567. $this->editedByTeacherAt = $editedByTeacherAt;
  568. return $this;
  569. }
  570. public function getTutorTerminateComment(): ?string
  571. {
  572. return $this->tutorTerminateComment;
  573. }
  574. public function setTutorTerminateComment(?string $tutorTerminateComment): self
  575. {
  576. $this->tutorTerminateComment = $tutorTerminateComment;
  577. return $this;
  578. }
  579. public function getAction(): ?string
  580. {
  581. return $this->action;
  582. }
  583. public function setAction(?string $action): self
  584. {
  585. $this->action = $action;
  586. return $this;
  587. }
  588. public function getSubAction(): ?string
  589. {
  590. return $this->subAction;
  591. }
  592. public function setSubAction(?string $subAction): self
  593. {
  594. $this->subAction = $subAction;
  595. return $this;
  596. }
  597. public function getActionAt(): ?\DateTimeInterface
  598. {
  599. return $this->actionAt;
  600. }
  601. public function setActionAt(?\DateTimeInterface $actionAt): self
  602. {
  603. $this->actionAt = $actionAt;
  604. return $this;
  605. }
  606. public function getFittingTimesPriority(): ?string
  607. {
  608. if ($this->fittingTimesPriority) {
  609. return $this->fittingTimesPriority;
  610. }
  611. return $this->child->getFittingTimesPriority();
  612. }
  613. public function setFittingTimesPriority(?string $fittingTimesPriority): self
  614. {
  615. $this->child->setFittingTimesPriority($fittingTimesPriority);
  616. $this->fittingTimesPriority = $fittingTimesPriority;
  617. return $this;
  618. }
  619. public function isKeepPreviousTutor(): ?bool
  620. {
  621. return $this->keepPreviousTutor;
  622. }
  623. public function setKeepPreviousTutor(?bool $keepPreviousTutor): self
  624. {
  625. $this->keepPreviousTutor = $keepPreviousTutor;
  626. return $this;
  627. }
  628. public function getAssignedAutomaticly(): ?\DateTimeInterface
  629. {
  630. return $this->assignedAutomaticly;
  631. }
  632. public function setAssignedAutomaticly(?\DateTimeInterface $assignedAutomaticly): self
  633. {
  634. $this->assignedAutomaticly = $assignedAutomaticly;
  635. return $this;
  636. }
  637. public function isFlagManualAssignment(): ?bool
  638. {
  639. return $this->flagManualAssignment;
  640. }
  641. public function setFlagManualAssignment(?bool $flagManualAssignment): self
  642. {
  643. $this->flagManualAssignment = $flagManualAssignment;
  644. return $this;
  645. }
  646. }