<?php

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

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

$this->title = Yii::t('backend/key', 'Keys');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="key-index">	

    <h1><?= Html::encode($this->title) ?></h1>
    <?php echo $this->render('_search', ['model' => $searchModel]); /* ezt megcsinálni hogy csak numberre lehessen     itt a fitness-web/backend/views/key/_search.php töltődik be    */?>

    <p>
        <?php 
           // Új kulcs gomb kigenerálása a Yii::t('backend/key'  a fitness-web/common/messages/hu/backend/key.php-ba lesz (miután létrehoztam)
           echo Html::a(Yii::t('backend/key', 'Create Key'), ['create'], ['class' => 'btn btn-success']);
         ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        //'filterModel' => $searchModel, // ezt nem szeretjük
        'columns' => [
           // ['class' => 'yii\grid\SerialColumn'],
           // 'id_key',
            'number',
            'rfid_key',
            [
				  'attribute' => 'status',
				  'value' => function ($model, $key, $index, $column){
					$statuszok = Key::statuses();
					$result = $statuszok[$model->status];
					return $result;
				}
			  ],
            //'status',
            [
            		'attribute' =>'type',
            		'value' =>'humanType'
            		
			 ],
            'created_at',
            // 'updated_at',

            [
				'class' => 'yii\grid\ActionColumn',
				'template' => '{view} {update}',
			],
        ],
    ]); ?>

</div>
