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

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
?>
<div class="trigger-trigger-index">

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

    <p>
        <?= Html::a('Добавить шаблон', ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',
            'name',
            'subject',
            [
                'attribute' => 'template',
                'format' => 'html',
                'options' => [
                    'style' => 'width: 200px;'
                ]
            ],
            'created_at:datetime',
            [
                'class' => 'yii\grid\ActionColumn',
                'template' => '{double}{update}{delete}',
                'buttons' => [
                    'double' => function($url, $model) {
                            $url = \yii\helpers\Url::toRoute(['/message-template/template-admin/copy', 'id' => $model->id]);
                            return \yii\helpers\Html::a('<span class="glyphicon"><img src="/img/copy.png"></span>', $url, ['title' => 'Сделать дубликат']);
                        }
                ]
            ],
        ],
    ]); ?>
</div>