@@ -571,4 +571,22 @@ class UserController extends BackendController | |||
'usersPointSaleHasOrder' => $usersPointSaleHasOrder, | |||
]); | |||
} | |||
public function actionSwitchIdentity(int $id) | |||
{ | |||
$userManager = $this->getUserManager(); | |||
if($this->isUserCurrentAdmin()) { | |||
$initialId = Yii::$app->user->getId(); | |||
if($initialId != $id) { | |||
$user = $userManager->findOneUserById($id); | |||
$duration = 0; | |||
Yii::$app->user->switchIdentity($user, $duration); | |||
Yii::$app->session->set('user.idbeforeswitch',$initialId); | |||
return $this->redirect(['index']); | |||
} | |||
} | |||
else { | |||
throw new NotFoundHttpException('Page introuvable'); | |||
} | |||
} | |||
} |
@@ -181,7 +181,7 @@ $this->render('_menu', [ | |||
], | |||
[ | |||
'class' => 'yii\grid\ActionColumn', | |||
'template' => '{update} {delete}', | |||
'template' => '{update} {delete} {switch}', | |||
'headerOptions' => ['class' => 'column-actions'], | |||
'contentOptions' => ['class' => 'column-actions'], | |||
'buttons' => [ | |||
@@ -196,6 +196,14 @@ $this->render('_menu', [ | |||
return Html::a('<span class="glyphicon glyphicon-trash"></span>', Yii::$app->urlManager->createUrl(array_merge(['user/delete', 'id' => $model->id], Yii::$app->getRequest()->getQueryParams())), [ | |||
'title' => 'Supprimer', 'class' => 'btn btn-default btn-confirm-delete' | |||
]); | |||
}, | |||
'switch' => function($url, $model) { | |||
$userManager = UserManager::getInstance(); | |||
if($userManager->isCurrentAdmin()) { | |||
return Html::a('<span class="glyphicon glyphicon-user"></span>', Yii::$app->urlManager->createUrl(['user/switch-identity', 'id' => $model->id]), [ | |||
'title' => 'Prendre la main', 'class' => 'btn btn-default' | |||
]); | |||
} | |||
} | |||
], | |||
], |
@@ -142,11 +142,13 @@ class OrderRepository extends AbstractRepository | |||
{ | |||
$queryIncoming = clone $this->createDefaultQuery() | |||
->filterByUser($user) | |||
->filterIsIncoming(); | |||
->filterIsIncoming() | |||
->orderByDistributionDate('ASC'); | |||
$queryPassed = clone $this->createDefaultQuery() | |||
->filterByUser($user) | |||
->filterIsPassed(); | |||
->filterIsPassed() | |||
->orderByDistributionDate('DESC'); | |||
return [ | |||
'incoming' => $queryIncoming, |
@@ -100,7 +100,7 @@ class OrderRepositoryQuery extends AbstractRepositoryQuery | |||
public function orderByDistributionDate(string $order = 'ASC'): self | |||
{ | |||
$this->orderBy(['distribution.date' => $order]); | |||
$this->orderBy('distribution.date '.$order ); | |||
return $this; | |||
} |