|
|
@@ -36,14 +36,12 @@ |
|
|
|
* termes. |
|
|
|
*/ |
|
|
|
|
|
|
|
use common\components\PageSizer; |
|
|
|
use common\logic\Producer\Producer\Wrapper\ProducerManager; |
|
|
|
use yii\helpers\Html; |
|
|
|
use yii\grid\GridView; |
|
|
|
use common\logic\User\User\Wrapper\UserModule; |
|
|
|
use common\logic\Order\Order\Model\Order; |
|
|
|
use common\logic\User\UserProducer\Model\UserProducer; |
|
|
|
use common\logic\User\User\Model\User; |
|
|
|
|
|
|
|
$userModule = UserModule::getInstance(); |
|
|
|
$producerManager = ProducerManager::getInstance(); |
|
|
@@ -75,9 +73,8 @@ $this->render('_menu', [ |
|
|
|
[ |
|
|
|
'attribute' => 'username', |
|
|
|
'label' => 'Nom', |
|
|
|
'value' => function ($model) { |
|
|
|
$userModule = UserModule::getInstance(); |
|
|
|
return $userModule->getUsername($model); |
|
|
|
'value' => function ($user) use ($userModule) { |
|
|
|
return $userModule->getUsername($user); |
|
|
|
} |
|
|
|
], |
|
|
|
[ |
|
|
@@ -87,13 +84,8 @@ $this->render('_menu', [ |
|
|
|
'filterOptions' => ['class' => 'column-hide-on-mobile'], |
|
|
|
'contentOptions' => ['class' => 'column-hide-on-mobile'], |
|
|
|
'filter' => $userModule->getTypeChoicesArray(), |
|
|
|
'value' => function ($model) { |
|
|
|
$userModule = UserModule::getInstance(); |
|
|
|
$typeArray = $userModule->getTypeChoicesArray(); |
|
|
|
if(isset($typeArray[$model['type']])) { |
|
|
|
return $typeArray[$model['type']]; |
|
|
|
} |
|
|
|
return ''; |
|
|
|
'value' => function ($user) use ($userModule) { |
|
|
|
return $userModule->getTypeLabel($user['type']); |
|
|
|
} |
|
|
|
], |
|
|
|
[ |
|
|
@@ -103,16 +95,16 @@ $this->render('_menu', [ |
|
|
|
'headerOptions' => ['class' => 'column-hide-on-mobile'], |
|
|
|
'filterOptions' => ['class' => 'column-hide-on-mobile'], |
|
|
|
'contentOptions' => ['class' => 'column-hide-on-mobile'], |
|
|
|
'value' => function ($model) { |
|
|
|
'value' => function ($user) { |
|
|
|
$html = ''; |
|
|
|
if (strlen($model['phone'])) { |
|
|
|
$html .= $model['phone']; |
|
|
|
if (strlen($user['phone'])) { |
|
|
|
$html .= $user['phone']; |
|
|
|
} |
|
|
|
if (strlen($model['phone']) && strlen($model['email'])) { |
|
|
|
if (strlen($user['phone']) && strlen($user['email'])) { |
|
|
|
$html .= '<br />'; |
|
|
|
} |
|
|
|
if (strlen($model['email'])) { |
|
|
|
$html .= $model['email']; |
|
|
|
if (strlen($user['email'])) { |
|
|
|
$html .= $user['email']; |
|
|
|
} |
|
|
|
return $html; |
|
|
|
} |
|
|
@@ -124,12 +116,14 @@ $this->render('_menu', [ |
|
|
|
'headerOptions' => ['class' => 'column-hide-on-mobile'], |
|
|
|
'filterOptions' => ['class' => 'column-hide-on-mobile'], |
|
|
|
'contentOptions' => ['class' => 'column-hide-on-mobile'], |
|
|
|
'value' => function ($model) { |
|
|
|
$userModule = UserModule::getInstance(); |
|
|
|
if($userModule->isUserSubscribedNewsletter($model)) { |
|
|
|
'filter' => [ |
|
|
|
0 => 'Non', |
|
|
|
1 => 'Oui' |
|
|
|
], |
|
|
|
'value' => function ($user) use ($userModule) { |
|
|
|
if($userModule->isUserSubscribedNewsletter($user)) { |
|
|
|
return '<span class="label label-success">Oui</span>'; |
|
|
|
} |
|
|
|
|
|
|
|
return '<span class="label label-danger">Non</span>'; |
|
|
|
} |
|
|
|
], |
|
|
@@ -193,24 +187,30 @@ $this->render('_menu', [ |
|
|
|
'headerOptions' => ['class' => 'column-actions'], |
|
|
|
'contentOptions' => ['class' => 'column-actions'], |
|
|
|
'buttons' => [ |
|
|
|
'update' => function ($url, $model) { |
|
|
|
$url = Yii::$app->urlManager->createUrl(['user/update', 'id' => $model->id]); |
|
|
|
$user = User::find()->with('userProducer')->where(['id' => $model->id])->one(); |
|
|
|
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ |
|
|
|
'title' => 'Modifier', 'class' => 'btn btn-default' |
|
|
|
]); |
|
|
|
'update' => function ($url, $user) { |
|
|
|
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', |
|
|
|
Yii::$app->urlManager->createUrl(['user/update', 'id' => $user->id]), |
|
|
|
[ |
|
|
|
'title' => 'Modifier', |
|
|
|
'class' => 'btn btn-default' |
|
|
|
]); |
|
|
|
}, |
|
|
|
'delete' => function ($url, $model) { |
|
|
|
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' |
|
|
|
]); |
|
|
|
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' |
|
|
|
]); |
|
|
|
}, |
|
|
|
'switch' => function($url, $model) { |
|
|
|
$userModule = UserModule::getInstance(); |
|
|
|
'switch' => function($url, $model) use ($userModule) { |
|
|
|
if($userModule->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' |
|
|
|
]); |
|
|
|
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' |
|
|
|
]); |
|
|
|
} |
|
|
|
} |
|
|
|
], |