$this->commonQueryFilter($entityClass, $queryBuilder); | $this->commonQueryFilter($entityClass, $queryBuilder); | ||||
$listFields = $this->entity['list']['fields']; | $listFields = $this->entity['list']['fields']; | ||||
$this->filtersForm = $this->createForm(ListFilterType::class, null, array( | $this->filtersForm = $this->createForm(ListFilterType::class, null, array( | ||||
'fields' => $listFields, | '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); | $this->filtersForm->handleRequest($this->request); | ||||
foreach ($listFields as $field) { | foreach ($listFields as $field) { | ||||
if ($this->filtersForm->has($field['property'])) { | if ($this->filtersForm->has($field['property'])) { | ||||
switch ($field['dataType']) { | switch ($field['dataType']) { | ||||
case 'option': | |||||
case 'integer': | case 'integer': | ||||
case 'text': | case 'text': | ||||
case 'string': | case 'string': |
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Doctrine\ORM\EntityRepository; | use Doctrine\ORM\EntityRepository; | ||||
use Lc\ShopBundle\Services\Utils; | |||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | use Symfony\Bridge\Doctrine\Form\Type\EntityType; | ||||
use Symfony\Component\Form\AbstractType; | use Symfony\Component\Form\AbstractType; | ||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | ||||
use Symfony\Component\Form\Extension\Core\Type\TextType; | use Symfony\Component\Form\Extension\Core\Type\TextType; | ||||
use Symfony\Component\Form\FormBuilderInterface; | use Symfony\Component\Form\FormBuilderInterface; | ||||
use Symfony\Component\OptionsResolver\OptionsResolver; | use Symfony\Component\OptionsResolver\OptionsResolver; | ||||
use Symfony\Contracts\Translation\TranslatorInterface; | |||||
class ListFilterType extends AbstractType | class ListFilterType extends AbstractType | ||||
{ | { | ||||
protected $em; | protected $em; | ||||
protected $translator; | |||||
protected $utils; | |||||
public function __construct(EntityManagerInterface $entityManager) | |||||
public function __construct(EntityManagerInterface $entityManager, TranslatorInterface $translator, Utils $utils) | |||||
{ | { | ||||
$this->em = $entityManager; | $this->em = $entityManager; | ||||
$this->translator = $translator; | |||||
$this->utils = $utils; | |||||
} | } | ||||
public function buildForm(FormBuilderInterface $builder, array $options) | public function buildForm(FormBuilderInterface $builder, array $options) | ||||
{ | { | ||||
foreach ($options['fields'] as $field) { | foreach ($options['fields'] as $field) { | ||||
switch ($field['dataType']) { | 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': | case 'integer': | ||||
$builder->add($field['property'], TextType::class, array( | $builder->add($field['property'], TextType::class, array( | ||||
'required' => false, | 'required' => false, | ||||
'label' => false, | 'label' => false, | ||||
'csrf_protection'=> false, | 'csrf_protection'=> false, | ||||
'translation_domain' => 'lcshop', | 'translation_domain' => 'lcshop', | ||||
'fields' => false | |||||
'fields' => false, | |||||
'entity_name' => false, | |||||
'entity_class' => false, | |||||
//'entityClass' => false | |||||
]); | ]); | ||||
} | } | ||||
} | } |
quantityProduct: Quantité (en rapport à l'unité) | quantityProduct: Quantité (en rapport à l'unité) | ||||
unit: Unité | unit: Unité | ||||
OrderShop: | OrderShop: | ||||
createdAt: Date de création | |||||
save: Sauvegarder | save: Sauvegarder | ||||
reference: Référence | reference: Référence | ||||
mainInfo: Information principal | mainInfo: Information principal |
{% 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 }} |
<div class="direct-chat-msg {{ message.answerByAdmin ? 'right' }}"> | <div class="direct-chat-msg {{ message.answerByAdmin ? 'right' }}"> | ||||
<div class="direct-chat-infos clearfix"> | <div class="direct-chat-infos clearfix"> | ||||
<span class="direct-chat-name {{ message.answerByAdmin ? 'float-right' : 'float-left' }}"> | <span class="direct-chat-name {{ message.answerByAdmin ? 'float-right' : 'float-left' }}"> | ||||
{{ entity.username }} | |||||
{{ message.createdBy }} | |||||
</span> | </span> | ||||
<span class="direct-chat-timestamp {{ message.answerByAdmin ? 'float-left' : 'float-right' }}"> | <span class="direct-chat-timestamp {{ message.answerByAdmin ? 'float-left' : 'float-right' }}"> | ||||
{{ message.createdAt|date('d/m/Y H:i') }} | {{ message.createdAt|date('d/m/Y H:i') }} |
return $this->session->getFlashBag()->all(); | 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) | public function getRemindersByUser($user) | ||||
{ | { |