/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = PersonsGroupRecord::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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, 'CardDeposit' => $this->CardDeposit, 'EmitCardCost' => $this->EmitCardCost, 'MinMoneyToEmit' => $this->MinMoneyToEmit, 'Deleted' => $this->Deleted, 'CardRepairCost' => $this->CardRepairCost, 'IsService' => $this->IsService, 'IsGift' => $this->IsGift]); $query->andFilterWhere(['like', 'Name', $this->Name])->andFilterWhere(['like', 'Description', $this->Description]); return $dataProvider; }
public function actionSelectGroup($hardId) { /** @var PersonsRecord $user */ $user = Yii::$app->user->identity; $dataProvider = new ActiveDataProvider(['query' => PersonsGroupRecord::find()->where(['Deleted' => 0])->andWhere(['>=', 'ID', $user->GroupID])]); return $this->render('selectGroup', ['dataProvider' => $dataProvider, 'hardId' => $hardId]); }
/** * Step 2 * @param $hardId * @return string */ public function actionSelectGroup($hardId) { $dataProvider = new ActiveDataProvider(['query' => PersonsGroupRecord::find()->where(['Deleted' => 0])]); return $this->render('selectGroup', ['dataProvider' => $dataProvider, 'hardId' => $hardId]); }
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) {