コード例 #1
0
 /**
  * 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.');
     }
 }
コード例 #2
0
ファイル: SiteController.php プロジェクト: MvegaR/ingSotfware
 public function actionEditarTViaje()
 {
     PermisosController::permisoAdministrador();
     $model = new TipoViajeForm();
     $msg = null;
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $table = TipoViaje::findOne($model->id_tipo_viaje);
             if ($table) {
                 $table->NOMBRE_TIPO_DE_VIAJE = $model->nombre_tipo_viaje;
                 $table->MONTO_MAXIMO = $model->monto_maximo;
                 if ($table->update()) {
                     $msg = '<div class="alert alert-success" role="alert"><strong>Modificado!</strong> El Tipo de Viaje fue modificado.</div>';
                 } else {
                     $msg = '<div class="alert alert-warning" role="alert"><strong>Peligro!</strong> El tipo de viaje no se modifico.</div>';
                 }
             } else {
                 $msg = '<div class="alert alert-danger" role="alert"><strong>Error!</strong> Tipo de Viaje no encontrado.</div>';
             }
             $model = $table->find()->all();
             return $this->render("tipo-viaje", ["model" => $model, 'msg' => $msg]);
         } else {
             $model->getErrors();
         }
     }
     if (Yii::$app->request->get("ID_TIPO_DE_VIAJE")) {
         $ID_TIPO_DE_VIAJE = Html::encode($_GET["ID_TIPO_DE_VIAJE"]);
         if ((int) $ID_TIPO_DE_VIAJE) {
             $table = TipoViaje::findOne($ID_TIPO_DE_VIAJE);
             if ($table) {
                 $model->id_tipo_viaje = $table->ID_TIPO_DE_VIAJE;
                 $model->nombre_tipo_viaje = $table->NOMBRE_TIPO_DE_VIAJE;
                 $model->monto_maximo = $table->MONTO_MAXIMO;
             } else {
                 return $this->redirect(["site/tipo-viaje"]);
             }
         } else {
             return $this->redirect(["site/tipo-viaje"]);
         }
     } else {
         return $this->redirect(["site/tipo-viaje"]);
     }
     return $this->render("editar-tipo-viaje", ["model" => $model, "msg" => $msg]);
 }
コード例 #3
0
 /**
  * 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']);
 }
コード例 #4
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]);
 }