/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ProyectoAeMeta::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, 'id_proyecto_accion_especifica' => $this->id_proyecto_accion_especifica, 'enero' => $this->enero, 'febrero' => $this->febrero, 'marzo' => $this->marzo, 'abril' => $this->abril, 'mayo' => $this->mayo, 'junio' => $this->junio, 'julio' => $this->julio, 'agosto' => $this->agosto, 'septiembre' => $this->septiembre, 'octubre' => $this->octubre, 'noviembre' => $this->noviembre, 'diciembre' => $this->diciembre, 'status' => $this->status, 'fecha_creacion' => $this->fecha_creacion]); return $dataProvider; }
/** * Updates an existing ProyectoAeMeta model. * For ajax request will return json object * and for non-ajax request if update is successful, the browser will be redirected to the 'view' page. * @param integer $accionEspecifica ID de la accion * @return mixed */ public function actionUpdate($accionEspecifica) { $request = Yii::$app->request; $model = ProyectoAeMeta::find()->where(['id_proyecto_accion_especifica' => $accionEspecifica])->one(); if ($request->isAjax) { /* * Process for ajax request */ Yii::$app->response->format = Response::FORMAT_JSON; if ($request->isGet) { return ['title' => "Update ProyectoAeMeta #" . $model->id, 'content' => $this->renderAjax('update', ['model' => $model]), 'footer' => Html::button('Cerrar', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Guardar', ['class' => 'btn btn-primary', 'type' => "submit"])]; } else { if ($model->load($request->post()) && $model->save()) { return ['forceReload' => '#especifica-pjax', 'title' => "ProyectoAeMeta #" . $model->id, 'content' => $this->renderAjax('view', ['model' => $model]), 'footer' => Html::button('Cerrar', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::a('Editar', ['update', 'accionEspecifica' => $model->id], ['class' => 'btn btn-primary', 'role' => 'modal-remote'])]; } else { return ['title' => "Update ProyectoAeMeta #" . $model->id, 'content' => $this->renderAjax('update', ['model' => $model]), 'footer' => Html::button('Cerrar', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Guardar', ['class' => 'btn btn-primary', 'type' => "submit"])]; } } } else { /* * Process for non-ajax request */ if ($model->load($request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model]); } } }