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

<?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

<?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

$this->documents = new ArrayCollection(); $this->documents = new ArrayCollection();
} }


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

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

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

namespace Lc\ShopBundle\Model; namespace Lc\ShopBundle\Model;


use App\Entity\TicketMessage; use App\Entity\TicketMessage;
use App\Entity\User;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\MerchantInterface; use Lc\ShopBundle\Context\MerchantInterface;
use Lc\ShopBundle\Context\OrderShopInterface; use Lc\ShopBundle\Context\OrderShopInterface;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;
use Lc\ShopBundle\Context\UserInterface;


/** /**
* @ORM\MappedSuperclass() * @ORM\MappedSuperclass()


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


use StatusTrait; use StatusTrait;


*/ */
protected $ticketMessages; protected $ticketMessages;


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

public function __construct() public function __construct()
{ {
$this->ticketMessages = new ArrayCollection(); $this->ticketMessages = new ArrayCollection();
return $this; return $this;
} }


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

public function getTypeHelp(): ?string public function getTypeHelp(): ?string
{ {
return $this->typeHelp; return $this->typeHelp;
return $this; return $this;
} }


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

public function getOrderShop(): ?OrderShopInterface public function getOrderShop(): ?OrderShopInterface
{ {
return $this->orderShop; return $this->orderShop;


return $this; 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

/** /**
* @ORM\MappedSuperclass() * @ORM\MappedSuperclass()
*/ */
abstract class TicketMessage
abstract class TicketMessage extends AbstractEntity
{ {
use StatusTrait; use StatusTrait;



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

namespace Lc\ShopBundle\Model; namespace Lc\ShopBundle\Model;


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


/** /**
* @ORM\MappedSuperclass() * @ORM\MappedSuperclass()
*/ */
protected $userMerchants; protected $userMerchants;


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

public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();


return $this; 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

emailFrom: "Email (From) : email" emailFrom: "Email (From) : email"
emailFromName: "Email (From) : nom" emailFromName: "Email (From) : nom"
emailSubjectPrefix: "Email : préfixe" emailSubjectPrefix: "Email : préfixe"
order: Commande
PointSale: PointSale:
code: Code code: Code
codeHelp: Code utilisé pour retrouver l'ambassade dans le tunnel de commande (Non sensible à la casse) codeHelp: Code utilisé pour retrouver l'ambassade dans le tunnel de commande (Non sensible à la casse)
dateReminder: Date limite dateReminder: Date limite
users: Utilisateurs concernés users: Utilisateurs concernés
usersHelp: Laissez vide si vous souhaitez ajouter ce pense-bête à tout les utilisateurs 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: action:
new: Créer %entity_label% new: Créer %entity_label%

Loading…
Cancel
Save