Explorar el Código

Filtre option list backoffice

feature/export_comptable
Fab hace 4 años
padre
commit
902a78d15e
Se han modificado 6 ficheros con 64 adiciones y 4 borrados
  1. +6
    -1
      ShopBundle/Controller/Backend/AdminController.php
  2. +32
    -2
      ShopBundle/Form/Backend/Filters/ListFilterType.php
  3. +1
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  4. +9
    -0
      ShopBundle/Resources/views/backend/ticket/list-fields/field_lastmessage_date.html.twig
  5. +1
    -1
      ShopBundle/Resources/views/backend/ticket/show.html.twig
  6. +15
    -0
      ShopBundle/Services/Utils.php

+ 6
- 1
ShopBundle/Controller/Backend/AdminController.php Ver fichero

@@ -162,9 +162,13 @@ class AdminController extends EasyAdminController
$this->commonQueryFilter($entityClass, $queryBuilder);

$listFields = $this->entity['list']['fields'];

$this->filtersForm = $this->createForm(ListFilterType::class, null, array(
'fields' => $listFields,
'method' => 'get'
'method' => 'get',
'entity_name' => $this->entity['name'],
//'entityClass' => $this->entity['class'],
'entity_class' => $this->entity['class']
));
$this->filtersForm->handleRequest($this->request);

@@ -172,6 +176,7 @@ class AdminController extends EasyAdminController
foreach ($listFields as $field) {
if ($this->filtersForm->has($field['property'])) {
switch ($field['dataType']) {
case 'option':
case 'integer':
case 'text':
case 'string':

+ 32
- 2
ShopBundle/Form/Backend/Filters/ListFilterType.php Ver fichero

@@ -4,6 +4,7 @@ namespace Lc\ShopBundle\Form\Backend\Filters;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Lc\ShopBundle\Services\Utils;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
@@ -14,23 +15,49 @@ use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\Translation\TranslatorInterface;


class ListFilterType extends AbstractType
{
protected $em;
protected $translator;
protected $utils;

public function __construct(EntityManagerInterface $entityManager)
public function __construct(EntityManagerInterface $entityManager, TranslatorInterface $translator, Utils $utils)
{
$this->em = $entityManager;
$this->translator = $translator;
$this->utils = $utils;
}


public function buildForm(FormBuilderInterface $builder, array $options)
{

foreach ($options['fields'] as $field) {

switch ($field['dataType']) {
case 'option':

$refl = new \ReflectionClass($options['entity_class']);

$choiceOptions= array();
foreach ($refl->getConstants() as $key => $value) {
if (stripos($key, $this->utils->snakeCase($field['property'])) !== false) {
$choiceOptions[$this->translator->trans('field.'.$options['entity_name'].'.'.$field['property'].'Options.'.$value)] = $value;
}
}

$builder->add($field['property'], ChoiceType::class, array(
'required' => false,
'choices'=> $choiceOptions,
'attr'=>array(
'class'=> 'select2 input-sm',
'form'=> 'filters-form'
)
));
break;
case 'integer':
$builder->add($field['property'], TextType::class, array(
'required' => false,
@@ -131,7 +158,10 @@ class ListFilterType extends AbstractType
'label' => false,
'csrf_protection'=> false,
'translation_domain' => 'lcshop',
'fields' => false
'fields' => false,
'entity_name' => false,
'entity_class' => false,
//'entityClass' => false
]);
}
}

+ 1
- 0
ShopBundle/Resources/translations/lcshop.fr.yaml Ver fichero

@@ -381,6 +381,7 @@ field:
quantityProduct: Quantité (en rapport à l'unité)
unit: Unité
OrderShop:
createdAt: Date de création
save: Sauvegarder
reference: Référence
mainInfo: Information principal

+ 9
- 0
ShopBundle/Resources/views/backend/ticket/list-fields/field_lastmessage_date.html.twig Ver fichero

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


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

+ 1
- 1
ShopBundle/Resources/views/backend/ticket/show.html.twig Ver fichero

@@ -46,7 +46,7 @@
<div class="direct-chat-msg {{ message.answerByAdmin ? 'right' }}">
<div class="direct-chat-infos clearfix">
<span class="direct-chat-name {{ message.answerByAdmin ? 'float-right' : 'float-left' }}">
{{ entity.username }}
{{ message.createdBy }}
</span>
<span class="direct-chat-timestamp {{ message.answerByAdmin ? 'float-left' : 'float-right' }}">
{{ message.createdAt|date('d/m/Y H:i') }}

+ 15
- 0
ShopBundle/Services/Utils.php Ver fichero

@@ -334,6 +334,21 @@ class Utils
return $this->session->getFlashBag()->all();
}

function camelCase($str) {
$i = array("-","_");
$str = preg_replace('/([a-z])([A-Z])/', "\\1 \\2", $str);
$str = preg_replace('@[^a-zA-Z0-9\-_ ]+@', '', $str);
$str = str_replace($i, ' ', $str);
$str = str_replace(' ', '', ucwords(strtolower($str)));
$str = strtolower(substr($str,0,1)).substr($str,1);
return $str;
}

function snakeCase($str) {
$str = preg_replace('/([a-z])([A-Z])/', "\\1_\\2", $str);
$str = strtolower($str);
return $str;
}

public function getRemindersByUser($user)
{

Cargando…
Cancelar
Guardar