<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\models\MoneyMovement;

/* @var $this yii\web\View */
/* @var $searchModel frontend\models\MoneyMovementSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('backend/money-movement', 'Money Movements');
$this->params['breadcrumbs'][] = $this->title;
?>

<style>
	.table .btn{ margin-right: 6px;}
</style>

<div class="money-movement-index">

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

    <p>
        <?= Html::a(Yii::t('backend/money-movement', 'Create Money Movement'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [

            'accountName',
            'userName',
        		[
        			'attribute' => 'type',
        			'value' =>'humanType'
    			],
            'name',
            'money',
            'created_at:datetime',
        		[
        		'attribute' => 'comment',
        		'format' => 'html'
        				],
        		[
        		'attribute' => 'status',
        		'value' => 'statusName',
        		'label' => "Státusz"
        		],

            ['class' => 'yii\grid\ActionColumn',
				'template' => '{view}{delete}',
            		  'buttons' => [
             	'view' => function($url, $model, $key){
             	 return  Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url,
             			[ 'title' =>  "Pénzmozgás részletei", 'class'=>'btn btn-success btn-xs', ])  ;
    			},		
             	'delete' => function($url, $model, $key){
             	return  $model->status == MoneyMovement::STATUS_STORNO  ? "" : Html::a('<span class="glyphicon glyphicon-trash"></span>', $url,
             			[ 'title' =>  "Bérlet módosítása", 'class'=>'btn btn-danger btn-xs', 'data-method' =>'post'])  ;
    			},	
			],
			],
        ],
    ]); ?>

</div>
