public function getRoleClass($teID, $te_id, $academy) { if ($te_id == "辅导员") { $classArray = teClass::find()->where(['teID' => $teID])->asArray()->all(); } else { if ($te_id == "副书记") { $classArray = Record::find()->where(["academy" => $academy, "status" => "等待副书记审核"])->asArray()->all(); } else { if ($te_id == "书记") { $classArray = Record::find()->where(["academy" => $academy, "status" => "等待书记审核"])->asArray()->all(); } } } return $classArray; }
public function search($params) { // $query = Record::find(); $b = Yii::$app->user->getId(); // var_dump(Yii::$app->user); // die; $admin = Users::findOne($b); $academy = $admin->te_aca; $id = $admin->id; $te_id = self::searchte_id(); $teClass = array(); $te = teClass::find()->where(['teID' => $id])->asArray()->all(); // var_dump($te);die; for ($i = 0; $i < sizeof($te); $i++) { $teClass[] = $te[$i]['st_class']; } // var_dump($teClass);die; if ($academy == "学生处") { $query = Record::find()->where(['status' => ['审核不通过', '审核通过']]); } else { if ($te_id == "辅导员") { $query = Record::find()->where(["academy" => $academy])->andwhere(['st_class' => $teClass])->andwhere(['status' => ['待审核', '审核通过', '审核不通过']]); } else { if ($te_id == "副书记") { $query = Record::find()->where(["academy" => $academy])->andwhere(['status' => ['等待副书记审核']]); } else { if ($te_id == "书记") { $query = Record::find()->where(["academy" => $academy])->andwhere(['status' => ['等待书记审核']]); } } } } // // $sql = 'SELECT * FROM record where academy=".$aa"'; // $sql = "SELECT * FROM record where academy=(select te_aca from admin where id='".$b."' )"; // $query = Record::findBySql($sql); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10], 'sort' => ['defaultOrder' => ['today' => 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(['totalday' => $this->totalday]); $query->andFilterWhere(['like', 'todaydetail', $this->todaydetail])->andFilterWhere(['like', 'st_classmark', $this->st_classmark])->andFilterWhere(['like', 'startday', $this->startday])->andFilterWhere(['like', 'endday', $this->endday])->andFilterWhere(['like', 'country', $this->country])->andFilterWhere(['like', 'countryEN', $this->countryEN])->andFilterWhere(['like', 'st_name', $this->st_name])->andFilterWhere(['like', 'st_nameEN', $this->st_nameEN])->andFilterWhere(['like', 'gaokaohao', $this->gaokaohao])->andFilterWhere(['like', 'idcard', $this->idcard])->andFilterWhere(['like', 'sex', $this->sex])->andFilterWhere(['like', 'st_year', $this->st_year])->andFilterWhere(['like', 'st_class', $this->st_class])->andFilterWhere(['like', 'academy', $this->academy])->andFilterWhere(['like', 'major', $this->major])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'model', $this->model])->andFilterWhere(['like', 'today', $this->today]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { //获取管理学院所有老师的id $this_aca = Yii::$app->user->identity->te_aca; $allid_in_aca = (new Query())->select('id')->from('admin')->where("te_aca = '{$this_aca}' and te_id='辅导员'")->all(); $arr_id = array_column($allid_in_aca, 'id'); $query = teClass::find()->where(['teID' => $arr_id]); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10], 'sort' => ['defaultOrder' => ['class_year' => 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; } // $this->class_year=substr($this->class_year,2,2); $query->andFilterWhere(['like', 'st_class', $this->st_class])->andFilterWhere(['like', 'teID', $this->teID])->andFilterWhere(['like', 'class_year', $this->class_year])->andFilterWhere(['like', 'class_major', $this->class_major])->andFilterWhere(['like', 'te_name', $this->te_name]); // ->andFilterWhere(['like', 'st_class', "____$this->class_year%",false]); return $dataProvider; }