src/Entity/ClickAndCollect.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ClickAndCollectRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8. * @ORM\Entity(repositoryClass=ClickAndCollectRepository::class)
  9. * @ORM\EntityListeners({
  10. * "App\Listener\EntityListener",
  11. * "App\Listener\ClickAndCollectListener"
  12. * })
  13. */
  14. class ClickAndCollect
  15. {
  16. /**
  17. * @ORM\Id()
  18. * @ORM\GeneratedValue()
  19. * @ORM\Column(type="integer")
  20. */
  21. private $id;
  22. /**
  23. * @ORM\Column(type="integer")
  24. */
  25. private $number;
  26. /**
  27. * @ORM\Column(type="string", length=3)
  28. */
  29. private $currency;
  30. /**
  31. * @ORM\Column(type="string", length=2)
  32. */
  33. private $locale;
  34. /**
  35. * @ORM\Column(type="float")
  36. */
  37. private $priceSum;
  38. /**
  39. * @ORM\Column(type="float")
  40. */
  41. private $priceSumNoTax;
  42. /**
  43. * @ORM\Column(type="text", nullable=true)
  44. */
  45. private $note;
  46. /**
  47. * @ORM\Column(type="string", length=100, nullable=true)
  48. */
  49. private $clientFirstName;
  50. /**
  51. * @ORM\Column(type="string", length=100, nullable=true)
  52. */
  53. private $clientLastName;
  54. /**
  55. * @ORM\Column(type="string", length=190, nullable=true)
  56. */
  57. private $clientEmail;
  58. /**
  59. * @ORM\Column(type="string", length=50, nullable=true)
  60. */
  61. private $clientPhone;
  62. /**
  63. * @ORM\Column(type="integer")
  64. */
  65. private $status = 0;
  66. /**
  67. * @ORM\Column(type="datetime", nullable=true)
  68. */
  69. private $notifyts;
  70. /**
  71. * @ORM\Column(type="datetime")
  72. */
  73. private $createts;
  74. /**
  75. * @ORM\Column(type="datetime", nullable=true)
  76. */
  77. private $editts;
  78. /**
  79. * @ORM\ManyToOne(targetEntity="App\Entity\User")
  80. */
  81. private $editUser;
  82. /**
  83. * @ORM\OneToMany(targetEntity=ClickAndCollectItem::class, mappedBy="collect",cascade={"persist"})
  84. */
  85. private $items;
  86. /**
  87. * @ORM\Column(type="boolean")
  88. */
  89. private $canSend = false;
  90. /**
  91. * @ORM\Column(type="boolean")
  92. */
  93. private $sendedEmail = false;
  94. /**
  95. * @ORM\Column(type="datetime", nullable=true)
  96. */
  97. private $sendedEmailts;
  98. /**
  99. * @ORM\Column(type="datetime", nullable=true)
  100. */
  101. private $reservedTo;
  102. /**
  103. * @ORM\Column(type="datetime", nullable=true)
  104. */
  105. private $stornots;
  106. /**
  107. * @ORM\Column(type="boolean")
  108. */
  109. private $extended = false;
  110. public function __construct()
  111. {
  112. $this->items = new ArrayCollection();
  113. }
  114. public function getId(): ?int
  115. {
  116. return $this->id;
  117. }
  118. public function getNumber(): ?int
  119. {
  120. return $this->number;
  121. }
  122. public function setNumber(int $number): self
  123. {
  124. $this->number = $number;
  125. return $this;
  126. }
  127. public function getCurrency(): ?string
  128. {
  129. return $this->currency;
  130. }
  131. public function setCurrency(string $currency): self
  132. {
  133. $this->currency = $currency;
  134. return $this;
  135. }
  136. public function getPriceSum(): ?float
  137. {
  138. return $this->priceSum;
  139. }
  140. public function setPriceSum(float $priceSum): self
  141. {
  142. $this->priceSum = $priceSum;
  143. return $this;
  144. }
  145. public function getPriceSumNoTax(): ?float
  146. {
  147. return $this->priceSumNoTax;
  148. }
  149. public function setPriceSumNoTax(float $priceSumNoTax): self
  150. {
  151. $this->priceSumNoTax = $priceSumNoTax;
  152. return $this;
  153. }
  154. public function getNote(): ?string
  155. {
  156. return $this->note;
  157. }
  158. public function setNote(?string $note): self
  159. {
  160. $this->note = $note;
  161. return $this;
  162. }
  163. public function getClientFirstName(): ?string
  164. {
  165. return $this->clientFirstName;
  166. }
  167. public function setClientFirstName(?string $clientFirstName): self
  168. {
  169. $this->clientFirstName = $clientFirstName;
  170. return $this;
  171. }
  172. public function getClientLastName(): ?string
  173. {
  174. return $this->clientLastName;
  175. }
  176. public function setClientLastName(?string $clientLastName): self
  177. {
  178. $this->clientLastName = $clientLastName;
  179. return $this;
  180. }
  181. public function getClientEmail(): ?string
  182. {
  183. return $this->clientEmail;
  184. }
  185. public function setClientEmail(?string $clientEmail): self
  186. {
  187. $this->clientEmail = $clientEmail;
  188. return $this;
  189. }
  190. public function getClientPhone(): ?string
  191. {
  192. return $this->clientPhone;
  193. }
  194. public function setClientPhone(?string $clientPhone): self
  195. {
  196. $this->clientPhone = $clientPhone;
  197. return $this;
  198. }
  199. public function getStatus(): ?int
  200. {
  201. return $this->status;
  202. }
  203. public function setStatus(int $status): self
  204. {
  205. $this->status = $status;
  206. return $this;
  207. }
  208. public function getNotifyts(): ?\DateTimeInterface
  209. {
  210. return $this->notifyts;
  211. }
  212. public function setNotifyts(?\DateTimeInterface $notifyts): self
  213. {
  214. $this->notifyts = $notifyts;
  215. return $this;
  216. }
  217. public function getCreatets(): ?\DateTimeInterface
  218. {
  219. return $this->createts;
  220. }
  221. public function setCreatets(\DateTimeInterface $createts): self
  222. {
  223. $this->createts = $createts;
  224. return $this;
  225. }
  226. public function getEditts(): ?\DateTimeInterface
  227. {
  228. return $this->editts;
  229. }
  230. public function setEditts(?\DateTimeInterface $editts): self
  231. {
  232. $this->editts = $editts;
  233. return $this;
  234. }
  235. public function getEditUser(): ?User
  236. {
  237. return $this->editUser;
  238. }
  239. public function setEditUser(?User $editUser): self
  240. {
  241. $this->editUser = $editUser;
  242. return $this;
  243. }
  244. public function getHash( )
  245. {
  246. return base64_encode(sprintf('%s|%s|%s',$this->getClientEmail(),$this->getNumber(),$this->getId()));
  247. }
  248. /**
  249. * @return Collection|ClickAndCollectItem[]
  250. */
  251. public function getItems(): Collection
  252. {
  253. return $this->items;
  254. }
  255. public function addItem(ClickAndCollectItem $item): self
  256. {
  257. if (!$this->items->contains($item)) {
  258. $this->items[] = $item;
  259. $item->setCollect($this);
  260. }
  261. return $this;
  262. }
  263. public function removeItem(ClickAndCollectItem $item): self
  264. {
  265. if ($this->items->contains($item)) {
  266. $this->items->removeElement($item);
  267. // set the owning side to null (unless already changed)
  268. if ($item->getCollect() === $this) {
  269. $item->setCollect(null);
  270. }
  271. }
  272. return $this;
  273. }
  274. public function initClient(?Client $client): self
  275. {
  276. if($client instanceof Client) {
  277. $this->setClient( $client );
  278. $this->setClientFirstName( $client->getFirstName() );
  279. $this->setClientLastName( $client->getLastName() );
  280. $this->setClientEmail( $client->getEmail() );
  281. $this->setClientPhone( $client->getPhone() );
  282. //$this->setClientPhone( $client->get );
  283. /*if($client->getBillingAddress() instanceof ClientAddress){
  284. $billing = $client->getBillingAddress();
  285. }else{
  286. $billing = $client->getClientAddresses()->first();
  287. }
  288. $billingAddress = new OrderAddress();
  289. $billingAddress->init( $billing );
  290. $this->setBillingAddress($billingAddress);
  291. if($client->getDeliveryAddress() instanceof ClientAddress){
  292. $delivery = $client->getDeliveryAddress();
  293. }else{
  294. $delivery = $billing;
  295. }
  296. $deliveryAddress = new OrderAddress();
  297. $deliveryAddress->init( $delivery );
  298. $this->setDeliveryAddress($deliveryAddress);*/
  299. }
  300. return $this;
  301. }
  302. public function initCart( Cart $cart )
  303. {
  304. $this->setClient($cart->getClient());
  305. $this->setClientPhone($cart->getPhone());
  306. $this->setClientEmail($cart->getEmail());
  307. $this->setClientLastName($cart->getLastName());
  308. $this->setClientFirstName($cart->getFirstName());
  309. $this->setNote($cart->getNote());
  310. $this->setLocale(\Locale::getDefault());
  311. foreach ($cart->getCartItems() as $cartItem){
  312. $item = new ClickAndCollectItem();
  313. $item->setCount($cartItem->getCount());
  314. $item->setProduct($cartItem->getProduct());
  315. $item->setVariant($cartItem->getVariant());
  316. $item->setName(sprintf('%s - %s',$cartItem->getProduct()->getName(),$cartItem->getVariant()->getName()));
  317. $item->setDealer($cartItem->getProduct()->getDealer());
  318. $item->setCourse($cartItem->getProduct()->getDealer()->getCourse());
  319. $pricelist = $cartItem->getProduct()->getPrice();
  320. $item->setPrice($pricelist->getPrice());
  321. $item->setTax($pricelist->getTax());
  322. $item->setCurrency($pricelist->getCurrency());
  323. $this->setCurrency($pricelist->getCurrency());
  324. $this->addItem($item);
  325. }
  326. return $this;
  327. }
  328. /**
  329. * Get CanSend
  330. *
  331. * @return mixed
  332. */
  333. public function getCanSend()
  334. {
  335. return $this->canSend;
  336. }
  337. /**
  338. * Set CanSend
  339. *
  340. * @param mixed $canSend
  341. */
  342. public function setCanSend( $canSend )
  343. {
  344. $this->canSend = $canSend;
  345. }
  346. /**
  347. * Get SendedEmail
  348. *
  349. * @return mixed
  350. */
  351. public function getSendedEmail()
  352. {
  353. return $this->sendedEmail;
  354. }
  355. /**
  356. * Set SendedEmail
  357. *
  358. * @param mixed $sendedEmail
  359. */
  360. public function setSendedEmail( $sendedEmail )
  361. {
  362. $this->sendedEmail = $sendedEmail;
  363. }
  364. /**
  365. * Get SendedEmailts
  366. *
  367. * @return mixed
  368. */
  369. public function getSendedEmailts()
  370. {
  371. return $this->sendedEmailts;
  372. }
  373. /**
  374. * Set SendedEmailts
  375. *
  376. * @param mixed $sendedEmailts
  377. */
  378. public function setSendedEmailts( $sendedEmailts )
  379. {
  380. $this->sendedEmailts = $sendedEmailts;
  381. }
  382. /**
  383. * Get ReservedTo
  384. *
  385. * @return mixed
  386. */
  387. public function getReservedTo()
  388. {
  389. return $this->reservedTo;
  390. }
  391. /**
  392. * Set ReservedTo
  393. *
  394. * @param mixed $reservedTo
  395. */
  396. public function setReservedTo( $reservedTo )
  397. {
  398. $this->reservedTo = $reservedTo;
  399. }
  400. /**
  401. * Get Extended
  402. *
  403. * @return mixed
  404. */
  405. public function getExtended()
  406. {
  407. return $this->extended;
  408. }
  409. /**
  410. * Set Extended
  411. *
  412. * @param mixed $extended
  413. */
  414. public function setExtended( $extended )
  415. {
  416. $this->extended = $extended;
  417. }
  418. /**
  419. * Get Stornots
  420. *
  421. * @return mixed
  422. */
  423. public function getStornots()
  424. {
  425. return $this->stornots;
  426. }
  427. /**
  428. * Set Stornots
  429. *
  430. * @param mixed $stornots
  431. */
  432. public function setStornots( $stornots )
  433. {
  434. $this->stornots = $stornots;
  435. }
  436. /**
  437. * Get Locale
  438. *
  439. * @return mixed
  440. */
  441. public function getLocale()
  442. {
  443. return $this->locale;
  444. }
  445. /**
  446. * Set Locale
  447. *
  448. * @param mixed $locale
  449. */
  450. public function setLocale( $locale )
  451. {
  452. $this->locale = $locale;
  453. }
  454. }