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.

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