/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Project::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(['date_of_flob' => $this->date_of_flob, 'date_of_completion' => $this->date_of_completion, 'percentage_of_completion' => $this->percentage_of_completion]); $query->joinWith('sitename'); $query->joinWith('pic'); $query->joinWith('account'); $query->andFilterWhere(['like', 'projectcode', $this->projectcode])->andFilterWhere(['like', 'projectname', $this->projectname])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'contractor', $this->contractor])->andFilterWhere(['like', 'sitename.sitename', $this->sitename_id])->andFilterWhere(['like', 'account.acct_name', $this->account_id])->andFilterWhere(['like', 'pic.pic_fullName', $this->pic_id])->andFilterWhere(['like', 'remarks', $this->remarks]); return $dataProvider; }
function actionSave() { $idcompany = 2; $name = $_POST['name']; $date = strtoupper(date("d-M-y h.i.s.u A")); $model = new Project(); $no = $model->find()->select(['FIELD1'])->orderby(['FIELD1' => SORT_DESC])->asArray()->scalar(); $model->FIELD1 = $no + 1; $model->FIELD2 = $idcompany; $model->FIELD3 = $name; $model->FIELD4 = ''; if ($model->insert()) { echo "sukses"; } else { echo $date; } echo "wreewrewr"; }