participant.php 6.2 KB
<?php
    /**
     * @var View                $this
     * @var PortfolioUserSearch $searchModel
     * @var ActiveDataProvider  $dataProvider
     */
    use common\models\PortfolioUser;
    use common\models\PortfolioUserSearch;
    use yii\data\ActiveDataProvider;
    use yii\grid\ActionColumn;
    use yii\grid\DataColumn;
    use yii\grid\GridView;
    use yii\helpers\Html;
    use yii\web\View;

    $this->title = 'Портфолио участник';
    $this->params[ 'breadcrumbs' ][] = $this->title;
?>
<div class="login-left-column-title fix"><?= $this->title ?></div>
<div class="admin-table-portfolio">
    <?= GridView::widget([
        'options'      => [ 'class' => 'style admin-all-pages-wr fix_last_td_' ],
        'dataProvider' => $dataProvider,
        'filterModel'  => $searchModel,
        'columns'      => [
            [
                'attribute' => 'project',
                'content'   => function($model, $key, $index, $column) {
                    /**
                     * @var PortfolioUser $model
                     */
                    $type = $model->portfolio->user->type;
                    $type_string = ( $type == 2 ) ? 'company' : 'performer';
                    return Html::a($model->portfolio->name, [
                        $type_string . '/portfolio-view',
                        $type_string . '_id' => $model->portfolio->user_id,
                        'portfolio_id'       => $model->portfolio->portfolio_id,
                    ], [
                        'target' => '_blank',
                    ]);
                },
            ],
            [
                'attribute' => 'position',
                'value'     => function($model, $key, $index, $column) {
                    /**
                     * @var PortfolioUser $model
                     * @var DataColumn    $column
                     * @var int           $key
                     * @var int           $index
                     */
                    if(empty( $model[ $column->attribute ] )) {
                        return NULL;
                    } else {
                        return $model[ $column->attribute ];
                    }
                },
            ],
            [
                'attribute'     => 'time',
                'filter'        => Html::tag('div', Html::activeInput('text', $searchModel, 'time_from', [ 'class' => 'form-control' ]), [ 'style' => 'width:70px;display:inline-block' ]) . Html::tag('div', Html::tag('i', '', [
                        'class' => 'glyphicon glyphicon-resize-horizontal',
                        'style' => 'left:3px',
                    ]), [ 'style' => 'width:20px;display:inline-block;' ]) . Html::tag('div', Html::activeInput('text', $searchModel, 'time_to', [ 'class' => 'form-control' ]), [ 'style' => 'width:70px;display:inline-block' ]) . ( ( $searchModel->hasErrors('time_from') ) ? Html::error($searchModel, 'time_from', [ 'class' => 'help-block' ]) : '' ) . ( ( $searchModel->hasErrors('time_to') ) ? Html::error($searchModel, 'time_to', [ 'class' => 'help-block' ]) : '' ),
                'filterOptions' => [
                    'class' => ( $searchModel->hasErrors('time_from') || $searchModel->hasErrors('time_to') ) ? 'has-error' : '',
                    'style' => 'width: 200px',
                ],
            ],
            [
                'attribute' => 'status',
                'filter'    => [
                    1 => 'Подтверждено',
                    2 => 'Ожидание',
                ],
                'value'     => function($model) {
                    if($model->status == 1) {
                        return 'Подтвержден';
                    } elseif($model->status == 2) {
                        return 'В ожидании';
                    } else {
                        return 'Неизвестный';
                    }
                },
            ],
            [
                'class'    => ActionColumn::className(),
                'buttons'  => [
                    'confirm' => function($url, $model, $key) {
                        return ( $model->status == 2 ) ? Html::a(Html::img('/images/tick.png', [
                            'width'  => '15px',
                            'height' => '15px',
                        ]), [
                            'accounts/participant-confirm',
                            'id' => $model->portfolio_user_id,
                        ], [
                            'title'        => 'Подтвердить',
                            'aria-label'   => 'Подтвердить',
                            'data-confirm' => 'Вы уверены, что хотите подтвердить участие в данном заказе?',
                            'data-method'  => 'post',
                            'data-pjax'    => 0,
                        ]) : '';
                    },
                    'edit'    => function($url, $model, $key) {
                        return Html::a(Html::img('/images/ico_pencil.png'), [
                            'accounts/participant-edit',
                            'id' => $model->portfolio_user_id,
                        ], [
                            'title'      => 'Редактировать',
                            'aria-label' => 'Редактировать',
                            'data-pjax'  => 0,
                        ]);
                    },
                    'deny'    => function($url, $model, $key) {
                        return Html::a(Html::img('/images/delete-ico.png'), [
                            'accounts/participant-delete',
                            'id' => $model->portfolio_user_id,
                        ], [
                            'title'        => 'Удалить',
                            'aria-label'   => 'Удалить',
                            'data-confirm' => 'Вы уверены, что хотите отказаться от участия в данном заказе?',
                            'data-method'  => 'post',
                            'data-pjax'    => 0,
                        ]);
                    },
                ],
                'template' => '{confirm}{edit}{deny}',
            ],
        ],
    ]); ?>
</div>