Browse Source

Merge branch 'develop' of https://forge.laclic.fr/Laclic/SovBundle into develop

develop
Fabien Normand 3 years ago
parent
commit
d1d79b62b7
7 changed files with 67 additions and 34 deletions
  1. +17
    -7
      Builder/Ticket/TicketBuilder.php
  2. +2
    -2
      Form/Setting/BaseSettingType.php
  3. +43
    -20
      Form/Ticket/TicketMessageType.php
  4. +2
    -0
      Resources/translations/admin.fr.yaml
  5. +1
    -3
      Resources/views/admin/setting/form.html.twig
  6. +1
    -1
      Resources/views/admin/ticket/detail.html.twig
  7. +1
    -1
      Solver/Ticket/TicketSolver.php

+ 17
- 7
Builder/Ticket/TicketBuilder.php View File

@@ -7,14 +7,15 @@ use Lc\CaracoleBundle\Notification\MailMailjetNotification;
use Lc\SovBundle\Component\FormComponent;
use Lc\SovBundle\Factory\Ticket\TicketFactory;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Model\Ticket\TicketMessageInterface;
use Lc\SovBundle\Model\Ticket\TicketModel;
use Lc\SovBundle\Repository\User\UserStore;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Security;

class TicketBuilder
{
protected Security $security;
protected EntityManagerInterface $entityManager;
protected MailMailjetNotification $mailMailjetNotification;
protected FormComponent $formComponent;
@@ -24,6 +25,7 @@ class TicketBuilder
protected UserStore $userStore;

public function __construct(
Security $security,
EntityManagerInterface $entityManager,
MailMailjetNotification $mailMailjetNotification,
FormComponent $formComponent,
@@ -32,12 +34,14 @@ class TicketBuilder
TicketFactory $ticketFactory,
UserStore $userStore
) {
$this->security = $security;
$this->entityManager = $entityManager;
$this->mailMailjetNotification = $mailMailjetNotification;
$this->formComponent = $formComponent;
$this->parameterBag = $parameterBag;
$this->ticketFactory = $ticketFactory;
$this->userStore = $userStore;
$this->authorizationChecker = $authorizationChecker;
}

public function create(array $params = []): TicketInterface
@@ -55,6 +59,9 @@ class TicketBuilder
$firstname = $params['visitorFirstname'];
}

$this->entityManager->create($ticket);
$this->entityManager->flush();

if (isset($params['createByAdmin']) && $params['createByAdmin']) {
// envoi email au client
$this->mailMailjetNotification->send(
@@ -82,9 +89,6 @@ class TicketBuilder
);
}

$this->entityManager->persist($ticket);
$this->entityManager->flush();

// notifyAdmin
$usersToNotify = $this->userStore->getByTicketTypesNotification($ticket->getType());

@@ -98,7 +102,7 @@ class TicketBuilder
MailMailjetNotification::CONTENT_DATA => [
'firstname' => $userToNotify->getFirstname(),
'ticket' => $ticket,
'ticketMessage' => $ticket->getTicketMessage(),
'ticketMessage' => $ticket->getTicketMessages()[0],
],
]
);
@@ -110,8 +114,14 @@ class TicketBuilder

