/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = LevelsRecord::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['Charge' => SORT_ASC]]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['ID' => $this->ID, 'Discount' => $this->Discount, 'PersonsExpression' => $this->PersonsExpression, 'ReturnPawn' => $this->ReturnPawn, 'Deleted' => $this->Deleted, 'Charge' => $this->Charge, 'StartLevel' => $this->StartLevel, 'OneCheckCharge' => $this->OneCheckCharge]); $query->andFilterWhere(['like', 'Name', $this->Name]); return $dataProvider; }
use yii\data\ActiveDataProvider; use yii\grid\GridView; use yii\helpers\Html; use yii\jui\DatePicker; use yii\web\View; use yii\widgets\Pjax; use kartik\export\ExportMenu; use kartik\grid\GridView as KartikGridView; /** * @var View $this * @var ActiveDataProvider $dataProvider * @var UserSearch $searchModel */ $this->title = Yii::t('user', 'Manage users'); $this->params['breadcrumbs'][] = $this->title; $gridColumns = [['attribute' => 'group.Name', 'filter' => \common\models\cf\PersonsGroupRecord::find()->select(['Name'])->indexBy('Name')->column(), 'options' => ['style' => 'width: 1%'], 'group' => true], ['attribute' => 'accountLevelID', 'header' => 'Уровень', 'filter' => \common\models\cf\LevelsRecord::find()->select(['Name'])->indexBy('ID')->column(), 'value' => function ($model) { if ($model->account && $model->account->level) { return $model->account->level->Name; } else { return ''; } }, 'options' => ['style' => 'width: 1%'], 'group' => true], ['attribute' => 'ID', 'format' => 'raw', 'value' => function ($model) { return $model->id . ':' . $model->account->id; }, 'options' => ['style' => 'width: 1%']], ['attribute' => 'card.HardID', 'header' => '№ карты', 'format' => 'raw', 'value' => function ($model) { return $model->card ? $model->card->id . ': ' . $model->card->HardID : 'без карты'; }, 'options' => ['style' => 'width: 1%']], ['attribute' => 'searchName', 'header' => 'Имя', 'format' => 'raw', 'value' => function ($model) { return $model->fullName; }], ['attribute' => 'childrenCount'], ['attribute' => 'IsRegularClient', 'visible' => $searchModel->hasAttribute('IsRegularClient'), 'class' => \common\components\BooleanFilterColumn::className()], 'Phone1', 'account.Money:currency', 'account.Spend:currency', ['attribute' => 'ServiceCard', 'class' => \common\components\BooleanFilterColumn::className()], ['attribute' => 'Deleted', 'class' => \common\components\BooleanFilterColumn::className()], ['attribute' => 'RegisterDate', 'format' => 'dateTime', 'filter' => \kartik\daterange\DateRangePicker::widget(['model' => $searchModel, 'attribute' => 'RegisterDate', 'presetDropdown' => true, 'hideInput' => true, 'pluginOptions' => ['locale' => ['format' => 'DD.MM.YYYY HH:mm']]])], ['header' => Yii::t('user', 'Block status'), 'stateAttribute' => 'Blocked', 'class' => \common\components\DisableActionColumn::className(), 'template' => '{disable}<br>{statistic} {update} {delete} ', 'buttons' => ['statistic' => function ($url, $model, $key) { $options = ['class' => 'btn btn-default btn-xs', 'title' => Yii::t('app', 'User\'s statistic'), 'aria-label' => Yii::t('app', 'User\'s statistic')]; return Html::a('<span class="glyphicon glyphicon-stats"></span>', \yii\helpers\Url::to(['/finances/person', 'id' => $model->ID]), $options); }, 'delete' => function ($url, $model, $key) {