|
- <?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) {
- $html = $model['credit'].' € ' ;
-
- $html = '<div class="input-group">
- <input type="text" class="form-control input-credit" readonly="readonly" value="'.$model['credit'].' €" 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>' ;
-
- /*$html = '<div class="btn-group" role="group" aria-label="">
- <input type="text" readonly="readonly" class="btn btn-default">'.$model['credit'].' € </button>
- '.Html::a(
- '<span class="glyphicon glyphicon-euro"></span> Créditer',
- Yii::$app->urlManager->createUrl(['user/credit','id' => $model['id']]),
- [
- 'title' => 'Créditer',
- 'class' => 'btn btn-default'
- ]
- ).'
- </div>' ;*/
-
- /*$html .= Html::a(
- '<span class="glyphicon glyphicon-euro"></span> Créditer',
- Yii::$app->urlManager->createUrl(['user/credit','id' => $model['id']]),
- [
- 'title' => 'Créditer',
- 'class' => 'btn btn-default btn-xs'
- ]
- ) ;*/
-
- 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>
|