選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

299 行
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 TICKET_STATUS_OPEN = 'open' ;
  23. const TICKET_STATUS_BEING_PROCESSED = 'being-processed' ;
  24. const TICKET_STATUS_CLOSED = 'closed' ;
  25. use StatusTrait;
  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 $ticketStatus;
  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. */
  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 getTicketStatus(): ?string
  124. {
  125. return $this->ticketStatus;
  126. }
  127. public function setTicketStatus(string $ticketStatus): self
  128. {
  129. $this->ticketStatus = $ticketStatus;
  130. return $this;
  131. }
  132. public function getTicketStatusLabel(): string
  133. {
  134. return 'field.Ticket.ticketStatusOptions.'.$this->getTicketStatus() ;
  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. }