Exemplo n.º 1
0
 public function actionCreatedep()
 {
     PermisosController::permisoAdministrador();
     $model = new DepartamentoForm();
     $msg = null;
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $tabla = new DepartamentoTabla();
             $tabla->NOMBRE_DEPARTAMENTO = $model->NOMBRE_DEPARTAMENTO;
             if ($tabla->insert()) {
                 $msg = '<div class="alert alert-success" role="alert">Registro insertado correctamente</div>';
                 $model = new DepartamentoForm();
             } else {
                 $msg = '<div class="alert alert-danger" role="alert">Error al insertar registro</div>';
             }
         }
     } else {
         $model->getErrors();
     }
     return $this->render("CreateDep", ["model" => $model, "msg" => $msg]);
 }