return $this->redirect('index'); | return $this->redirect('index'); | ||||
} | } | ||||
public function actionRedirectView(int $idUserProducer) | |||||
public function actionRedirectUpdate(int $idUserProducer) | |||||
{ | { | ||||
$userCurrent = $this->getUserCurrent(); | $userCurrent = $this->getUserCurrent(); | ||||
$userProducer = $this->getUserProducerModule()->getRepository()->findOneUserProducerById($idUserProducer); | $userProducer = $this->getUserProducerModule()->getRepository()->findOneUserProducerById($idUserProducer); | ||||
$user = $userProducer->user; | $user = $userProducer->user; | ||||
$producer = $userProducer->producer; | $producer = $userProducer->producer; | ||||
$this->getUserModule()->getBuilder()->switchProducer($userCurrent, $producer); | $this->getUserModule()->getBuilder()->switchProducer($userCurrent, $producer); | ||||
return $this->redirect(['user/view', 'id' => $user->id]); | |||||
return $this->redirect(['user/update', 'id' => $user->id]); | |||||
} | } | ||||
else { | else { | ||||
$this->addFlash('error', "L'utilisateur n'a pas été trouvé."); | $this->addFlash('error', "L'utilisateur n'a pas été trouvé."); |
], | ], | ||||
[ | [ | ||||
'attribute' => 'producers', | 'attribute' => 'producers', | ||||
'label' => 'Producteurs', | |||||
'label' => 'Profils', | |||||
'format' => 'raw', | 'format' => 'raw', | ||||
'contentOptions' => ['class' => 'column-hide-on-mobile align-center'], | 'contentOptions' => ['class' => 'column-hide-on-mobile align-center'], | ||||
'value' => function ($user) use ($userProducerModule) { | 'value' => function ($user) use ($userProducerModule) { | ||||
$userProducersArray = $userProducerModule->getRepository()->findUserProducersByUser($user); | $userProducersArray = $userProducerModule->getRepository()->findUserProducersByUser($user); | ||||
foreach($userProducersArray as $userProducer) { | foreach($userProducersArray as $userProducer) { | ||||
$html .= '<a href="'.Yii::$app->urlManager->createUrl(['user-admin/redirect-view', 'idUserProducer' => $userProducer->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-eye-open"></span> '.$userProducer->producer->name.'</a> '; | |||||
$html .= '<a href="'.Yii::$app->urlManager->createUrl(['user-admin/redirect-update', 'idUserProducer' => $userProducer->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-user"></span> '.$userProducer->producer->name.'</a> '; | |||||
} | } | ||||
return $html; | return $html; |
], | ], | ||||
[ | [ | ||||
'attribute' => 'producers', | 'attribute' => 'producers', | ||||
'label' => 'Producteurs', | |||||
'label' => 'Profils', | |||||
'format' => 'raw', | 'format' => 'raw', | ||||
'contentOptions' => ['class' => 'column-hide-on-mobile align-center'], | 'contentOptions' => ['class' => 'column-hide-on-mobile align-center'], | ||||
'value' => function ($user) use ($userProducerModule) { | 'value' => function ($user) use ($userProducerModule) { | ||||
$userProducersArray = $userProducerModule->getRepository()->findUserProducersByUser($user); | $userProducersArray = $userProducerModule->getRepository()->findUserProducersByUser($user); | ||||
foreach($userProducersArray as $userProducer) { | foreach($userProducersArray as $userProducer) { | ||||
$html .= '<a href="'.Yii::$app->urlManager->createUrl(['user-admin/redirect-view', 'idUserProducer' => $userProducer->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-eye-open"></span> '.$userProducer->producer->name.'</a> '; | |||||
$html .= '<a href="'.Yii::$app->urlManager->createUrl(['user-admin/redirect-update', 'idUserProducer' => $userProducer->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-user"></span> '.$userProducer->producer->name.'</a> '; | |||||
} | } | ||||
return $html; | return $html; |