guild/backend/modules/questionnaire/views/user-response/index.php
2021-11-12 14:30:01 +03:00

67 lines
2.1 KiB
PHP

<?php
use backend\modules\questionnaire\models\Question;
use backend\modules\questionnaire\models\UserQuestionnaire;
use common\helpers\AnswerHelper;
use common\models\User;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\questionnaire\models\UserResponseSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Ответы пользователей';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-response-index">
<p>
<?= Html::a('Новый ответ пользователя', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?php
//echo $this->render('_search_by_questionnaire', [
// 'model' => $searchModel,
// ])
?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'user_id',
'filter' => User::find()->select(['username', 'id'])->indexBy('id')->column(),
'value' => 'user.username',
],
[
'attribute' => 'question_id',
'filter' => Question::find()->select(['question_body', 'id'])->indexBy('id')->column(),
'value' => 'question.question_body',
],
'response_body',
'created_at',
'updated_at',
[
'attribute' =>'answer_flag',
'format' => 'raw',
'filter' => AnswerHelper::answerFlagsList(),
'value' => function ($model) {
return AnswerHelper::answerStatusLabel($model->answer_flag);
},
],
[
'attribute' => 'user_questionnaire_uuid',
'filter' => UserQuestionnaire::find()->select(['uuid', 'id'])->indexBy('id')->column(),
'value' => 'questionnaire.title',
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>