|
|
@@ -93,7 +93,7 @@ class AdminController extends EasyAdminController |
|
|
|
|
|
|
|
$response = array(); |
|
|
|
foreach ($values as $value) { |
|
|
|
$response[] = $value[$field]; |
|
|
|
$response[] = $value[$this->utils->getFilterWithoutAssociationAlias($field, '_')]; |
|
|
|
} |
|
|
|
return new JsonResponse($response); |
|
|
|
|
|
|
@@ -138,11 +138,11 @@ class AdminController extends EasyAdminController |
|
|
|
|
|
|
|
if ($pos = strpos($dqlFilter, 'TODAYSTART')) { |
|
|
|
$date = new \DateTime(); |
|
|
|
$dqlFilter = sprintf(str_replace('TODAYSTART', $date->format('Y-m-d').' 00:00:00', $dqlFilter)); |
|
|
|
$dqlFilter = sprintf(str_replace('TODAYSTART', $date->format('Y-m-d') . ' 00:00:00', $dqlFilter)); |
|
|
|
} |
|
|
|
if ($pos = strpos($dqlFilter, 'TODAYEND')) { |
|
|
|
$date = new \DateTime(); |
|
|
|
$dqlFilter = sprintf(str_replace('TODAYEND', $date->format('Y-m-d').' 23:59:59', $dqlFilter)); |
|
|
|
$dqlFilter = sprintf(str_replace('TODAYEND', $date->format('Y-m-d') . ' 23:59:59', $dqlFilter)); |
|
|
|
} |
|
|
|
|
|
|
|
if ($pos = strpos($dqlFilter, 'sectionLunch')) { |
|
|
@@ -195,9 +195,12 @@ class AdminController extends EasyAdminController |
|
|
|
$this->filtersForm->handleRequest($this->request); |
|
|
|
$easyadmin = $this->request->attributes->get('easyadmin'); |
|
|
|
$view = $easyadmin['view']; |
|
|
|
if($easyadmin['view']=='listChildren') $view = 'list'; |
|
|
|
if (($this->filtersForm->isSubmitted() && $this->filtersForm->isValid()) || $this->entity[$view]['filters']!==false) { |
|
|
|
if ($easyadmin['view'] == 'listChildren') $view = 'list'; |
|
|
|
if (($this->filtersForm->isSubmitted() && $this->filtersForm->isValid()) || $this->entity[$view]['filters'] !== false) { |
|
|
|
foreach ($listFields as $field) { |
|
|
|
$field['initProperty'] = $field['property']; |
|
|
|
$field['property'] = $this->utils->getFilterPropertyClean($field['property']); |
|
|
|
//if ($this->filtersForm->has($field['property'])->getConfig()->getOption('AdminController')) { |
|
|
|
if ($this->filtersForm->has($field['property'])) { |
|
|
|
switch ($field['dataType']) { |
|
|
|
case 'option': |
|
|
@@ -206,16 +209,29 @@ 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 . '%'); |
|
|
|
if ($this->utils->hasFilterAssociation($field['initProperty'])) { |
|
|
|
$aliasRelation = $this->utils->getFilterAssociationAlias($field['initProperty']); |
|
|
|
if(array_search($aliasRelation, $queryBuilder->getAllAliases())===false){ |
|
|
|
$queryBuilder->innerJoin('entity.'.$aliasRelation, $aliasRelation); |
|
|
|
} |
|
|
|
$queryBuilder->andWhere($field['initProperty'] . ' LIKE :' . $field['property'] . ''); |
|
|
|
$queryBuilder->setParameter($field['property'], '%' . $filter . '%'); |
|
|
|
} else { |
|
|
|
$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) { |
|
|
|
|
|
|
|
//TODO Faut généraliser avec TreeInterface, ça ne doit pas être ici |
|
|
|
if($field['property'] == 'productCategories') { |
|
|
|
|
|
|
|
$queryBuilder->andWhere(':' . $field['property'] . ' MEMBER OF entity.' . $field['property'].' OR product_categories.parent = :' . $field['property']); |
|
|
@@ -254,7 +270,7 @@ class AdminController extends EasyAdminController |
|
|
|
} |
|
|
|
|
|
|
|
//TODO déplacer dans LC |
|
|
|
if($this->entity['name']== 'OrderShopLunch' || $this->entity['name']== 'OrderShopLunchDay'){ |
|
|
|
if ($this->entity['name'] == 'OrderShopLunch' || $this->entity['name'] == 'OrderShopLunchDay') { |
|
|
|
$queryBuilder->addOrderBy('entity.user', 'asc'); |
|
|
|
} |
|
|
|
|
|
|
@@ -263,34 +279,35 @@ class AdminController extends EasyAdminController |
|
|
|
|
|
|
|
//TODO finaliser la sauvegarde des filtres |
|
|
|
|
|
|
|
protected function getListFilterParam($param, $extraParam = null){ |
|
|
|
protected function getListFilterParam($param, $extraParam = null) |
|
|
|
{ |
|
|
|
$entityName = $this->entity['name']; |
|
|
|
$sessionParam = $entityName.$param.$extraParam; |
|
|
|
$sessionParam = $entityName . $param . $extraParam; |
|
|
|
//CUSTOM |
|
|
|
if($extraParam){ |
|
|
|
if ($extraParam) { |
|
|
|
$value = $this->filtersForm->get($param)->get($extraParam)->getViewData(); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
$value = $this->filtersForm->get($param)->getViewData(); |
|
|
|
} |
|
|
|
|
|
|
|
if($this->request->query->get('filterClear')){ |
|
|
|
if ($this->request->query->get('filterClear')) { |
|
|
|
$this->session->remove($sessionParam); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
if ($value) { |
|
|
|
$this->session->set($sessionParam, $value); |
|
|
|
} else if ($this->session->get($sessionParam) && !$this->filtersForm->isSubmitted() && $this->filtersForm->get($param)) { |
|
|
|
$value = $this->session->get($sessionParam); |
|
|
|
|
|
|
|
if($extraParam){ |
|
|
|
if ($extraParam) { |
|
|
|
|
|
|
|
if($this->filtersForm->get($param)->get($extraParam)->getConfig()->getOption('input')=='datetime'){ |
|
|
|
if ($this->filtersForm->get($param)->get($extraParam)->getConfig()->getOption('input') == 'datetime') { |
|
|
|
|
|
|
|
$this->filtersForm->get($param)->get($extraParam)->setData(new \DateTime($value)); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
$this->filtersForm->get($param)->get($extraParam)->setData($value); |
|
|
|
} |
|
|
|
|
|
|
|
}else { |
|
|
|
} else { |
|
|
|
//Champ association |
|
|
|
if ($this->filtersForm->get($param)->getConfig()->getOption('class')) { |
|
|
|
$valFormated = $this->em->getRepository($this->filtersForm->get($param)->getConfig()->getOption('class'))->find($value); |
|
|
@@ -304,13 +321,12 @@ class AdminController extends EasyAdminController |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if($value !== "")return $value; |
|
|
|
if ($value !== "") return $value; |
|
|
|
else return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function renderTemplate($actionName, $templatePath, array $parameters = []) |
|
|
|
{ |
|
|
|
|
|
|
@@ -388,24 +404,21 @@ class AdminController extends EasyAdminController |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected function getListParam($param, $default =null) { |
|
|
|
|
|
|
|
protected function getListParam($param, $default = null) |
|
|
|
{ |
|
|
|
$entityName = $this->entity['name']; |
|
|
|
$sessionParam = $entityName.$param; |
|
|
|
|
|
|
|
$sessionParam = $entityName . $param; |
|
|
|
//CUSTOM |
|
|
|
if($param == 'maxResults'){ |
|
|
|
if ($param == 'maxResults') { |
|
|
|
$val = $this->entity['list']['max_results']; |
|
|
|
} |
|
|
|
else{ |
|
|
|
} else { |
|
|
|
$val = $this->request->query->get($param, $default); |
|
|
|
} |
|
|
|
|
|
|
|
if(isset($_GET[$param])) { |
|
|
|
$val = $this->request->query->get($param); |
|
|
|
if (isset($_GET[$param])) { |
|
|
|
$val = $this->request->query->get($param); |
|
|
|
$this->session->set($sessionParam, $val); |
|
|
|
} |
|
|
|
elseif($this->session->get($sessionParam)) { |
|
|
|
} else if ($this->session->get($sessionParam)) { |
|
|
|
$val = $this->session->get($sessionParam); |
|
|
|
$this->request->query->set($param, $val); |
|
|
|
} |
|
|
@@ -419,7 +432,7 @@ class AdminController extends EasyAdminController |
|
|
|
|
|
|
|
$fields = $this->entity['list']['fields']; |
|
|
|
|
|
|
|
$paginator = $this->findAll($this->entity['class'], $this->getListParam('page', 1), $this->getListParam('maxResults'), $this->getListParam('sortField'), $this->getListParam('sortDirection'), $this->entity['list']['dql_filter']); |
|
|
|
$paginator = $this->findAll($this->entity['class'], $this->getListParam('page', 1), $this->getListParam('maxResults'), $this->getListParam('sortField'), $this->getListParam('sortDirection'), $this->entity['list']['dql_filter']); |
|
|
|
|
|
|
|
$this->dispatch(EasyAdminEvents::POST_LIST, ['paginator' => $paginator]); |
|
|
|
|