<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\components\RoleDefinition;

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

$this->title = Yii::t('common/ticket_type', 'Ticket Types');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="ticket-type-index">

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

    <?php if ( RoleDefinition::isAdmin()) {?>
    <p>
        <?= Html::a(Yii::t('common/ticket_type', 'Create Ticket Type'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?php  }?>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            'name',
            'price_brutto',
            'max_usage_count',
            'time_unit_count',
			[
	
            	'attribute' =>'time_unit_type',
            	'value' =>'timeUnitHuman',
			],
            [
    			'attribute' =>	'id_account',
    			'value' =>	'accountName',
			],
			[
				'attribute' =>'flag_student',
				'value' =>function($model, $key, $index, $column){
					return $model->isStudent() ? Yii::t('common', "Yes") : Yii::t('common', "No")  ;
				},

			],
			[
            	'attribute' =>'status',
            	'value' =>'statusHuman',
				],
            'created_at:datetime',
            'updated_at:datetime',

            [
            	'class' => 'yii\grid\ActionColumn',
            	'template' => RoleDefinition::getRoleTemplate( ['admin' =>  '{view} {update}','employee' => '{view}' , 'reception' => '{view}']),
            		
    		],
        ],
    ]); ?>

</div>
