Browse Source

Frontend : système de tickets

feature/export_comptable
Guillaume 4 years ago
parent
commit
dd11407c5c
7 changed files with 212 additions and 2 deletions
  1. +44
    -0
      ShopBundle/Form/Frontend/TicketMessageType.php
  2. +80
    -0
      ShopBundle/Form/Frontend/TicketType.php
  3. +5
    -0
      ShopBundle/Model/OrderShop.php
  4. +30
    -1
      ShopBundle/Model/Ticket.php
  5. +1
    -1
      ShopBundle/Model/TicketMessage.php
  6. +38
    -0
      ShopBundle/Model/User.php
  7. +14
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml

+ 44
- 0
ShopBundle/Form/Frontend/TicketMessageType.php View File

@@ -0,0 +1,44 @@
<?php

namespace Lc\ShopBundle\Form\Frontend;

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\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;

class TicketMessageType extends AbstractType
{

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('message', TextareaType::class, [
'label' => 'field.Ticket.yourAnswer',
'translation_domain' => 'lcshop',
])
->add('closeTicket', CheckboxType::class, [
'label' => 'field.Ticket.closeTicket',
'translation_domain' => 'lcshop',
'required' => false,
]);
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
// Configure your form options here
]);
}
}

+ 80
- 0
ShopBundle/Form/Frontend/TicketType.php View File

@@ -0,0 +1,80 @@
<?php

namespace Lc\ShopBundle\Form\Frontend;

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\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
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;

class TicketType extends AbstractType
{
protected $orderShopRepository ;
protected $security ;
protected $em ;
protected $priceUtils ;

public function __construct(Security $security, EntityManagerInterface $em, UtilsManager $utilsManager)
{
$this->security = $security ;
$this->em = $em ;
$this->orderShopRepository = $this->em->getRepository(OrderShop::class) ;
$this->priceUtils = $utilsManager->getPriceUtils() ;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('type', ChoiceType::class, [
'label' => 'field.Ticket.type',
'multiple' => false,
'expanded' => false,
'choices' => [
'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,
'field.Ticket.typeOptions.'.Ticket::TYPE_TECHNICAL_PROBLEM => Ticket::TYPE_TECHNICAL_PROBLEM,
],
'translation_domain' => 'lcshop',
])
->add('orderShop', EntityType::class, [
'class' => $this->em->getClassMetadata(OrderShop::class)->getName(),
'multiple' => false,
'expanded' => false,
'choices' => $this->orderShopRepository->findAllBy([
'user' => $this->security->getUser(),
'isValid' => true
]),
'label' => 'field.default.order',
'placeholder' => '-- Choisissez une commande --',
'required' => false,
'choice_label' => function ($orderShop, $key, $value) {
return 'Commande du '.$orderShop->getValidationDate()->format('d/m/Y').' ('.number_format($this->priceUtils->getTotalWithTax($orderShop), 2).' €)' ;
},
'translation_domain' => 'lcshop',
])
->add('subject', TextType::class, [
'label' => 'Sujet'
])
->add('message', TextareaType::class, [
'label' => 'Message'
]);
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
// Configure your form options here
]);
}
}

+ 5
- 0
ShopBundle/Model/OrderShop.php View File

@@ -127,6 +127,11 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
$this->documents = new ArrayCollection();
}

public function __toString()
{
return 'Commande du '.$this->getValidationDate()->format('d/m/Y') ;
}

public function getValidationDate(): ?\DateTimeInterface
{
return $this->validationDate;

+ 30
- 1
ShopBundle/Model/Ticket.php View File

@@ -3,6 +3,7 @@
namespace Lc\ShopBundle\Model;

use App\Entity\TicketMessage;
use App\Entity\User;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@@ -10,6 +11,7 @@ use Lc\ShopBundle\Context\FilterMerchantInterface;
use Lc\ShopBundle\Context\MerchantInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Gedmo\Mapping\Annotation as Gedmo;
use Lc\ShopBundle\Context\UserInterface;

/**
* @ORM\MappedSuperclass()
@@ -23,7 +25,7 @@ abstract class Ticket extends AbstractEntity implements FilterMerchantInterface

const TICKET_STATUS_OPEN = 'open' ;
const TICKET_STATUS_BEING_PROCESSED = 'being-processed' ;
const TICKET_STATUS_CLOSED = 'fermé' ;
const TICKET_STATUS_CLOSED = 'closed' ;

use StatusTrait;

@@ -102,6 +104,11 @@ abstract class Ticket extends AbstractEntity implements FilterMerchantInterface
*/
protected $ticketMessages;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="tickets")
*/
protected $user;

