<?php

use yii\grid\GridView;
use yii\helpers\Html;

/* @var $searchModel backend\models\search\PolicySearch */
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $cengciList [] */

$this->title = '政策列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<?php $this->beginBlock('content-header'); ?>
<?= $this->title . ' ' . Html::a(Yii::t('common', '新增政策'), ['create'], ['class' => 'btn btn-success']) ?>
<?php $this->endBlock(); ?>
<?php echo $this->render('_search', ['model' => $searchModel, 'cengciList' => $cengciList]); ?>
<div class="box box-success">
    <div class="box-body">
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            'id',
            'title',
            [
                'attribute' => 'type',
                'value' => function ($model) {
                    /* @var  $model \common\models\Policy */
                    return $model->getTypeText();
                },
            ],
            [
                'attribute' => 'estate',
                'value' => function ($model) {
                    /* @var  $model \common\models\Policy */
                    if ($model->estate) {
                        return \common\enums\PolicyEnum::$list[$model->estate];
                    } else {
                        return '';
                    }
                },
            ],
            'cengci',
            'author',
            [
                'class' => 'backend\widgets\grid\PositionColumn',
                'attribute' => 'sort'
            ],
            'created_at:datetime',
            ['class' => 'common\helpers\DiyActionColumn'],
        ],
    ]); ?>
    </div>
</div>
