<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use common\components\RoleDefinition;
use common\models\Ticket;
use common\models\Transfer;

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

$this->title = $model->id_transfer;
$this->params ['breadcrumbs'] [] = [ 
		'label' => Yii::t ( 'frontend/transfer', 'Transfers' ),
		'url' => [ 
				'index' 
		] 
];
$this->params ['breadcrumbs'] [] = $this->title;
?>
<div class="transfer-view">

	<h1><?= Html::encode($this->title) ?></h1>
	<div class="row">
		<div class="col-md-6">
    		<?=DetailView::widget ( 
    				[ 'model' => $model,
    				  'attributes' => [ 
    				  		[ 'attribute' => 'id_transfer' ],
    				  		[ 'attribute' => 'id_account','value' => $model->accountName ],
    				  		[ 'attribute' => 'type','value' => $model->transferTypeName ],
    				  		[ 'attribute' => 'id_object','value' => $model->objectName ],
    				  		[ 'attribute' => 'id_user','value' => $model->userName ],
    				  		[ 'attribute' => 'id_discount','value' => $model->discountName ],
    				  		[ 'attribute' => 'payment_method','value' => $model->paymentMethodName ],
    				  		[ 'attribute' => 'status','value' => $model->statusName ],
    				  		'item_price',
    				  		'count',
    				  		'money',
    				  		'comment',
    				  		'created_at',
    				  		'paid_at' ] ] )?>
		</div>
	</div>

</div>

<?php

if (RoleDefinition::isAdmin () ) {

	if ( $model->type == Transfer::TYPE_TICKET ){
		
		if ($model->status == Transfer::STATUS_STORNO || $model->status == Transfer::STATUS_PAID ) {
			
			?>
				<p>Sztornózott vagy fizetett bérlet fizetettlenre állítása: </p>
				<ul>
					<li>A tranzakció státusza fizetetlen lesz</li>
					<li>A bérlet státusza inaktív lesz ( a bérlettel nem lehet bemenni a forgó kapun)</li>
					<li>A bérlet a vásárló kosarába kerül</li>
				</ul>
				<?php 
			
			echo Html::a ( "Bérlet fizetetlennek jelölése és vásárló kosarába helyezése", [ 
					'transfer/unstorno',
					'id' => $model->id_transfer 
			], [ 
					'class' => 'btn btn-danger',
					'data-confirm' => "Figyelem, a bérlet fizetetlennek lesz jelölve !!",
					'data-method' => 'post' 
			] );
		}
	}
	
	 
}
?>
