Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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