<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
use frontend\components\CustomerTabWidget;

/* @var $this yii\web\View */
/* @var $searchModel frontend\models\KeySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('frontend/key', 'Vendéghez rendelt kulcsok');
$this->params['breadcrumbs'][] = $this->title;
?>

<?php echo CustomerTabWidget::widget(['card' => $searchModel->card])?>

<div class="key-index">

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

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
        	[
            'attribute' =>	'key_number',
        	'label' => 'Kulcs'
        			
        	],
        	[
            'attribute' =>	'assign_created_at',
        	'label' => 'Kiadás dátuma',
        	'format' => 'datetime'
        			
        	],
        	[
            'attribute' =>	'user_username',
        	'label' => 'Felhasználó',
        	],

            ['class' => 'yii\grid\ActionColumn',
             'template' => '{delete}',
             'buttons' => [
             		'delete' =>  function ($url, $model, $key) {
		               return   Html::a('Visszaad', $url, ['class'=> 'btn btn-xs btn-danger','data-method' => 'post' ])  ;
		           },
			],
           'urlCreator' => function ($action, $model, $key, $index){
           		$url = "";
           		if ( 'delete' == $action ){
           			$url = Url::to(['key/delete','id_key' => $model['key_id_key']]);
           		} 
           		return $url;
           }		
            		
    ],
        ],
    ]); ?>

</div>
