Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

161 line
3.9KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Model\Order;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Lc\SovBundle\Doctrine\EntityInterface;
  7. /**
  8. * @ORM\MappedSuperclass()
  9. */
  10. abstract class OrderStatusModel implements EntityInterface
  11. {
  12. const ALIAS_CART = 'cart';
  13. const ALIAS_CART_CANCELED = 'cart-canceled';
  14. const ALIAS_WAITING_PAYMENT_ONLINE = 'waiting-payment-online';
  15. const ALIAS_WAITING_BANK_RETURN = 'waiting-bank-return';
  16. const ALIAS_PARTIAL_PAYMENT = 'partial-payment';
  17. const ALIAS_PAID = 'paid';
  18. const ALIAS_ERROR_PAYMENT_ONLINE = 'error-payment-online';
  19. const ALIAS_WAITING_DELIVERY = 'waiting-delivery';
  20. const ALIAS_WAITING_DELIVERY_WITH_PAYMENT = 'waiting-delivery-with-payment';
  21. const ALIAS_DELIVERED_WITHOUT_PAYMENT = 'delivered-without-payment';
  22. const ALIAS_DONE = 'done';
  23. const ALIAS_CANCELED = 'canceled';
  24. const ALIAS_CANCELED_WAITING_REFUND = 'canceled-waiting-refund';
  25. const ALIAS_REFUND = 'refund';
  26. //TODO : AJOUTER un champ valid ds orderSTATUS
  27. static $statusAliasAsValid = [
  28. self::ALIAS_PAID,
  29. self::ALIAS_WAITING_DELIVERY,
  30. self::ALIAS_WAITING_BANK_RETURN,
  31. self::ALIAS_WAITING_DELIVERY_WITH_PAYMENT,
  32. self::ALIAS_DELIVERED_WITHOUT_PAYMENT,
  33. self::ALIAS_DONE
  34. ];
  35. static $statusAliasWaitingDelivery = [
  36. self::ALIAS_WAITING_DELIVERY,
  37. self::ALIAS_WAITING_DELIVERY_WITH_PAYMENT,
  38. ];
  39. static $statusAliasAsCart = [
  40. self::ALIAS_CART,
  41. self::ALIAS_PARTIAL_PAYMENT,
  42. self::ALIAS_WAITING_PAYMENT_ONLINE,
  43. self::ALIAS_ERROR_PAYMENT_ONLINE
  44. ];
  45. /**
  46. * @ORM\Column(type="string", length=255)
  47. */
  48. protected $title;
  49. /**
  50. * @ORM\Column(type="text", nullable=true)
  51. */
  52. protected $description;
  53. /**
  54. * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderStatusInterface")
  55. */
  56. protected $nextStatusAllowed;
  57. /**
  58. * @ORM\Column(type="string", length=255)
  59. */
  60. protected $alias;
  61. /**
  62. * @ORM\Column(type="string", length=255, nullable=true)
  63. */
  64. protected $color;
  65. public function __toString()
  66. {
  67. return $this->title . ' [' . $this->alias . ']';
  68. }
  69. public function __construct()
  70. {
  71. $this->nextStatusAllowed = new ArrayCollection();
  72. }
  73. public function getTitle(): ?string
  74. {
  75. return $this->title;
  76. }
  77. public function setTitle(string $title): self
  78. {
  79. $this->title = $title;
  80. return $this;
  81. }
  82. public function getDescription(): ?string
  83. {
  84. return $this->description;
  85. }
  86. public function setDescription(?string $description): self
  87. {
  88. $this->description = $description;
  89. return $this;
  90. }
  91. /**
  92. * @return Collection|self[]
  93. */
  94. public function getNextStatusAllowed(): Collection
  95. {
  96. return $this->nextStatusAllowed;
  97. }
  98. public function addNextStatusAllowed(self $nextStatusAllowed): self
  99. {
  100. if (!$this->nextStatusAllowed->contains($nextStatusAllowed)) {
  101. $this->nextStatusAllowed[] = $nextStatusAllowed;
  102. }
  103. return $this;
  104. }
  105. public function removeNextStatusAllowed(self $nextStatusAllowed): self
  106. {
  107. if ($this->nextStatusAllowed->contains($nextStatusAllowed)) {
  108. $this->nextStatusAllowed->removeElement($nextStatusAllowed);
  109. }
  110. return $this;
  111. }
  112. public function getAlias(): ?string
  113. {
  114. return $this->alias;
  115. }
  116. public function setAlias(string $alias): self
  117. {
  118. $this->alias = $alias;
  119. return $this;
  120. }
  121. public function getColor(): ?string
  122. {
  123. return $this->color;
  124. }
  125. public function setColor(?string $color): self
  126. {
  127. $this->color = $color;
  128. return $this;
  129. }
  130. }