<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\DetailView;
use yii\base\Widget;
use yii\base\Object;
use yii\data\ArrayDataProvider;
use common\components\AccountStatisticWidget;
use common\components\DataProviderTotal;

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

$this->title = Yii::t('frontend/transfer', 'Transfers');
$this->params['breadcrumbs'][] = $this->title;
?>
<style>
	.table-transfer .money,
	.table-transfer .count,
	.table-transfer .item-price
	{
		text-align: right;	
	}
</style>

<div class="transfer-index">

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

 
	<?php 
	echo AccountStatisticWidget::widget([
			'totals' =>  $searchModel->totals
			]);
	
	?>
	
	<h2>Tranzakciók</h2>
    <?= GridView::widget([
    	'tableOptions' => ['class' => 'table table-striped table-bordered table-transfer'],	
        'dataProvider' => $dataProvider,
    	'showFooter'=>TRUE,
    		
        'columns' => [

        		[
        		'attribute' => 'id_transfer',
        		'value' => 'id_transfer',
        		'footer' => 'Összesen *'
        		],
        		[
        		'attribute' => 'type',
        		'value' => 'transferTypeName'
        		],
        		[
        		'attribute' => 'objectName',
        				],
            [
            	'attribute' => 'id_user',
            	'value' => 'userName'	,
            	'label' => 'Kiadta'	,
    		],
            [
            	'attribute' => 'paid_by',
            	'value' => 'paidByName'	,
            	'label' => 'Fizette'
    		],
            [
            	'attribute' => 'id_customer',
            	'value' => 'customerName'	,
            	'label' => 'Vendég'
    		],
            [
            	'attribute' => 'id_account',
            	'value' => 'accountName'	
    		],
        		[
        			'contentOptions' =>[ 'class' => 'item-price' ],		
        			'attribute' =>  'item_price',
    			],
        		[
        			'contentOptions' =>[ 'class' => 'count' ],		
        			'attribute' =>  'count',
    			],
        		[
        			'contentOptions' =>[ 'class' => 'money' ],		
        			'footerOptions' =>[ 'class' => 'money' ],		
        			'attribute' => 'money',
        			'value' => 'signedMoney'	,
        			'footer'=>DataProviderTotal::pageTotal($dataProvider->models,'signedMoney'),
    			],
        		[
        		'attribute' => 'status',
        		'value' => 'statusName'
        		],
        		[
        			'attribute' => 'payment_method',
        			'value' => 'paymentMethodName',
        			'label' => "Fizetési mód"
        		],
            'created_at:datetime',
            'paid_at:datetime',

            ['class' => 'yii\grid\ActionColumn',
            'template' => '{view}'
    ],
        ],
    ]); ?>

	<p>
		* A láblécben szereplő összesítések csak a táblázat aktuális oldalára vonatkoznak!
	</p>

</div>
