src/Entity/Quotes.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\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Doctrine\Common\Collections\Criteria;
  8. #[ORM\Table(name: 'quotes')]
  9. #[ORM\Entity]
  10. class Quotes
  11. {
  12. #[ORM\Column(name: 'id', type: 'integer', nullable: false)]
  13. #[ORM\Id]
  14. #[ORM\GeneratedValue(strategy: 'IDENTITY')]
  15. private $id;
  16. #[ORM\Column(name: 'price_sum', type: 'integer', nullable: true)]
  17. private $priceSum;
  18. #[ORM\Column(name: 'price_sum_br', type: 'integer', nullable: true)]
  19. private $priceSumBr;
  20. #[ORM\Column(name: 'note', type: 'text', length: 65535, nullable: true)]
  21. private $note;
  22. #[ORM\Column(name: 'created', type: 'datetime', nullable: false)]
  23. private $created;
  24. #[ORM\Column(name: 'sent_date', type: 'datetime', nullable: true)]
  25. private $sentDate;
  26. #[ORM\Column(name: 'updated', type: 'datetime', nullable: true)]
  27. private $updated;
  28. #[ORM\Column(name: 'price_bodyguard', type: 'integer', nullable: true)]
  29. private $priceBodyguard;
  30. #[ORM\Column(name: 'price_paint', type: 'integer', nullable: true)]
  31. private $pricePaint;
  32. #[ORM\Column(name: 'price_assembly', type: 'integer', nullable: true)]
  33. private $priceAssembly;
  34. #[ORM\Column(name: 'tax', type: 'string', nullable: true)]
  35. private $tax;
  36. #[ORM\OneToMany(targetEntity: QuoteItems::class, mappedBy: 'quote', cascade: ['persist'], orphanRemoval: true)]
  37. public $quoteItems;
  38. #[ORM\OneToMany(targetEntity: Attachment::class, mappedBy: 'quote', cascade: ['persist'], orphanRemoval: true)]
  39. public $attachments;
  40. #[ORM\Column(name: 'modified', type: 'datetime', nullable: true, options: ['comment' => 'Módosítva'])]
  41. private $modified;
  42. #[ORM\Column(length: 255, nullable: true)]
  43. private ?string $CustomerName = null;
  44. #[ORM\Column(length: 255, nullable: true)]
  45. private ?string $CustomerMail = null;
  46. #[ORM\Column(length: 255, nullable: true)]
  47. private ?string $CustomerPhone = null;
  48. #[ORM\Column(length: 255, nullable: true)]
  49. private ?string $CustomerAddress = null;
  50. #[ORM\Column(length: 255, nullable: true)]
  51. private ?string $Title = null;
  52. #[ORM\Column(type: Types::TEXT, nullable: true)]
  53. private ?string $OriginalText = null;
  54. #[ORM\Column(type: Types::TEXT, nullable: true)]
  55. private ?string $ShortDesc = null;
  56. #[ORM\Column]
  57. private ?int $status = null;
  58. public static $statuses = [
  59. 0 => 'Új',
  60. 1 => 'Piszkozat',
  61. 2 => 'Kiküldve',
  62. 3 => 'Pontosítás szükséges',
  63. 4 => 'Visszahívás szükséges',
  64. 5 => 'Email érdeklődés szükséges',
  65. 6 => 'Elfogadva',
  66. 7 => 'Elutasítva',
  67. 8 => 'Lezárva',
  68. 9 => 'Archivált',
  69. ];
  70. public static $discoveries = [
  71. 0 => 'Telefonon',
  72. 1 => 'E-mailben',
  73. 2 => 'Személyesen',
  74. ];
  75. #[ORM\Column(type: Types::INTEGER, nullable: true)]
  76. private ?int $discovery = 1;
  77. #[ORM\Column(type: Types::TEXT, nullable: true)]
  78. private ?string $sentMail = null;
  79. #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'quotes')]
  80. private ?self $parent = null;
  81. #[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
  82. private Collection $quotes;
  83. public function __construct()
  84. {
  85. $this->created = new \DateTime();
  86. $this->quoteItems = new ArrayCollection();
  87. $this->attachments = new ArrayCollection();
  88. $this->status = 0;
  89. $this->quotes = new ArrayCollection();
  90. }
  91. public function getId(): ?int
  92. {
  93. return $this->id;
  94. }
  95. public function getTax(): ?string
  96. {
  97. return $this->tax;
  98. }
  99. public function setTax(?string $tax): self
  100. {
  101. $this->tax = $tax;
  102. return $this;
  103. }
  104. public function getPriceSum(): ?int
  105. {
  106. return $this->priceSum;
  107. }
  108. public function setPriceSum(?int $priceSum): self
  109. {
  110. $this->priceSum = $priceSum;
  111. return $this;
  112. }
  113. public function getPriceSumBr(): ?int
  114. {
  115. return $this->priceSumBr;
  116. }
  117. public function setPriceSumBr(?int $priceSumBr): self
  118. {
  119. $this->priceSumBr = $priceSumBr;
  120. return $this;
  121. }
  122. public function getNote(): ?string
  123. {
  124. return $this->note;
  125. }
  126. public function setNote(?string $note): self
  127. {
  128. $this->note = $note;
  129. return $this;
  130. }
  131. public function getCreated(): ?\DateTimeInterface
  132. {
  133. return $this->created;
  134. }
  135. public function setCreated(\DateTimeInterface $created): self
  136. {
  137. $this->created = $created;
  138. return $this;
  139. }
  140. /**
  141. * @return Collection|QuoteItems[]
  142. */
  143. public function getQuoteItems(): Collection
  144. {
  145. return $this->quoteItems;
  146. }
  147. /* public function addQuoteItem(QuoteItems $quoteItem): self
  148. {
  149. if (!$this->quoteItems->contains($quoteItem)) {
  150. $quoteItem->setQuote($this);
  151. $this->quoteItems[] = $quoteItem;
  152. }
  153. return $this;
  154. }
  155. public function removeQuoteItem(QuoteItems $quoteItem): self
  156. {
  157. if ($this->quoteItems->removeElement($quoteItem)) {
  158. // set the owning side to null (unless already changed)
  159. if ($quoteItem->getQuote() === $this) {
  160. $quoteItem->setQuote(null);
  161. }
  162. }
  163. return $this;
  164. }
  165. */
  166. /**
  167. * @return Collection|QuoteItems[]
  168. */
  169. public function getQuotePaintItems(): Collection
  170. {
  171. $criteria = Criteria::create();
  172. $criteria->where(Criteria::expr()->eq('type', QuoteItems::PAINT));
  173. return $this->quoteItems->matching($criteria);
  174. }
  175. public function addQuotePaintItem(QuoteItems $quoteItem): self
  176. {
  177. if (!$this->quoteItems->contains($quoteItem)) {
  178. $quoteItem->setType(QuoteItems::PAINT);
  179. if($this->getPricePaint() !== null){
  180. $quoteItem->setPriceQty($this->pricePaint);
  181. }
  182. $quoteItem->setQuote($this);
  183. $this->quoteItems[] = $quoteItem;
  184. }
  185. return $this;
  186. }
  187. public function removeQuotePaintItem(QuoteItems $quoteItem): self
  188. {
  189. if ($this->quoteItems->removeElement($quoteItem)) {
  190. // set the owning side to null (unless already changed)
  191. /*if ($quoteItem->getQuote() === $this) {
  192. $quoteItem->setQuote(null);
  193. }*/
  194. }
  195. return $this;
  196. }
  197. /**
  198. * @return Collection|QuoteItems[]
  199. */
  200. public function getQuoteAssemblyItems(): Collection
  201. {
  202. $criteria = Criteria::create();
  203. $criteria->where(Criteria::expr()->eq('type', QuoteItems::ASSEMBLY));
  204. return $this->quoteItems->matching($criteria);
  205. }
  206. public function addQuoteAssemblyItem(QuoteItems $quoteItem): self
  207. {
  208. if (!$this->quoteItems->contains($quoteItem)) {
  209. $quoteItem->setType(QuoteItems::ASSEMBLY);
  210. if($this->getPriceAssembly() !== null){
  211. $quoteItem->setPriceQty($this->priceAssembly);
  212. }
  213. $quoteItem->setQuote($this);
  214. $this->quoteItems[] = $quoteItem;
  215. }
  216. return $this;
  217. }
  218. public function removeQuoteAssemblyItem(QuoteItems $quoteItem): self
  219. {
  220. if ($this->quoteItems->removeElement($quoteItem)) {
  221. // set the owning side to null (unless already changed)
  222. if ($quoteItem->getQuote() === $this) {
  223. $quoteItem->setQuote(null);
  224. }
  225. }
  226. return $this;
  227. }
  228. /**
  229. * @return Collection|QuoteItems[]
  230. */
  231. public function getQuoteBodyguardItems(): Collection
  232. {
  233. $criteria = Criteria::create();
  234. $criteria->where(Criteria::expr()->eq('type', QuoteItems::BODYGUARD));
  235. return $this->quoteItems->matching($criteria);
  236. }
  237. public function addQuoteBodyguardItem(QuoteItems $quoteItem): self
  238. {
  239. if (!$this->quoteItems->contains($quoteItem)) {
  240. $quoteItem->setType(QuoteItems::BODYGUARD);
  241. if($this->getPriceBodyguard() !== null){
  242. $quoteItem->setPriceQty($this->priceBodyguard);
  243. }
  244. $quoteItem->setQuote($this);
  245. $this->quoteItems[] = $quoteItem;
  246. }
  247. return $this;
  248. }
  249. public function removeQuoteBodyguardItem(QuoteItems $quoteItem): self
  250. {
  251. if ($this->quoteItems->removeElement($quoteItem)) {
  252. // set the owning side to null (unless already changed)
  253. if ($quoteItem->getQuote() === $this) {
  254. $quoteItem->setQuote(null);
  255. }
  256. }
  257. return $this;
  258. }
  259. /**
  260. * @return Collection|QuoteItems[]
  261. */
  262. public function getQuoteOtherItems(): Collection
  263. {
  264. $criteria = Criteria::create();
  265. $criteria->where(Criteria::expr()->eq('type', QuoteItems::OTHER));
  266. return $this->quoteItems->matching($criteria);
  267. }
  268. public function addQuoteOtherItem(QuoteItems $quoteItem): self
  269. {
  270. if (!$this->quoteItems->contains($quoteItem)) {
  271. $quoteItem->setType(QuoteItems::OTHER);
  272. $quoteItem->setQuote($this);
  273. $this->quoteItems[] = $quoteItem;
  274. }
  275. return $this;
  276. }
  277. public function removeQuoteOtherItem(QuoteItems $quoteItem): self
  278. {
  279. if ($this->quoteItems->removeElement($quoteItem)) {
  280. // set the owning side to null (unless already changed)
  281. if ($quoteItem->getQuote() === $this) {
  282. $quoteItem->setQuote(null);
  283. }
  284. }
  285. return $this;
  286. }
  287. /**
  288. * @return Collection|Attachment[]
  289. */
  290. public function getAttachments(): Collection
  291. {
  292. return $this->attachments;
  293. }
  294. public function addAttachment(Attachment $photo): self
  295. {
  296. if (!$this->attachments->contains($photo)) {
  297. $photo->setQuote($this);
  298. $this->attachments[] = $photo;
  299. }
  300. return $this;
  301. }
  302. public function removeAttachment(Attachment $photo): self
  303. {
  304. if ($this->attachments->removeElement($photo)) {
  305. // set the owning side to null (unless already changed)
  306. if ($photo->getQuote() === $this) {
  307. $photo->setQuote(null);
  308. }
  309. }
  310. return $this;
  311. }
  312. public function getPriceBodyguard(): ?int
  313. {
  314. return $this->priceBodyguard;
  315. }
  316. public function setPriceBodyguard(?int $priceBodyguard): self
  317. {
  318. $this->priceBodyguard = $priceBodyguard;
  319. return $this;
  320. }
  321. public function getPricePaint(): ?int
  322. {
  323. return $this->pricePaint;
  324. }
  325. public function setPricePaint(?int $pricePaint): self
  326. {
  327. $this->pricePaint = $pricePaint;
  328. return $this;
  329. }
  330. public function getPriceAssembly(): ?int
  331. {
  332. return $this->priceAssembly;
  333. }
  334. public function setPriceAssembly(?int $priceAssembly): self
  335. {
  336. $this->priceAssembly = $priceAssembly;
  337. return $this;
  338. }
  339. public function __toString()
  340. {
  341. return 'Ajánlat - '. $this->getCustomerName() . " - " . $this->getTitle();
  342. }
  343. public function rowCss(){
  344. return "";
  345. }
  346. public function getModified(): ?\DateTimeInterface
  347. {
  348. return $this->modified;
  349. }
  350. public function setModified(?\DateTimeInterface $modified): self
  351. {
  352. $this->modified = $modified;
  353. return $this;
  354. }
  355. public function getSentDate(): ?\DateTimeInterface
  356. {
  357. return $this->sentDate;
  358. }
  359. public function setSentDate(?\DateTimeInterface $sentDate): self
  360. {
  361. $this->sentDate = $sentDate;
  362. return $this;
  363. }
  364. public function getUpdated(): ?\DateTimeInterface
  365. {
  366. return $this->updated;
  367. }
  368. public function setUpdated(?\DateTimeInterface $updated): self
  369. {
  370. $this->updated = $updated;
  371. return $this;
  372. }
  373. public function getCustomerName(): ?string
  374. {
  375. return $this->CustomerName;
  376. }
  377. public function setCustomerName(?string $CustomerName): static
  378. {
  379. $this->CustomerName = $CustomerName;
  380. return $this;
  381. }
  382. public function getCustomerMail(): ?string
  383. {
  384. return $this->CustomerMail;
  385. }
  386. public function setCustomerMail(string $CustomerMail): static
  387. {
  388. $this->CustomerMail = $CustomerMail;
  389. return $this;
  390. }
  391. public function getCustomerPhone(): ?string
  392. {
  393. return $this->CustomerPhone;
  394. }
  395. public function setCustomerPhone(?string $CustomerPhone): static
  396. {
  397. $this->CustomerPhone = $CustomerPhone;
  398. return $this;
  399. }
  400. public function getCustomerAddress(): ?string
  401. {
  402. return $this->CustomerAddress;
  403. }
  404. public function setCustomerAddress(?string $CustomerAddress): static
  405. {
  406. $this->CustomerAddress = $CustomerAddress;
  407. return $this;
  408. }
  409. public function getTitle(): ?string
  410. {
  411. return $this->Title;
  412. }
  413. public function setTitle(string $Title): static
  414. {
  415. $this->Title = $Title;
  416. return $this;
  417. }
  418. public function getOriginalText(): ?string
  419. {
  420. if ($this->OriginalText === null || $this->OriginalText === '') {
  421. return $this->OriginalText;
  422. }
  423. $lines = preg_split('/\R/', $this->OriginalText);
  424. $lines = array_values(array_filter(array_map('trim', $lines), static fn ($line): bool => $line !== ''));
  425. return implode("\n", $lines);
  426. }
  427. public function setOriginalText(?string $OriginalText): static
  428. {
  429. $this->OriginalText = $OriginalText;
  430. return $this;
  431. }
  432. public function getShortDesc(): ?string
  433. {
  434. return $this->ShortDesc;
  435. }
  436. public function setShortDesc(?string $ShortDesc): static
  437. {
  438. $this->ShortDesc = $ShortDesc;
  439. return $this;
  440. }
  441. public function getStatus(): ?int
  442. {
  443. return $this->status;
  444. }
  445. public function setStatus(int $status): static
  446. {
  447. $this->status = $status;
  448. return $this;
  449. }
  450. public function getStatusName(): ?string
  451. {
  452. return self::$statuses[$this->status];
  453. }
  454. public function getDiscovery(): ?int
  455. {
  456. return $this->discovery;
  457. }
  458. public function setDiscovery(?int $discovery): static
  459. {
  460. $this->discovery = $discovery;
  461. return $this;
  462. }
  463. public function getSentMail(): ?string
  464. {
  465. return $this->sentMail;
  466. }
  467. public function getSentMailHtml(): ?string
  468. {
  469. return nl2br($this->sentMail);
  470. }
  471. public function setSentMail(?string $sentMail): static
  472. {
  473. $this->sentMail = $sentMail;
  474. return $this;
  475. }
  476. public function getParent(): ?self
  477. {
  478. return $this->parent;
  479. }
  480. public function setParent(?self $parent): static
  481. {
  482. $this->parent = $parent;
  483. return $this;
  484. }
  485. /**
  486. * @return Collection<int, self>
  487. */
  488. public function getQuotes(): Collection
  489. {
  490. return $this->quotes;
  491. }
  492. public function addQuote(self $quote): static
  493. {
  494. if (!$this->quotes->contains($quote)) {
  495. $this->quotes->add($quote);
  496. $quote->setParent($this);
  497. }
  498. return $this;
  499. }
  500. public function removeQuote(self $quote): static
  501. {
  502. if ($this->quotes->removeElement($quote)) {
  503. // set the owning side to null (unless already changed)
  504. if ($quote->getParent() === $this) {
  505. $quote->setParent(null);
  506. }
  507. }
  508. return $this;
  509. }
  510. }