diff --git a/common/models/CustomerSearch.php b/common/models/CustomerSearch.php index d307076..fc2d72d 100644 --- a/common/models/CustomerSearch.php +++ b/common/models/CustomerSearch.php @@ -50,6 +50,20 @@ /** * @inheritdoc */ + public function attributeLabels() + { + return [ + 'type' => Yii::t('app', 'Тип заказчика'), + 'rating' => Yii::t('app', 'Рейтинг'), + 'online' => Yii::t('app', 'Статус'), + 'city' => Yii::t('app', 'Город'), + 'info' => Yii::t('app', 'Любая информация о заказчике'), + ]; + } + + /** + * @inheritdoc + */ public function scenarios() { // bypass scenarios() implementation in the parent class @@ -94,7 +108,7 @@ $query->andWhere([ 'type' => 2, ]); - } else { + } elseif($this->type == 1) { $query->andWhere([ 'type' => 1, ]); @@ -112,6 +126,53 @@ 'like', 'user_info.city', $this->city, + ])->andFilterWhere([ + 'or', + [ + 'like', + 'LOWER(username)', + mb_strtolower($this->info), + ], + [ + 'like', + 'LOWER(lastname)', + mb_strtolower($this->info), + ], + [ + 'like', + 'LOWER(firstname)', + mb_strtolower($this->info), + ], + [ + 'like', + 'LOWER(middlename)', + mb_strtolower($this->info), + ], + [ + 'like', + 'LOWER(company_info.name)', + mb_strtolower($this->info), + ], + [ + 'like', + 'LOWER(company_info.street)', + mb_strtolower($this->info), + ], + [ + 'like', + 'LOWER(user_info.country)', + mb_strtolower($this->info), + ], + [ + 'like', + 'LOWER(user_info.city)', + mb_strtolower($this->info), + ], + [ + 'like', + 'LOWER(user_info.about)', + mb_strtolower($this->info), + ], ]); return $dataProvider; diff --git a/frontend/controllers/SearchController.php b/frontend/controllers/SearchController.php index 351712b..e70dd2e 100755 --- a/frontend/controllers/SearchController.php +++ b/frontend/controllers/SearchController.php @@ -1,6 +1,7 @@ search(Yii::$app->request->queryParams); + $dataProvider->setSort([ + 'attributes' => [ + 'name' => [ + 'asc' => [ + 'company_info.name' => SORT_ASC, + 'firstname' => SORT_ASC, + 'lastname' => SORT_ASC, + ], + 'desc' => [ + 'company_info.name' => SORT_DESC, + 'firstname' => SORT_DESC, + 'lastname' => SORT_DESC, + ], + 'default' => SORT_ASC, + 'label' => 'Название', + ], + 'staff' => [ + 'asc' => [ + 'company_info.staff' => SORT_ASC, + ], + 'desc' => [ + 'company_info.staff' => SORT_DESC, + ], + 'default' => SORT_DESC, + 'label' => 'Количество сотрудников', + ], + 'visit' => [ + 'asc' => [ + 'user_info.date_visit' => SORT_ASC, + ], + 'desc' => [ + 'user_info.date_visit' => SORT_DESC, + ], + 'default' => SORT_DESC, + 'label' => 'Последний визит', + ], + 'city' => [ + 'asc' => [ + 'user_info.city' => SORT_ASC, + ], + 'desc' => [ + 'user_info.city' => SORT_DESC, + ], + 'default' => SORT_ASC, + 'label' => 'Город', + ], + ], + ]); + $model->load(Yii::$app->request->queryParams); + $cities = UserInfo::find()->select('city')->distinct()->asArray()->indexBy('city')->column(); return $this->render('customer',[ + 'model' => $model, + 'dataProvider' => $dataProvider, + 'cities' => $cities, ]); } diff --git a/frontend/views/search/_customer_list_view.php b/frontend/views/search/_customer_list_view.php new file mode 100644 index 0000000..1aca034 --- /dev/null +++ b/frontend/views/search/_customer_list_view.php @@ -0,0 +1,60 @@ + +