|
|
@@ -38,13 +38,6 @@ |
|
|
|
|
|
|
|
namespace backend\controllers; |
|
|
|
|
|
|
|
use common\helpers\Alwaysdata; |
|
|
|
use common\helpers\GlobalParam; |
|
|
|
use common\logic\Distribution\Distribution\Model\Distribution; |
|
|
|
use common\logic\Order\Order\Model\Order; |
|
|
|
use common\logic\PointSale\PointSale\Model\PointSale; |
|
|
|
use common\logic\Product\Product\Model\Product; |
|
|
|
use common\logic\Product\Product\Wrapper\ProductContainer; |
|
|
|
use common\logic\User\User\Model\User; |
|
|
|
use Yii; |
|
|
|
use yii\filters\AccessControl; |
|
|
@@ -70,7 +63,7 @@ class SiteController extends BackendController |
|
|
|
'allow' => true, |
|
|
|
], |
|
|
|
[ |
|
|
|
'actions' => ['logout', 'index'], |
|
|
|
'actions' => ['logout'], |
|
|
|
'allow' => true, |
|
|
|
'roles' => ['@'], |
|
|
|
'matchCallback' => function ($rule, $action) { |
|
|
@@ -78,7 +71,7 @@ class SiteController extends BackendController |
|
|
|
} |
|
|
|
], |
|
|
|
[ |
|
|
|
'actions' => ['change-producer'], |
|
|
|
'actions' => ['switch-producer'], |
|
|
|
'allow' => true, |
|
|
|
'roles' => ['@'], |
|
|
|
'matchCallback' => function ($rule, $action) { |
|
|
@@ -140,10 +133,18 @@ class SiteController extends BackendController |
|
|
|
* Change le producteur courant de l'utilisateur connecté. |
|
|
|
* Permet de passer d'un producteur à un autre en tant qu'administrateur. |
|
|
|
*/ |
|
|
|
public function actionChangeProducer(int $id) |
|
|
|
public function actionSwitchProducer(int $id) |
|
|
|
{ |
|
|
|
Yii::$app->user->identity->id_producer = $id; |
|
|
|
Yii::$app->user->identity->save(); |
|
|
|
$user = $this->getUserCurrent(); |
|
|
|
$producer = $this->getProducerContainer()->getRepository()->findOneProducerById($id); |
|
|
|
|
|
|
|
if($producer) { |
|
|
|
$this->getUserContainer()->getBuilder()->switchProducer($user, $producer); |
|
|
|
} |
|
|
|
else { |
|
|
|
$this->addFlash('error', 'Producteur introuvable.'); |
|
|
|
} |
|
|
|
|
|
|
|
$this->redirect(['dashboard/index']); |
|
|
|
} |
|
|
|
} |