|
|
|
|
|
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; |
|
|
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; |
|
|
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; |
|
|
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; |
|
|
use Lc\SovBundle\Factory\Ticket\TicketFactory; |
|
|
use Lc\SovBundle\Factory\Ticket\TicketFactory; |
|
|
|
|
|
use Lc\SovBundle\Factory\Ticket\TicketMessageFactory; |
|
|
use Lc\SovBundle\Field\StatusField; |
|
|
use Lc\SovBundle\Field\StatusField; |
|
|
use Lc\SovBundle\Form\Ticket\TicketFormType; |
|
|
use Lc\SovBundle\Form\Ticket\TicketFormType; |
|
|
|
|
|
use Lc\SovBundle\Form\Ticket\TicketMessageFormType; |
|
|
use Lc\SovBundle\Form\Ticket\TicketStatusType; |
|
|
use Lc\SovBundle\Form\Ticket\TicketStatusType; |
|
|
use Lc\SovBundle\Model\Ticket\TicketInterface; |
|
|
use Lc\SovBundle\Model\Ticket\TicketInterface; |
|
|
use Lc\SovBundle\Controller\AbstractAdminController; |
|
|
use Lc\SovBundle\Controller\AbstractAdminController; |
|
|
|
|
|
use Lc\SovBundle\Model\Ticket\TicketModel; |
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
|
|
use Symfony\Component\HttpFoundation\Request; |
|
|
use Symfony\Component\HttpFoundation\Request; |
|
|
use Symfony\Component\HttpFoundation\Response; |
|
|
use Symfony\Component\HttpFoundation\Response; |
|
|
|
|
|
|
|
|
class TicketAdminController extends AbstractAdminController |
|
|
class TicketAdminController extends AbstractAdminController |
|
|
{ |
|
|
{ |
|
|
protected $ticketFactory; |
|
|
protected $ticketFactory; |
|
|
|
|
|
protected $ticketMessageFactory; |
|
|
protected $adminUrlGenerator; |
|
|
protected $adminUrlGenerator; |
|
|
|
|
|
protected $em; |
|
|
|
|
|
|
|
|
public function __construct(TicketFactory $ticketFactory, AdminUrlGenerator $adminUrlGenerator) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
public function __construct( |
|
|
|
|
|
TicketFactory $ticketFactory, |
|
|
|
|
|
TicketMessageFactory $ticketMessageFactory, |
|
|
|
|
|
AdminUrlGenerator $adminUrlGenerator |
|
|
|
|
|
) { |
|
|
$this->ticketFactory = $ticketFactory; |
|
|
$this->ticketFactory = $ticketFactory; |
|
|
|
|
|
$this->ticketMessageFactory = $ticketMessageFactory; |
|
|
$this->adminUrlGenerator = $adminUrlGenerator; |
|
|
$this->adminUrlGenerator = $adminUrlGenerator; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return TicketInterface::class; |
|
|
return TicketInterface::class; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function configureAssets(Assets $assets): Assets |
|
|
public function configureAssets(Assets $assets): Assets |
|
|
{ |
|
|
{ |
|
|
$assets = parent::configureAssets($assets); |
|
|
$assets = parent::configureAssets($assets); |
|
|
|
|
|
|
|
|
ChoiceField::new('type') |
|
|
ChoiceField::new('type') |
|
|
->autocomplete() |
|
|
->autocomplete() |
|
|
->setChoices( |
|
|
->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') |
|
|
ChoiceField::new('status') |
|
|
->autocomplete() |
|
|
->autocomplete() |
|
|
->setChoices( |
|
|
->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') |
|
|
->setTemplatePath('@LcSov/admin/ticket/index_status.html.twig') |
|
|
->hideOnForm(), |
|
|
->hideOnForm(), |
|
|
|
|
|
|
|
|
$actions |
|
|
$actions |
|
|
->add(Crud::PAGE_INDEX, Action::DETAIL) |
|
|
->add(Crud::PAGE_INDEX, Action::DETAIL) |
|
|
->remove(Crud::PAGE_INDEX, Action::EDIT); |
|
|
->remove(Crud::PAGE_INDEX, Action::EDIT); |
|
|
|
|
|
|
|
|
return parent::configureActions($actions); |
|
|
return parent::configureActions($actions); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->get('em')->persist($ticket); |
|
|
$this->get('em')->persist($ticket); |
|
|
$this->get('em')->flush(); |
|
|
$this->get('em')->flush(); |
|
|
|
|
|
|
|
|
return $this->redirectToRoute('admin_dashboard'); |
|
|
|
|
|
|
|
|
$url = $this->adminUrlGenerator |
|
|
|
|
|
->setAction('index') |
|
|
|
|
|
->generateUrl(); |
|
|
|
|
|
|
|
|
|
|
|
return $this->redirect($url); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $this->render( |
|
|
return $this->render( |
|
|
|
|
|
|
|
|
] |
|
|
] |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
$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( |
|
|
return $this->render( |
|
|
'@LcSov/admin/ticket/detail.html.twig', |
|
|
'@LcSov/admin/ticket/detail.html.twig', |
|
|
[ |
|
|
[ |
|
|
'form_ticket_status' => $formTicketStatus->createView(), |
|
|
'form_ticket_status' => $formTicketStatus->createView(), |
|
|
|
|
|
'form_add_ticket_message' => $formAddTicketMessage->createView(), |
|
|
'ticket' => $ticket, |
|
|
'ticket' => $ticket, |
|
|
] |
|
|
] |
|
|
); |
|
|
); |