преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Lc\ShopBundle\Context\FilterMerchantInterface;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. /**
  9. * @ORM\MappedSuperclass()
  10. */
  11. abstract class Document extends AbstractDocumentEntity implements FilterMerchantInterface
  12. {
  13. const TYPE_INVOICE = 'invoice';
  14. const TYPE_QUOTATION = 'quotation';
  15. const TYPE_PURCHASE_ORDER = 'purchase-order';
  16. const TYPE_DELIVERY_NOTE = 'delivery-note';
  17. /**
  18. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
  19. * @ORM\JoinColumn(nullable=false)
  20. */
  21. protected $merchant;
  22. /**
  23. * @ORM\Column(type="string", length=64)
  24. */
  25. protected $type;
  26. /**
  27. * @ORM\Column(type="string", length=128, nullable=true)
  28. */
  29. protected $reference;
  30. /**
  31. * @ORM\Column(type="string", length=255, nullable=true)
  32. */
  33. protected $logo;
  34. /**
  35. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface")
  36. * @ORM\JoinColumn(nullable=false)
  37. */
  38. protected $merchantAddress;
  39. /**
  40. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface")
  41. * @ORM\JoinColumn(nullable=true)
  42. */
  43. protected $buyerAddress;
  44. /**
  45. * @ORM\Column(type="text")
  46. */
  47. protected $merchantAddressText;
  48. /**
  49. * @ORM\Column(type="text",nullable=true)
  50. */
  51. protected $buyerAddressText;
  52. /**
  53. * @ORM\Column(type="text", nullable=true)
  54. */
  55. protected $deliveryAddressText;
  56. /**
  57. * @ORM\Column(type="boolean", nullable=true)
  58. */
  59. protected $isSent;
  60. /**
  61. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="documents")
  62. */
  63. protected $orderShops;
  64. /**
  65. * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderRefundInterface", mappedBy="document", cascade={"persist", "remove"})
  66. */
  67. protected $orderRefund;
  68. /**
  69. * @Gedmo\Blameable(on="create")
  70. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface")
  71. * @ORM\JoinColumn(nullable=true)
  72. */
  73. protected $createdBy;
  74. /**
  75. * @Gedmo\Blameable(on="update")
  76. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface")
  77. * @ORM\JoinColumn(nullable=true)
  78. */
  79. protected $updatedBy;
  80. public function __construct()
  81. {
  82. $this->orderShops = new ArrayCollection();
  83. }
  84. public function __toString()
  85. {
  86. return $this->getReference();
  87. }
  88. public function getMerchant(): ?Merchant
  89. {
  90. return $this->merchant;
  91. }
  92. public function setMerchant(?Merchant $merchant): self
  93. {
  94. $this->merchant = $merchant;
  95. return $this;
  96. }
  97. public function getLabel()
  98. {
  99. if ($this->getType() == self::TYPE_INVOICE) {
  100. return 'Facture';
  101. } elseif ($this->getType() == self::TYPE_QUOTATION) {
  102. return 'Devis';
  103. } elseif ($this->getType() == self::TYPE_PURCHASE_ORDER) {
  104. return 'Bon de commande';
  105. } elseif ($this->getType() == self::TYPE_DELIVERY_NOTE) {
  106. return 'Bon de livraison';
  107. }
  108. }
  109. public function getType(): ?string
  110. {
  111. return $this->type;
  112. }
  113. public function setType(string $type): self
  114. {
  115. $this->type = $type;
  116. return $this;
  117. }
  118. public function getReference(): ?string
  119. {
  120. return $this->reference;
  121. }
  122. public function setReference(?string $reference): self
  123. {
  124. $this->reference = $reference;
  125. return $this;
  126. }
  127. public function getLogo(): ?string
  128. {
  129. return $this->logo;
  130. }
  131. public function setLogo(string $logo): self
  132. {
  133. $this->logo = $logo;
  134. return $this;
  135. }
  136. public function getMerchantAddress(): ?Address
  137. {
  138. return $this->merchantAddress;
  139. }
  140. public function setMerchantAddress(?Address $merchantAddress): self
  141. {
  142. $this->merchantAddress = $merchantAddress;
  143. return $this;
  144. }
  145. public function getBuyerAddress(): ?Address
  146. {
  147. return $this->buyerAddress;
  148. }
  149. public function setBuyerAddress(?Address $buyerAddress): self
  150. {
  151. $this->buyerAddress = $buyerAddress;
  152. return $this;
  153. }
  154. public function getMerchantAddressText(): ?string
  155. {
  156. return $this->merchantAddressText;
  157. }
  158. public function setMerchantAddressText(string $merchantAddressText): self
  159. {
  160. $this->merchantAddressText = $merchantAddressText;
  161. return $this;
  162. }
  163. public function getBuyerAddressText(): ?string
  164. {
  165. return $this->buyerAddressText;
  166. }
  167. public function setBuyerAddressText(?string $buyerAddressText): self
  168. {
  169. $this->buyerAddressText = $buyerAddressText;
  170. return $this;
  171. }
  172. public function getDeliveryAddressText(): ?string
  173. {
  174. return $this->deliveryAddressText;
  175. }
  176. public function setDeliveryAddressText(?string $deliveryAddressText): self
  177. {
  178. $this->deliveryAddressText = $deliveryAddressText;
  179. return $this;
  180. }
  181. public function getIsSent(): ?bool
  182. {
  183. return $this->isSent;
  184. }
  185. public function setIsSent(?bool $isSent): self
  186. {
  187. $this->isSent = $isSent;
  188. return $this;
  189. }
  190. /**
  191. * @return Collection|OrderShop[]
  192. */
  193. public function getOrderShops(): Collection
  194. {
  195. return $this->orderShops;
  196. }
  197. public function addOrderShop(OrderShop $orderShop): self
  198. {
  199. if (!$this->orderShops->contains($orderShop)) {
  200. $this->orderShops[] = $orderShop;
  201. $orderShop->addDocument($this);
  202. }
  203. return $this;
  204. }
  205. public function removeOrderShop(OrderShop $orderShop): self
  206. {
  207. if ($this->orderShops->contains($orderShop)) {
  208. $this->orderShops->removeElement($orderShop);
  209. $orderShop->removeDocument($this);
  210. }
  211. return $this;
  212. }
  213. public function getOrderRefund(): ?OrderRefund
  214. {
  215. return $this->orderRefund;
  216. }
  217. public function setOrderRefund(OrderRefund $orderRefund): self
  218. {
  219. $this->orderRefund = $orderRefund;
  220. // set the owning side of the relation if necessary
  221. if ($orderRefund->getDocument() !== $this) {
  222. $orderRefund->setDocument($this);
  223. }
  224. return $this;
  225. }
  226. }