public function actionUpdate()
 {
     PermisosController::permisoDirectorDecano();
     $model = new SolicitudFormulario();
     $msg = null;
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $modelsolicitud = SolicitudFormulario::findOne($_GET["ID_SOLICITUD"]);
             if ($modelsolicitud) {
                 $modelsolicitud->ID_ESTADO = $model->ID_ESTADO;
             }
             if ($modelsolicitud->update()) {
                 $msg = '<div class="alert alert-success" role="alert">Estado actualizado correctamente.</div>';
             } else {
                 $msg = '<div class="alert alert-danger" role="alert">Error al actualizar o no existen cambios</div>';
             }
         } else {
             $msg = '<div class="alert alert-warning" role="alert">Estado no encontrado.</div>';
         }
     }
     if (Yii::$app->request->get("ID_SOLICITUD")) {
         $ID_SOLICITUD = Html::encode($_GET["ID_SOLICITUD"]);
         if ((int) $ID_SOLICITUD) {
             $modelsolicitud = SolicitudTabla::findOne($ID_SOLICITUD);
             if ($modelsolicitud) {
                 $model->ID_ESTADO = $modelsolicitud->ID_ESTADO;
             } else {
                 $msg = "Tabla no encontrada";
                 return $this->redirect(["solicitudes/view"]);
             }
         } else {
             $msg = "ID no valido";
             return $this->redirect(["solicitudes/view"]);
         }
     } else {
         return $this->redirect(["solicitudes/view"]);
     }
     return $this->render("update", ["model" => $model, "msg" => $msg]);
 }
 /**
  * Finds the Estadogasto model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Estadogasto the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     PermisosController::permisoAdministrador();
     if (($model = Estadogasto::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Deletes an existing Gastosasociados model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     PermisosController::permisoAdministrador();
     $this->findModel($id)->delete();
     return $this->redirect(['index']);
 }
Esempio n. 4
0
 public function actionCrear()
 {
     PermisosController::permisoDocenteDirectorDecano();
     $model = new SolicitudMet();
     if ($model->load(Yii::$app->request->post())) {
         $tableviaje = new Viaje();
         $tableviaje->ORIGEN_VIAJE = $model->origen;
         $tableviaje->FECHA_INICIO_DIRECCION = $model->anhoi . '-' . $model->mesi . '-' . $model->diai . ' ' . '00:' . '00:' . '01';
         $tableviaje->FECHA_TERMINO_DIRECCION = $model->anhot . '-' . $model->mest . '-' . $model->diat . ' ' . '23:' . '59:' . '59';
         $tableviaje->insert();
         $ultimoidviaje = solicitudMet::ultimoID();
         if ($model->check1 == 1) {
             $tabledestino = new Destino();
             $tabledestino->ID_VIAJE = $ultimoidviaje;
             $tabledestino->DURACION_VIAJE_DIAS = $model->duracion1;
             $tabledestino->MEDIO_DE_TRANSPORTE = $model->transporte1;
             $tabledestino->CIUDAD_DESTINO = $model->ciudad1;
             $tabledestino->PAIS_DESTINO = $model->pais1;
             $tabledestino->insert();
         } else {
             $viaje = Viaje::find()->where(['ID_VIAJE' => $ultimoidviaje])->one();
             $viaje->delete();
             $tablesolicitud = new Solicitud();
             $msg = '<div class="alert alert-warning" role="alert"><strong>ERROR!</strong> No se envi&#243; la solicitud, ingrese datos v&#225;lidos.</div>';
             $modelsolicitud = $tablesolicitud->find()->where(['ID_USUARIO' => Yii::$app->user->identity->ID_USUARIO])->all();
             return $this->render('index', ['model' => $modelsolicitud, 'msg' => $msg]);
         }
         if ($model->check2 == 1) {
             if ($model->duracion2 != null && $model->transporte2 != null && $model->ciudad2 != null && $model->pais2 != null) {
                 $tabledestino2 = new Destino();
                 $tabledestino2->ID_VIAJE = $ultimoidviaje;
                 $tabledestino2->DURACION_VIAJE_DIAS = $model->duracion2;
                 $tabledestino2->MEDIO_DE_TRANSPORTE = $model->transporte2;
                 $tabledestino2->CIUDAD_DESTINO = $model->ciudad2;
                 $tabledestino2->PAIS_DESTINO = $model->pais2;
                 $tabledestino2->insert();
             } else {
                 Destino::deleteAll("ID_VIAJE=" . $ultimoidviaje);
                 $viaje = Viaje::find()->where(['ID_VIAJE' => $ultimoidviaje])->one();
                 $viaje->delete();
                 $tablesolicitud = new Solicitud();
                 $msg = '<div class="alert alert-danger" role="alert"><strong>ERROR!</strong> No se envi&#243; la solicitud, ingrese datos v&#225;lidos.</div>';
                 $modelsolicitud = $tablesolicitud->find()->where(['ID_USUARIO' => Yii::$app->user->identity->ID_USUARIO])->all();
                 return $this->render('index', ['model' => $modelsolicitud, 'msg' => $msg]);
             }
         }
         if ($model->check3 == 1) {
             if ($model->duracion3 != null && $model->transporte3 != null && $model->ciudad3 != null && $model->pais3 != null) {
                 $tabledestino3 = new Destino();
                 $tabledestino3->ID_VIAJE = $ultimoidviaje;
                 $tabledestino3->DURACION_VIAJE_DIAS = $model->duracion3;
                 $tabledestino3->MEDIO_DE_TRANSPORTE = $model->transporte3;
                 $tabledestino3->CIUDAD_DESTINO = $model->ciudad3;
                 $tabledestino3->PAIS_DESTINO = $model->pais3;
                 $tabledestino3->insert();
             } else {
                 Destino::deleteAll("ID_VIAJE=" . $ultimoidviaje);
                 $viaje = Viaje::find()->where(['ID_VIAJE' => $ultimoidviaje])->one();
                 $viaje->delete();
                 $tablesolicitud = new Solicitud();
                 $msg = '<div class="alert alert-danger" role="alert"><strong>ERROR!</strong> No se envi&#243; la solicitud, ingrese datos v&#225;lidos.</div>';
                 $modelsolicitud = $tablesolicitud->find()->where(['ID_USUARIO' => Yii::$app->user->identity->ID_USUARIO])->all();
                 return $this->render('index', ['model' => $modelsolicitud, 'msg' => $msg]);
             }
         }
         if ($model->check4 == 1) {
             if ($model->duracion4 != null && $model->transporte4 != null && $model->ciudad4 != null && $model->pais4 != null) {
                 $tabledestino4 = new Destino();
                 $tabledestino4->ID_VIAJE = $ultimoidviaje;
                 $tabledestino4->DURACION_VIAJE_DIAS = $model->duracion4;
                 $tabledestino4->MEDIO_DE_TRANSPORTE = $model->transporte4;
                 $tabledestino4->CIUDAD_DESTINO = $model->ciudad4;
                 $tabledestino4->PAIS_DESTINO = $model->pais4;
                 $tabledestino4->insert();
             } else {
                 Destino::deleteAll("ID_VIAJE=" . $ultimoidviaje);
                 $viaje = Viaje::find()->where(['ID_VIAJE' => $ultimoidviaje])->one();
                 $viaje->delete();
                 $tablesolicitud = new Solicitud();
                 $msg = '<div class="alert alert-danger" role="alert"><strong>ERROR!</strong> No se envi&#243; la solicitud, ingrese datos v&#225;lidos.</div>';
                 $modelsolicitud = $tablesolicitud->find()->where(['ID_USUARIO' => Yii::$app->user->identity->ID_USUARIO])->all();
                 return $this->render('index', ['model' => $modelsolicitud, 'msg' => $msg]);
             }
         }
         if ($model->check5 == 1) {
             if ($model->duracion5 != null && $model->transporte5 != null && $model->ciudad5 != null && $model->pais5 != null) {
                 $tabledestino5 = new Destino();
                 $tabledestino5->ID_VIAJE = $ultimoidviaje;
                 $tabledestino5->DURACION_VIAJE_DIAS = $model->duracion5;
                 $tabledestino5->MEDIO_DE_TRANSPORTE = $model->transporte5;
                 $tabledestino5->CIUDAD_DESTINO = $model->ciudad5;
                 $tabledestino5->PAIS_DESTINO = $model->pais5;
                 $tabledestino5->insert();
             } else {
                 Destino::deleteAll("ID_VIAJE=" . $ultimoidviaje);
                 $viaje = Viaje::find()->where(['ID_VIAJE' => $ultimoidviaje])->one();
                 $viaje->delete();
                 $tablesolicitud = new Solicitud();
                 $msg = '<div class="alert alert-danger" role="alert"><strong>ERROR!</strong> No se envi&#243; la solicitud, ingrese datos v&#225;lidos.</div>';
                 $modelsolicitud = $tablesolicitud->find()->where(['ID_USUARIO' => 1])->all();
                 return $this->render('index', ['model' => $modelsolicitud, 'msg' => $msg]);
             }
         }
         $tablesolicitud = new Solicitud();
         $tablesolicitud->ID_USUARIO = Yii::$app->user->identity->ID_USUARIO;
         $tablesolicitud->ID_TIPO_DE_VIAJE = $model->idtipoviaje;
         $tablesolicitud->ID_VIAJE = $ultimoidviaje;
         $tablesolicitud->FECHA_SOLICITUD = date("Y-m-d H:i:s");
         $tablesolicitud->ID_ESTADO = 1;
         $tablesolicitud->CUERPO_SOLICITUD = $model->cuerpo;
         $tablesolicitud->insert();
         $tablesolicitud = new Solicitud();
         $msg = '<div class="alert alert-success" role="alert"><strong>Enviada!</strong> Solicitud enviada.</div>';
         $modelsolicitud = $tablesolicitud->find()->where(['ID_USUARIO' => Yii::$app->user->identity->ID_USUARIO])->all();
         return $this->render('index', ['model' => $modelsolicitud, 'msg' => $msg]);
     } else {
         $msg = null;
         $tablesolicitud = new TipoViaje();
         $modeltipos = $tablesolicitud->find()->all();
         return $this->render('crear-solicitud', ['model' => $model, 'tipos' => $modeltipos, 'msg' => $msg]);
     }
 }
Esempio n. 5
0
 public function actionCreate()
 {
     PermisosController::permisoDocenteDirectorDecano();
     $model = new FormGastos();
     $msg = null;
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $table = new Gastos();
             $table->ID_VIAJE = $model->id_viaje;
             $table->NOMBRE_GASTO = $model->nombregasto;
             $table->MONTO_GASTO = $model->montogasto;
             $table->FECHA_GASTO = $model->fechagasto;
             if ($table->insert()) {
                 $msg = "Registro guardado correctamente";
                 $model->id_viaje = null;
                 $model->nombregasto = null;
                 $model->montogasto = null;
             } else {
                 $msg = "Ha ocurrido un error";
             }
         } else {
             $model->getErrors();
         }
     }
     return $this->render("create", ['model' => $model, 'msg' => $msg]);
 }
Esempio n. 6
0
 public function actionUpdatedep()
 {
     PermisosController::permisoAdministrador();
     $model = new DepartamentoForm();
     $msg = null;
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $tabla = DepartamentoTabla::findOne($_GET["id_departamento"]);
             if ($tabla) {
                 $tabla->NOMBRE_DEPARTAMENTO = $model->NOMBRE_DEPARTAMENTO;
                 if ($tabla->update()) {
                     $msg = '<div class="alert alert-success" role="alert">Departamento actualizado correctamente.</div>';
                 } else {
                     $msg = '<div class="alert alert-danger" role="alert">Error al actualizar o no existen cambios</div>';
                 }
             } else {
                 $msg = '<div class="alert alert-warning" role="alert">Departamento no encontrado.</div>';
             }
         }
     }
     if (Yii::$app->request->get("id_departamento")) {
         $id_departamento = Html::encode($_GET["id_departamento"]);
         if ((int) $id_departamento) {
             $tabla = DepartamentoTabla::findOne($id_departamento);
             if ($tabla) {
                 $model->NOMBRE_DEPARTAMENTO = $tabla->NOMBRE_DEPARTAMENTO;
             } else {
                 $msg = "Tabla no encontrada";
                 return $this->redirect(["usuario/viewdep"]);
             }
         } else {
             $msg = "ID no valido";
             return $this->redirect(["usuario/viewdep"]);
         }
     } else {
         return $this->redirect(["usuario/viewdep"]);
     }
     return $this->render("Updatedep", ["model" => $model, "msg" => $msg]);
 }