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

use Lc\SovBundle\Component\FormComponent; use Lc\SovBundle\Component\FormComponent;
use Lc\SovBundle\Factory\Ticket\TicketFactory; use Lc\SovBundle\Factory\Ticket\TicketFactory;
use Lc\SovBundle\Model\Ticket\TicketInterface; use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Model\Ticket\TicketMessageInterface;
use Lc\SovBundle\Model\Ticket\TicketModel; use Lc\SovBundle\Model\Ticket\TicketModel;
use Lc\SovBundle\Repository\User\UserStore; use Lc\SovBundle\Repository\User\UserStore;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Security;


class TicketBuilder class TicketBuilder
{ {
protected Security $security;
protected EntityManagerInterface $entityManager; protected EntityManagerInterface $entityManager;
protected MailMailjetNotification $mailMailjetNotification; protected MailMailjetNotification $mailMailjetNotification;
protected FormComponent $formComponent; protected FormComponent $formComponent;
protected UserStore $userStore; protected UserStore $userStore;


public function __construct( public function __construct(
Security $security,
EntityManagerInterface $entityManager, EntityManagerInterface $entityManager,
MailMailjetNotification $mailMailjetNotification, MailMailjetNotification $mailMailjetNotification,
FormComponent $formComponent, FormComponent $formComponent,
TicketFactory $ticketFactory, TicketFactory $ticketFactory,
UserStore $userStore UserStore $userStore
) { ) {
$this->security = $security;
$this->entityManager = $entityManager; $this->entityManager = $entityManager;
$this->mailMailjetNotification = $mailMailjetNotification; $this->mailMailjetNotification = $mailMailjetNotification;
$this->formComponent = $formComponent; $this->formComponent = $formComponent;
$this->parameterBag = $parameterBag; $this->parameterBag = $parameterBag;
$this->ticketFactory = $ticketFactory; $this->ticketFactory = $ticketFactory;
$this->userStore = $userStore; $this->userStore = $userStore;
$this->authorizationChecker = $authorizationChecker;
} }


public function create(array $params = []): TicketInterface public function create(array $params = []): TicketInterface
$firstname = $params['visitorFirstname']; $firstname = $params['visitorFirstname'];
} }


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

if (isset($params['createByAdmin']) && $params['createByAdmin']) { if (isset($params['createByAdmin']) && $params['createByAdmin']) {
// envoi email au client // envoi email au client
$this->mailMailjetNotification->send( $this->mailMailjetNotification->send(
); );
} }


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

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


MailMailjetNotification::CONTENT_DATA => [ MailMailjetNotification::CONTENT_DATA => [
'firstname' => $userToNotify->getFirstname(), 'firstname' => $userToNotify->getFirstname(),
'ticket' => $ticket, 'ticket' => $ticket,
'ticketMessage' => $ticket->getTicketMessage(),
'ticketMessage' => $ticket->getTicketMessages()[0],
], ],
] ]
); );


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

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

} else { } else {
$ticket->setVisitorFirstname($params['visitorFirstname']); $ticket->setVisitorFirstname($params['visitorFirstname']);
$ticket->setVisitorLastname($params['visitorLastname']); $ticket->setVisitorLastname($params['visitorLastname']);
->setType($params['type']) ->setType($params['type'])
->setSubject($params['subject']); ->setSubject($params['subject']);


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


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

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



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


public function __construct( public function __construct(
EntityManagerInterface $entityManager, EntityManagerInterface $entityManager,

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



namespace Lc\SovBundle\Form\Ticket; 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\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\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Validator\Constraints\File;


class TicketMessageType extends AbstractType class TicketMessageType extends AbstractType
{ {
protected $em;

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


public function buildForm(FormBuilderInterface $builder, array $options) 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) 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

TicketMessage: TicketMessage:
fields: fields:
message: Votre réponse message: Votre réponse
closeTicket: Fermer la demande
ProductFamily: ProductFamily:
label: Produit label: Produit
label_plurial: Produits label_plurial: Produits
groupUser: Groupe d'utilisateur groupUser: Groupe d'utilisateur
quantity: Quantité quantity: Quantité
unit: Unité unit: Unité
phone: Téléphone
panels: panels:
general: Général general: Général
configuration: Configuration configuration: Configuration

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

{% endblock %} {% endblock %}
{% endembed %} {% endembed %}


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


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

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

{% endembed %} {% endembed %}


{{ macro.infobox('Date',ticket.createdAt|date('d/m/Y'), "yellow", "fa fa-calendar") }} {{ 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>
<div class="col-8"> <div class="col-8">
{% embed '@LcSov/adminlte/embed/card.html.twig' %} {% embed '@LcSov/adminlte/embed/card.html.twig' %}

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



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


public function getUsername(TicketInterface $ticket) public function getUsername(TicketInterface $ticket)

Loading…
Cancel
Save