浏览代码

[Backend] Ajout de ticket depuis back

develop
Fab 3 年前
父节点
当前提交
2c3e6b6914
共有 3 个文件被更改,包括 87 次插入6 次删除
  1. +5
    -0
      ShopBundle/Controller/Backend/TicketController.php
  2. +76
    -0
      ShopBundle/Form/Backend/Ticket/TicketTypeType.php
  3. +6
    -6
      ShopBundle/Resources/views/backend/ticket/list-fields/field_lastmessage_date.html.twig

+ 5
- 0
ShopBundle/Controller/Backend/TicketController.php 查看文件

@@ -24,6 +24,11 @@ class TicketController extends AdminController

}

public function persistEntity($entity)
{
$entity->setStatus(Ticket::TICKET_STATUS_OPEN);
parent::persistEntity($entity);
}

protected function createListQueryBuilder($entityClass, $sortDirection, $sortField = null, $dqlFilter = null)
{

+ 76
- 0
ShopBundle/Form/Backend/Ticket/TicketTypeType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Ticket;

use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\CreditHistoryInterface;
use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderReductionCartInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Context\ReductionCartInterface;
use Lc\ShopBundle\Context\ReductionCreditInterface;
use Lc\ShopBundle\Context\TicketInterface;
use Lc\ShopBundle\Context\TicketMessageInterface;
use Lc\ShopBundle\Form\DataTransformer\ProductToIdTransformer;
use Lc\ShopBundle\Model\CreditHistory;
use Lc\ShopBundle\Model\Ticket;
use Lc\ShopBundle\Services\Utils;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
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\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

class TicketTypeType extends AbstractType
{
protected $em;


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

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event){
$builder = $event->getForm()->getParent();

$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,
'field.Ticket.typeOptions.' . Ticket::TYPE_POULTRY_BOOKING => Ticket::TYPE_POULTRY_BOOKING,
],
'translation_domain' => 'lcshop',
]);
});

}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(TicketInterface::class)->getName(),
'translation_domain' => 'lcshop'
]);
}
}

+ 6
- 6
ShopBundle/Resources/views/backend/ticket/list-fields/field_lastmessage_date.html.twig 查看文件

@@ -1,9 +1,9 @@


{% set lastMessage = item.ticketMessages.last %}
{% if lastMessage.answerByAdmin != true %}
<span class="badge badge-danger">
{% if lastMessage %}
{% if lastMessage.answerByAdmin != true %}
<span class="badge badge-danger">
New
</span>
</span>
{% endif %}
{{ lastMessage.createdAt|date('d/m/Y H:i') }} par {{ lastMessage.createdBy }}
{% endif %}
{{ lastMessage.createdAt|date('d/m/Y H:i') }} par {{ lastMessage.createdBy }}

正在加载...
取消
保存