Exemple #1
0
 /**
 * Creates a new model.
 * If creation is successful, the browser will be redirected to the 'view' page.
 */
 public function actionCreate()
 {
     $model = new Matricula();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Matricula'])) {
         $model->attributes = $_POST['Matricula'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->idMatricula));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function postStore()
 {
     $this->sanarInputProfesor();
     $profesor = new Profesor();
     $profesor->nombres = Request::input('nombres');
     $profesor->apellidos = Request::input('apellidos');
     $profesor->sexo = Request::input('sexo');
     $profesor->tipo_doc = Request::input('tipo_doc');
     $profesor->num_doc = Request::input('num_doc');
     $profesor->ciudad_doc = Request::input('ciudad_doc');
     $profesor->fecha_nac = Request::input('fecha_nac');
     $profesor->ciudad_nac = Request::input('ciudad_nac');
     $profesor->titulo = Request::input('titulo');
     $profesor->estado_civil = Request::input('estado_civil');
     $profesor->barrio = Request::input('barrio');
     $profesor->direccion = Request::input('direccion');
     $profesor->telefono = Request::input('telefono');
     $profesor->celular = Request::input('celular');
     $profesor->facebook = Request::input('facebook');
     $profesor->email = Request::input('email');
     $profesor->tipo_profesor = Request::input('tipo_profesor');
     $profesor->save();
     $this->sanarInputUser();
     $this->checkOrChangeUsername($profesor->user_id);
     $usuario = new User();
     $usuario->username = Request::input('username');
     $usuario->password = Hash::make(Request::input('password', '123456'));
     $usuario->email = Request::input('email2');
     $usuario->is_superuser = Request::input('is_superuser', false);
     $usuario->is_active = Request::input('is_active', true);
     $usuario->tipo = 'Profesor';
     $usuario->save();
     $profesor->user_id = $usuario->id;
     $role = Role::where('name', '=', 'Profesor')->get();
     $usuario->attachRole($role[0]);
     $profesor->save();
     $profesor->user = $usuario;
     if (Request::input('grupo')['id']) {
         $grupo_id = Request::input('grupo')['id'];
         $matricula = new Matricula();
         $matricula->alumno_id = $profesor->id;
         $matricula->grupo_id = $grupo_id;
         $matricula->matriculado = true;
         $matricula->save();
         $grupo = Grupo::find($matricula->grupo_id);
         $profesor->grupo = $grupo;
     }
     return $profesor;
 }
 public function actionCreate()
 {
     $model = new Matricula();
     if (isset($_POST['Matricula'])) {
         $model->setAttributes($_POST['Matricula']);
         if ($model->save()) {
             if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                 Yii::app()->end();
             } else {
                 $this->redirect(array('view', 'id' => $model->IDMATRICULA));
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
Exemple #4
0
 function add()
 {
     App::Import('Model', 'Matricula');
     $Matricula = new Matricula();
     if (!empty($this->data)) {
         //die(var_dump($this->data));
         $data_matricula = array();
         $this->Aluno->create();
         $this->data['Aluno']['codigo'] = $this->Aluno->geraCodigo();
         $nome_foto = WWW_ROOT . "\ffotos\\" . $this->data['Aluno']['foto']['name'];
         $imagem = array($this->data['Aluno']['foto']);
         $fileOk = $this->uploadFiles('upload', $imagem);
         if (isset($fileOk['urls']) and $fileOk['urls'] != null) {
             $this->data['Aluno']['foto'] = $fileOk['urls'][0];
         } else {
             $this->data['Aluno']['foto'] = '';
         }
         $this->Aluno->User->create();
         $this->data['User']['username'] = $this->data['Aluno']['codigo'];
         $this->data['User']['password'] = md5($this->data['Aluno']['codigo']);
         $this->data['User']['codigocartao'] = $this->data['Aluno']['codigo'];
         $this->data['User']['name'] = $this->data['Aluno']['name'];
         $this->data['User']['group_id'] = 3;
         $this->Aluno->User->save($this->data);
         $this->data['Aluno']['user_id'] = $this->Aluno->User->getLastInsertID();
         //$this->data['Aluno']['foto'] = $this->data['Aluno']['codigo'].".jpg";
         if ($this->Aluno->save($this->data)) {
             /**
              * Pega os dados da matricula e realiza a matricula
              * @TODO Mudar o ano lectivo para algo mais serio :)
              * @Todo O turno e o nivel tambem ainda esta weak
              */
             $data_matricula['aluno_id'] = $this->Aluno->getInsertID();
             $data_matricula['curso_id'] = $this->data['Aluno']['curso_id'];
             $data_matricula['planoestudo_id'] = $this->data['Aluno']['planoestudo_id'];
             $data_matricula['estadomatricula_id'] = 1;
             $data_matricula['data'] = $this->data['Aluno']['dataingresso'];
             $data_matricula['user_id'] = $this->Session->read('Auth.User.id');
             $data_matricula['anolectivo_id'] = 4;
             $matricula_gravar = array('Matricula' => $data_matricula);
             if ($Matricula->save($matricula_gravar)) {
                 $this->Session->setFlash('Aluno Registrado com sucesso</p><p>A matricula do aluno foi registrada com sucesso', 'flashok');
                 $this->redirect(array('action' => 'index'));
             } else {
                 $this->Session->setFlash('Erro ao registrar aluno. Por favor tente de novo.', 'flasherror');
             }
         }
     }
     $cursos = $this->Aluno->Curso->find('list');
     $planoestudos = $Matricula->Planoestudo->find('list');
     $users = $this->Aluno->User->find('list');
     $paises = $this->Aluno->Paise->find('list');
     $cidades = $this->Aluno->Cidade->find('list');
     $provincias = $this->Aluno->Provincia->find('list');
     $provenienciacidades = $this->Aluno->ProvenienciaCidade->find('list');
     $proveniencianomes = $this->Aluno->ProvenienciaProvincia->find('list');
     $documentos = $this->Aluno->Documento->find('list');
     $areatrabalhos = $this->Aluno->Areatrabalho->find('list');
     $generos = $this->Aluno->Genero->find('list');
     $cidadenascimentos = $this->Aluno->CidadeNascimento->find('list');
     $this->set(compact('cursos', 'planoestudos', 'users', 'paises', 'cidades', 'provincias', 'documentos', 'areatrabalhos', 'generos', 'cidadenascimentos', 'proveniencianomes', 'provenienciacidades'));
 }