Quellcode durchsuchen

Merge branch 'develop' of https://gitea.laclic.fr/Laclic/LcShopBundle into develop

feature/export_comptable
Fab vor 4 Jahren
Ursprung
Commit
64df06702d
4 geänderte Dateien mit 49 neuen und 3 gelöschten Zeilen
  1. +1
    -0
      ShopBundle/Model/Ticket.php
  2. +5
    -0
      ShopBundle/Resources/views/backend/default/block/list_tickets.html.twig
  3. +11
    -0
      ShopBundle/Resources/views/backend/default/list-fields/field_ticket_last_message.html.twig
  4. +32
    -3
      ShopBundle/Services/TicketUtils.php

+ 1
- 0
ShopBundle/Model/Ticket.php Datei anzeigen

@@ -94,6 +94,7 @@ abstract class Ticket extends AbstractEntity implements FilterMerchantInterface

/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\TicketMessageInterface", mappedBy="ticket", orphanRemoval=true)
* @ORM\OrderBy({"id" = "ASC"})
*/
protected $ticketMessages;


+ 5
- 0
ShopBundle/Resources/views/backend/default/block/list_tickets.html.twig Datei anzeigen

@@ -3,6 +3,7 @@
<tr>
<th>Sujet</th>
<th>Statut</th>
<th>Dernier message</th>
<th></th>
</tr>
</thead>
@@ -14,6 +15,10 @@
{% set value = ticket.status %}
{% include '@LcShop/backend/default/list-fields/field_ticket_status.html.twig' %}
</td>
<td>
{% set item = ticket %}
{% include '@LcShop/backend/default/list-fields/field_ticket_last_message.html.twig' %}
</td>
<td>
<a class="btn-sm btn-success" href="{{ path('easyadmin', {id: ticket.id, entity: 'Ticket', action: 'show'}) }}">
<i class="fas fa-eye"></i>

+ 11
- 0
ShopBundle/Resources/views/backend/default/list-fields/field_ticket_last_message.html.twig Datei anzeigen

@@ -0,0 +1,11 @@
{% if item.ticketMessages %}
{% for message in item.ticketMessages %}
{% if loop.last %}
{% if message.answerByAdmin %}
Place du Local
{% else %}
Client
{% endif %}
{% endif %}
{% endfor %}
{% endif %}

+ 32
- 3
ShopBundle/Services/TicketUtils.php Datei anzeigen

@@ -14,11 +14,13 @@ class TicketUtils
{
protected $em ;
protected $merchantUtils ;
protected $mailUtils ;

public function __construct(EntityManagerInterface $em, MerchantUtilsInterface $merchantUtils)
public function __construct(EntityManagerInterface $em, MerchantUtilsInterface $merchantUtils, MailUtils $mailUtils)
{
$this->em = $em ;
$this->merchantUtils = $merchantUtils ;
$this->mailUtils = $mailUtils ;
}

public function createTicket($params): TicketInterface
@@ -30,12 +32,18 @@ class TicketUtils

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

$email = $params['user']->getEmail() ;
$firstname = $params['user']->getFirstname() ;
}
else {
$ticket->setVisitorFirstname($params['visitorFirstname']) ;
$ticket->setVisitorLastname($params['visitorLastname']) ;
$ticket->setVisitorEmail($params['visitorEmail']) ;
$ticket->setVisitorToken(uniqid()) ;

$email = $params['visitorEmail'] ;
$firstname = $params['visitorFirstname'] ;
}

$ticket->setStatus(Ticket::TICKET_STATUS_OPEN) ;
@@ -55,6 +63,17 @@ class TicketUtils

$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
],
]) ;

return $ticket ;
}

@@ -70,14 +89,24 @@ class TicketUtils
$ticketMessage->setMessage($params['message']) ;
if(isset($params['answerByAdmin']) && $params['answerByAdmin']) {
$ticketMessage->setAnswerByAdmin($params['answerByAdmin']) ;

// envoi email au client
$this->mailUtils->send([
MailUtils::SUBJECT => 'Réponse à votre demande',
MailUtils::TO_EMAIL => $ticket->getUser() ? $ticket->getUser()->getEmail() : $ticket->getVisitorEmail(),
MailUtils::CONTENT_TEMPLATE => 'mail/ticket-response',
MailUtils::CONTENT_DATA => [
'firstname' => $ticket->getUser() ? $ticket->getUser()->getFirstname() : $ticket->getVisitorFirstname(),
'ticket' => $ticket
],
]) ;
}
$this->em->persist($ticketMessage);

if(isset($params['closeTicket']) && $params['closeTicket']) {
$ticket->setTicketStatus(Ticket::TICKET_STATUS_CLOSED) ;
$ticket->setStatus(Ticket::TICKET_STATUS_CLOSED) ;
}


$ticket->setUpdatedAt(new \DateTime()) ;
$this->em->persist($ticket);


Laden…
Abbrechen
Speichern