Beispiel #1
0
 public function nuevaDependencia($inputs)
 {
     DB::transaction(function () use($inputs) {
         $dep = new Dependencia();
         $dep->NombreDependencia = $inputs['NuevaDependencia'];
         $dep->AcronimoDependencia = $inputs['NuevaDependenciaAcronimo'];
         $dep->save();
     });
     $Id = DB::table('dependencia')->max('IdDependencia');
     return $Id;
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Dependencia();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Dependencia'])) {
         $model->attributes = $_POST['Dependencia'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->idDependencia));
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Dependencia();
     $user_id = Yii::app()->user->getId();
     $user = Usuario::model()->findbyPk($user_id);
     $model->sede_id = $user->dependencia->sede_id;
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Dependencia'])) {
         $model->attributes = $_POST['Dependencia'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $generos = Sexo::model()->findAll(array('select' => 'id, descripcion', 'order' => 'descripcion ASC'));
     $this->render('create', array('model' => $model, 'generos' => $generos));
 }
 public function post_nuevo()
 {
     $inputs = Input::all();
     $reglas = array('nombre' => 'required|max:50', 'direccion' => 'required|max:50', 'telefono' => 'required|max:50');
     $mensajes = array('required' => 'Campo Obligatorio');
     $validar = Validator::make($inputs, $reglas);
     if ($validar->fails()) {
         Input::flash();
         return Redirect::back()->withInput()->withErrors($validar);
     } else {
         $dependencia = new Dependencia();
         $dependencia->nombre = Input::get('nombre');
         $dependencia->direccion = Input::get('direccion');
         $dependencia->telefono = Input::get('telefono');
         $dependencia->save();
         return Redirect::to('lista_dependencias')->with('error', 'La dependencia ha sido registrada con Éxito')->withInput();
     }
 }