<div class="user-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Добавить пользователя', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'id', 'headerOptions' => ['class' => 'col-md-1']], ['attribute' => 'username', 'format' => 'raw', 'value' => function ($model) { return Html::a($model->username, 'user/view?id=' . $model->id, ['target' => '_blank']); }], 'name', ['attribute' => 'status', 'format' => 'raw', 'value' => function ($model) { if ($model->status == 10) { $class = 'text-success'; } else { $class = 'text-danger'; } return '<span class="' . $class . '">' . User::getStatusName($model->status) . '</span>'; }], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
?> </h1> <p> <?php echo Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a('Delete', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]); ?> <?php if (Yii::$app->user->can('admin')) { echo Html::a('Изменить пароль', ['password-change', 'id' => $model->id], ['class' => 'btn btn-primary']); } ?> </p> <?php $status = User::getStatusName($model->status); echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'username', 'name', 'email:email', ['attribute' => 'status', 'format' => 'raw', 'value' => $model->status == 10 ? '<span class="label label-success">' . $status . '</span>' : '<span class="label label-danger">' . $status . '</span>'], ['attribute' => 'created_at', 'value' => date('d-M-Y H:i:s', $model->created_at)], ['attribute' => 'updated_at', 'value' => date('d-M-Y H:i:s', $model->updated_at)]]]); echo Html::tag('p', 'Назначенные роли'); $auth = AuthAssignment::findAll(['user_id' => $model->id]); $assignment = []; foreach ($auth as $item) { $assignment[] = $item->item_name; } echo Html::listBox('roles', null, $assignment); ?> </div>