|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace backend\controllers; |
|
|
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 common\logic\User\User\Model\User; |
|
|
use Yii; |
|
|
use Yii; |
|
|
use yii\filters\AccessControl; |
|
|
use yii\filters\AccessControl; |
|
|
|
|
|
|
|
|
'allow' => true, |
|
|
'allow' => true, |
|
|
], |
|
|
], |
|
|
[ |
|
|
[ |
|
|
'actions' => ['logout', 'index'], |
|
|
|
|
|
|
|
|
'actions' => ['logout'], |
|
|
'allow' => true, |
|
|
'allow' => true, |
|
|
'roles' => ['@'], |
|
|
'roles' => ['@'], |
|
|
'matchCallback' => function ($rule, $action) { |
|
|
'matchCallback' => function ($rule, $action) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
], |
|
|
], |
|
|
[ |
|
|
[ |
|
|
'actions' => ['change-producer'], |
|
|
|
|
|
|
|
|
'actions' => ['switch-producer'], |
|
|
'allow' => true, |
|
|
'allow' => true, |
|
|
'roles' => ['@'], |
|
|
'roles' => ['@'], |
|
|
'matchCallback' => function ($rule, $action) { |
|
|
'matchCallback' => function ($rule, $action) { |
|
|
|
|
|
|
|
|
* Change le producteur courant de l'utilisateur connecté. |
|
|
* Change le producteur courant de l'utilisateur connecté. |
|
|
* Permet de passer d'un producteur à un autre en tant qu'administrateur. |
|
|
* 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']); |
|
|
$this->redirect(['dashboard/index']); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |