<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\components\AccountTotalWidget;

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

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

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

    
	<div class="row">
	    <div class="col-md-4 ">
	    	<?php 
	    	echo AccountTotalWidget::widget([
				'statistic' => $searchModel->totals
	    	])?>
	    </div>
    </div>
    

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            'id_collection',
			[
				'attribute' => 'id_user',
				'value' => 'userName',
				],
			[
				'attribute' => 'id_account',
				'value' => 'accountName',
			],
            'money:integer',
			[
				'attribute' => 'start',
				'value' => function($model){
					return Yii::$app->formatter->asDatetime($model->start,'yyyy-MM-dd HH:mm:ss');
				}
			],
			[
				'attribute' => 'end',
				'value' => function($model){
					return Yii::$app->formatter->asDatetime($model->end,'yyyy-MM-dd HH:mm:ss');
				}
			],
            'created_at:datetime',

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

</div>
