Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Proyecto::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, 'fecha_inicio' => $this->fecha_inicio, 'fecha_fin' => $this->fecha_fin, 'estatus_proyecto' => $this->estatus_proyecto, 'situacion_presupuestaria' => $this->situacion_presupuestaria, 'monto_proyecto' => $this->monto_proyecto, 'sub_sector' => $this->sub_sector, 'plan_operativo' => $this->plan_operativo, 'objetivo_general' => $this->objetivo_general]);
     $query->andFilterWhere(['like', 'codigo_proyecto', $this->codigo_proyecto])->andFilterWhere(['like', 'codigo_sne', $this->codigo_sne])->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'descripcion', $this->descripcion]);
     $query->andFilterWhere(['estatus' => $this->nombreEstatus]);
     return $dataProvider;
 }
 /**
  * Updates an existing ProyectoAsignar 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 $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $request = Yii::$app->request;
     $model = $this->findModel($id);
     //Listas desplegables
     $proyectos = Proyecto::find(['estatus' => 1])->all();
     if ($request->isAjax) {
         /*
          *   Process for ajax request
          */
         Yii::$app->response->format = Response::FORMAT_JSON;
         if ($request->isGet) {
             return ['title' => "Asignar", 'content' => $this->renderPartial('update', ['model' => $model, 'proyectos' => $proyectos]), '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' => 'true', 'title' => "Asignado", 'content' => $this->renderPartial('view', ['model' => $model]), 'footer' => Html::button('Cerrar', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::a('Editar', ['update', 'id' => $id], ['class' => 'btn btn-primary', 'role' => 'modal-remote'])];
             } else {
                 return ['title' => "Asignar", 'content' => $this->renderPartial('update', ['model' => $model, 'proyectos' => $proyectos]), '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, 'proyectos' => $proyectos]);
         }
     }
 }