/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $this->scenario = 'search'; $query = User::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => array('pageSize' => 100), 'sort' => array('defaultOrder' => ['created_at' => SORT_DESC])]); $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, 'gender' => $this->gender, 'status' => $this->status, 'role_id' => $this->role_id]); $query->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'last_name', $this->last_name])->andFilterWhere(['like', 'created_at', CFF::FormatData($this->created_at)])->andFilterWhere(['like', 'updated_at', CFF::FormatData($this->updated_at)])->andFilterWhere(['like', 'birthday', $this->birthday])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'email_confirm_token', $this->email_confirm_token])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'photo', $this->photo]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $this->scenario = 'search'; $query = Document::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 100], 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]); $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, 'lft' => $this->lft, 'rgt' => $this->rgt, 'depth' => $this->depth, 'template_id' => $this->template_id, 'is_folder' => $this->is_folder, 'status' => $this->status]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'created_user_name', $this->created_user_name])->andFilterWhere(['like', 'updated_user_name', $this->updated_user_name])->andFilterWhere(['like', 'root_name', $this->root_name])->andFilterWhere(['like', 'parent_name', $this->parent_name])->andFilterWhere(['like', 'created_at', CFF::FormatData($this->created_at)])->andFilterWhere(['like', 'updated_at', CFF::FormatData($this->updated_at)])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'annotation', $this->annotation])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'img', $this->img])->andFilterWhere(['like', 'meta_description', $this->meta_description])->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])->andFilterWhere(['>=', 'id', $this->id_from])->andFilterWhere(['<=', 'id', $this->id_till])->andFilterWhere(['<>', 'id', 1]); for ($i = 1; $i <= Template::OPTIONS_COUNT; $i++) { $option = 'option_' . $i; $query->andFilterWhere(['like', $option, $this->{$option}]); } if ($this->created_at_from) { $query->andFilterWhere(['>=', 'created_at', CFF::FormatData($this->created_at_from, false) . ' 00:00:00']); } if ($this->created_at_till) { $query->andFilterWhere(['<=', 'created_at', CFF::FormatData($this->created_at_till, false) . ' 23:59:00']); } if ($this->updated_at_from) { $query->andFilterWhere(['>=', 'updated_at', CFF::FormatData($this->updated_at_from, false) . ' 00:00:00']); } if ($this->updated_at_till) { $query->andFilterWhere(['<=', 'updated_at', CFF::FormatData($this->updated_at_till, false) . ' 23:59:00']); } return $dataProvider; }
/** * Инициализация пользователя * @return $this */ public function initial() { if (!$this->isNewRecord) { $this->birthday = CFF::FormatData($this->birthday); } return $this; }
<?php echo $this->render('@app/views/site/_alert'); ?> <?php $gridColumns = [['class' => 'kartik\\grid\\SerialColumn', 'contentOptions' => ['class' => 'kartik-sheet-style'], 'width' => '30px', 'header' => '', 'headerOptions' => ['class' => 'kartik-sheet-style']], ['class' => 'kartik\\grid\\ExpandRowColumn', 'width' => '50px', 'value' => function () { return GridView::ROW_COLLAPSED; }, 'detail' => function ($model) { return Yii::$app->controller->renderPartial('_view', ['model' => $model]); }, 'headerOptions' => ['class' => 'kartik-sheet-style']], ['attribute' => 'id', 'width' => '70px'], ['attribute' => 'role_id', 'value' => function ($model) { return isset($model->role) ? $model->role->name : ''; }, 'filter' => AuthItem::getAll(1), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => '', 'class' => 'form-control'], 'format' => 'raw'], ['attribute' => 'first_name', 'format' => 'html', 'value' => function ($model) { return Html::a($model->first_name, ['/user/update', 'id' => $model->id]); }], 'last_name', 'email:email', 'phone', ['attribute' => 'created_at', 'value' => function ($model) { return CFF::FormatData($model->created_at, true); }, 'width' => '200px', 'filter' => DatePicker::widget(['value' => isset($_GET['UserSearch']['created_at']) ? $_GET['UserSearch']['created_at'] : '', 'name' => 'UserSearch[created_at]', 'type' => DatePicker::TYPE_COMPONENT_APPEND, 'pluginOptions' => ['format' => 'dd.mm.yyyy', 'todayHighlight' => true]])], ['attribute' => 'status', 'vAlign' => 'middle', 'format' => 'raw', 'value' => function ($model) { switch ($model->status) { case User::STATUS_BLOCKED: return '<span class="label label-danger"> <i class="glyphicon glyphicon-lock"></i> Заблокирован</span>'; break; case User::STATUS_WAIT: return '<span class="label label-warning"> <i class="glyphicon glyphicon-hourglass"></i> Не активен</span>'; break; case User::STATUS_ACTIVE: return '<span class="label label-success"> <i class="glyphicon glyphicon-ok"></i> Активен</span>'; break; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $this->scenario = 'search'; $query = Message::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 100], 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]); $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, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_user_id' => $this->created_user_id, 'updated_user_id' => $this->updated_user_id, 'for_document_id' => $this->for_document_id, 'for_user_id' => $this->for_user_id, 'parent_message_id' => $this->parent_message_id]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'attachment', $this->attachment])->andFilterWhere(['like', 'created_user_name', $this->created_user_name])->andFilterWhere(['like', 'updated_user_name', $this->updated_user_name])->andFilterWhere(['like', 'created_ip', $this->created_ip])->andFilterWhere(['>=', 'id', $this->id_from])->andFilterWhere(['<=', 'id', $this->id_till]); for ($i = 1; $i <= Message::OPTIONS_COUNT; $i++) { $option = 'option_' . $i; $query->andFilterWhere(['like', $option, $this->{$option}]); } if ($this->created_at_from) { $query->andFilterWhere(['>=', 'created_at', CFF::FormatData($this->created_at_from, false) . ' 00:00:00']); } if ($this->created_at_till) { $query->andFilterWhere(['<=', 'created_at', CFF::FormatData($this->created_at_till, false) . ' 23:59:00']); } if ($this->updated_at_from) { $query->andFilterWhere(['>=', 'updated_at', CFF::FormatData($this->updated_at_from, false) . ' 00:00:00']); } if ($this->updated_at_till) { $query->andFilterWhere(['<=', 'updated_at', CFF::FormatData($this->updated_at_till, false) . ' 23:59:00']); } return $dataProvider; }