<?php

use yii\helpers\Html;
use yii\grid\GridView;
use dosamigos\datepicker\DatePicker;

$this->title = Yii::t('app', 'Holidays');
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="holidays-index">

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

    <p>
        <?= Html::a(Yii::t('app', 'Create Holiday'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            [
                'attribute' => 'name',
                'headerOptions' => ['style' => 'width: 45%;'],
            ],
            [
                'attribute' => 'date',
                'headerOptions' => ['style' => 'width: 45%;'],
                'format' => 'raw',
                'filter' => DatePicker::widget([
                    'name' => 'Holidays[date]',
                    'model' => $searchModel,
                    'attribute' => 'date',
                    'language' => Yii::$app->language,
                    'clientOptions' => [
                        'autoclose' => true,
                        'format' => 'yyyy-mm-dd',
                        'todayHighlight' => true,
                        'todayBtn' => 'linked',
                    ]
                ]),
            ],
            [
                'class' => 'yii\grid\ActionColumn',
                'headerOptions' => ['style' => 'width: 10%;'],
                'buttons' => [
                    'delete' => function($url, $model){
                        return Html::a('<span class="glyphicon glyphicon-trash"></span>', 
                            ['delete', 'id' => $model->id],
                            [
                                'data' => [
                                    'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
                                    'method' => 'POST'
                                ],
                                'title' => Yii::t('app', 'Delete'),
                            ]);
                    }
                ]
            ],
        ],
    ]); ?>
</div>
