<?php
use yii\helpers\Html;
use yii\grid\GridView;
use app\models\Files;
use app\models\FilesSearch;
use kartik\daterange\DateRangePicker;
use yii\helpers\ArrayHelper;
use app\models\User;
use app\models\FilesSearch as FS;
use yii\data\ActiveDataProvider;

/*
 * This file is part of the Dektrium project.
 *
 * (c) Dektrium project <http://github.com/dektrium>
 *
 * For the full copyright and license information, please view the LICENSE.md
 * file that was distributed with this source code.
 */

/**
 * @var yii\widgets\ActiveForm 		$form
 * @var dektrium\user\models\User 	$user
 */

 $searchModel = new FS();
 //$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
 $dataProvider = new ActiveDataProvider([
    'query' => FS::find()->where(['user_id' => $user->id]),
]);
?>

<?= $form->field($user, 'email')->textInput(['maxlength' => 255]) ?>
<?= $form->field($user, 'username')->textInput(['maxlength' => 255]) ?>
<?= $form->field($user, 'password')->passwordInput() ?>

<div class="files-index">

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            [
                'attribute' =>'name',
                'header' => Yii::t('app', 'FileName ID'),
                'filter' => false,
            ],
            [
                'attribute' => 'type',
                'header' => Yii::t('app','Тип документу'),
            ],
            [
                    'attribute' => 'date',
                    'header' => Yii::t('app', 'Date'),
                    // 'filter' => DateRangePicker::widget([
                    //     'name'=>'date_range_2',
                    //     'presetDropdown'=>true,
                    //     'hideInput'=>true
                    // ])
            ],
            [
                'class' => 'yii\grid\ActionColumn',
                'template' => '{maintenance} {delete}',
                'buttons' => [
                    'maintenance' => function ($url, $model, $key)
                    {
                        return Html::a('<span class="glyphicon glyphicon-download"></span>', ['/files/download', 'id' => $model->id], [
                            'title' => 'download files',
                            'data-pjax' => '0',

                        ]);
                    }

                ]
            ],

            //'user_id',
           // 'auction_id',
            // 'lot_id',

           // ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
</div>
