<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model common\models\Ticket */

$this->title = $model->id_ticket;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/ticket', 'Tickets'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="ticket-view">
    <h1>Bérlet információ: #<?= Html::encode($this->title) ?></h1>
    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'id_ticket',
            [
                'attribute' => 'id_user',
                'value' => $model->user->username,

            ],
            [
                'attribute' => 'id_ticket_type',
                'format' => 'raw',
                'value' => Html::a($model->ticketTypeName, ['ticket-type/view', 'id' => $model->id_ticket_type]),

            ],
            [
                'attribute' => 'id_account',
                'format' => 'raw',
                'value' => Html::a($model->accountName, ['account/view', 'id' => $model->id_account]),

            ],
            [
                'attribute' => 'id_discount',
                'value' => $model->discountName,

            ],
            'start:date',
            'end:date',
            'max_usage_count',
            'usage_count',
            [
                'attribute' => 'status',
                'value' => $model->statusName
            ],
            'price_brutto',
            [
                'attribute' => 'price_brutto',
                'format' => 'raw',
                'value' => Html::a($model->price_brutto, ['transfer/view', 'id' => $model->transfer->id_transfer]),

            ],
            'comment:raw',
            'created_at:datetime',
            'updated_at:datetime',
            'original_end:date',
            'original_price',
        ],
    ]) ?>


    <h3>Bérletkártya</h3>
    <?php

    echo DetailView::widget([
        'model' => $model->card,
        'attributes' => [
            [
                'attribute' => 'number',
                'format' => 'raw',
                'value' => Html::a($model->card->number, ['card/view', 'id' => $model->card->id_card]),
            ]
        ]]);

    ?>

    <h3>Vendég</h3>
    <?php

    echo DetailView::widget([
        'model' => $model->customer,
        'attributes' => [
            [
                'attribute' => 'name',
                'format' => 'raw',
                'value' => Html::a($model->customer->name, ['customer/view', 'id' => $model->customer->id_customer]),
            ]

        ]]);

    ?>

    <?php
    $contract = $model->contract;
    if (isset($contract)) {
        ?>
        <h3>Szerződés</h3>
        <?php

        echo DetailView::widget([
            'model' => $contract,
            'attributes' => [
                [
                    'attribute' => 'id_contract',
                    'format' => 'raw',
                    'value' => Html::a($contract->id_contract, ['contract/details', 'id' => $contract->id_contract]),
                ]

            ]]);

        ?>

        <?php
    }
    ?>


</div>
