|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- <?php
-
- namespace Lc\CaracoleBundle\Model\File;
-
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
- use Gedmo\Mapping\Annotation as Gedmo;
- use Lc\CaracoleBundle\Model\Address\AddressInterface;
- use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
- use Lc\CaracoleBundle\Model\Order\OrderRefundInterface;
- use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
- use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
-
- /**
- * @ORM\MappedSuperclass()
- */
- abstract class DocumentModel extends AbstractFullEntity implements FilterMerchantInterface
- {
- const TYPE_INVOICE = 'invoice';
- const TYPE_QUOTATION = 'quotation';
- const TYPE_PURCHASE_ORDER = 'purchase-order';
- const TYPE_DELIVERY_NOTE = 'delivery-note';
-
- /**
- * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface")
- * @ORM\JoinColumn(nullable=false)
- */
- protected $merchant;
-
- /**
- * @ORM\Column(type="string", length=64)
- */
- protected $type;
-
- /**
- * @ORM\Column(type="string", length=128, nullable=true)
- */
- protected $reference;
-
- /**
- * @ORM\Column(type="string", length=255, nullable=true)
- */
- protected $logo;
-
- /**
- * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Address\AddressInterface")
- * @ORM\JoinColumn(nullable=false)
- */
- protected $merchantAddress;
-
- /**
- * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Address\AddressInterface")
- * @ORM\JoinColumn(nullable=true)
- */
- protected $buyerAddress;
-
- /**
- * @ORM\Column(type="text")
- */
- protected $merchantAddressText;
-
- /**
- * @ORM\Column(type="text",nullable=true)
- */
- protected $buyerAddressText;
-
- /**
- * @ORM\Column(type="text", nullable=true)
- */
- protected $deliveryAddressText;
-
- /**
- * @ORM\Column(type="boolean", nullable=true)
- */
- protected $isSent;
-
- /**
- * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", mappedBy="documents")
- * @ORM\JoinColumn(nullable=true)
- */
- protected $orderShops;
-
-
- /**
- * @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderRefundInterface", mappedBy="document", cascade={"persist", "remove"})
- */
- protected $orderRefund;
-
- /**
- * @Gedmo\Blameable(on="create")
- * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\User\UserInterface")
- * @ORM\JoinColumn(nullable=true)
- */
- protected $createdBy;
-
- /**
- * @Gedmo\Blameable(on="update")
- * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\User\UserInterface")
- * @ORM\JoinColumn(nullable=true)
- */
- protected $updatedBy;
-
- public function __construct()
- {
- $this->orderShops = new ArrayCollection();
- }
-
- public function __toString()
- {
- return $this->getReference();
- }
-
- public function getMerchant(): ?MerchantInterface
- {
- return $this->merchant;
- }
-
- public function setMerchant(?MerchantInterface $merchant): self
- {
- $this->merchant = $merchant;
-
- return $this;
- }
-
- public function getLabel()
- {
- if ($this->getType() == self::TYPE_INVOICE) {
- return 'Facture';
- } elseif ($this->getType() == self::TYPE_QUOTATION) {
- return 'Devis';
- } elseif ($this->getType() == self::TYPE_PURCHASE_ORDER) {
- return 'Bon de commande';
- } elseif ($this->getType() == self::TYPE_DELIVERY_NOTE) {
- return 'Bon de livraison';
- }
- }
-
- public function getType(): ?string
- {
- return $this->type;
- }
-
- public function setType(string $type): self
- {
- $this->type = $type;
-
- return $this;
- }
-
- public function getReference(): ?string
- {
- return $this->reference;
- }
-
- public function setReference(?string $reference): self
- {
- $this->reference = $reference;
-
- return $this;
- }
-
- public function getLogo(): ?string
- {
- return $this->logo;
- }
-
- public function setLogo(string $logo): self
- {
- $this->logo = $logo;
-
- return $this;
- }
-
- public function getMerchantAddress(): ?AddressInterface
- {
- return $this->merchantAddress;
- }
-
- public function setMerchantAddress(?AddressInterface $merchantAddress): self
- {
- $this->merchantAddress = $merchantAddress;
-
- return $this;
- }
-
- public function getBuyerAddress(): ?AddressInterface
- {
- return $this->buyerAddress;
- }
-
- public function setBuyerAddress(?AddressInterface $buyerAddress): self
- {
- $this->buyerAddress = $buyerAddress;
-
- return $this;
- }
-
- public function getMerchantAddressText(): ?string
- {
- return $this->merchantAddressText;
- }
-
- public function setMerchantAddressText(string $merchantAddressText): self
- {
- $this->merchantAddressText = $merchantAddressText;
-
- return $this;
- }
-
- public function getBuyerAddressText(): ?string
- {
- return $this->buyerAddressText;
- }
-
- public function setBuyerAddressText(?string $buyerAddressText): self
- {
- $this->buyerAddressText = $buyerAddressText;
-
- return $this;
- }
-
- public function getDeliveryAddressText(): ?string
- {
- return $this->deliveryAddressText;
- }
-
- public function setDeliveryAddressText(?string $deliveryAddressText): self
- {
- $this->deliveryAddressText = $deliveryAddressText;
-
- return $this;
- }
-
- public function getIsSent(): ?bool
- {
- return $this->isSent;
- }
-
- public function setIsSent(?bool $isSent): self
- {
- $this->isSent = $isSent;
-
- return $this;
- }
-
- /**
- * @return Collection|OrderShopInterface[]
- */
- public function getOrderShops(): Collection
- {
- return $this->orderShops;
- }
-
- public function addOrderShop(OrderShopInterface $orderShop): self
- {
- if (!$this->orderShops->contains($orderShop)) {
- $this->orderShops[] = $orderShop;
- $orderShop->addDocument($this);
- }
-
- return $this;
- }
-
- public function removeOrderShop(OrderShopInterface $orderShop): self
- {
- if ($this->orderShops->contains($orderShop)) {
- $this->orderShops->removeElement($orderShop);
- $orderShop->removeDocument($this);
- }
-
- return $this;
- }
-
-
- public function getOrderRefund(): ?OrderRefundInterface
- {
- return $this->orderRefund;
- }
-
- public function setOrderRefund(OrderRefundInterface $orderRefund): self
- {
- $this->orderRefund = $orderRefund;
-
- // set the owning side of the relation if necessary
- if ($orderRefund->getDocument() !== $this) {
- $orderRefund->setDocument($this);
- }
-
- return $this;
- }
- }
|