<?php

use yii\helpers\Url;
use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel common\modules\sessions\models\SearchSession */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->params['breadcrumbs'][] = $this->title;
?>
<div class="session-index">

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            // ['class' => 'yii\grid\SerialColumn'],

            [
                'attribute' => 'session_id',
                'value' => function($model)
                {
                    $session = '';

                    if($model->session->user_id)
                    {
                        $session .= $model->session->user->surname.' '.$model->session->user->name . ' / ';
                    }

                    $session .= $model->session->PHPSESSID;

                    return $session;
                }
            ],
            'url',
            'referer',

            [
                'header' => 'Время просмотра',
                'value' => function($model)
                {
                    return date('H:i:s', mktime(0, 0, $model->time));
                }
            ],

        ],
    ]); ?>
</div>
