/**
  * Updates an existing LocalizacionAccVariable model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id, $variable, $localizacion
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $request = Yii::$app->request;
     $model = $this->findModel($id);
     $model1 = AccionCentralizadaVariableProgramacion::find()->where(['id_localizacion' => $model->id])->One();
     $model->scenario = $localizacion == '0' ? 'Nacional' : 'Estadal';
     //lista desplegable
     $paises = Pais::find()->all();
     $estados = Estados::find()->all();
     if ($request->isAjax) {
         /*
          *   Process for ajax request
          */
         Yii::$app->response->format = Response::FORMAT_JSON;
         if ($request->isGet) {
             return ['title' => "Localización y Programación", 'content' => $this->renderPartial('update', ['model' => $model, 'pais' => $paises, 'estados' => $estados, 'model1' => $model1]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
         } else {
             if ($model->load($request->post()) && $model->save()) {
                 $model1->id_localizacion = $model->id;
                 if ($model1->load($request->post()) && $model1->save()) {
                     return ['forceReload' => 'true', 'title' => "Localización y Programación", 'content' => $this->renderAjax('view', ['model' => $model, 'model1' => $model1, 'id' => $model->id]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::a('Editar', ['update', 'id' => $model->id, 'variable' => $model->id_variable, 'localizacion' => $model->idVariable->localizacion], ['class' => 'btn btn-primary', 'role' => 'modal-remote'])];
                 } else {
                     return ['title' => "Localización y Programación", 'content' => $this->renderAjax('update', ['model' => $model, 'pais' => $paises, 'estados' => $estados, 'model1' => $model1]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
                 }
             } else {
                 return ['title' => "Localización", 'content' => $this->renderAjax('update', ['model' => $model, 'pais' => $paises, 'estados' => $estados, 'model1' => $model1]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
             }
         }
     } else {
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('update', ['model' => $model]);
         }
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdEstado()
 {
     return $this->hasOne(Estados::className(), ['id' => 'id_estado']);
 }
 /**
  * Updates an existing ProyectoLocalizacion 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);
     //Escenario
     $model->scenario = $this->findAmbito($model->id_proyecto);
     switch ($model->scenario) {
         case 'Nacional':
             $model->id_pais = Pais::findOne(['nombre' => 'Venezuela'])->id;
             break;
         default:
             $model->id_pais = Pais::findOne(['nombre' => 'Venezuela'])->id;
             break;
     }
     //Listas desplegables
     $paises = Pais::find()->all();
     $estados = Estados::find()->all();
     $parroquias = Parroquia::find()->all();
     $municipios = Municipio::find()->all();
     if ($request->isAjax) {
         /*
          *   Process for ajax request
          */
         Yii::$app->response->format = Response::FORMAT_JSON;
         if ($request->isGet) {
             return ['title' => "Update ProyectoLocalizacion #" . $id, 'content' => $this->renderPartial('update', ['model' => $model, 'paises' => $paises, 'estados' => $estados, 'municipios' => $municipios, 'parroquias' => $parroquias]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
         } else {
             if ($model->load($request->post()) && $model->save()) {
                 return ['forceReload' => 'true', 'title' => "ProyectoLocalizacion #" . $id, 'content' => $this->renderPartial('view', ['model' => $model, 'paises' => $paises, 'estados' => $estados, 'municipios' => $municipios, 'parroquias' => $parroquias]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::a('Edit', ['update', 'id' => $id], ['class' => 'btn btn-primary', 'role' => 'modal-remote'])];
             } else {
                 return ['title' => "Update ProyectoLocalizacion #" . $id, 'content' => $this->renderPartial('update', ['model' => $model, 'paises' => $paises, 'estados' => $estados, 'municipios' => $municipios, 'parroquias' => $parroquias]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['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, 'paises' => $paises, 'estados' => $estados, 'municipios' => $municipios, 'parroquias' => $parroquias]);
         }
     }
 }