Browse Source

[Backend] Utilisateur : retour à la liste après modification #1145

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
70c02d2181
2 changed files with 12 additions and 11 deletions
  1. +8
    -11
      backend/controllers/UserController.php
  2. +4
    -0
      backend/views/user/_form.php

+ 8
- 11
backend/controllers/UserController.php View File

@@ -51,10 +51,12 @@ use common\logic\User\User\Model\User;
use common\logic\User\User\Model\UserSearch;
use common\logic\User\UserProducer\Model\UserProducer;
use common\logic\User\UserUserGroup\Model\UserUserGroup;
use Faker\Provider\HtmlLorem;
use yii\base\UserException;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use \Yii;
use yii\helpers\Html;
use yii\web\NotFoundHttpException;

/**
@@ -130,8 +132,6 @@ class UserController extends BackendController
$userProducerManager = $this->getUserProducerManager();
$userGroupManager = $this->getUserGroupManager();

$producerCurrent = $this->getProducerCurrent();

if ($model->id) {
$userPointSaleArray = $userPointSaleManager->findUserPointSalesByUser($model);
if ($userPointSaleArray && count($userPointSaleArray) > 0) {
@@ -178,7 +178,6 @@ class UserController extends BackendController
{
$userManager = $this->getUserManager();
$producerManager = $this->getProducerManager();
$pointSaleManager = $this->getPointSaleManager();

$producerCurrent = $this->getProducerCurrent();
$model = $userManager->instanciateUser();
@@ -232,10 +231,6 @@ class UserController extends BackendController

}

/**
* Updates an existing User model.
* If update is successful, the browser will be redirected to the 'view' page.
*/
public function actionUpdate($id)
{
$userManager = $this->getUserManager();
@@ -262,7 +257,9 @@ class UserController extends BackendController
$this->processLinkUserGroup($model);
$this->processProductPricePercent($model);

$this->setFlash('success', 'Utilisateur modifié.');
$this->setFlash('success', 'Utilisateur <strong>'.Html::encode($userManager->getUsername($model)).'</strong> modifié.');

return $this->redirect(['index']);
}
} else {
throw new UserException("Vous ne pouvez pas modifier cet utilisateur.");
@@ -292,7 +289,9 @@ class UserController extends BackendController
]
]);

$this->setFlash('success', 'Nouveau mot de passe envoyé.');
$this->setFlash('success', 'Nouveau mot de passe envoyé à <strong>'.Html::encode($userManager->getUsername($model)).'</strong>.');

return $this->redirect(['index']);
}

return $this->render('update', array_merge($this->initForm($model), [
@@ -376,7 +375,6 @@ class UserController extends BackendController
$userProducerManager = $this->getUserProducerManager();

$user = $userManager->findOneUserById($id);
$producer = $this->getProducerCurrent();
$userProducer = $userProducerManager->findOneUserProducer($user);

if ($userProducer) {
@@ -554,7 +552,6 @@ class UserController extends BackendController
$userProducerManager = $this->getUserProducerManager();

$user = $userManager->findOneUserById($idUser);
$producerCurrent = $this->getproducerCurrent();
$userProducer = $userProducerManager->findOneUserProducer($user);

if ($userProducer) {

+ 4
- 0
backend/views/user/_form.php View File

@@ -69,6 +69,7 @@ $producerManager = $this->getProducerManager();
<?= $form->field($model, 'evoliz_code')->textInput() ?>
<?php endif; ?>

<?php if($pointsSaleArray && count($pointsSaleArray) > 0): ?>
<?= $form->field($model, 'points_sale')->checkboxlist(
ArrayHelper::map($pointsSaleArray, 'id', function ($pointSale) use ($model) {
$commentUserPointSale = isset($pointSale->userPointSale[0]) ? $pointSale->userPointSale[0]->comment : '';
@@ -81,7 +82,9 @@ $producerManager = $this->getProducerManager();
'encode' => false
]);
?>
<?php endif; ?>

<?php if($userGroupsArray && count($userGroupsArray) > 0): ?>
<?= $form->field($model, 'user_groups')->checkboxlist(
ArrayHelper::map($userGroupsArray, 'id', function ($userGroup) use ($model) {
return Html::encode($userGroup->name);
@@ -89,6 +92,7 @@ $producerManager = $this->getProducerManager();
'encode' => false
]);
?>
<?php endif; ?>

<?php /* $form->field($model, 'product_price_percent')
->dropDownList( ProductPrice::percentValues(), [])->hint('Pourcentage appliqué aux prix de chaque produit pour cet utilisateur.');*/ ?>

Loading…
Cancel
Save