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.

OrderShopModel.php 13KB

3 yıl önce
3 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. <?php
  2. namespace Lc\CaracoleBundle\Model\Order;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
  8. use Lc\CaracoleBundle\Model\Address\AddressInterface;
  9. use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface;
  10. use Lc\CaracoleBundle\Model\File\DocumentInterface;
  11. use Lc\CaracoleBundle\Model\File\DocumentModel;
  12. use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
  13. use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
  14. use Lc\CaracoleBundle\Model\Product\ProductInterface;
  15. use Lc\CaracoleBundle\Model\Section\SectionInterface;
  16. use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait;
  17. use Lc\SovBundle\Model\Ticket\TicketInterface;
  18. use Lc\CaracoleBundle\Model\User\VisitorInterface;
  19. use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
  20. use Lc\SovBundle\Model\User\UserInterface;
  21. /**
  22. * @ORM\MappedSuperclass()
  23. */
  24. abstract class OrderShopModel extends AbstractLightEntity implements FilterSectionInterface
  25. {
  26. use BlameableNullableTrait;
  27. /**
  28. * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface", inversedBy="orderShops", fetch="EAGER")
  29. */
  30. protected $user;
  31. /**
  32. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\User\VisitorInterface", inversedBy="orders")
  33. */
  34. protected $visitor;
  35. /**
  36. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Address\AddressInterface")
  37. */
  38. protected $invoiceAddress;
  39. /**
  40. * @ORM\Column(type="text", nullable=true)
  41. */
  42. protected $invoiceAddressText;
  43. /**
  44. * @ORM\Column(type="datetime", nullable=true)
  45. */
  46. protected $validationDate;
  47. /**
  48. * @ORM\Column(type="text", nullable=true)
  49. */
  50. protected $comment;
  51. /**
  52. * @ORM\Column(type="string", length=31, nullable=true)
  53. */
  54. protected $meanPayment;
  55. /**
  56. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderStatusHistoryInterface", mappedBy="orderShop", orphanRemoval=true)
  57. */
  58. protected $orderStatusHistories;
  59. /**
  60. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderPaymentInterface", mappedBy="orderShop", orphanRemoval=true)
  61. */
  62. protected $orderPayments;
  63. /**
  64. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderProductInterface", mappedBy="orderShop", cascade={"persist", "remove"}, orphanRemoval=true, fetch="EAGER")
  65. */
  66. protected $orderProducts;
  67. /**
  68. * @ORM\Column(type="text", nullable=true)
  69. */
  70. protected $deliveryInfos;
  71. /**
  72. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderStatusInterface")
  73. * @ORM\JoinColumn(nullable=false)
  74. */
  75. protected $orderStatus;
  76. /**
  77. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderReductionCartInterface", mappedBy="orderShop", orphanRemoval=true)
  78. */
  79. protected $orderReductionCarts;
  80. /**
  81. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderReductionCreditInterface", mappedBy="orderShop", orphanRemoval=true)
  82. */
  83. protected $orderReductionCredits;
  84. /**
  85. * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\File\DocumentInterface", inversedBy="orderShops")
  86. */
  87. protected $documents;
  88. /**
  89. * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Ticket\TicketInterface", mappedBy="orderShop")
  90. */
  91. protected $tickets;
  92. /**
  93. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="orderShops")
  94. * @ORM\JoinColumn(nullable=false)
  95. */
  96. protected $section;
  97. /**
  98. * @ORM\Column(type="integer", nullable=true)
  99. */
  100. protected $cycleId;
  101. public function __construct()
  102. {
  103. $this->orderStatusHistories = new ArrayCollection();
  104. $this->orderPayments = new ArrayCollection();
  105. $this->orderProducts = new ArrayCollection();
  106. $this->orderReductionCarts = new ArrayCollection();
  107. $this->orderReductionCredits = new ArrayCollection();
  108. $this->documents = new ArrayCollection();
  109. }
  110. public function __toString()
  111. {
  112. if ($this->getValidationDate()) {
  113. return 'Commande du ' . $this->getValidationDate()->format('d/m/Y');
  114. } else {
  115. return 'Commande #' . $this->getId();
  116. }
  117. }
  118. public function getValidationDate(): ?\DateTimeInterface
  119. {
  120. return $this->validationDate;
  121. }
  122. public function setValidationDate(\DateTimeInterface $validationDate): self
  123. {
  124. $this->validationDate = $validationDate;
  125. return $this;
  126. }
  127. public function getUser(): ?UserInterface
  128. {
  129. return $this->user;
  130. }
  131. public function setUser(?UserInterface $user): self
  132. {
  133. $this->user = $user;
  134. return $this;
  135. }
  136. public function getInvoiceAddress(): ?AddressInterface
  137. {
  138. return $this->invoiceAddress;
  139. }
  140. public function setInvoiceAddress(?AddressInterface $invoiceAddress): self
  141. {
  142. $this->invoiceAddress = $invoiceAddress;
  143. return $this;
  144. }
  145. public function getInvoiceAddressText(): ?string
  146. {
  147. return $this->invoiceAddressText;
  148. }
  149. public function setInvoiceAddressText(string $invoiceAddressText): self
  150. {
  151. $this->invoiceAddressText = $invoiceAddressText;
  152. return $this;
  153. }
  154. public function getComment(): ?string
  155. {
  156. return $this->comment;
  157. }
  158. public function setComment(?string $comment): self
  159. {
  160. $this->comment = $comment;
  161. return $this;
  162. }
  163. public function getMeanPayment(): ?string
  164. {
  165. return $this->meanPayment;
  166. }
  167. public function setMeanPayment(string $meanPayment): self
  168. {
  169. $this->meanPayment = $meanPayment;
  170. return $this;
  171. }
  172. /**
  173. * @return Collection|OrderStatusHistoryInterface[]
  174. */
  175. public function getOrderStatusHistories(): Collection
  176. {
  177. return $this->orderStatusHistories;
  178. }
  179. public function addOrderStatusHistory(OrderStatusHistoryInterface $orderStatusHistory): self
  180. {
  181. if (!$this->orderStatusHistories->contains($orderStatusHistory)) {
  182. $this->orderStatusHistories[] = $orderStatusHistory;
  183. $orderStatusHistory->setOrderShop($this);
  184. }
  185. return $this;
  186. }
  187. public function removeOrderStatusHistory(OrderStatusHistoryInterface $orderStatusHistory): self
  188. {
  189. if ($this->orderStatusHistories->contains($orderStatusHistory)) {
  190. $this->orderStatusHistories->removeElement($orderStatusHistory);
  191. // set the owning side to null (unless already changed)
  192. if ($orderStatusHistory->getOrderShop() === $this) {
  193. $orderStatusHistory->setOrderShop(null);
  194. }
  195. }
  196. return $this;
  197. }
  198. /**
  199. * @return Collection|OrderPaymentInterface[]
  200. */
  201. public function getOrderPayments($meanPayment = null): Collection
  202. {
  203. if ($meanPayment) {
  204. $orderPaymentsReturn = new ArrayCollection();
  205. foreach ($this->orderPayments as $orderPayment) {
  206. if ($orderPayment->getMeanPayment() == $meanPayment) {
  207. $orderPaymentsReturn[] = $orderPayment;
  208. }
  209. }
  210. return $orderPaymentsReturn;
  211. }
  212. return $this->orderPayments;
  213. }
  214. public function addOrderPayment(OrderPaymentInterface $orderPayment): self
  215. {
  216. if (!$this->orderPayments->contains($orderPayment)) {
  217. $this->orderPayments[] = $orderPayment;
  218. $orderPayment->setOrderShop($this);
  219. }
  220. return $this;
  221. }
  222. public function removeOrderPayment(OrderPaymentInterface $orderPayment): self
  223. {
  224. if ($this->orderPayments->contains($orderPayment)) {
  225. $this->orderPayments->removeElement($orderPayment);
  226. // set the owning side to null (unless already changed)
  227. if ($orderPayment->getOrderShop() === $this) {
  228. $orderPayment->setOrderShop(null);
  229. }
  230. }
  231. return $this;
  232. }
  233. /**
  234. * @return Collection|OrderProductInterface[]
  235. */
  236. public function getOrderProducts(): Collection
  237. {
  238. return $this->orderProducts;
  239. }
  240. public function addOrderProduct(OrderProductInterface $orderProduct): self
  241. {
  242. if (!$this->orderProducts->contains($orderProduct)) {
  243. $this->orderProducts[] = $orderProduct;
  244. $orderProduct->setOrderShop($this);
  245. }
  246. return $this;
  247. }
  248. public function removeOrderProduct(OrderProductInterface $orderProduct): self
  249. {
  250. if ($this->orderProducts->contains($orderProduct)) {
  251. $this->orderProducts->removeElement($orderProduct);
  252. // set the owning side to null (unless already changed)
  253. if ($orderProduct->getOrderShop() === $this) {
  254. $orderProduct->setOrderShop(null);
  255. }
  256. }
  257. return $this;
  258. }
  259. public function getVisitor(): ?VisitorInterface
  260. {
  261. return $this->visitor;
  262. }
  263. public function setVisitor(?VisitorInterface $visitor): self
  264. {
  265. $this->visitor = $visitor;
  266. return $this;
  267. }
  268. public function getDeliveryInfos(): ?string
  269. {
  270. return $this->deliveryInfos;
  271. }
  272. public function setDeliveryInfos(?string $deliveryInfos): self
  273. {
  274. $this->deliveryInfos = $deliveryInfos;
  275. return $this;
  276. }
  277. public function getOrderStatus(): ?OrderStatusInterface
  278. {
  279. return $this->orderStatus;
  280. }
  281. public function setOrderStatusProtected(?OrderStatusInterface $orderStatus): self
  282. {
  283. $this->orderStatus = $orderStatus;
  284. return $this;
  285. }
  286. /**
  287. * @return Collection|OrderReductionCartInterface[]
  288. */
  289. public function getOrderReductionCarts(): Collection
  290. {
  291. return $this->orderReductionCarts;
  292. }
  293. public function addOrderReductionCart(OrderReductionCartInterface $orderReductionCart): self
  294. {
  295. if (!$this->orderReductionCarts->contains($orderReductionCart)) {
  296. $this->orderReductionCarts[] = $orderReductionCart;
  297. $orderReductionCart->setOrderShop($this);
  298. }
  299. return $this;
  300. }
  301. public function removeOrderReductionCart(OrderReductionCartInterface $orderReductionCart): self
  302. {
  303. if ($this->orderReductionCarts->contains($orderReductionCart)) {
  304. $this->orderReductionCarts->removeElement($orderReductionCart);
  305. // set the owning side to null (unless already changed)
  306. if ($orderReductionCart->getOrderShop() === $this) {
  307. $orderReductionCart->setOrderShop(null);
  308. }
  309. }
  310. return $this;
  311. }
  312. /**
  313. * @return Collection|OrderReductionCreditInterface[]
  314. */
  315. public function getOrderReductionCredits(): Collection
  316. {
  317. return $this->orderReductionCredits;
  318. }
  319. public function addOrderReductionCredit(OrderReductionCreditInterface $orderReductionCredit): self
  320. {
  321. if (!$this->orderReductionCredits->contains($orderReductionCredit)) {
  322. $this->orderReductionCredits[] = $orderReductionCredit;
  323. $orderReductionCredit->setOrderShop($this);
  324. }
  325. return $this;
  326. }
  327. public function removeOrderReductionCredit(OrderReductionCreditInterface $orderReductionCredit): self
  328. {
  329. if ($this->orderReductionCredits->contains($orderReductionCredit)) {
  330. $this->orderReductionCredits->removeElement($orderReductionCredit);
  331. // set the owning side to null (unless already changed)
  332. if ($orderReductionCredit->getOrderShop() === $this) {
  333. $orderReductionCredit->setOrderShop(null);
  334. }
  335. }
  336. return $this;
  337. }
  338. /**
  339. * @return Collection|DocumentInterface[]
  340. */
  341. public function getDocuments(): Collection
  342. {
  343. return $this->documents;
  344. }
  345. public function addDocument(DocumentInterface $document): self
  346. {
  347. if (!$this->documents->contains($document)) {
  348. $this->documents[] = $document;
  349. }
  350. return $this;
  351. }
  352. public function removeDocument(DocumentInterface $document): self
  353. {
  354. if ($this->documents->contains($document)) {
  355. $this->documents->removeElement($document);
  356. }
  357. return $this;
  358. }
  359. /**
  360. * @return Collection|TicketInterface[]
  361. */
  362. public function getTickets(): Collection
  363. {
  364. return $this->tickets;
  365. }
  366. public function addTicket(TicketInterface $ticket): self
  367. {
  368. if (!$this->tickets->contains($ticket)) {
  369. $this->tickets[] = $ticket;
  370. $ticket->setOrderShop($this);
  371. }
  372. return $this;
  373. }
  374. public function removeTicket(TicketInterface $ticket): self
  375. {
  376. if ($this->tickets->contains($ticket)) {
  377. $this->tickets->removeElement($ticket);
  378. // set the owning side to null (unless already changed)
  379. if ($ticket->getOrderShop() === $this) {
  380. $ticket->setOrderShop(null);
  381. }
  382. }
  383. return $this;
  384. }
  385. public function getSection(): ?SectionInterface
  386. {
  387. return $this->section;
  388. }
  389. public function setSection(?SectionInterface $section): self
  390. {
  391. $this->section = $section;
  392. return $this;
  393. }
  394. public function getCycleId(): ?int
  395. {
  396. return $this->cycleId;
  397. }
  398. public function setCycleId(?int $cycleId): self
  399. {
  400. $this->cycleId = $cycleId;
  401. return $this;
  402. }
  403. }