<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\components\Helper;
use common\models\DoorLog;
use common\models\Card;

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

$this->title = Yii::t('common/door_log', 'Kártya események');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="door-log-index">

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


    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
    		[ 
    			'attribute' => 'door_log_created_at',
    			'label' => "Időpont",
    			'value' => 'door_log_created_at',
    			'format' => 'datetime'
    		],
			[
				'attribute' => 'card_number',
				'label' => 'Kártya szám'
    		],
			[
				'attribute' => 'door_log_type',
				'label' => 'Kártya típus',
				'value' => function ($model, $key, $index, $column){
					return Helper::getArrayValue(Card::types(), $model['door_log_type'], "-");
				}
    		],
			[
				'attribute' => 'key_number',
				'label' => 'Kulcs'
    		],
			[
				'attribute' => 'account_name',
				'label' => 'Kassza'
    		],
			[
				'attribute' => 'customer_id_customer',
				'label' => 'Vendég azon.'
    		],
			[
				'attribute' => 'customer_name',
				'label' => 'Vendég'
    		],
			[
				'attribute' => 'door_log_direction',
				'label' => 'Esemény',
				'value' => function ($model, $key, $index, $column){
					return  Helper::getArrayValue(DoorLog::getDirectionTypes(),  $model['door_log_direction'],"-" );
			    }
    		],
			[
				'attribute' => 'door_log_card_flag',
				'label' => 'Info',
				'value' => function ($model, $key, $index, $column){
					return  Helper::getArrayValue(DoorLog::getCardFlagTexts(),  $model['door_log_card_flag'],"-" );
			    }
    		],
			[
				'attribute' => 'door_log_source_app',
				'label' => 'Forrás alkalmazás',
				'value' => function ($model, $key, $index, $column){
					return DoorLog::getSourceAppName($model['door_log_source_app']);	
    			}
    		],
        		/*
            // 'type',
				*/
        ],
    ]); ?>

</div>
