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.

OrderStatusModel.php 3.6KB

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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. public function __toString()
  62. {
  63. return $this->title . ' [' . $this->alias . ']';
  64. }
  65. public function __construct()
  66. {
  67. $this->nextStatusAllowed = new ArrayCollection();
  68. }
  69. public function getTitle(): ?string
  70. {
  71. return $this->title;
  72. }
  73. public function setTitle(string $title): self
  74. {
  75. $this->title = $title;
  76. return $this;
  77. }
  78. public function getDescription(): ?string
  79. {
  80. return $this->description;
  81. }
  82. public function setDescription(?string $description): self
  83. {
  84. $this->description = $description;
  85. return $this;
  86. }
  87. /**
  88. * @return Collection|self[]
  89. */
  90. public function getNextStatusAllowed(): Collection
  91. {
  92. return $this->nextStatusAllowed;
  93. }
  94. public function addNextStatusAllowed(self $nextStatusAllowed): self
  95. {
  96. if (!$this->nextStatusAllowed->contains($nextStatusAllowed)) {
  97. $this->nextStatusAllowed[] = $nextStatusAllowed;
  98. }
  99. return $this;
  100. }
  101. public function removeNextStatusAllowed(self $nextStatusAllowed): self
  102. {
  103. if ($this->nextStatusAllowed->contains($nextStatusAllowed)) {
  104. $this->nextStatusAllowed->removeElement($nextStatusAllowed);
  105. }
  106. return $this;
  107. }
  108. public function getAlias(): ?string
  109. {
  110. return $this->alias;
  111. }
  112. public function setAlias(string $alias): self
  113. {
  114. $this->alias = $alias;
  115. return $this;
  116. }
  117. }