před 4 roky
před 4 roky
před 4 roky
před 4 roky
před 4 roky
před 4 roky
před 4 roky
před 4 roky
před 4 roky
před 4 roky
před 4 roky
před 4 roky
před 4 roky
před 4 roky
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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. */
  81. protected $ticketMessages;
  82. /**
  83. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="tickets")
  84. */
  85. protected $user;
  86. public function __construct()
  87. {
  88. $this->ticketMessages = new ArrayCollection();
  89. }
  90. public function getUsername(){
  91. if($this->getUser()){
  92. return $this->getUser()->getName();
  93. }else{
  94. return strtoupper($this->getVisitorLastname()).' '.$this->getVisitorFirstname();
  95. }
  96. }
  97. public function getVisitorInfos(){
  98. return strtoupper($this->getVisitorLastname()).' '.$this->getVisitorFirstname(). ' ('.$this->getVisitorEmail().')';
  99. }
  100. public function getMerchant(): ?MerchantInterface
  101. {
  102. return $this->merchant;
  103. }
  104. public function setMerchant(?MerchantInterface $merchant): self
  105. {
  106. $this->merchant = $merchant;
  107. return $this;
  108. }
  109. public function getType(): ?string
  110. {
  111. return $this->type;
  112. }
  113. public function setType(string $type): self
  114. {
  115. $this->type = $type;
  116. return $this;
  117. }
  118. public function getTypeLabel(): string
  119. {
  120. return 'field.Ticket.typeOptions.'.$this->getType() ;
  121. }
  122. public function getStatus(): ?string
  123. {
  124. return $this->status;
  125. }
  126. public function setStatus(string $status): self
  127. {
  128. $this->status = $status;
  129. return $this;
  130. }
  131. public function getStatusLabel(): string
  132. {
  133. return 'field.Ticket.statusOptions.'.$this->getStatus() ;
  134. }
  135. public function getOrderShop(): ?OrderShopInterface
  136. {
  137. return $this->orderShop;
  138. }
  139. public function setOrderShop(?OrderShopInterface $orderShop): self
  140. {
  141. $this->orderShop = $orderShop;
  142. return $this;
  143. }
  144. public function getSubject(): ?string
  145. {
  146. return $this->subject;
  147. }
  148. public function setSubject(string $subject): self
  149. {
  150. $this->subject = $subject;
  151. return $this;
  152. }
  153. public function getTags(): ?array
  154. {
  155. return $this->tags;
  156. }
  157. public function setTags(?array $tags): self
  158. {
  159. $this->tags = $tags;
  160. return $this;
  161. }
  162. public function getVisitorFirstname(): ?string
  163. {
  164. return $this->visitorFirstname;
  165. }
  166. public function setVisitorFirstname(?string $visitorFirstname): self
  167. {
  168. $this->visitorFirstname = $visitorFirstname;
  169. return $this;
  170. }
  171. public function getVisitorLastname(): ?string
  172. {
  173. return $this->visitorLastname;
  174. }
  175. public function setVisitorLastname(?string $visitorLastname): self
  176. {
  177. $this->visitorLastname = $visitorLastname;
  178. return $this;
  179. }
  180. public function getVisitorEmail(): ?string
  181. {
  182. return $this->visitorEmail;
  183. }
  184. public function setVisitorEmail(?string $visitorEmail): self
  185. {
  186. $this->visitorEmail = $visitorEmail;
  187. return $this;
  188. }
  189. public function getVisitorToken(): ?string
  190. {
  191. return $this->visitorToken;
  192. }
  193. public function setVisitorToken(?string $visitorToken): self
  194. {
  195. $this->visitorToken = $visitorToken;
  196. return $this;
  197. }
  198. /**
  199. * @return Collection|TicketMessage[]
  200. */
  201. public function getTicketMessages(): Collection
  202. {
  203. return $this->ticketMessages;
  204. }
  205. public function addTicketMessage(TicketMessage $ticketMessage): self
  206. {
  207. if (!$this->ticketMessages->contains($ticketMessage)) {
  208. $this->ticketMessages[] = $ticketMessage;
  209. $ticketMessage->setTicket($this);
  210. }
  211. return $this;
  212. }
  213. public function removeTicketMessage(TicketMessage $ticketMessage): self
  214. {
  215. if ($this->ticketMessages->contains($ticketMessage)) {
  216. $this->ticketMessages->removeElement($ticketMessage);
  217. // set the owning side to null (unless already changed)
  218. if ($ticketMessage->getTicket() === $this) {
  219. $ticketMessage->setTicket(null);
  220. }
  221. }
  222. return $this;
  223. }
  224. public function getUser(): ?UserInterface
  225. {
  226. return $this->user;
  227. }
  228. public function setUser(?UserInterface $user): self
  229. {
  230. $this->user = $user;
  231. return $this;
  232. }
  233. }