/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = KpiItem::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, 'group_id' => $this->group_id]); $query->andFilterWhere(['like', 'the_must', $this->the_must])->andFilterWhere(['like', 'the_best', $this->the_best]); return $dataProvider; }
/** * [createEvauateScoreModels description] * @param [type] $hospital_id [description] * @param [type] $year [description] * @return [type] [description] */ public function createEvauateScoreModels($hospital_id, $year, $group_id = null) { $items = KpiItem::find()->byGroup($group_id)->orderBy('group_id')->all(); $evauateScores = []; foreach ($items as $item) { $evauateScores[] = new EvauateScore(['kpi_id' => $item->id, 'theMust' => $item->the_must, 'theBest' => $item->the_best, 'year' => $year, 'level' => Yii::$app->user->identity->level, 'hospital_id' => $hospital_id, 'groupName' => $item->group->name]); } return $evauateScores; }