<?php
use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
/** @var $model common\modules\triggers\models\CasesSchedule */
?>
<div class="trigger-trigger-index">

    <h1><?= Html::encode($this->title) ?></h1>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',
            [
                'attribute' => 'actual',
                'value' => function($model) {
                        return ($model->actual==1) ? 'Активен' : 'Не активен';
                    }
            ],
            [
                'attribute' => 'sended',
                'value' => function($model) {
                        return ($model->sended==1) ? 'Отправлено' : 'Не отправлено';
                    }
            ],
            [
                'attribute' => 'user_id',
                'value' => function($model) {
                        return $model->user->getFio();
                    }
            ],
            [
                'attribute' => 'case_id',
                'value' => function($model) {
                        /** @var $model common\modules\triggers\models\CasesSchedule */
                        return $model->case->url;
                    }
            ],
            [
                'attribute' => 'template_id',
                'value' => function($model) {
                        /** @var $model common\modules\triggers\models\CasesSchedule */
                        return $model->template->name;
                    }
            ],
            [
                'attribute' => 'sended_date',
                'value' => function($model) {
                        /** @var $model common\modules\triggers\models\CasesSchedule */
                        return (!is_null($model->sended_date)) ? date('Y.m.d H:i:s', strtotime($model->sended_date)) : 'Не отправлено';
                    }
            ],
//            [
//                'class' => 'yii\grid\ActionColumn',
//                'template' => '{update}{delete}',
//            ],
        ],
    ]); ?>
</div>