@@ -5,6 +5,8 @@ namespace Lc\ShopBundle\Controller\Backend; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | |||
use FOS\UserBundle\Model\UserManagerInterface; | |||
use Lc\ShopBundle\Context\OrderShopInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Lc\ShopBundle\Form\Backend\Ticket\TicketMessageType; | |||
use Lc\ShopBundle\Form\Backend\Ticket\TicketStatusType; | |||
use Lc\ShopBundle\Model\Ticket; | |||
@@ -17,9 +19,12 @@ use Symfony\Contracts\Translation\TranslatorInterface; | |||
class TicketController extends AdminController | |||
{ | |||
protected $ticketUtils; | |||
protected $userUtils; | |||
public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, MailjetTransport $mailjetTransport, UtilsManager $utilsManager, TranslatorInterface $translator) | |||
{ | |||
$this->ticketUtils = $utilsManager->getTicketUtils(); | |||
$this->userUtils = $utilsManager->getUserUtils(); | |||
parent::__construct($security, $userManager, $em, $mailjetTransport, $utilsManager, $translator); | |||
} | |||
@@ -34,8 +39,8 @@ class TicketController extends AdminController | |||
'orderShop' => $entity->getOrderShop(), | |||
'subject' => $entity->getSubject(), | |||
'message' => $form->get('message')->getData(), | |||
'answerByAdmin' =>true, | |||
]) ; | |||
'createByAdmin' => true, | |||
]); | |||
} | |||
@@ -95,7 +100,8 @@ class TicketController extends AdminController | |||
} | |||
public function ticketStatusAction(){ | |||
public function ticketStatusAction() | |||
{ | |||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||
$ticket = $easyadmin['item']; | |||
@@ -103,10 +109,10 @@ class TicketController extends AdminController | |||
$formTicketStatusForm->handleRequest($this->request); | |||
if ($formTicketStatusForm->isSubmitted() && $formTicketStatusForm->isValid()) { | |||
$this->em->persist($ticket); | |||
$this->em->flush(); | |||
$this->em->persist($ticket); | |||
$this->em->flush(); | |||
$this->utils->addFlash('success', 'success.ticket.statusChange'); | |||
$this->utils->addFlash('success', 'success.ticket.statusChange'); | |||
} else { | |||
$this->utils->addFlash('error', $formTicketStatusForm->getErrors()); | |||
} | |||
@@ -115,7 +121,8 @@ class TicketController extends AdminController | |||
return new Response(json_encode($response)); | |||
} | |||
public function newMessageTicketAction(){ | |||
public function newMessageTicketAction() | |||
{ | |||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||
$ticket = $easyadmin['item']; | |||
@@ -124,9 +131,9 @@ class TicketController extends AdminController | |||
if ($formAddTicketMessage->isSubmitted() && $formAddTicketMessage->isValid()) { | |||
$this->ticketUtils->createTicketMessage(array( | |||
'ticket'=>$ticket, | |||
'message'=> $formAddTicketMessage->get('message')->getData(), | |||
'answerByAdmin'=>true | |||
'ticket' => $ticket, | |||
'message' => $formAddTicketMessage->get('message')->getData(), | |||
'answerByAdmin' => true | |||
)); | |||
$this->utils->addFlash('success', 'success.ticket.addMessage'); | |||
@@ -140,4 +147,76 @@ class TicketController extends AdminController | |||
'id' => $ticket->getId() | |||
]); | |||
} | |||
public function newAction() | |||
{ | |||
$this->dispatch(EasyAdminEvents::PRE_NEW); | |||
$entity = $this->executeDynamicMethod('createNew<EntityName>Entity'); | |||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||
$easyadmin['item'] = $entity; | |||
$this->request->attributes->set('easyadmin', $easyadmin); | |||
$fields = $this->entity['new']['fields']; | |||
$newForm = $this->executeDynamicMethod('create<EntityName>NewForm', [$entity, $fields]); | |||
if ($this->request->request->get('user')) { | |||
$userRepo = $this->em->getRepository(UserInterface::class); | |||
$newForm->get('user')->setData($userRepo->find($this->request->request->get('user'))); | |||
} | |||
if ($this->request->request->get('orderId')) { | |||
$newForm->get('orderId')->setData($this->request->request->get('orderId')); | |||
} | |||
$newForm->handleRequest($this->request); | |||
if ($newForm->isSubmitted() && $newForm->isValid()) { | |||
if ($newForm->get('orderId')->getData()) { | |||
$orderShopRepo = $this->em->getRepository(OrderShopInterface::class); | |||
$orderShop = $orderShopRepo->find($newForm->get('orderId')->getData()); | |||
if($orderShop)$entity->setOrderShop($orderShop); | |||
} | |||
$this->processUploadedFiles($newForm); | |||
$this->dispatch(EasyAdminEvents::PRE_PERSIST, ['entity' => $entity]); | |||
$this->executeDynamicMethod('persist<EntityName>Entity', [$entity, $newForm]); | |||
$this->dispatch(EasyAdminEvents::POST_PERSIST, ['entity' => $entity]); | |||
$this->utils->addFlash('success', 'success.ticket.addMessage'); | |||
if ($this->request->isXmlHttpRequest()) { | |||
$response['type'] = 'success'; | |||
$response['flashMessages'] = $this->utils->getFlashMessages(); | |||
return new Response(json_encode($response)); | |||
} else { | |||
return $this->redirectToReferrer(); | |||
} | |||
} | |||
$this->dispatch(EasyAdminEvents::POST_NEW, [ | |||
'entity_fields' => $fields, | |||
'form' => $newForm, | |||
'entity' => $entity, | |||
]); | |||
$parameters = [ | |||
'form' => $newForm->createView(), | |||
'entity_fields' => $fields, | |||
'entity' => $entity, | |||
]; | |||
if ($this->request->isXmlHttpRequest()) { | |||
$response['modal'] = $this->renderView('@LcShop/backend/ticket/modal/create.html.twig', $parameters); | |||
return new Response(json_encode($response)); | |||
} else { | |||
return $this->executeDynamicMethod('render<EntityName>Template', ['new', $this->entity['templates']['new'], $parameters]); | |||
} | |||
} | |||
} |
@@ -46,6 +46,7 @@ class TicketTypeType extends AbstractType | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event){ | |||
$builder = $event->getForm()->getParent(); | |||
@@ -54,6 +55,7 @@ class TicketTypeType extends AbstractType | |||
'multiple' => false, | |||
'expanded' => false, | |||
'choices' => [ | |||
'field.Ticket.typeOptions.' . Ticket::TYPE_MESSAGE_FROM_PDL => Ticket::TYPE_MESSAGE_FROM_PDL, | |||
'field.Ticket.typeOptions.' . Ticket::TYPE_GENERAL_QUESTION => Ticket::TYPE_GENERAL_QUESTION, | |||
'field.Ticket.typeOptions.' . Ticket::TYPE_PRODUCT_UNAVAILABLE => Ticket::TYPE_PRODUCT_UNAVAILABLE, | |||
'field.Ticket.typeOptions.' . Ticket::TYPE_PRODUCT_ERROR => Ticket::TYPE_PRODUCT_ERROR, |
@@ -23,6 +23,7 @@ abstract class Ticket extends AbstractEntity implements FilterMerchantInterface | |||
const TYPE_TECHNICAL_PROBLEM = 'technical-problem' ; | |||
const TYPE_GENERAL_QUESTION = 'general-question' ; | |||
const TYPE_POULTRY_BOOKING = 'poultry-booking' ; | |||
const TYPE_MESSAGE_FROM_PDL = 'message-from-pdl' ; | |||
const TICKET_STATUS_OPEN = 'open' ; |
@@ -4,6 +4,7 @@ jQuery(document).ready(function () { | |||
initButtonConfirm() | |||
initNotice(); | |||
initBtnEditReminder(); | |||
initBtnWriteToUser(); | |||
$('form').on('focus', 'input[type=number]', function (e) { | |||
$(this).on('wheel.disableScroll', function (e) { | |||
e.preventDefault() | |||
@@ -274,3 +275,48 @@ function initReminderModal(url) { | |||
}); | |||
} | |||
function initBtnWriteToUser(){ | |||
$('#btn-ticket-write-to-user').on('click', function () { | |||
$btn = $(this); | |||
var order = ''; | |||
if($btn.data('order')) { | |||
order = '&orderId=' + $btn.data('order'); | |||
} | |||
$.ajax({ | |||
url: $btn.data('url'), | |||
data: "user="+$btn.data('user')+order, | |||
method: "POST", | |||
dataType: "json", | |||
success: function (response) { | |||
$('body').append(response.modal); | |||
initModalNewTicket(); | |||
} | |||
}); | |||
}); | |||
} | |||
function initModalNewTicket(){ | |||
$('#modal-new-ticket select.form-control').each(function (i, elm) { | |||
if (!$(this).hasClass('disable-select2')) { | |||
setSelect2($(elm)); | |||
} | |||
}); | |||
$('#modal-new-ticket').modal('show'); | |||
log($('#modal-new-ticket .btn-save')); | |||
$('#modal-new-ticket .btn-save').on('click', function (){ | |||
$form = $(this).parents('form'); | |||
if(checkFormValidity('#'+$form.prop('id'))) { | |||
$('#modal-new-ticket').modal('hide'); | |||
$.ajax({ | |||
url: $form.prop('action'), | |||
data: $form.serialize(), | |||
method: $form.prop('method'), | |||
dataType: "json", | |||
success: function (response) { | |||
setFlashMessages(response.flashMessages); | |||
$('#modal-new-ticket').remove(); | |||
} | |||
}); | |||
} | |||
}) | |||
} |
@@ -467,6 +467,7 @@ field: | |||
type: Catégorie | |||
message: Votre réponse | |||
typeOptions: | |||
message-from-pdl: Messsage de l'équipe Place du Local | |||
general-question: Questions générales | |||
product-unavailable: Produit manquant | |||
product-error: Erreur sur un produit | |||
@@ -539,6 +540,8 @@ action: | |||
add: Ajouter un pense-bête | |||
address: | |||
add: Ajouter une adresse | |||
ticket: | |||
writeToUser: Écrire à l'utilisateur | |||
resetting: | |||
check_email: | | |||
Un e-mail vous a été envoyé. Il contient un lien sur lequel il vous faudra cliquer pour réinitialiser votre mot de passe. Si vous ne recevez pas d'email, vérifiez votre dossier spam ou essayez à nouveau. |
@@ -3,6 +3,17 @@ | |||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||
{% import '@LcShop/backend/order/macros.html.twig' as order_macros %} | |||
{% block global_actions %} | |||
{% if entity.user is not null %} | |||
<button id="btn-ticket-write-to-user" | |||
data-url="{{ path('easyadmin', {'entity': 'Ticket', 'action': 'new'}) }}" | |||
data-user="{{ entity.user.id }}" | |||
class="btn-sm btn-success" | |||
type="button"><i class="fa fa-pen-alt"></i> {{ "action.ticket.writeToUser"|trans }} | |||
</button> | |||
{% endif %} | |||
{% endblock %} | |||
{% block main %} | |||
<div class="lc-vue-js-container" id="lc-order-edit"> |
@@ -3,6 +3,18 @@ | |||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||
{% import '@LcShop/backend/order/macros.html.twig' as order_macros %} | |||
{% block global_actions %} | |||
{% if entity.user is not null %} | |||
<button id="btn-ticket-write-to-user" | |||
data-url="{{ path('easyadmin', {'entity': 'Ticket', 'action': 'new'}) }}" | |||
data-user="{{ entity.user.id }}" | |||
data-order="{{ entity.id }}" | |||
class="btn-sm btn-success" | |||
type="button"><i class="fa fa-pen-alt"></i> {{ "action.ticket.writeToUser"|trans }} | |||
</button> | |||
{% endif %} | |||
{% endblock %} | |||
{% block main %} | |||
<div class="lc-vue-js-container" id="lc-order-edit"> |
@@ -0,0 +1,35 @@ | |||
{% embed "@LcShop/backend/default/block/embed_modal.twig" %} | |||
{% trans_default_domain 'lcshop' %} | |||
{% block id %}modal-new-ticket{% endblock %} | |||
{% block title %}{{ "action.ticket.writeToUser"|trans }}{% endblock %} | |||
{% block form_start %} | |||
{{ form_start(form, {'attr': { 'id' : 'newTicket', 'action': path('easyadmin', {'entity' : 'Ticket', 'action': 'new'})}}) }} | |||
{% form_theme form '@LcShop/backend/form/custom_modal_bootstrap_4.html.twig' %} | |||
{% endblock %} | |||
{% block content %} | |||
<div class="col"> | |||
{{ form_row(form.user) }} | |||
{{ form_row(form.subject) }} | |||
<p> | |||
<strong>Ce ticket concernera la commande #{{ form.orderId.vars.value }}</strong><br /> | |||
<i>Si vous le souhaitez pas, écriver à l'utilisateur depuis l'onglet utilisateur</i> | |||
</p> | |||
{{ form_rest(form) }} | |||
</div> | |||
{% endblock %} | |||
{% block footer %} | |||
{{ parent() }} | |||
<button type="button" class="btn btn-primary btn-save" >{{ 'action.send'|trans }}</button> | |||
{#{{ form_rest(form) }}#} | |||
{% endblock %} | |||
{% block form_end %} | |||
{{ form_end(form) }} | |||
{% endblock %} | |||
{% endembed %} |
@@ -1,31 +1,44 @@ | |||
{% extends app.request.query.get('action') == 'edit' ? '@LcShop/backend/default/edit.html.twig' : '@LcShop/backend/default/new.html.twig' %} | |||
{% extends app.request.query.get('action') == 'edit' ? '@LcShop/backend/default/edit.html.twig' : '@LcShop/backend/default/new.html.twig' %} | |||
{% trans_default_domain 'lcshop' %} | |||
{% block global_actions %} | |||
<button id="btn-ticket-write-to-user" | |||
data-url="{{ path('easyadmin', {'entity': 'Ticket', 'action': 'new'}) }}" | |||
data-user="{{ entity.id }}" | |||
class="btn-sm btn-success" | |||
type="button"><i class="fa fa-pen-alt"></i> {{ "action.ticket.writeToUser"|trans }}</button> | |||
{% endblock %} | |||
{% block entity_form %} | |||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||
{{ form_start(form) }} | |||
{% form_theme form '@LcShop/backend/form/custom_bootstrap_4.html.twig' %} | |||
<div class="row"> | |||
<div class="col-7"> | |||
{{ macros.card_start() }} | |||
<div class="col"> | |||
{% for field in form.children %} | |||
{{ form_row(field) }} | |||
{% endfor %} | |||
</div> | |||
{{ macros.card_end() }} | |||
</div> | |||
<div class="col-7"> | |||
{{ macros.card_start() }} | |||
<div class="col"> | |||
{% for field in form.children %} | |||
{{ form_row(field) }} | |||
{% endfor %} | |||
</div> | |||
{{ macros.card_end() }} | |||
</div> | |||
<div class="col-5"> | |||
<div class="row" id="user-addresses"> | |||
{% for address in entity.addresses %} | |||
{% if address.status >=0 %} | |||
{% include '@LcShop/backend/user/block_useraddress.html.twig' %} | |||
{% endif %} | |||
{% endfor %} | |||
{% for address in entity.addresses %} | |||
{% if address.status >=0 %} | |||
{% include '@LcShop/backend/user/block_useraddress.html.twig' %} | |||
{% endif %} | |||
{% endfor %} | |||
</div> | |||
<button type="button" data-url="{{ path('easyadmin', {"action": 'editAddressUser', 'entity': 'User', 'id': entity.id, 'addressId': 'new'}) }}" | |||
class="btn btn-primary btn-add-user-address" ><i class="fa fa-plus"></i> {{ 'action.address.add'|trans }} | |||
<button type="button" | |||
data-url="{{ path('easyadmin', {"action": 'editAddressUser', 'entity': 'User', 'id': entity.id, 'addressId': 'new'}) }}" | |||
class="btn btn-primary btn-add-user-address"><i | |||
class="fa fa-plus"></i> {{ 'action.address.add'|trans }} | |||
</button> | |||
</div> |
@@ -1,6 +1,15 @@ | |||
{% extends '@LcShop/backend/default/show.html.twig' %} | |||
{% trans_default_domain 'lcshop' %} | |||
{% block global_actions %} | |||
<button id="btn-ticket-write-to-user" | |||
data-url="{{ path('easyadmin', {'entity': 'Ticket', 'action': 'new'}) }}" | |||
data-user="{{ entity.user.id }}" | |||
class="btn-sm btn-success" | |||
type="button"><i class="fa fa-pen-alt"></i> {{ "action.ticket.writeToUser"|trans }}</button> | |||
{% endblock %} | |||
{% block main %} | |||
<div class="row"> | |||
@@ -38,10 +47,10 @@ | |||
<td class="sorted">{{ creditHistory.id }}</td> | |||
<td class="association">{{ creditHistory.type }}</td> | |||
<td class="">{{ creditHistory.amountInherited }} €</td> | |||
<td class="">{{ creditHistory.meanPaymentInherited }}</td> | |||
<td class="">{{ creditHistory.meanPaymentInherited }}</td> | |||
<td class="">{{ creditHistory.paidAtInherited |date('d-m-y') }}</td> | |||
<td class="">{{ creditHistory.referenceInherited }}</td> | |||
<td class="">{{ creditHistory.commentInherited }}</td> | |||
<td class="">{{ creditHistory.referenceInherited }}</td> | |||
<td class="">{{ creditHistory.commentInherited }}</td> | |||
</tr> | |||
{% else %} | |||
@@ -64,7 +73,8 @@ | |||
{% block head_stylesheets %} | |||
{{ parent() }} | |||
<link rel="stylesheet" href="{{ asset('bundles/lcshop/css/backend/adminlte/plugins/datatables/fixedHeader.dataTables.min.css') }}"> | |||
<link rel="stylesheet" | |||
href="{{ asset('bundles/lcshop/css/backend/adminlte/plugins/datatables/fixedHeader.dataTables.min.css') }}"> | |||
<link rel="stylesheet" | |||
href="{{ asset('bundles/lcshop/css/backend/adminlte/plugins/datatables/dataTables.bootstrap4.min.css') }}"> | |||
{% endblock %} |
@@ -63,21 +63,33 @@ class TicketUtils | |||
$ticketMessage->setStatus(1) ; | |||
$ticketMessage->setTicket($ticket) ; | |||
$ticketMessage->setMessage($params['message']) ; | |||
if(isset($params['answerByAdmin']) && $params['answerByAdmin'])$ticketMessage->setAnswerByAdmin(true); | |||
if(isset($params['createByAdmin']) && $params['createByAdmin'])$ticketMessage->setAnswerByAdmin(true); | |||
$this->em->persist($ticketMessage); | |||
$this->em->flush() ; | |||
// envoi email au client | |||
$this->mailUtils->send([ | |||
MailUtils::SUBJECT => 'Nouvelle demande', | |||
MailUtils::TO_EMAIL => $email, | |||
MailUtils::CONTENT_TEMPLATE => 'mail/ticket-new', | |||
MailUtils::CONTENT_DATA => [ | |||
'firstname' => $firstname, | |||
'ticket' => $ticket | |||
], | |||
]) ; | |||
if(isset($params['createByAdmin']) && $params['createByAdmin']) { | |||
// envoi email au client | |||
$this->mailUtils->send([ | |||
MailUtils::SUBJECT => 'Vous avez reçu un nouveau message', | |||
MailUtils::TO_EMAIL => $email, | |||
MailUtils::CONTENT_TEMPLATE => 'mail/ticket-new-by-admin', | |||
MailUtils::CONTENT_DATA => [ | |||
'firstname' => $firstname, | |||
'ticket' => $ticket | |||
], | |||
]); | |||
}else{ | |||
$this->mailUtils->send([ | |||
MailUtils::SUBJECT => 'Nouvelle demande', | |||
MailUtils::TO_EMAIL => $email, | |||
MailUtils::CONTENT_TEMPLATE => 'mail/ticket-new', | |||
MailUtils::CONTENT_DATA => [ | |||
'firstname' => $firstname, | |||
'ticket' => $ticket | |||
], | |||
]); | |||
} | |||
$this->notifyAdmin($ticket, $ticketMessage); |