index.php 2.57 KB
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;
use common\models\Feedback;
use yiister\gentelella\widgets\Panel;
/* @var $this yii\web\View */
/* @var $searchModel common\models\ObjectkbSearchFeedback */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Feedbacks');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="feedback-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a(Yii::t('app', 'Create Feedback'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'rowOptions'   => function (Feedback $model) {
            if ($model->status) {
                return [];
            } else {
                return [
                    'class' => 'success',
                ];
            }
        },
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',
            'topic',
            'name',
            'email:email',
            'phone',
            [
                'attribute' => 'created_at',
                'format'    => [
                    'datetime',
                    'php:d.m.Y H:i',
                ],
            ],
            [
                'class'    => 'yii\grid\ActionColumn',
                'buttons'  => [
                    'viewed' => function (string $url, Feedback $model) {
                        if ($model->status) {
                            return Html::tag(
                                'span',
                                '',
                                [
                                    'class' => 'glyphicon glyphicon-ok',
                                ]
                            );
                        } else {
                            return Html::a(
                                Html::tag(
                                    'span',
                                    '',
                                    [
                                        'class' => 'glyphicon glyphicon-flag',
                                    ]
                                ),
                                $url,
                                [
                                    'class' => 'viewed-toggle',
                                ]
                            );
                        }
                    },
                ],
                'template' => '{viewed} {view} {update} {delete}',
            ],
        ],
    ]); ?>