<?php

use yii\helpers\Html;
use yii\grid\GridView;
use frontend\components\ReceptionMenuWidget;
use frontend\components\ReceptionCardNumberWidget;
use frontend\components\ReceptionWidget;
use yii\base\Widget;
use common\models\Ticket;
use frontend\components\CustomerTabWidget;

/* @var $this yii\web\View */
/* @var $searchModel frontend\models\TicketSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $receptionForm frotned\models\ReceptionForm */

$card = $receptionForm->card;
$customer = $receptionForm->customer;

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


	<?php // echo ReceptionWidget::widget( ['form' => $receptionForm, 'route' => ['customer/reception'] ] )?>


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

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

    <p>
        <?= Html::a(Yii::t('common/ticket', 'Create Ticket'), ['create' ,'number' => $card->number ], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
        		[
        		'attribute' => 'id_ticket',
        		'value' => 'id_ticket',
        		'label' => "B. Azonosító"
        				],
			[
				'attribute' => 'id_account',
				'value' => 'accountName'
    		],
			[
				'attribute' => 'id_ticket_type',
				'value' => 'ticketTypeName'
    		],
            'start:date',
            'end:date',
            'max_usage_count',
             'usage_count',
			[
				'attribute' => 'id_user',
				'value' => 'userName'
    		],
        	[
        		'attribute' => 'status',
        		'value' => 'statusName'
        	],
        		/*
			[
				'attribute' => 'id_discount',
				'value' => 'discountName'
    		],
    		*/
             'price_brutto',
        		
            'created_at:datetime',
            ['class' => 'yii\grid\ActionColumn',
		     'template' =>'{delete} {update}',
             'buttons' => [
             	'update' => function($url, $model, $key){
             	 return $model->status == Ticket::STATUS_DELETED  ? "" : Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url,
             			[ 'title' =>  "Bérlet módosítása", 'class'=>'btn btn-primary btn-xs', ])  ;
    			},		
             	'delete' => function($url, $model, $key){
             	return $model->status == Ticket::STATUS_DELETED  ? "" : Html::a('<span class="glyphicon glyphicon-trash"></span>', $url,
             			[ 'title' =>  "Bérlet törlése", 'class'=>'btn btn-primary btn-xs', 'data-method' =>'post'])  ;
    			},		
    		 ],
//              'buttons ' => [
             		
//             		'update' =>function ($url, $model, $key){
//              			return "update";
//     				},
//             		'delete' =>function ($url, $model, $key){
//              			return "delete";
             	
//     				}
// 			    ]
// 		     'template' => function($model){ return $model->status == Ticket::STATUS_DELETED ? ""  : "'{delete} {update}'" ;},
			],
        ],
    ]); ?>

</div>
