public function actionIndex() | public function actionIndex() | ||||
{ | { | ||||
$searchModel = new OrderSearch(); | $searchModel = new OrderSearch(); | ||||
$dataProvider = $searchModel->search(array_merge(\Yii::$app->request->queryParams)); | |||||
$dataProvider = $searchModel->search([ | |||||
'order_by' => 'IF(ISNULL(date_update), `order`.`date`, `order`.`date_update`) DESC' | |||||
]); | |||||
return $this->render('index', [ | return $this->render('index', [ | ||||
'searchModel' => $searchModel, | 'searchModel' => $searchModel, |
} | } | ||||
], | ], | ||||
[ | [ | ||||
'label' => 'Origine', | |||||
'label' => 'Utilisateur', | |||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function ($order) use ($orderModule) { | 'value' => function ($order) use ($orderModule) { | ||||
return $orderModule->getSolver()->getLabelOrigin($order, true);; | |||||
return $orderModule->getSolver()->getOrderUsername($order) | |||||
.'<br />'.$orderModule->getSolver()->getLabelOrigin($order, true); | |||||
} | } | ||||
], | ], | ||||
[ | [ |
{ | { | ||||
public function search($params) | public function search($params) | ||||
{ | { | ||||
$orderRepository = OrderRepository::getInstance(); | |||||
$optionsSearch = $orderRepository->getDefaultOptionsSearch() ; | |||||
$paramsSearch = []; | $paramsSearch = []; | ||||
if(isset($params['id_user'])) { | if(isset($params['id_user'])) { | ||||
$paramsSearch['id_user'] = $params['id_user']; | $paramsSearch['id_user'] = $params['id_user']; | ||||
$query = Order::searchQuery($paramsSearch, [ | $query = Order::searchQuery($paramsSearch, [ | ||||
'ignore_id_producer' => true, | 'ignore_id_producer' => true, | ||||
'orderby' => 'distribution.date DESC' | |||||
'orderby' => isset($params['order_by']) ? $params['order_by'] : 'distribution.date DESC' | |||||
]); | ]); | ||||
$dataProvider = new ActiveDataProvider([ | $dataProvider = new ActiveDataProvider([ |