123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. /**
  8. * @ORM\MappedSuperclass()
  9. */
  10. abstract class Document extends AbstractDocumentEntity implements FilterMerchantInterface
  11. {
  12. const TYPE_INVOICE = 'invoice' ;
  13. const TYPE_QUOTATION = 'quotation' ;
  14. const TYPE_PURCHASE_ORDER = 'purchase-order' ;
  15. const TYPE_DELIVERY_NOTE = 'delivery-note' ;
  16. /**
  17. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
  18. * @ORM\JoinColumn(nullable=false)
  19. */
  20. protected $merchant;
  21. /**
  22. * @ORM\Column(type="string", length=64)
  23. */
  24. protected $type;
  25. /**
  26. * @ORM\Column(type="string", length=128, nullable=true)
  27. */
  28. protected $reference;
  29. /**
  30. * @ORM\Column(type="string", length=255, nullable=true)
  31. */
  32. protected $logo;
  33. /**
  34. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface")
  35. * @ORM\JoinColumn(nullable=false)
  36. */
  37. protected $merchantAddress;
  38. /**
  39. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface")
  40. * @ORM\JoinColumn(nullable=false)
  41. */
  42. protected $buyerAddress;
  43. /**
  44. * @ORM\Column(type="text")
  45. */
  46. protected $merchantAddressText;
  47. /**
  48. * @ORM\Column(type="text",nullable=true)
  49. */
  50. protected $buyerAddressText;
  51. /**
  52. * @ORM\Column(type="text", nullable=true)
  53. */
  54. protected $deliveryAddressText;
  55. /**
  56. * @ORM\Column(type="boolean", nullable=true)
  57. */
  58. protected $isSent;
  59. /**
  60. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="documents")
  61. */
  62. protected $orderShops;
  63. public function __construct()
  64. {
  65. $this->orderShops = new ArrayCollection();
  66. }
  67. public function getMerchant(): ?Merchant
  68. {
  69. return $this->merchant;
  70. }
  71. public function setMerchant(?Merchant $merchant): self
  72. {
  73. $this->merchant = $merchant;
  74. return $this;
  75. }
  76. public function getLabel()
  77. {
  78. if($this->getType() == self::TYPE_INVOICE) {
  79. return 'Facture' ;
  80. }
  81. elseif($this->getType() == self::TYPE_QUOTATION) {
  82. return 'Devis' ;
  83. }
  84. elseif($this->getType() == self::TYPE_PURCHASE_ORDER) {
  85. return 'Bon de commande' ;
  86. }
  87. elseif($this->getType() == self::TYPE_DELIVERY_NOTE) {
  88. return 'Bon de livraison' ;
  89. }
  90. }
  91. public function getType(): ?string
  92. {
  93. return $this->type;
  94. }
  95. public function setType(string $type): self
  96. {
  97. $this->type = $type;
  98. return $this;
  99. }
  100. public function getReference(): ?string
  101. {
  102. return $this->reference;
  103. }
  104. public function setReference(?string $reference): self
  105. {
  106. $this->reference = $reference;
  107. return $this;
  108. }
  109. public function getLogo(): ?string
  110. {
  111. return $this->logo;
  112. }
  113. public function setLogo(string $logo): self
  114. {
  115. $this->logo = $logo;
  116. return $this;
  117. }
  118. public function getMerchantAddress(): ?Address
  119. {
  120. return $this->merchantAddress;
  121. }
  122. public function setMerchantAddress(?Address $merchantAddress): self
  123. {
  124. $this->merchantAddress = $merchantAddress;
  125. return $this;
  126. }
  127. public function getBuyerAddress(): ?Address
  128. {
  129. return $this->buyerAddress;
  130. }
  131. public function setBuyerAddress(?Address $buyerAddress): self
  132. {
  133. $this->buyerAddress = $buyerAddress;
  134. return $this;
  135. }
  136. public function getMerchantAddressText(): ?string
  137. {
  138. return $this->merchantAddressText;
  139. }
  140. public function setMerchantAddressText(string $merchantAddressText): self
  141. {
  142. $this->merchantAddressText = $merchantAddressText;
  143. return $this;
  144. }
  145. public function getBuyerAddressText(): ?string
  146. {
  147. return $this->buyerAddressText;
  148. }
  149. public function setBuyerAddressText(?string $buyerAddressText): self
  150. {
  151. $this->buyerAddressText = $buyerAddressText;
  152. return $this;
  153. }
  154. public function getDeliveryAddressText(): ?string
  155. {
  156. return $this->deliveryAddressText;
  157. }
  158. public function setDeliveryAddressText(?string $deliveryAddressText): self
  159. {
  160. $this->deliveryAddressText = $deliveryAddressText;
  161. return $this;
  162. }
  163. public function getIsSent(): ?bool
  164. {
  165. return $this->isSent;
  166. }
  167. public function setIsSent(?bool $isSent): self
  168. {
  169. $this->isSent = $isSent;
  170. return $this;
  171. }
  172. /**
  173. * @return Collection|OrderShop[]
  174. */
  175. public function getOrderShops(): Collection
  176. {
  177. return $this->orderShops;
  178. }
  179. public function addOrderShop(OrderShop $orderShop): self
  180. {
  181. if (!$this->orderShops->contains($orderShop)) {
  182. $this->orderShops[] = $orderShop;
  183. $orderShop->addDocument($this);
  184. }
  185. return $this;
  186. }
  187. public function removeOrderShop(OrderShop $orderShop): self
  188. {
  189. if ($this->orderShops->contains($orderShop)) {
  190. $this->orderShops->removeElement($orderShop);
  191. $orderShop->removeDocument($this);
  192. }
  193. return $this;
  194. }
  195. }