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

301 行
7.0KB

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