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.

DocumentModel.php 6.4KB

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