From 658a5f37537813f0f9b3d3243ccebee7fc468698 Mon Sep 17 00:00:00 2001 From: Yarik Date: Thu, 10 Mar 2016 14:52:25 +0200 Subject: [PATCH] test --- common/models/CustomerSearch.php | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/models/User.php | 5 +++++ frontend/controllers/SearchController.php | 1 + frontend/views/search/customer.php | 11 +++++------ 4 files changed, 130 insertions(+), 6 deletions(-) create mode 100644 common/models/CustomerSearch.php diff --git a/common/models/CustomerSearch.php b/common/models/CustomerSearch.php new file mode 100644 index 0000000..bf2fb4c --- /dev/null +++ b/common/models/CustomerSearch.php @@ -0,0 +1,119 @@ +joinWith('userInfo') + ->joinWith('companyInfo'); + + $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->andWhere([ + 'is_customer' => 1, + ]); + + if($this->type == 2) { + $query->andWhere([ + 'not', + [ 'company_info.company_info_id' => NULL ], + ]); + + $query->andWhere([ + 'type' => 2, + ]); + } else { + $query->andWhere([ + 'type', + ]); + } + + if($this->online == 1) { + $query->andWhere([ + '>=', + 'user_info.date_visit', + date('Y-m-d H:i:s.u', time() - 1800), + ]); + } + + $query->andFilterWhere([ + 'like', + 'user_info.city', + $this->city, + ]); + + return $dataProvider; + } + } diff --git a/common/models/User.php b/common/models/User.php index 4188aa6..5d036aa 100755 --- a/common/models/User.php +++ b/common/models/User.php @@ -97,6 +97,11 @@ ], 'safe', ], + [ + 'type', + 'default', + 'value' => 1, + ] ]; } diff --git a/frontend/controllers/SearchController.php b/frontend/controllers/SearchController.php index 12681b0..351712b 100755 --- a/frontend/controllers/SearchController.php +++ b/frontend/controllers/SearchController.php @@ -68,6 +68,7 @@ class SearchController extends Controller public function actionCustomer(){ + return $this->render('customer',[ ]); } diff --git a/frontend/views/search/customer.php b/frontend/views/search/customer.php index 9a97b0b..6c69528 100644 --- a/frontend/views/search/customer.php +++ b/frontend/views/search/customer.php @@ -1,10 +1,9 @@ search(\Yii::$app->request->queryParams); + var_dump($model->totalCount); + ?>
-- libgit2 0.21.4