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.

300 lines
7.9KB

  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use App\Entity\TicketMessage;
  4. use App\Entity\User;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Lc\ShopBundle\Context\FilterMerchantInterface;
  9. use Lc\ShopBundle\Context\MerchantInterface;
  10. use Lc\ShopBundle\Context\OrderShopInterface;
  11. use Gedmo\Mapping\Annotation as Gedmo;
  12. use Lc\ShopBundle\Context\UserInterface;
  13. /**
  14. * @ORM\MappedSuperclass()
  15. */
  16. abstract class Ticket extends AbstractEntity implements FilterMerchantInterface
  17. {
  18. const TYPE_PRODUCT_UNAVAILABLE = 'product-unavailable' ;
  19. const TYPE_PRODUCT_ERROR = 'product-error' ;
  20. const TYPE_TECHNICAL_PROBLEM = 'technical-problem' ;
  21. const TYPE_GENERAL_QUESTION = 'general-question' ;
  22. const TYPE_POULTRY_BOOKING = 'poultry-booking' ;
  23. const TICKET_STATUS_OPEN = 'open' ;
  24. const TICKET_STATUS_BEING_PROCESSED = 'being-processed' ;
  25. const TICKET_STATUS_CLOSED = 'closed' ;
  26. /**
  27. * @Gedmo\Blameable(on="create")
  28. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface")
  29. * @ORM\JoinColumn(nullable=true)
  30. */
  31. protected $createdBy;
  32. /**
  33. * @Gedmo\Blameable(on="update")
  34. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface")
  35. * @ORM\JoinColumn(nullable=true)
  36. */
  37. protected $updatedBy;
  38. /**
  39. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
  40. * @ORM\JoinColumn(nullable=false)
  41. */
  42. protected $merchant;
  43. /**
  44. * @ORM\Column(type="string", length=32)
  45. */
  46. protected $type;
  47. /**
  48. * @ORM\Column(type="string", length=32)
  49. */
  50. protected $status;
  51. /**
  52. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", inversedBy="tickets")
  53. */
  54. protected $orderShop;
  55. /**
  56. * @ORM\Column(type="string", length=255)
  57. */
  58. protected $subject;
  59. /**
  60. * @ORM\Column(type="array", nullable=true)
  61. */
  62. protected $tags = [];
  63. /**
  64. * @ORM\Column(type="string", length=64, nullable=true)
  65. */
  66. protected $visitorFirstname;
  67. /**
  68. * @ORM\Column(type="string", length=64, nullable=true)
  69. */
  70. protected $visitorLastname;
  71. /**
  72. * @ORM\Column(type="string", length=128, nullable=true)
  73. */
  74. protected $visitorEmail;
  75. /**
  76. * @ORM\Column(type="string", length=255, nullable=true)
  77. */
  78. protected $visitorToken;
  79. /**
  80. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\TicketMessageInterface", mappedBy="ticket", orphanRemoval=true)
  81. * @ORM\OrderBy({"id" = "ASC"})
  82. */
  83. protected $ticketMessages;
  84. /**
  85. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="tickets")
  86. */
  87. protected $user;
  88. public function __construct()
  89. {
  90. $this->ticketMessages = new ArrayCollection();
  91. }
  92. public function getUsername(){
  93. if($this->getUser()){
  94. return $this->getUser()->getName();
  95. }else{
  96. return strtoupper($this->getVisitorLastname()).' '.$this->getVisitorFirstname();
  97. }
  98. }
  99. public function getVisitorInfos(){
  100. return strtoupper($this->getVisitorLastname()).' '.$this->getVisitorFirstname(). ' ('.$this->getVisitorEmail().')';
  101. }
  102. public function getMerchant(): ?MerchantInterface
  103. {
  104. return $this->merchant;
  105. }
  106. public function setMerchant(?MerchantInterface $merchant): self
  107. {
  108. $this->merchant = $merchant;
  109. return $this;
  110. }
  111. public function getType(): ?string
  112. {
  113. return $this->type;
  114. }
  115. public function setType(string $type): self
  116. {
  117. $this->type = $type;
  118. return $this;
  119. }
  120. public function getTypeLabel(): string
  121. {
  122. return 'field.Ticket.typeOptions.'.$this->getType() ;
  123. }
  124. public function getStatus(): ?string
  125. {
  126. return $this->status;
  127. }
  128. public function setStatus(string $status): self
  129. {
  130. $this->status = $status;
  131. return $this;
  132. }
  133. public function getStatusLabel(): string
  134. {
  135. return 'field.Ticket.statusOptions.'.$this->getStatus() ;
  136. }
  137. public function getOrderShop(): ?OrderShopInterface
  138. {
  139. return $this->orderShop;
  140. }
  141. public function setOrderShop(?OrderShopInterface $orderShop): self
  142. {
  143. $this->orderShop = $orderShop;
  144. return $this;
  145. }
  146. public function getSubject(): ?string
  147. {
  148. return $this->subject;
  149. }
  150. public function setSubject(string $subject): self
  151. {
  152. $this->subject = $subject;
  153. return $this;
  154. }
  155. public function getTags(): ?array
  156. {
  157. return $this->tags;
  158. }
  159. public function setTags(?array $tags): self
  160. {
  161. $this->tags = $tags;
  162. return $this;
  163. }
  164. public function getVisitorFirstname(): ?string
  165. {
  166. return $this->visitorFirstname;
  167. }
  168. public function setVisitorFirstname(?string $visitorFirstname): self
  169. {
  170. $this->visitorFirstname = $visitorFirstname;
  171. return $this;
  172. }
  173. public function getVisitorLastname(): ?string
  174. {
  175. return $this->visitorLastname;
  176. }
  177. public function setVisitorLastname(?string $visitorLastname): self
  178. {
  179. $this->visitorLastname = $visitorLastname;
  180. return $this;
  181. }
  182. public function getVisitorEmail(): ?string
  183. {
  184. return $this->visitorEmail;
  185. }
  186. public function setVisitorEmail(?string $visitorEmail): self
  187. {
  188. $this->visitorEmail = $visitorEmail;
  189. return $this;
  190. }
  191. public function getVisitorToken(): ?string
  192. {
  193. return $this->visitorToken;
  194. }
  195. public function setVisitorToken(?string $visitorToken): self
  196. {
  197. $this->visitorToken = $visitorToken;
  198. return $this;
  199. }
  200. /**
  201. * @return Collection|TicketMessage[]
  202. */
  203. public function getTicketMessages(): Collection
  204. {
  205. return $this->ticketMessages;
  206. }
  207. public function addTicketMessage(TicketMessage $ticketMessage): self
  208. {
  209. if (!$this->ticketMessages->contains($ticketMessage)) {
  210. $this->ticketMessages[] = $ticketMessage;
  211. $ticketMessage->setTicket($this);
  212. }
  213. return $this;
  214. }
  215. public function removeTicketMessage(TicketMessage $ticketMessage): self
  216. {
  217. if ($this->ticketMessages->contains($ticketMessage)) {
  218. $this->ticketMessages->removeElement($ticketMessage);
  219. // set the owning side to null (unless already changed)
  220. if ($ticketMessage->getTicket() === $this) {
  221. $ticketMessage->setTicket(null);
  222. }
  223. }
  224. return $this;
  225. }
  226. public function getUser(): ?UserInterface
  227. {
  228. return $this->user;
  229. }
  230. public function setUser(?UserInterface $user): self
  231. {
  232. $this->user = $user;
  233. return $this;
  234. }
  235. }