/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Priskhead::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(['risk_id' => $this->risk_id, 'risk_date' => $this->risk_date, 'date_complete' => $this->date_complete, 'input_complain' => $this->input_complain]); $query->andFilterWhere(['like', 'event_name', $this->event_name])->andFilterWhere(['like', 'ref', $this->ref])->andFilterWhere(['like', 'risk_again', $this->risk_again])->andFilterWhere(['like', 'risk_ref_no', $this->risk_ref_no]); return $dataProvider; }
public function actionDeletefileAjax() { $model = Uploadsp::findOne(Yii::$app->request->post('key')); if ($model !== NULL) { $filename = Priskhead::getUploadPath() . $model->ref . '/' . $model->real_filename; $thumbnail = Priskhead::getUploadPath() . $model->ref . '/thumbnail/' . $model->real_filename; if ($model->delete()) { @unlink($filename); @unlink($thumbnail); echo json_encode(['success' => true]); } else { echo json_encode(['success' => false]); } } else { echo json_encode(['success' => false]); } }