'usersPointSaleHasOrder' => $usersPointSaleHasOrder, | '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'); | |||||
} | |||||
} | |||||
} | } |
], | ], | ||||
[ | [ | ||||
'class' => 'yii\grid\ActionColumn', | 'class' => 'yii\grid\ActionColumn', | ||||
'template' => '{update} {delete}', | |||||
'template' => '{update} {delete} {switch}', | |||||
'headerOptions' => ['class' => 'column-actions'], | 'headerOptions' => ['class' => 'column-actions'], | ||||
'contentOptions' => ['class' => 'column-actions'], | 'contentOptions' => ['class' => 'column-actions'], | ||||
'buttons' => [ | 'buttons' => [ | ||||
return Html::a('<span class="glyphicon glyphicon-trash"></span>', Yii::$app->urlManager->createUrl(array_merge(['user/delete', 'id' => $model->id], Yii::$app->getRequest()->getQueryParams())), [ | 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' | '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' | |||||
]); | |||||
} | |||||
} | } | ||||
], | ], | ||||
], | ], |
{ | { | ||||
$queryIncoming = clone $this->createDefaultQuery() | $queryIncoming = clone $this->createDefaultQuery() | ||||
->filterByUser($user) | ->filterByUser($user) | ||||
->filterIsIncoming(); | |||||
->filterIsIncoming() | |||||
->orderByDistributionDate('ASC'); | |||||
$queryPassed = clone $this->createDefaultQuery() | $queryPassed = clone $this->createDefaultQuery() | ||||
->filterByUser($user) | ->filterByUser($user) | ||||
->filterIsPassed(); | |||||
->filterIsPassed() | |||||
->orderByDistributionDate('DESC'); | |||||
return [ | return [ | ||||
'incoming' => $queryIncoming, | 'incoming' => $queryIncoming, |
public function orderByDistributionDate(string $order = 'ASC'): self | public function orderByDistributionDate(string $order = 'ASC'): self | ||||
{ | { | ||||
$this->orderBy(['distribution.date' => $order]); | |||||
$this->orderBy('distribution.date '.$order ); | |||||
return $this; | return $this; | ||||
} | } |