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.

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