team.php 1.82 KB
<?php
    /**
     * @var TeamSearch         $searchModel
     * @var ActiveDataProvider $dataProvider
     */
    use common\models\TeamSearch;
    use yii\data\ActiveDataProvider;
    use yii\grid\GridView;
    use yii\helpers\Html;

    $this->title = 'Команда';
    $this->params[ 'breadcrumbs' ][] = $this->title;
?>
    <h1><?= $this->title ?></h1>
    <p>
        <?= Html::a(Yii::t('app', 'Добавить'), [ 'team-create' ], [ 'class' => 'btn btn-success' ]) ?>
    </p>
<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel'  => $searchModel,
    'columns'      => [
        [
            'attribute' => 'team_id',
            'label' => 'ID',
        ],
        [
            'value' => function($model, $key, $index, $column) {
                return $model->lastname.' '.$model->firstname.' '.$model->middlename;
            },
            'label' => 'ФИО',
        ],
        [
            'value' => function($model, $key, $index, $column) {
                return \Yii::$app->formatter->asBoolean(!empty($model->link));
            },
            'label' => 'Участник МФП',
        ],
        [
            'attribute' => 'department.name',
            'label' => 'Отдел компании',
        ],
        [
            'value' => function($model, $key, $index, $column) {
                return \Yii::$app->formatter->asDate(time(), 'yyyy') - $model->experience_from;
            },
            'label' => 'Опыл, лет',
        ],
        'team_id',
        'user_id',
        'firstname',
        'lastname',
        'middlename',
        // 'link',
        // 'position',
        // 'department_id',
        // 'date_add',
        // 'user_add_id',
        // 'photo',
        // 'country_id',
        // 'experience_from',

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