You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

344 lines
10KB

  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. public function __construct()
  71. {
  72. $this->orderStatusHistories = new ArrayCollection();
  73. $this->orderProducts = new ArrayCollection();
  74. $this->creditHistories = new ArrayCollection();
  75. }
  76. public function getDateCreated()
  77. {
  78. $orderStatusHistory = $this->getOrderStatusHistory('new') ;
  79. if($orderStatusHistory) {
  80. return $orderStatusHistory->getCreatedAt() ;
  81. }
  82. return null ;
  83. }
  84. public function getOrderStatusHistory($status)
  85. {
  86. $orderStatusHistories = $this->getOrderStatusHistories() ;
  87. if(count($orderStatusHistories) > 0) {
  88. foreach($orderStatusHistories as $orderStatusHistory) {
  89. if($orderStatusHistory->getOrderStatus() == $status) {
  90. return $orderStatusHistory ;
  91. }
  92. }
  93. }
  94. return null ;
  95. }
  96. public function getMerchant(): ?Merchant
  97. {
  98. return $this->merchant;
  99. }
  100. public function setMerchant(?Merchant $merchant): self
  101. {
  102. $this->merchant = $merchant;
  103. return $this;
  104. }
  105. public function getUser(): ?User
  106. {
  107. return $this->user;
  108. }
  109. public function setUser(?User $user): self
  110. {
  111. $this->user = $user;
  112. return $this;
  113. }
  114. public function getInvoiceAddress(): ?Address
  115. {
  116. return $this->invoiceAddress;
  117. }
  118. public function setInvoiceAddress(?Address $invoiceAddress): self
  119. {
  120. $this->invoiceAddress = $invoiceAddress;
  121. return $this;
  122. }
  123. public function getComment(): ?string
  124. {
  125. return $this->comment;
  126. }
  127. public function setComment(?string $comment): self
  128. {
  129. $this->comment = $comment;
  130. return $this;
  131. }
  132. public function getAutoPayment(): ?bool
  133. {
  134. return $this->autoPayment;
  135. }
  136. public function setAutoPayment(bool $autoPayment): self
  137. {
  138. $this->autoPayment = $autoPayment;
  139. return $this;
  140. }
  141. public function getMeanPayment(): ?string
  142. {
  143. return $this->meanPayment;
  144. }
  145. public function setMeanPayment(string $meanPayment): self
  146. {
  147. $this->meanPayment = $meanPayment;
  148. return $this;
  149. }
  150. /**
  151. * @return Collection|OrderStatusHistory[]
  152. */
  153. public function getOrderStatusHistories(): Collection
  154. {
  155. return $this->orderStatusHistories;
  156. }
  157. public function addOrderStatusHistory(OrderStatusHistory $orderStatusHistory): self
  158. {
  159. if (!$this->orderStatusHistories->contains($orderStatusHistory)) {
  160. $this->orderStatusHistories[] = $orderStatusHistory;
  161. $orderStatusHistory->setOrderShop($this);
  162. }
  163. return $this;
  164. }
  165. public function removeOrderStatusHistory(OrderStatusHistory $orderStatusHistory): self
  166. {
  167. if ($this->orderStatusHistories->contains($orderStatusHistory)) {
  168. $this->orderStatusHistories->removeElement($orderStatusHistory);
  169. // set the owning side to null (unless already changed)
  170. if ($orderStatusHistory->getOrderShop() === $this) {
  171. $orderStatusHistory->setOrderShop(null);
  172. }
  173. }
  174. return $this;
  175. }
  176. /**
  177. * @return Collection|OrderProduct[]
  178. */
  179. public function getOrderProducts(): Collection
  180. {
  181. return $this->orderProducts;
  182. }
  183. public function addOrderProduct(OrderProduct $orderProduct): self
  184. {
  185. if (!$this->orderProducts->contains($orderProduct)) {
  186. $this->orderProducts[] = $orderProduct;
  187. $orderProduct->setOrderShop($this);
  188. }
  189. return $this;
  190. }
  191. public function removeOrderProduct(OrderProduct $orderProduct): self
  192. {
  193. if ($this->orderProducts->contains($orderProduct)) {
  194. $this->orderProducts->removeElement($orderProduct);
  195. // set the owning side to null (unless already changed)
  196. if ($orderProduct->getOrderShop() === $this) {
  197. $orderProduct->setOrderShop(null);
  198. }
  199. }
  200. return $this;
  201. }
  202. /**
  203. * @return Collection|CreditHistory[]
  204. */
  205. public function getCreditHistories(): Collection
  206. {
  207. return $this->creditHistories;
  208. }
  209. public function addCreditHistory(CreditHistory $creditHistory): self
  210. {
  211. if (!$this->creditHistories->contains($creditHistory)) {
  212. $this->creditHistories[] = $creditHistory;
  213. $creditHistory->setOrderShop($this);
  214. }
  215. return $this;
  216. }
  217. public function removeCreditHistory(CreditHistory $creditHistory): self
  218. {
  219. if ($this->creditHistories->contains($creditHistory)) {
  220. $this->creditHistories->removeElement($creditHistory);
  221. // set the owning side to null (unless already changed)
  222. if ($creditHistory->getOrderShop() === $this) {
  223. $creditHistory->setOrderShop(null);
  224. }
  225. }
  226. return $this;
  227. }
  228. public function getDocumentInvoice(): ?DocumentInvoice
  229. {
  230. return $this->documentInvoice;
  231. }
  232. public function setDocumentInvoice(?DocumentInvoice $documentInvoice): self
  233. {
  234. $this->documentInvoice = $documentInvoice;
  235. return $this;
  236. }
  237. public function getDocumentQuotation(): ?DocumentQuotation
  238. {
  239. return $this->documentQuotation;
  240. }
  241. public function setDocumentQuotation(?DocumentQuotation $documentQuotation): self
  242. {
  243. $this->documentQuotation = $documentQuotation;
  244. return $this;
  245. }
  246. public function getDocumentDeliveryNote(): ?DocumentDeliveryNote
  247. {
  248. return $this->documentDeliveryNote;
  249. }
  250. public function setDocumentDeliveryNote(?DocumentDeliveryNote $documentDeliveryNote): self
  251. {
  252. $this->documentDeliveryNote = $documentDeliveryNote;
  253. return $this;
  254. }
  255. public function getVisitor(): ?Visitor
  256. {
  257. return $this->visitor;
  258. }
  259. public function setVisitor(?Visitor $visitor): self
  260. {
  261. $this->visitor = $visitor;
  262. return $this;
  263. }
  264. public function getDeliveryInfos(): ?string
  265. {
  266. return $this->deliveryInfos;
  267. }
  268. public function setDeliveryInfos(?string $deliveryInfos): self
  269. {
  270. $this->deliveryInfos = $deliveryInfos;
  271. return $this;
  272. }
  273. }