public function __construct()
{
$this->ticketMessages = new ArrayCollection();
@@ -131,6 +138,11 @@ abstract class Ticket extends AbstractEntity implements FilterMerchantInterface
return $this;
}

public function getTypeLabel(): string
{
return 'field.Ticket.typeOptions.'.$this->getType() ;
}

public function getTypeHelp(): ?string
{
return $this->typeHelp;
@@ -155,6 +167,11 @@ abstract class Ticket extends AbstractEntity implements FilterMerchantInterface
return $this;
}

public function getTicketStatusLabel(): string
{
return 'field.Ticket.ticketStatusOptions.'.$this->getTicketStatus() ;
}

public function getOrderShop(): ?OrderShopInterface
{
return $this->orderShop;
@@ -269,4 +286,16 @@ abstract class Ticket extends AbstractEntity implements FilterMerchantInterface

return $this;
}

public function getUser(): ?UserInterface
{
return $this->user;
}

public function setUser(?UserInterface $user): self
{
$this->user = $user;

return $this;
}
}

+ 1
- 1
ShopBundle/Model/TicketMessage.php View File

@@ -10,7 +10,7 @@ use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\MappedSuperclass()
*/
abstract class TicketMessage
abstract class TicketMessage extends AbstractEntity
{
use StatusTrait;


+ 38
- 0
ShopBundle/Model/User.php View File

@@ -3,12 +3,14 @@
namespace Lc\ShopBundle\Model;

use App\Entity\Newsletter;
use App\Entity\Ticket;
use App\Entity\UserPointSale;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Model\User as UserModelFOS;
use Lc\ShopBundle\Context\MerchantInterface;
use Lc\ShopBundle\Context\TicketInterface;

/**
* @ORM\MappedSuperclass()
@@ -87,6 +89,11 @@ abstract class User extends UserModelFOS
*/
protected $userMerchants;

/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\TicketInterface", mappedBy="user")
*/
protected $tickets;

public function __construct()
{
parent::__construct();
@@ -386,4 +393,35 @@ abstract class User extends UserModelFOS

return $this;
}

/**
* @return Collection|TicketInterface[]
*/
public function getTickets(): Collection
{
return $this->tickets;
}

public function addTicket(TicketInterface $ticket): self
{
if (!$this->tickets->contains($ticket)) {
$this->tickets[] = $ticket;
$ticket->setUser($this);
}

return $this;
}

public function removeTicket(TicketInterface $ticket): self
{
if ($this->tickets->contains($ticket)) {
$this->tickets->removeElement($ticket);
// set the owning side to null (unless already changed)
if ($ticket->getUser() === $this) {
$ticket->setUser(null);
}
}

return $this;
}
}

+ 14
- 0
ShopBundle/Resources/translations/lcshop.fr.yaml View File

@@ -217,6 +217,7 @@ field:
emailFrom: "Email (From) : email"
emailFromName: "Email (From) : nom"
emailSubjectPrefix: "Email : préfixe"
order: Commande
PointSale:
code: Code
codeHelp: Code utilisé pour retrouver l'ambassade dans le tunnel de commande (Non sensible à la casse)
@@ -339,6 +340,19 @@ field:
dateReminder: Date limite
users: Utilisateurs concernés
usersHelp: Laissez vide si vous souhaitez ajouter ce pense-bête à tout les utilisateurs
Ticket:
type: Catégorie
typeOptions:
general-question: Questions générales
product-unavailable: Produit manquant
product-error: Erreur sur un produit
technical-problem: Problème techique
ticketStatusOptions:
open: Ouvert
being-processed: En cours de traitement
closed: Fermée
yourAnswer: Votre réponse
closeTicket: Fermer la demande

action:
new: Créer %entity_label%

Loading…
Cancel
Save