public function submit_create_grupo() { if (Auth::check()) { $data["inside_url"] = Config::get('app.inside_url'); $data["user"] = Session::get('user'); // Verifico si el usuario es un Webmaster if ($data["user"]->idrol == 1) { // Validate the info, create rules for the inputs $attributes = array('nombre_grupo' => 'Nombre del Grupo', 'usuario_responsable' => 'Usuario Responsable', 'descripcion_grupo' => 'Descripción del Grupo'); $messages = array(); $rules = array('nombre_grupo' => 'required|max:100|alpha_num_spaces|unique:grupos,nombre', 'descripcion_grupo' => 'max:200|alpha_num_spaces_colon', 'usuario_responsable' => 'required'); // Run the validation rules on the inputs from the form $validator = Validator::make(Input::all(), $rules, $messages, $attributes); // If the validator fails, redirect back to the form if ($validator->fails()) { return Redirect::to('grupos/create_grupo')->withErrors($validator)->withInput(Input::all()); } else { $grupo = new Grupo(); $grupo->nombre = Input::get('nombre_grupo'); $grupo->descripcion = Input::get('descripcion_grupo'); $grupo->id_responsable = Input::get('usuario_responsable'); $grupo->idestado = 1; $grupo->save(); return Redirect::to('grupos/list_grupos')->with('message', 'Se registró correctamente el grupo: ' . $grupo->nombre); } } else { return View::make('error/error', $data); } } else { return View::make('error/error', $data); } }
/** * 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 coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aGrupo !== null) { if ($this->aGrupo->isModified() || $this->aGrupo->isNew()) { $affectedRows += $this->aGrupo->save($con); } $this->setGrupo($this->aGrupo); } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = GrupoModuloPeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setNew(false); } else { $affectedRows += GrupoModuloPeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } $this->alreadyInSave = false; } return $affectedRows; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Grupo(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Grupo'])) { $model->attributes = $_POST['Grupo']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function agregarGrupo() { if (Request::ajax()) { $new_grupo = new Grupo(); $new_grupo->nombre = Input::get("nombre"); if ($new_grupo->validate()) { $new_grupo->save(); if ($new_grupo) { return Response::json(array('success' => true)); } } else { return Response::json(array('success' => false, 'errores' => $new_grupo->errors()->toArray())); } } }
public function store() { //RECUPERAR LOS DATOS DE CREATE Y GUARDAR LOS DATOS EN LA BASE DE DATOS $nombre = Input::get('nombre'); $a = '[{"nombre":"' . $nombre . '"}]'; $b = Grupo::select('nombre')->where('nombre', $nombre)->get(); if ($a == $b) { Session::flash('message', "El grupo ({$nombre}) ya existe en la base de datos!"); Session::flash('class', 'danger'); } else { $grupo = new Grupo(); $grupo->nombre = Input::get('nombre'); $grupo->save(); Session::flash('message', 'Guardado correctamente!'); Session::flash('class', 'success'); } return Redirect::to('grupo/create'); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Grupo(); $model->atividade = new PermissaoAtividadeForm(); $model->pessoa = new PermissaoPessoaForm(); $model->projeto = new PermissaoProjetoForm(); $model->gerencial = new PermissaoGerencialForm(); $model->acervo = new PermissaoAcervoForm(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Grupo'])) { $model->attributes = $_POST['Grupo']; $perm = array(); if (isset($_POST['PermissaoAtividadeForm'])) { $perm['atividade'] = $_POST['PermissaoAtividadeForm']; } if (isset($_POST['PermissaoAtividadeForm'])) { $perm['pessoa'] = $_POST['PermissaoPessoaForm']; } if (isset($_POST['PermissaoProjetoForm'])) { $perm['projeto'] = $_POST['PermissaoProjetoForm']; } if (isset($_POST['PermissaoAcervoForm'])) { $perm['acervo'] = $_POST['PermissaoAcervoForm']; } if (isset($_POST['PermissaoGerencialForm'])) { $perm['gerencial'] = $_POST['PermissaoGerencialForm']; } $model->permissao = json_encode($perm); if ($model->save()) { //Valida pessoas if (isset($_POST['Grupo']['pessoas'])) { $model->pessoas = $_POST['Grupo']['pessoas']; $this->salvaPessoas($model->cod_grupo, $model->pessoas); } $this->redirect(array('index')); } } $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() { Yii::import('ext.multimodelform.MultiModelForm'); $model = new Grupo(); $chico = new Chico(); $validatedMembers = array(); //ensure an empty array // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Grupo'])) { $model->attributes = $_POST['Grupo']; if (MultiModelForm::validate($chico, $validatedMembers, $deleteItems) && $model->save()) { //the value for the foreign key 'groupid' $masterValues = array('grupo_id' => $model->id); if (MultiModelForm::save($chico, $validatedMembers, $deleteMembers, $masterValues)) { //$this->redirect(array('view','id'=>$model->id)); $this->redirect(array('registro/create', 'id' => $model->id)); } } } $this->render('create', array('model' => $model, 'chico' => $chico, 'validatedMembers' => $validatedMembers)); $this->renderPartial('/site/buscarsalida'); }
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 . '|unique:tipo_grupos_personas'); $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())); } $tpgrupo = TipoGrupoPersona::find(Input::get('grupo')); $tgrupo = new Grupo(); $tgrupo->nombre = Input::get('nombre'); $tgrupo->tipo_grupo_id = Input::get('grupo'); if ($tpgrupo->ubigeo == '1') { $tgrupo->departamento_id = Input::get('region'); $tgrupo->provincia_id = Input::get('provincia'); $tgrupo->distrito_id = Input::get('distrito'); $tgrupo->localidad = Input::get('localidad'); $tgrupo->direccion = Input::get('direccion'); $tgrupo->telefono = Input::get('telefono'); } $tgrupo->estado = Input::get('estado'); $tgrupo->usuario_created_at = Auth::user()->id; $tgrupo->save(); return Response::json(array('rst' => 1, 'msj' => 'Registro realizado correctamente')); } }
protected function guardar_combos($CODIGO_DANE_SEDE, $TIPO_JORNADA, $GRADO, $GRUPO_CURSO) { if ($CODIGO_DANE_SEDE != "") { if ($TIPO_JORNADA != "") { $jornada = Jornada::model()->find("idjornada=" . $TIPO_JORNADA . " AND codigo_dane_sede='" . $CODIGO_DANE_SEDE . "'"); if ($jornada == null) { $newjornada = new Jornada(); $newjornada->idjornada = $TIPO_JORNADA; $newjornada->codigo_dane_sede = $CODIGO_DANE_SEDE; $newjornada->jornada = JornadaEducativa::model()->findByPk($TIPO_JORNADA)->Descripcion; $newjornada->save(); } if ($GRADO != "") { $grado = Grado::model()->find("idgrado=" . $GRADO . " AND jornada_id=" . $TIPO_JORNADA . " AND codigo_dane_sede='" . $CODIGO_DANE_SEDE . "'"); if ($grado == null) { $newgrado = new Grado(); $newgrado->jornada_id = $TIPO_JORNADA; $newgrado->codigo_dane_sede = $CODIGO_DANE_SEDE; $newgrado->idgrado = $GRADO; $newgrado->grado = GradoEducativo::model()->find("Codigo=" . $GRADO)->Descripcion; $newgrado->save(); } if ($GRUPO_CURSO != "") { $grupo = Grupo::model()->find("grado=" . $GRADO . " AND grupo_curso=" . $GRUPO_CURSO . " AND codigo_dane_sede='" . $CODIGO_DANE_SEDE . "'"); if ($grupo == null) { $newgrupo = new Grupo(); $newgrupo->grado = $GRADO; $newgrupo->codigo_dane_sede = $CODIGO_DANE_SEDE; $newgrupo->grupo_curso = $GRUPO_CURSO; $newgrupo->save(); } } } } } }
include '../Models/Conexao.php'; include '../Models/Secao.php'; include '../Models/Divisao.php'; include '../Models/Grupo.php'; include '../Models/Classe.php'; include '../Models/Subclasse.php'; if ($_REQUEST['action'] == 'extrair' && !empty($_REQUEST['data_url'])) { $dados = RequisicaoController::extrair(); $secao = new Secao($dados); $secao_id = Secao::save($secao); $divisao = new Divisao($dados); $divisao->secao_id = $secao_id; $divisao_id = Divisao::save($divisao); $grupo = new Grupo($dados); $grupo->divisao_id = $divisao_id; $grupo_id = Grupo::save($grupo); $classe = new Classe($dados); $classe->grupo_id = $grupo_id; $classe_id = Classe::save($classe); $subclasse = new Subclasse($dados); $subclasse->classe_id = $classe_id; $subclasse_id = Subclasse::save($subclasse); } class RequisicaoController { public function extrair() { $url = $_REQUEST['data_url']; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);