|
|
@@ -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,11 @@ 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']) { |
|
|
@@ -209,14 +211,24 @@ class AdminController extends EasyAdminController |
|
|
|
$filter = $this->getListFilterParam($field['property']); |
|
|
|
//$filter = $this->filtersForm->get($field['property'])->getData(); |
|
|
|
if ($filter !== null) { |
|
|
|
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 . '%'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$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(); |
|
|
|
//$filter = $this->filtersForm->get($field['property'])->getData(); |
|
|
|
if ($filter !== null) { |
|
|
|
if ($field['type_options']['multiple']) { |
|
|
|
$queryBuilder->andWhere(':' . $field['property'] . ' MEMBER OF entity.' . $field['property'] . ''); |
|
|
@@ -246,7 +258,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'); |
|
|
|
} |
|
|
|
|
|
|
@@ -255,34 +267,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); |
|
|
@@ -296,13 +309,12 @@ class AdminController extends EasyAdminController |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if($value !== "")return $value; |
|
|
|
if ($value !== "") return $value; |
|
|
|
else return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function renderTemplate($actionName, $templatePath, array $parameters = []) |
|
|
|
{ |
|
|
|
|
|
|
@@ -380,21 +392,22 @@ 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'){ |
|
|
|
$val = $this->entity['list']['max_results']; |
|
|
|
}else{ |
|
|
|
if ($param == 'maxResults') { |
|
|
|
$val = $this->entity['list']['max_results']; |
|
|
|
} 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); |
|
|
|
}else if($this->session->get($sessionParam)){ |
|
|
|
$val = $this->session->get($sessionParam); |
|
|
|
} else if ($this->session->get($sessionParam)) { |
|
|
|
$val = $this->session->get($sessionParam); |
|
|
|
$this->request->query->set($param, $val); |
|
|
|
} |
|
|
|
|
|
|
@@ -407,7 +420,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]); |
|
|
|
|