/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = WorkloadIc::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(['ref' => $this->ref, 'factor' => $this->factor, 'position' => $this->position, 'disease' => $this->disease, 'infect_ward' => $this->infect_ward, 'last_update' => $this->last_update]); $query->andFilterWhere(['like', 'hn', $this->hn])->andFilterWhere(['like', 'an', $this->an])->andFilterWhere(['like', 'type', $this->type]); return $dataProvider; }
/** * Creates a new WorkloadIc model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($an) { $model = new WorkloadIc(); $fullname = Yii::$app->request->get('fullname'); $ic_query = WorkloadIc::find()->byAn($an); $dataProvider = new ActiveDataProvider(['query' => $ic_query]); if (Yii::$app->request->post('WorkloadIc') && isset($an)) { $model->attributes = Yii::$app->request->post('WorkloadIc'); $model->an = $an; $model->save(); return $this->refresh(); } else { return $this->render('create', ['model' => $model, 'dataProvider' => $dataProvider, 'fullname' => $fullname]); } }