|
- <?php
-
- use yii\helpers\Html;
- use yii\grid\GridView;
- use common\models\User ;
-
- /* @var $this yii\web\View */
- /* @var $dataProvider yii\data\ActiveDataProvider */
-
- $this->title = 'Utilisateurs';
- $this->params['breadcrumbs'][] = $this->title;
- ?>
- <div class="user-index">
-
- <h1>
- <?= Html::encode($this->title) ?>
- <?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-primary']) ?>
- <?= Html::a('<span class="glyphicon glyphicon-envelope"></span> Liste des emails', ['mail'], ['class' => 'btn btn-default']) ?>
- </h1>
-
- <?= GridView::widget([
- 'dataProvider' => $dataProvider,
- 'columns' => [
- 'nom',
- 'prenom',
- 'telephone',
- 'email',
- [
- 'attribute' => 'credit',
- 'format' => 'raw',
- 'value' => function($model) use($etablissement) {
- $html = '<div class="input-group">
- <input type="text" class="form-control input-credit" readonly="readonly" value="'.number_format($model['credit'],2).' €" placeholder="">
- <span class="input-group-btn">
- '.Html::a(
- '<span class="glyphicon glyphicon-euro"></span> Crédit',
- Yii::$app->urlManager->createUrl(['user/credit','id' => $model['id']]),
- [
- 'title' => 'Crédit',
- 'class' => 'btn btn-default'
- ]
- ).'
- </span>
- </div>' ;
- return $html ;
- }
- ],
- [
- 'class' => 'yii\grid\ActionColumn',
- 'template' => '{update}',
- 'headerOptions' => ['class' => 'actions'],
- 'buttons' => [
- 'update' => function ($url, $model) {
- $url = Yii::$app->urlManager->createUrl(['user/update','id' => $model['id']]) ;
- $user = User::find()->with('userEtablissement')->where(['id' => $model['id']])->one() ;
- if(count($user->userEtablissement) <= 1)
- {
- return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
- 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
- ]);
- }
- else {
- return '<span data-toggle="tooltip" data-placement="top" title="Vous ne pouvez pas modifier les utilisateurs qui appartiennent à plusieurs boulangeries."><span class="glyphicon glyphicon-remove-sign"></span> Non modifiable</span>' ;
- }
- },
- ],
- ],
- ],
- ]); ?>
-
- </div>
|