|
|
@@ -197,7 +197,6 @@ class AdminController extends EasyAdminController |
|
|
|
|
|
|
|
if (($this->filtersForm->isSubmitted() && $this->filtersForm->isValid()) || $this->entity[$easyadmin['view']]['filters']!==false) { |
|
|
|
foreach ($listFields as $field) { |
|
|
|
//if ($this->filtersForm->has($field['property'])->getConfig()->getOption('AdminController')) { |
|
|
|
if ($this->filtersForm->has($field['property'])) { |
|
|
|
switch ($field['dataType']) { |
|
|
|
case 'option': |
|
|
@@ -206,27 +205,36 @@ class AdminController extends EasyAdminController |
|
|
|
case 'string': |
|
|
|
case 'toggle': |
|
|
|
$filter = $this->getListFilterParam($field['property']); |
|
|
|
//$filter = $this->filtersForm->get($field['property'])->getData(); |
|
|
|
if ($filter !== null) { |
|
|
|
|
|
|
|
$queryBuilder->andWhere('entity.' . $field['property'] . ' LIKE :' . $field['property'] . ''); |
|
|
|
$queryBuilder->setParameter($field['property'], '%' . $filter . '%'); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 'association' : |
|
|
|
$filter = $this->getListFilterParam($field['property']); |
|
|
|
//$filter = $this->filtersForm->get($field['property'])->getData(); |
|
|
|
|
|
|
|
if ($filter !== null) { |
|
|
|
if ($field['type_options']['multiple']) { |
|
|
|
$queryBuilder->andWhere(':' . $field['property'] . ' MEMBER OF entity.' . $field['property'] . ''); |
|
|
|
} else { |
|
|
|
$queryBuilder->andWhere('entity.' . $field['property'] . ' = :' . $field['property'] . ''); |
|
|
|
} |
|
|
|
if ($filter instanceof TreeInterface && $filter->getParent() == null) { |
|
|
|
$queryBuilder->setParameter($field['property'], array_merge(array($filter), $filter->getChildrens()->toArray())); |
|
|
|
} else { |
|
|
|
|
|
|
|
if($field['property'] == 'productCategories') { |
|
|
|
|
|
|
|
$queryBuilder->andWhere(':' . $field['property'] . ' MEMBER OF entity.' . $field['property'].' OR product_categories.parent = :' . $field['property']); |
|
|
|
$queryBuilder->setParameter($field['property'], $filter); |
|
|
|
} |
|
|
|
else { |
|
|
|
if ($field['type_options']['multiple']) { |
|
|
|
$queryBuilder->andWhere(':' . $field['property'] . ' MEMBER OF entity.' . $field['property'] . ''); |
|
|
|
} |
|
|
|
else { |
|
|
|
$queryBuilder->andWhere('entity.' . $field['property'] . ' = :' . $field['property'] . ''); |
|
|
|
} |
|
|
|
|
|
|
|
if ($filter instanceof TreeInterface && $filter->getParent() == null) { |
|
|
|
$queryBuilder->setParameter($field['property'], array_merge(array($filter), $filter->getChildrens()->toArray())); |
|
|
|
} |
|
|
|
else { |
|
|
|
$queryBuilder->setParameter($field['property'], $filter); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
case 'datetime': |
|
|
@@ -379,21 +387,25 @@ class AdminController extends EasyAdminController |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected function getListParam($param, $default =null){ |
|
|
|
protected function getListParam($param, $default =null) { |
|
|
|
|
|
|
|
$entityName = $this->entity['name']; |
|
|
|
$sessionParam = $entityName.$param; |
|
|
|
|
|
|
|
//CUSTOM |
|
|
|
if($param == 'maxResults'){ |
|
|
|
$val = $this->entity['list']['max_results']; |
|
|
|
}else{ |
|
|
|
$val = $this->entity['list']['max_results']; |
|
|
|
} |
|
|
|
else{ |
|
|
|
$val = $this->request->query->get($param, $default); |
|
|
|
} |
|
|
|
|
|
|
|
if(isset($_GET[$param])){ |
|
|
|
if(isset($_GET[$param])) { |
|
|
|
$val = $this->request->query->get($param); |
|
|
|
$this->session->set($sessionParam, $val); |
|
|
|
}else if($this->session->get($sessionParam)){ |
|
|
|
$val = $this->session->get($sessionParam); |
|
|
|
} |
|
|
|
elseif($this->session->get($sessionParam)) { |
|
|
|
$val = $this->session->get($sessionParam); |
|
|
|
$this->request->query->set($param, $val); |
|
|
|
} |
|
|
|
|