src/Entity/PaymentLog.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PaymentLogRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6. * @ORM\Entity(repositoryClass=PaymentLogRepository::class)
  7. */
  8. class PaymentLog
  9. {
  10. /**
  11. * @ORM\Id
  12. * @ORM\GeneratedValue
  13. * @ORM\Column(type="integer")
  14. */
  15. private $id;
  16. /**
  17. * @ORM\ManyToOne(targetEntity=Guardian::class, inversedBy="paymentLogs")
  18. */
  19. private $guardian;
  20. /**
  21. * @ORM\ManyToOne(targetEntity=Lesson::class, inversedBy="paymentLogs")
  22. * @ORM\JoinColumn(name="lesson_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
  23. */
  24. private $lesson;
  25. /**
  26. * @ORM\Column(type="float", nullable=true)
  27. */
  28. private $amount;
  29. /**
  30. * @ORM\Column(type="datetime", nullable=true)
  31. */
  32. private $dateAdd;
  33. /**
  34. * @ORM\ManyToOne(targetEntity=Child::class, inversedBy="paymentLogs")
  35. */
  36. private $child;
  37. /**
  38. * @ORM\Column(type="datetime", nullable=true)
  39. */
  40. private $dateFor;
  41. /**
  42. * @ORM\Column(type="text", nullable=true)
  43. */
  44. private $info;
  45. /**
  46. * @ORM\Column(type="integer", nullable=true)
  47. */
  48. private $duration;
  49. /**
  50. * @ORM\Column(type="datetime", nullable=true)
  51. */
  52. private $startTime;
  53. /**
  54. * @ORM\Column(type="datetime", nullable=true)
  55. */
  56. private $endTime;
  57. /**
  58. * @ORM\Column(type="string", length=255, nullable=true)
  59. */
  60. private $status;
  61. /**
  62. * @ORM\Column(type="string", length=255, nullable=true)
  63. */
  64. private $discipline;
  65. /**
  66. * @ORM\Column(type="string", length=255, nullable=true)
  67. */
  68. private $discountType;
  69. /**
  70. * @ORM\Column(type="float", nullable=true)
  71. */
  72. private $discountPercent;
  73. /**
  74. * @ORM\Column(type="float", nullable=true)
  75. */
  76. private $amountWithoutDiscounts;
  77. public function __construct()
  78. {
  79. $this->dateAdd = new \DateTime();
  80. }
  81. public function getId(): ?int
  82. {
  83. return $this->id;
  84. }
  85. public function getGuardian(): ?Guardian
  86. {
  87. return $this->guardian;
  88. }
  89. public function setGuardian(?Guardian $guardian): self
  90. {
  91. $this->guardian = $guardian;
  92. return $this;
  93. }
  94. public function getLesson(): ?Lesson
  95. {
  96. return $this->lesson;
  97. }
  98. public function setLesson(?Lesson $lesson): self
  99. {
  100. $this->lesson = $lesson;
  101. return $this;
  102. }
  103. public function getAmount(): ?float
  104. {
  105. return $this->amount;
  106. }
  107. public function setAmount(?float $amount): self
  108. {
  109. $this->amount = $amount;
  110. return $this;
  111. }
  112. public function getDateAdd(): ?\DateTimeInterface
  113. {
  114. return $this->dateAdd;
  115. }
  116. public function setDateAdd(?\DateTimeInterface $dateAdd): self
  117. {
  118. $this->dateAdd = $dateAdd;
  119. return $this;
  120. }
  121. public function getChild(): ?Child
  122. {
  123. return $this->child;
  124. }
  125. public function setChild(?Child $child): self
  126. {
  127. $this->child = $child;
  128. return $this;
  129. }
  130. public function getDateFor(): ?\DateTimeInterface
  131. {
  132. return $this->dateFor;
  133. }
  134. public function setDateFor(?\DateTimeInterface $dateFor): self
  135. {
  136. $this->dateFor = $dateFor;
  137. return $this;
  138. }
  139. public function getInfo(): ?string
  140. {
  141. return $this->info;
  142. }
  143. public function setInfo(?string $info): self
  144. {
  145. $this->info = $info;
  146. return $this;
  147. }
  148. public function getDuration(): ?int
  149. {
  150. return $this->duration;
  151. }
  152. public function setDuration(?int $duration): self
  153. {
  154. $this->duration = $duration;
  155. return $this;
  156. }
  157. public function getStartTime(): ?\DateTimeInterface
  158. {
  159. return $this->startTime;
  160. }
  161. public function setStartTime(?\DateTimeInterface $startTime): self
  162. {
  163. $this->startTime = $startTime;
  164. return $this;
  165. }
  166. public function getEndTime(): ?\DateTimeInterface
  167. {
  168. return $this->endTime;
  169. }
  170. public function setEndTime(?\DateTimeInterface $endTime): self
  171. {
  172. $this->endTime = $endTime;
  173. return $this;
  174. }
  175. public function getStatus(): ?string
  176. {
  177. $text = $this->status;
  178. foreach (Lesson::STATUSES as $STATUS)
  179. {
  180. if($STATUS['value'] == $this->status)
  181. {
  182. $text = $STATUS['text'];
  183. }
  184. }
  185. if(!$this->lesson && $this->amount > 0)
  186. {
  187. return 'Sumokėta už anuliuotą pamoką';
  188. }
  189. if(!$this->lesson && $this->amount < 0)
  190. {
  191. return 'Pamokos anuliavimas';
  192. }
  193. return $text;
  194. }
  195. public function setStatus(?string $status): self
  196. {
  197. foreach (Lesson::STATUSES as $STATUS)
  198. {
  199. if($STATUS['text'] == $status)
  200. {
  201. $status = $STATUS['value'];
  202. }
  203. }
  204. $this->status = $status;
  205. return $this;
  206. }
  207. public function getDisciplineFull(): ?string
  208. {
  209. $disciplines = ['MAT' => 'Matematika',
  210. 'LT' => 'Lietuvių k.',
  211. 'ANG' => 'Anglu k.',
  212. 'FIZ' => 'Fizika',
  213. 'CHE' => 'Chemija',
  214. 'BIO' => 'Biologija',
  215. 'IST' => 'Istorija',
  216. 'IT' => 'Informatika',
  217. 'VOK' => 'Vokiečių k.',
  218. 'FRA' => 'Prancūzų k.',
  219. 'RU' => 'Rusų k.',
  220. 'GEO' => 'Geografija',
  221. 'ISP' => 'Ispanų k.',
  222. ];
  223. if (isset($disciplines[$this->discipline])) {
  224. return $disciplines[$this->discipline];
  225. }
  226. return $this->discipline;
  227. }
  228. public function getDiscipline(): ?string
  229. {
  230. return $this->discipline;
  231. }
  232. public function setDiscipline(?string $discipline): self
  233. {
  234. $this->discipline = $discipline;
  235. return $this;
  236. }
  237. public function getStatusColor(): ?string
  238. {
  239. $color = "";
  240. foreach (Lesson::ALL_STATUSES as $STATUS)
  241. {
  242. if($STATUS['value'] == $this->status)
  243. {
  244. $color = $STATUS['color'];
  245. }
  246. }
  247. if(!$this->lesson)
  248. {
  249. return '#AAB7B8';
  250. }
  251. return $color;
  252. }
  253. public function getDiscountType(): ?string
  254. {
  255. return $this->discountType;
  256. }
  257. public function setDiscountType(?string $discountType): self
  258. {
  259. $this->discountType = $discountType;
  260. return $this;
  261. }
  262. public function getDiscountPercent(): ?float
  263. {
  264. return $this->discountPercent;
  265. }
  266. public function setDiscountPercent(?float $discountPercent): self
  267. {
  268. $this->discountPercent = $discountPercent;
  269. return $this;
  270. }
  271. public function getAmountWithoutDiscounts(): ?float
  272. {
  273. return $this->amountWithoutDiscounts;
  274. }
  275. public function setAmountWithoutDiscounts(?float $amountWithoutDiscounts): self
  276. {
  277. $this->amountWithoutDiscounts = $amountWithoutDiscounts;
  278. return $this;
  279. }
  280. }