public function init(TicketInterface $ticket, array $params = []): void
{
$user = $this->security->getUser();
if($user) {
$ticket->setCreatedBy($user);
}

if (isset($params['user'])) {
$ticket->setUser($params['user']);

} else {
$ticket->setVisitorFirstname($params['visitorFirstname']);
$ticket->setVisitorLastname($params['visitorLastname']);
@@ -124,8 +134,8 @@ class TicketBuilder
->setType($params['type'])
->setSubject($params['subject']);

$ticketMessage = $ticket->getTicketMessage();
$ticketMessage->setStatus(1);
$ticketMessageArray = $ticket->getTicketMessages();
$ticketMessage = $ticketMessageArray[0];
$ticketMessage->setMessage($params['message']);

if (isset($params['imageFilename']) && $params['imageFilename']) {

+ 2
- 2
Form/Setting/BaseSettingType.php View File

@@ -15,8 +15,8 @@ use Symfony\Component\Form\Extension\Core\Type\TimeType;

abstract class BaseSettingType extends AbstractType
{
protected $em;
protected $settingDefinition;
protected EntityManagerInterface $em;
protected SiteSettingDefinitionInterface $settingDefinition;

public function __construct(
EntityManagerInterface $entityManager,

+ 43
- 20
Form/Ticket/TicketMessageType.php View File

@@ -2,39 +2,62 @@

namespace Lc\SovBundle\Form\Ticket;

use Lc\SovBundle\Doctrine\EntityManager;
use Lc\SovBundle\Model\Ticket\TicketMessageInterface;
use App\Entity\Address;
use App\Entity\OrderShop;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Model\Ticket;
use Lc\ShopBundle\Services\UtilsManager;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Validator\Constraints\File;

class TicketMessageType extends AbstractType
{
protected $em;

public function __construct(EntityManager $em)
{
$this->em = $em;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add(
'message',
TextareaType::class,
[
'required' => true
]
);
$builder
->add('message', TextareaType::class, [
'label' => 'entity.TicketMessage.fields.message',
'translation_domain' => 'admin',
])
->add('image', FileType::class, [
'label' => 'Photo',
'mapped' => false,
'required' => false,
'constraints' => [
new File([
'maxSize' => '2048k',
'mimeTypes' => [
'image/png',
'image/jpeg',
'image/jpg',
'image/gif',
],
'mimeTypesMessage' => "Mauvais format d'image (formats acceptés : jpeg, png, gif)",
])
],
])
->add('closeTicket', CheckboxType::class, [
'label' => 'entity.TicketMessage.fields.closeTicket',
'translation_domain' => 'admin',
'required' => false,
]);
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
[
'data_class' => $this->em->getEntityName(TicketMessageInterface::class),
]
);
$resolver->setDefaults([
// Configure your form options here
]);
}
}

+ 2
- 0
Resources/translations/admin.fr.yaml View File

@@ -97,6 +97,7 @@ entity:
TicketMessage:
fields:
message: Votre réponse
closeTicket: Fermer la demande
ProductFamily:
label: Produit
label_plurial: Produits
@@ -130,6 +131,7 @@ entity:
groupUser: Groupe d'utilisateur
quantity: Quantité
unit: Unité
phone: Téléphone
panels:
general: Général
configuration: Configuration

+ 1
- 3
Resources/views/admin/setting/form.html.twig View File

@@ -44,9 +44,7 @@
{% endblock %}
{% endembed %}

{# {% for child in form.settings %}#}
{# {% do child.setRendered() %}#}
{# {% endfor %}#}
{% do form.settings.setRendered %}

{{ form_end(form) }}
{% endblock %}

+ 1
- 1
Resources/views/admin/ticket/detail.html.twig View File

@@ -32,7 +32,7 @@
{% endembed %}

{{ macro.infobox('Date',ticket.createdAt|date('d/m/Y'), "yellow", "fa fa-calendar") }}
{{ macro.infobox('Catégorie',ticket.getTypeLabel()|trans({},'admin'), "green", "fa fa-archive") }}
{{ macro.infobox('Catégorie',ticket_container.solver.getTypeLabel(ticket)|trans({},'admin'), "green", "fa fa-archive") }}
</div>
<div class="col-8">
{% embed '@LcSov/adminlte/embed/card.html.twig' %}

+ 1
- 1
Solver/Ticket/TicketSolver.php View File

@@ -31,7 +31,7 @@ class TicketSolver

public function getStatusLabel(TicketInterface $ticket): string
{
return 'entity.Ticket.statuChoices.'.$ticket->getStatus();
return 'entity.Ticket.fields.statusChoices.'.$ticket->getStatus();
}

public function getUsername(TicketInterface $ticket)

Loading…
Cancel
Save