/**
  * Carrega o view de inscrição
  * @param  string $cpf_param cadastro de pessoa física do ouvinte
  * @return void 
  */
 public function inscricao($cpf_param = null)
 {
     $cpf = valida_cpf($cpf_param);
     $user_logged = $this->usuario_bo->getUserSession();
     if ($user_logged) {
         $isOuvinte = $this->ouvinte_bo->isCurrentUserOuvinte();
         if ($isOuvinte) {
             $this->session->set_flashdata('aviso', 'Usuario já cadastrado como ouvinte');
             redirect(base_url() . 'usuario/ouvinte_ctr');
         } else {
             redirect(base_url() . 'usuario/ouvinte_ctr/inscricao_incremental');
         }
     } else {
         if ($cpf != null) {
             if ($cpf == false) {
                 $this->session->set_flashdata('erro', 'O CPF informado é inválido');
                 redirect(base_url() . 'home/home_ctr');
             } else {
                 $this->ouvinte_inscricao_vm->setCpf($cpf);
                 $data['ouvinte'] = $this->ouvinte_inscricao_vm;
                 $data['is_registered'] = FALSE;
                 $data['cpf'] = $this->ouvinte_inscricao_vm->getCpf();
                 $data['instituicao_list'] = $this->instituicao_bo->list_all();
                 $this->load->view('ouvinte/inscricao_ouvinte.html.php', $data);
             }
         } else {
             $this->session->set_flashdata('erro', 'O link de inscrição não pode ser acessado sem informar o CPF');
             redirect(base_url() . 'home/home_ctr');
         }
     }
 }
 public function verificar_cpf($cpf)
 {
     $valid_cpf = valida_cpf($cpf);
     //eval(Psy\sh());
     if (!$valid_cpf) {
         echo 'invalid';
     } else {
         $user = $this->usuario_bo->find_user_by($cpf);
         if ($user != null && $user != false) {
             echo 'true';
         } else {
             echo 'false';
         }
     }
 }
 /**
  * Autentica um usuário no sistema
  * @param string $cpf o cpf do usuário
  * @param strnig $password a senha do usuário
  * @return boolean true se o usuário está autenticado, false se a senha
  * está incorreta ou nulo se o usuário não existe no sistema
  * @throws InvalidArgumentException se o cpf estiver inválido
  */
 public function auth_user($cpf, $password)
 {
     //TODO: possibilidade de fazer um sleep caso muitas tentativas para o mesmo cpf
     $cpf_validado = valida_cpf($cpf);
     if ($cpf_validado != false) {
         $user = $this->usuario_dao->find_user_by_cpf($cpf_validado);
         //TODO: testar se objeto está nulo
         if ($user == null) {
             throw new Exception("Este usuário não existe no sistema!");
         }
         if ($user->getSenha() == $password) {
             // proteger senha
             $user->setSenha("");
             $this->setUserSession($user->getIdUsuario());
             return $user;
         } else {
             return false;
         }
     } else {
         throw new InvalidArgumentException("CPF Inválido!");
     }
 }
 public function validate()
 {
     $cpf = valida_cpf($this->getCpf());
     if (!$cpf) {
         throw new Exception('CPF inválido.', 4);
     }
     $this->setCpf($cpf);
     if (strlen($this->getNome()) < 4) {
         throw new Exception('Nome inválido', 4);
     }
     $data = $this->input->post();
     if (strlen($this->getEmail()) < 4 || comparar_email_confirmacao($data)) {
         throw new Exception('Email inválido', 4);
     }
     if (strlen($this->getSenha()) < 3 || comparar_senha_confirmacao($data)) {
         throw new Exception('Senha inválida', 4);
     }
     $tipo_ouvinte = $this->getTipoOuvinte();
     if ($tipo_ouvinte < 1 || $tipo_ouvinte > 4) {
         throw new Exception('Tipo de ouvinte inválido', 4);
     }
     return true;
 }
 public function validate()
 {
     $cpf = valida_cpf($this->getCpf());
     if (!$cpf) {
         throw new Exception('CPF inválido.', 4);
     }
     $this->setCpf($cpf);
     if (strlen($this->getNome()) < 4) {
         throw new Exception('Nome inválido', 4);
     }
     $data = $this->input->post();
     if (strlen($this->getEmail()) < 4 || comparar_email_confirmacao($data)) {
         throw new Exception('Email inválido', 4);
     }
     if (strlen($this->getSenha()) < 3 || comparar_senha_confirmacao($data)) {
         throw new Exception('Senha inválida', 4);
     }
     if (!$this->getManhaDisponivel() && !$this->getTardeDisponivel() && !$this->getNoiteDisponivel()) {
         throw new Exception('Por favor, preencha disponibilidade em pelo menos um dos turnos', 4);
     }
     /*
     * * Não funciona em versão menor que 5.5 e no PC local Win XP não existe XAMPP 5.5.
             if (empty($this->getTelefone1()) && empty($this->getTelefone2()) && empty($this->getTelefone3())) {
        throw new Exception("Por favor, preencha pelo menos um telefone", 4);
             }
     
             if (empty($this->getCurso())) {
        throw new Exception("por favor, preencha com algum curso", 4);
             }
     *
     */
 }
Exemple #6
0
            data_nascimento = :data_nascimento
      where id=:id';
    $st = $app['pdo']->prepare($sql);
    $st->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
    $st->execute(array(':id' => $id, ':cpf' => $cpf, ':nome' => $nome, ':endereco' => $endereco, ':data_nascimento' => $data_nascimento));
    //return new Response($sql, 201);
    return $app->redirect("/editar/{$id}");
});
//criar novo registro funcionario
$app->post('/salvar/', function (Request $request) use($app) {
    $nome = $request->get('nome');
    $cpf = $request->get('cpf');
    $endereco = $request->get('endereco');
    $data_nascimento = $request->get('data_nascimento');
    //validacoes
    if (!valida_cpf($cpf)) {
        return new Response('CPF inválido<br><br><a href="/editar/">Voltar</a> ', 201);
    }
    if (!validaData2($data_nascimento)) {
        return new Response('Data inválida<br><br><a href="/editar/">Voltar</a> ', 201);
    }
    //insert
    $sql = 'INSERT into funcionario (cpf,nome,endereco,data_nascimento)
            VALUES (:cpf,:nome,:endereco,:data_nascimento);';
    $st = $app['pdo']->prepare($sql);
    $st->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
    $st->execute(array(':cpf' => $cpf, ':nome' => $nome, ':endereco' => $endereco, ':data_nascimento' => $data_nascimento));
    //return new Response($sql, 201);
    return $app->redirect("/itriad/");
});
// apagar registro funcionario