|
|
@@ -27,11 +27,14 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; |
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; |
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; |
|
|
|
use Lc\SovBundle\Factory\Ticket\TicketFactory; |
|
|
|
use Lc\SovBundle\Factory\Ticket\TicketMessageFactory; |
|
|
|
use Lc\SovBundle\Field\StatusField; |
|
|
|
use Lc\SovBundle\Form\Ticket\TicketFormType; |
|
|
|
use Lc\SovBundle\Form\Ticket\TicketMessageFormType; |
|
|
|
use Lc\SovBundle\Form\Ticket\TicketStatusType; |
|
|
|
use Lc\SovBundle\Model\Ticket\TicketInterface; |
|
|
|
use Lc\SovBundle\Controller\AbstractAdminController; |
|
|
|
use Lc\SovBundle\Model\Ticket\TicketModel; |
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
|
@@ -40,11 +43,17 @@ use Symfony\Component\Translation\TranslatableMessage; |
|
|
|
class TicketAdminController extends AbstractAdminController |
|
|
|
{ |
|
|
|
protected $ticketFactory; |
|
|
|
protected $ticketMessageFactory; |
|
|
|
protected $adminUrlGenerator; |
|
|
|
protected $em; |
|
|
|
|
|
|
|
public function __construct(TicketFactory $ticketFactory, AdminUrlGenerator $adminUrlGenerator) |
|
|
|
{ |
|
|
|
public function __construct( |
|
|
|
TicketFactory $ticketFactory, |
|
|
|
TicketMessageFactory $ticketMessageFactory, |
|
|
|
AdminUrlGenerator $adminUrlGenerator |
|
|
|
) { |
|
|
|
$this->ticketFactory = $ticketFactory; |
|
|
|
$this->ticketMessageFactory = $ticketMessageFactory; |
|
|
|
$this->adminUrlGenerator = $adminUrlGenerator; |
|
|
|
} |
|
|
|
|
|
|
@@ -53,7 +62,6 @@ class TicketAdminController extends AbstractAdminController |
|
|
|
return TicketInterface::class; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function configureAssets(Assets $assets): Assets |
|
|
|
{ |
|
|
|
$assets = parent::configureAssets($assets); |
|
|
@@ -85,19 +93,12 @@ class TicketAdminController extends AbstractAdminController |
|
|
|
ChoiceField::new('type') |
|
|
|
->autocomplete() |
|
|
|
->setChoices( |
|
|
|
[ |
|
|
|
'entity.Ticket.fields.typeOptions.' . Ticket::TYPE_GENERAL_QUESTION => Ticket::TYPE_GENERAL_QUESTION, |
|
|
|
'entity.Ticket.fields.typeOptions.' . Ticket::TYPE_TECHNICAL_PROBLEM => Ticket::TYPE_TECHNICAL_PROBLEM, |
|
|
|
] |
|
|
|
TicketModel::getChoicesType() |
|
|
|
), |
|
|
|
ChoiceField::new('status') |
|
|
|
->autocomplete() |
|
|
|
->setChoices( |
|
|
|
[ |
|
|
|
'entity.Ticket.fields.statusOptions.' . Ticket::TICKET_STATUS_OPEN => Ticket::TICKET_STATUS_OPEN, |
|
|
|
'entity.Ticket.fields.statusOptions.' . Ticket::TICKET_STATUS_BEING_PROCESSED => Ticket::TICKET_STATUS_BEING_PROCESSED, |
|
|
|
'entity.Ticket.fields.statusOptions.' . Ticket::TICKET_STATUS_CLOSED => Ticket::TICKET_STATUS_CLOSED, |
|
|
|
] |
|
|
|
TicketModel::getChoicesStatus() |
|
|
|
) |
|
|
|
->setTemplatePath('@LcSov/admin/ticket/index_status.html.twig') |
|
|
|
->hideOnForm(), |
|
|
@@ -109,6 +110,7 @@ class TicketAdminController extends AbstractAdminController |
|
|
|
$actions |
|
|
|
->add(Crud::PAGE_INDEX, Action::DETAIL) |
|
|
|
->remove(Crud::PAGE_INDEX, Action::EDIT); |
|
|
|
|
|
|
|
return parent::configureActions($actions); |
|
|
|
} |
|
|
|
|
|
|
@@ -128,7 +130,11 @@ class TicketAdminController extends AbstractAdminController |
|
|
|
$this->get('em')->persist($ticket); |
|
|
|
$this->get('em')->flush(); |
|
|
|
|
|
|
|
return $this->redirectToRoute('admin_dashboard'); |
|
|
|
$url = $this->adminUrlGenerator |
|
|
|
->setAction('index') |
|
|
|
->generateUrl(); |
|
|
|
|
|
|
|
return $this->redirect($url); |
|
|
|
} |
|
|
|
|
|
|
|
return $this->render( |
|
|
@@ -156,10 +162,23 @@ class TicketAdminController extends AbstractAdminController |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
$ticketMessage = $this->ticketMessageFactory->create(); |
|
|
|
$formAddTicketMessage = $this->createForm(TicketMessageFormType::class, $ticketMessage); |
|
|
|
$formAddTicketMessage->handleRequest($this->get('request')->getMainRequest()); |
|
|
|
|
|
|
|
if ($formAddTicketMessage->isSubmitted() && $formAddTicketMessage->isValid()) { |
|
|
|
$ticketMessage = $formAddTicketMessage->getData(); |
|
|
|
$ticketMessage->setTicket($ticket); |
|
|
|
$ticketMessage->setAnswerByAdmin(true); |
|
|
|
$this->get('em')->persist($ticketMessage); |
|
|
|
$this->get('em')->flush(); |
|
|
|
} |
|
|
|
|
|
|
|
return $this->render( |
|
|
|
'@LcSov/admin/ticket/detail.html.twig', |
|
|
|
[ |
|
|
|
'form_ticket_status' => $formTicketStatus->createView(), |
|
|
|
'form_add_ticket_message' => $formAddTicketMessage->createView(), |
|
|
|
'ticket' => $ticket, |
|
|
|
] |
|
|
|
); |