Browse Source

Merge branch 'develop'

master
Fab 4 years ago
parent
commit
1c5ddecd02
7 changed files with 80 additions and 7 deletions
  1. +6
    -1
      ShopBundle/Controller/Backend/AdminController.php
  2. +4
    -1
      ShopBundle/Controller/CitiesController.php
  3. +32
    -2
      ShopBundle/Form/Backend/Filters/ListFilterType.php
  4. +1
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  5. +9
    -0
      ShopBundle/Resources/views/backend/ticket/list-fields/field_lastmessage_date.html.twig
  6. +1
    -1
      ShopBundle/Resources/views/backend/ticket/show.html.twig
  7. +27
    -2
      ShopBundle/Services/Utils.php

+ 6
- 1
ShopBundle/Controller/Backend/AdminController.php View File

@@ -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':

+ 4
- 1
ShopBundle/Controller/CitiesController.php View File

@@ -39,8 +39,11 @@ class CitiesController extends AbstractController

$return = [] ;
foreach($result as $city) {

$codesPostaux = $city->codesPostaux ;

$return[] = [
'label' => $city->nom,
'label' => '<span class="city">'.$city->nom.'</span> <span class="zip">'.$codesPostaux[0].'</span>',
'value' => $city->code
] ;
}

+ 32
- 2
ShopBundle/Form/Backend/Filters/ListFilterType.php View File

@@ -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 View File

@@ -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 View File

@@ -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 View File

@@ -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') }}

+ 27
- 2
ShopBundle/Services/Utils.php View File

@@ -252,10 +252,20 @@ class Utils
return $result;
}

public function getZipByCity($city)
public function getZipByCity($city, $code = null)
{
$zip = null ;
$returnCitiesSearchZip = json_decode($this->callCitiesApi('get', 'communes', ['nom' => $city, 'fields' => 'nom,codesPostaux'])) ;

$paramsSearch = [
'nom' => $city,
'fields' => 'nom,codesPostaux'
] ;

if($code != null && $code != 0) {
$paramsSearch['code'] = $code ;
}

$returnCitiesSearchZip = json_decode($this->callCitiesApi('get', 'communes', $paramsSearch)) ;

if($returnCitiesSearchZip) {
foreach($returnCitiesSearchZip as $citySearchZip) {
@@ -334,6 +344,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)
{

Loading…
Cancel
Save