feedback-company.php 4.92 KB
<?php
    use common\models\FeedbackCompanySearch;
    use yii\data\ActiveDataProvider;
    use yii\grid\ActionColumn;
    use yii\grid\GridView;
    use yii\grid\SerialColumn;
    use yii\helpers\Html;
    use yii\jui\DatePicker;
    use yii\web\View;

    /**
     * @var View                  $this
     * @var FeedbackCompanySearch $searchModel
     * @var ActiveDataProvider    $dataProvider
     */
    $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'      => [
            [ 'class' => SerialColumn::className() ],
            [
                'attribute' => 'date_add',
                'filter'    => "<div class=\"input-group input-group-xs input-daterange\">
<span class='field-teamsearch-experience_from_from'>" . DatePicker::widget([
                        'model'         => $searchModel,
                        'attribute'     => 'date_add_from',
                        'language'      => 'ru',
                        'dateFormat'    => 'yyyy-MM-dd',
                        'clientOptions' => [
                            'changeYear'  => true,
                            'changeMonth' => true,
                            'maxDate' => ($searchModel->date_add_to?:date('Y-m-d')),
                        ],
                    ]) . "</span>
<span class=\"input-group-addon kv-field-separator\">
<i class=\"glyphicon glyphicon-resize-horizontal\"></i>
</span>
<span class='field-teamsearch-experience_from_to'>" . DatePicker::widget([
                        'model'         => $searchModel,
                        'attribute'     => 'date_add_to',
                        'language'      => 'ru',
                        'dateFormat'    => 'yyyy-MM-dd',
                        'clientOptions' => [
                            'changeYear'  => true,
                            'changeMonth' => true,
                            'minDate' => $searchModel->date_add_from,
                            'maxDate' => date('Y-m-d'),
                        ],
                    ]) . "</span>
</div>",
                'value'     => function($model, $key) {
                    return date('Y-m-d H:i:s', $model->date_add);
                },
            ],
            [
                'attribute' => 'name',
                'label'     => 'Имя и фамилия',
            ],
            'phone',
            [
                'attribute' => 'status',
                'filter' => [
                    1 => 'Только непрочитанные',
                ],
                'filterInputOptions' => [
                    'prompt' => 'Все записи',
                    'class' => 'form-control',
                ],
            ],
            [
                'class'    => ActionColumn::className(),
                'buttons'  => [
                    'delete' => function($url, $model, $key) {
                        return Html::a(Html::tag('span', '', [
                            'class' => 'glyphicon glyphicon-trash',
                        ]), [
                            'accounts/feedback-delete',
                            'id' => $model->feedback_company_id,
                        ], [
                            'title'        => 'Удалить',
                            'aria-label'   => 'Удалить',
                            'data-confirm' => 'Вы уверены, что хотите удалить данную заявку?',
                            'data-method'  => 'post',
                            'data-pjax'    => 0,
                        ]);
                    },
                    'read'   => function($url, $model, $key) {
                        if($model->status == $model::STATUS_NEW) {
                            return Html::a(Html::tag('span', '', [
                                'class' => 'glyphicon glyphicon-ok',
                            ]), [
                                'accounts/feedback-read',
                                'id' => $model->feedback_company_id,
                            ], [
                                'title'        => 'Прочесть',
                                'aria-label'   => 'Прочесть',
                                'data-confirm' => 'Вы уверены, что хотите отметить заявку прочтенной?',
                                'data-method'  => 'post',
                                'data-pjax'    => 0,
                            ]);
                        } else {
                            return false;
                        }
                    },
                ],
                'template' => '{read}{delete}',
            ],
        ],
    ]); ?>
</div>