/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ActivityUsers::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, 'activity_id' => $this->activity_id, 'user_id' => $this->user_id, 'status' => $this->status, 'practice_score' => $this->practice_score, 'theory_score' => $this->theory_score, 'rule_score' => $this->rule_score, 'create_time' => $this->create_time, 'update_time' => $this->update_time]);
     $query->andFilterWhere(['like', 'score_appraise', $this->score_appraise])->andFilterWhere(['like', 'attendance_appraise', $this->attendance_appraise])->andFilterWhere(['like', 'practice_comment', $this->practice_comment])->andFilterWhere(['like', 'theory_comment', $this->theory_comment])->andFilterWhere(['like', 'rule_comment', $this->rule_comment])->andFilterWhere(['like', 'total_comment', $this->total_comment])->andFilterWhere(['like', 'result_comment', $this->result_comment])->andFilterWhere(['like', 'create_user', $this->create_user])->andFilterWhere(['like', 'update_user', $this->update_user]);
     return $dataProvider;
 }
 public function actionIndex()
 {
     $levelId = \Yii::$app->request->get('levelId') ? \Yii::$app->request->get('levelId') : 2;
     $query = Activity::find()->where(['level_id' => $levelId]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count()]);
     $models = $query->offset($pages->offset)->limit($pages->limit)->all();
     if (!empty($models)) {
         foreach ($models as $key => $val) {
             $val->begin_time = date('Y-m-d', strtotime($val->begin_time));
             //录取人数
             $countResult = \app\models\ActivityUsers::find()->where(['activity_id' => $val->id, 'status' => [ActivityUsers::APPROVED, ActivityUsers::DOING, ActivityUsers::END]]);
             $val->already_recruit_count = $countResult->count();
         }
     }
     return $this->render('index', ['models' => $models, 'pages' => $pages, 'levelId' => $levelId]);
 }
 public function getActivityListByLevelId($levelId)
 {
     $query = Activity::find()->where(['level_id' => $levelId]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count()]);
     $models = $query->offset($pages->offset)->limit($pages->limit)->all();
     if (!empty($models)) {
         foreach ($models as $key => $val) {
             $val->begin_time = date('Y-m-d', strtotime($val->begin_time));
             //录取人数
             $countResult = ActivityUsers::find()->where(['activity_id' => $val->id, 'status' => [ActivityUsers::APPROVED, ActivityUsers::DOING, ActivityUsers::END]]);
             $val->already_recruit_count = $countResult->count();
         }
     }
     return $models;
 }