/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Modulo();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Modulo'])) {
         $model->attributes = $_POST['Modulo'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
示例#2
0
 public function store()
 {
     $data = Input::all();
     $modulo = new Modulo();
     $modulo->fill($data['modulo']);
     $modulo->save();
     foreach ($data['materiales'] as $index => $m_data) {
         $material = new ModuloVinculacion();
         $material->validFill($m_data);
         $material->save();
         $modulo->vinculaciones()->save($material);
     }
     return Redirect::route('modulos.index');
 }
示例#3
0
 public function store()
 {
     $modulo = new Modulo();
     $modulo->ruta = Input::get('ruta');
     $modulo->nombre = Input::get('nombre');
     $modulo->icono = Input::get('icono');
     $modulo->orden = Input::get('orden');
     $modulo->activo = Input::get('activo');
     $modulo->save();
     //Asociar con Roles
     if (count(Input::get('modulo_role')) > 0) {
         $modulo_role = Input::get('modulo_role');
         $modulo->roles()->sync($modulo_role);
     }
     return Redirect::action('ModuloController@index');
 }
示例#4
0
 /**
  * Store a newly created resource in storage.
  * POST /modulo/crear
  *
  * @return Response
  */
 public function postCrear()
 {
     //si la peticion es ajax
     if (Request::ajax()) {
         $regex = 'regex:/^([a-zA-Z .,ñÑÁÉÍÓÚáéíóú]{2,60})$/i';
         $required = 'required';
         $reglas = array('nombre' => $required . '|' . $regex, 'path' => $regex . '|unique:modulos,path,');
         $mensaje = array('required' => ':attribute Es requerido', 'regex' => ':attribute Solo debe ser Texto');
         $validator = Validator::make(Input::all(), $reglas, $mensaje);
         if ($validator->fails()) {
             return Response::json(array('rst' => 2, 'msj' => $validator->messages()));
         }
         $modulos = new Modulo();
         $modulos->nombre = Input::get('nombre');
         $modulos->path = Input::get('path');
         $modulos->estado = Input::get('estado');
         $modulos->save();
         return Response::json(array('rst' => 1, 'msj' => 'Registro realizado correctamente'));
     }
 }
示例#5
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aModulo !== null) {
             if ($this->aModulo->isModified() || $this->aModulo->isNew()) {
                 $affectedRows += $this->aModulo->save($con);
             }
             $this->setModulo($this->aModulo);
         }
         if ($this->aRol !== null) {
             if ($this->aRol->isModified() || $this->aRol->isNew()) {
                 $affectedRows += $this->aRol->save($con);
             }
             $this->setRol($this->aRol);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
示例#6
0
     $view->modulo = Modulo::getModulos();
     $view->contentTemplate = "templates/modulosGrid.php";
     // seteo el template que se va a mostrar
     break;
 case 'grabar':
     // limpio todos los valores antes de guardarlos
     // por ls dudas venga algo raro
     $Id = intval($_POST['Id']);
     $IdDia = intval($_POST['IdDia']);
     $Inicio = cleanString($_POST['Inicio']);
     $Fin = cleanString($_POST['Fin']);
     $Modulo = new Modulo($Id);
     $Modulo->setIdDia($IdDia);
     $Modulo->setInicio($Inicio);
     $Modulo->setFin($Fin);
     $Modulo->save();
     break;
 case 'nuevo':
     $view->modulo = new Modulo();
     $view->label = 'Nuevo Módulo';
     $view->disableLayout = true;
     $view->contentTemplate = "templates/moduloForm.php";
     // seteo el template que se va a mostrar
     break;
 case 'editar':
     $editId = intval($_POST['Id']);
     $view->label = 'Editar Módulo';
     $view->modulo = new Modulo($editId);
     $view->disableLayout = true;
     $view->contentTemplate = "templates/moduloForm.php";
     // seteo el template que se va a mostrar