<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\models\Newsletter;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\NewsletterSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('common/newsletter', 'Hírlevelek');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="newsletter-index">

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

    <p>
        <?= Html::a(Yii::t('common/newsletter', 'Új hírlevél'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [

            'id_newsletter',
            'subject',
			[
				'attribute' => 'status',
				'value' => 'statusName'
    		],
			[
				'attribute' => 'sent',
				'value' => 'sentName'
    		],
            'sent_at:datetime',
            'created_at:datetime',
            // 'updated_at',
        		
            ['class' => 'yii\grid\ActionColumn',
            		'buttons' =>[
            				'update' => function ($url, $model, $key) {
            					return $model->sent ===  Newsletter::$SENT_NOT
            				? Html::a('Módosít', $url,['class' => 'btn btn-xs btn-success']) : '';
            				},
            				'view' => function ($url, $model, $key) {
            					return   Html::a('Részletek', $url,['class' => 'btn btn-xs btn-success']) ;
            				},
            				'delete' => function ($url, $model, $key) {
            					return $model->sent ===  Newsletter::$SENT_NOT ? Html::a('Törlés', $url,['class' => 'btn btn-xs btn-success']) : '';
            				},
            				],
            		
    		],
        ],
    ]); ?>

</div>
