Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

439 lines
13KB

  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use App\Entity\Visitor;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Lc\ShopBundle\Context\FilterMerchantInterface;
  8. /**
  9. * @ORM\MappedSuperclass()
  10. */
  11. abstract class OrderShop extends AbstractEntity implements FilterMerchantInterface
  12. {
  13. /**
  14. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="productFamilies")
  15. * @ORM\JoinColumn(nullable=false)
  16. */
  17. protected $merchant;
  18. /**
  19. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="orders")
  20. */
  21. protected $user;
  22. /**
  23. * @ORM\ManyToOne(targetEntity="App\Entity\Visitor", inversedBy="orders")
  24. */
  25. protected $visitor;
  26. /**
  27. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface", inversedBy="order")
  28. */
  29. protected $invoiceAddress;
  30. /**
  31. * @ORM\Column(type="text", nullable=true)
  32. */
  33. protected $comment;
  34. /**
  35. * @ORM\Column(type="boolean", nullable=true)
  36. */
  37. protected $autoPayment;
  38. /**
  39. * @ORM\Column(type="string", length=31, nullable=true)
  40. */
  41. protected $meanPayment;
  42. /**
  43. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderStatusHistoryInterface", mappedBy="orderShop", orphanRemoval=true)
  44. */
  45. protected $orderStatusHistories;
  46. /**
  47. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderProductInterface", mappedBy="orderShop", cascade={"persist", "remove"}, orphanRemoval=true)
  48. */
  49. protected $orderProducts;
  50. /**
  51. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\CreditHistoryInterface", mappedBy="orderShop", orphanRemoval=true)
  52. */
  53. protected $creditHistories;
  54. /**
  55. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\DocumentInvoiceInterface", inversedBy="orderShops")
  56. */
  57. protected $documentInvoice;
  58. /**
  59. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\DocumentQuotationInterface", inversedBy="orderShops")
  60. */
  61. protected $documentQuotation;
  62. /**
  63. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\DocumentDeliveryNoteInterface", inversedBy="orderShops")
  64. */
  65. protected $documentDeliveryNote;
  66. /**
  67. * @ORM\Column(type="text", nullable=true)
  68. */
  69. protected $deliveryInfos;
  70. /**
  71. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderStatusInterface")
  72. * @ORM\JoinColumn(nullable=false)
  73. */
  74. protected $orderStatus;
  75. /**
  76. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderReductionCartInterface", mappedBy="orderShop", orphanRemoval=true)
  77. */
  78. protected $orderReductionCarts;
  79. /**
  80. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderReductionCreditInterface", mappedBy="orderShop", orphanRemoval=true)
  81. */
  82. protected $orderReductionCredits;
  83. public function __construct()
  84. {
  85. $this->orderStatusHistories = new ArrayCollection();
  86. $this->orderProducts = new ArrayCollection();
  87. $this->creditHistories = new ArrayCollection();
  88. $this->orderReductionCarts = new ArrayCollection();
  89. $this->orderReductionCredits = new ArrayCollection();
  90. }
  91. public function getDateCreated()
  92. {
  93. $orderStatusHistory = $this->getOrderStatusHistory('new');
  94. if ($orderStatusHistory) {
  95. return $orderStatusHistory->getCreatedAt();
  96. }
  97. return null;
  98. }
  99. public function getOrderStatusHistory($status)
  100. {
  101. $orderStatusHistories = $this->getOrderStatusHistories();
  102. if (count($orderStatusHistories) > 0) {
  103. foreach ($orderStatusHistories as $orderStatusHistory) {
  104. if ($orderStatusHistory->getOrderStatus() == $status) {
  105. return $orderStatusHistory;
  106. }
  107. }
  108. }
  109. return null;
  110. }
  111. public function getMerchant(): ?Merchant
  112. {
  113. return $this->merchant;
  114. }
  115. public function setMerchant(?Merchant $merchant): self
  116. {
  117. $this->merchant = $merchant;
  118. return $this;
  119. }
  120. public function getUser(): ?User
  121. {
  122. return $this->user;
  123. }
  124. public function setUser(?User $user): self
  125. {
  126. $this->user = $user;
  127. return $this;
  128. }
  129. public function getInvoiceAddress(): ?Address
  130. {
  131. return $this->invoiceAddress;
  132. }
  133. public function setInvoiceAddress(?Address $invoiceAddress): self
  134. {
  135. $this->invoiceAddress = $invoiceAddress;
  136. return $this;
  137. }
  138. public function getComment(): ?string
  139. {
  140. return $this->comment;
  141. }
  142. public function setComment(?string $comment): self
  143. {
  144. $this->comment = $comment;
  145. return $this;
  146. }
  147. public function getAutoPayment(): ?bool
  148. {
  149. return $this->autoPayment;
  150. }
  151. public function setAutoPayment(bool $autoPayment): self
  152. {
  153. $this->autoPayment = $autoPayment;
  154. return $this;
  155. }
  156. public function getMeanPayment(): ?string
  157. {
  158. return $this->meanPayment;
  159. }
  160. public function setMeanPayment(string $meanPayment): self
  161. {
  162. $this->meanPayment = $meanPayment;
  163. return $this;
  164. }
  165. /**
  166. * @return Collection|OrderStatusHistory[]
  167. */
  168. public function getOrderStatusHistories(): Collection
  169. {
  170. return $this->orderStatusHistories;
  171. }
  172. public function addOrderStatusHistory(OrderStatusHistory $orderStatusHistory): self
  173. {
  174. if (!$this->orderStatusHistories->contains($orderStatusHistory)) {
  175. $this->orderStatusHistories[] = $orderStatusHistory;
  176. $orderStatusHistory->setOrderShop($this);
  177. }
  178. return $this;
  179. }
  180. public function removeOrderStatusHistory(OrderStatusHistory $orderStatusHistory): self
  181. {
  182. if ($this->orderStatusHistories->contains($orderStatusHistory)) {
  183. $this->orderStatusHistories->removeElement($orderStatusHistory);
  184. // set the owning side to null (unless already changed)
  185. if ($orderStatusHistory->getOrderShop() === $this) {
  186. $orderStatusHistory->setOrderShop(null);
  187. }
  188. }
  189. return $this;
  190. }
  191. /**
  192. * @return Collection|OrderProduct[]
  193. */
  194. public function getOrderProducts(): Collection
  195. {
  196. return $this->orderProducts;
  197. }
  198. public function addOrderProduct(OrderProduct $orderProduct): self
  199. {
  200. if (!$this->orderProducts->contains($orderProduct)) {
  201. $this->orderProducts[] = $orderProduct;
  202. $orderProduct->setOrderShop($this);
  203. }
  204. return $this;
  205. }
  206. public function removeOrderProduct(OrderProduct $orderProduct): self
  207. {
  208. if ($this->orderProducts->contains($orderProduct)) {
  209. $this->orderProducts->removeElement($orderProduct);
  210. // set the owning side to null (unless already changed)
  211. if ($orderProduct->getOrderShop() === $this) {
  212. $orderProduct->setOrderShop(null);
  213. }
  214. }
  215. return $this;
  216. }
  217. /**
  218. * @return Collection|CreditHistory[]
  219. */
  220. public function getCreditHistories(): Collection
  221. {
  222. return $this->creditHistories;
  223. }
  224. public function addCreditHistory(CreditHistory $creditHistory): self
  225. {
  226. if (!$this->creditHistories->contains($creditHistory)) {
  227. $this->creditHistories[] = $creditHistory;
  228. $creditHistory->setOrderShop($this);
  229. }
  230. return $this;
  231. }
  232. public function removeCreditHistory(CreditHistory $creditHistory): self
  233. {
  234. if ($this->creditHistories->contains($creditHistory)) {
  235. $this->creditHistories->removeElement($creditHistory);
  236. // set the owning side to null (unless already changed)
  237. if ($creditHistory->getOrderShop() === $this) {
  238. $creditHistory->setOrderShop(null);
  239. }
  240. }
  241. return $this;
  242. }
  243. public function getDocumentInvoice(): ?DocumentInvoice
  244. {
  245. return $this->documentInvoice;
  246. }
  247. public function setDocumentInvoice(?DocumentInvoice $documentInvoice): self
  248. {
  249. $this->documentInvoice = $documentInvoice;
  250. return $this;
  251. }
  252. public function getDocumentQuotation(): ?DocumentQuotation
  253. {
  254. return $this->documentQuotation;
  255. }
  256. public function setDocumentQuotation(?DocumentQuotation $documentQuotation): self
  257. {
  258. $this->documentQuotation = $documentQuotation;
  259. return $this;
  260. }
  261. public function getDocumentDeliveryNote(): ?DocumentDeliveryNote
  262. {
  263. return $this->documentDeliveryNote;
  264. }
  265. public function setDocumentDeliveryNote(?DocumentDeliveryNote $documentDeliveryNote): self
  266. {
  267. $this->documentDeliveryNote = $documentDeliveryNote;
  268. return $this;
  269. }
  270. public function getVisitor(): ?Visitor
  271. {
  272. return $this->visitor;
  273. }
  274. public function setVisitor(?Visitor $visitor): self
  275. {
  276. $this->visitor = $visitor;
  277. return $this;
  278. }
  279. public function getDeliveryInfos(): ?string
  280. {
  281. return $this->deliveryInfos;
  282. }
  283. public function setDeliveryInfos(?string $deliveryInfos): self
  284. {
  285. $this->deliveryInfos = $deliveryInfos;
  286. return $this;
  287. }
  288. public function getOrderStatus(): ?OrderStatus
  289. {
  290. return $this->orderStatus;
  291. }
  292. public function setOrderStatusProtected(?OrderStatus $orderStatus): self
  293. {
  294. $this->orderStatus = $orderStatus;
  295. return $this;
  296. }
  297. /**
  298. * @return Collection|OrderReductionCart[]
  299. */
  300. public function getOrderReductionCarts(): Collection
  301. {
  302. return $this->orderReductionCarts;
  303. }
  304. public function addOrderReductionCart(OrderReductionCart $orderReductionCart): self
  305. {
  306. if (!$this->orderReductionCarts->contains($orderReductionCart)) {
  307. $this->orderReductionCarts[] = $orderReductionCart;
  308. $orderReductionCart->setOrderShop($this);
  309. }
  310. return $this;
  311. }
  312. public function removeOrderReductionCart(OrderReductionCart $orderReductionCart): self
  313. {
  314. if ($this->orderReductionCarts->contains($orderReductionCart)) {
  315. $this->orderReductionCarts->removeElement($orderReductionCart);
  316. // set the owning side to null (unless already changed)
  317. if ($orderReductionCart->getOrderShop() === $this) {
  318. $orderReductionCart->setOrderShop(null);
  319. }
  320. }
  321. return $this;
  322. }
  323. /**
  324. * @return Collection|OrderReductionCart[]
  325. */
  326. public function getOrderReductionCredits(): Collection
  327. {
  328. return $this->orderReductionCredits;
  329. }
  330. public function addOrderReductionCredit(OrderReductionCredit $orderReductionCredit): self
  331. {
  332. if (!$this->orderReductionCredits->contains($orderReductionCredit)) {
  333. $this->orderReductionCredits[] = $orderReductionCredit;
  334. $orderReductionCredit->setOrderShop($this);
  335. }
  336. return $this;
  337. }
  338. public function removeOrderReductionCredit(OrderReductionCredit $orderReductionCredit): self
  339. {
  340. if ($this->orderReductionCredits->contains($orderReductionCredit)) {
  341. $this->orderReductionCredits->removeElement($orderReductionCredit);
  342. // set the owning side to null (unless already changed)
  343. if ($orderReductionCredit->getOrderShop() === $this) {
  344. $orderReductionCredit->setOrderShop(null);
  345. }
  346. }
  347. return $this;
  348. }
  349. }