diff --git a/API/Threads.php b/API/Threads.php index 9fbb814..421714e 100644 --- a/API/Threads.php +++ b/API/Threads.php @@ -15,6 +15,7 @@ use Webkul\UVDesk\CoreFrameworkBundle\Entity\Ticket; use Webkul\UVDesk\CoreFrameworkBundle\Entity\TicketStatus; use Webkul\UVDesk\CoreFrameworkBundle\Entity\User; +use Webkul\UVDesk\CoreFrameworkBundle\Entity\UserInstance; use Webkul\UVDesk\CoreFrameworkBundle\Entity\Attachment; use Webkul\UVDesk\CoreFrameworkBundle\Workflow\Events as CoreWorkflowEvents; @@ -117,9 +118,17 @@ public function saveThread(Request $request, $ticketid, ContainerInterface $cont // Create Thread $thread = $container->get('ticket.service')->createThread($ticket, $threadDetails); + $customer = $this->getDoctrine()->getRepository(UserInstance::class)->findOneBy(array('user' => $user->getId(), 'supportRole' => 4 )); + // Check for thread types switch ($thread->getThreadType()) { case 'note': + + if ($customer) { + $json['success'] = "success', Can't add note user account."; + return new JsonResponse($json, Response::HTTP_BAD_REQUEST); + } + $event = new CoreWorkflowEvents\Ticket\Note(); $event ->setTicket($ticket) @@ -145,6 +154,11 @@ public function saveThread(Request $request, $ticketid, ContainerInterface $cont break; case 'forward': // Prepare headers + if ($customer) { + $json['success'] = "success', Can't forward ticket to user account."; + return new JsonResponse($json, Response::HTTP_BAD_REQUEST); + } + $headers = ['References' => $ticket->getReferenceIds()]; if (null != $ticket->currentThread->getMessageId()) { diff --git a/API/Tickets.php b/API/Tickets.php index dc37a77..ed13bc2 100644 --- a/API/Tickets.php +++ b/API/Tickets.php @@ -552,6 +552,13 @@ public function assignAgent(Request $request, ContainerInterface $container) if ($agent) { if($ticket->getAgent() != $agent) { + + if ($ticket->getIsTrashed()) { + $json['status'] = false; + $json['error'] = $container->get('translator')->trans('Tickets is in trashed can not assign to agent.'); + return new JsonResponse($json, Response::HTTP_BAD_REQUEST); + } + $ticket->setAgent($agent); $entityManager->persist($ticket); $entityManager->flush();