Browse Source

[Espace producteur] Mes commandes : correctif ordre des commandes

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
abd2952ac8
4 changed files with 32 additions and 4 deletions
  1. +18
    -0
      backend/controllers/UserController.php
  2. +9
    -1
      backend/views/user/index.php
  3. +4
    -2
      common/logic/Order/Order/Repository/OrderRepository.php
  4. +1
    -1
      common/logic/Order/Order/Repository/OrderRepositoryQuery.php

+ 18
- 0
backend/controllers/UserController.php View File

'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');
}
}
} }

+ 9
- 1
backend/views/user/index.php View File

], ],
[ [
'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'
]);
}
} }
], ],
], ],

+ 4
- 2
common/logic/Order/Order/Repository/OrderRepository.php View File

{ {
$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,

+ 1
- 1
common/logic/Order/Order/Repository/OrderRepositoryQuery.php View File



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;
} }

Loading…
Cancel
Save