Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

294 Zeilen
6.8KB

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