예제 #1
0
 /**
  * Método que define a tabela
  * @param string $tabelas Define como a tabela ou tabelas.
  */
 public function into($tabelas)
 {
     if (!\Strings::validar($tabelas)) {
         throw new SqlException("Query mal formada. A tabela é inválida");
     }
     $this->tabela = $tabelas;
     return $this;
 }
예제 #2
0
 /**
  * Método que defien a tabela alvo da interação
  * @param string $tabela A tabela alvo
  */
 public function setTabela($tabela)
 {
     if (!\Strings::validar($tabela)) {
         throw new SqlException("A tabela definida é inválida");
     }
     $this->tabela = $tabela;
     return $this;
 }
예제 #3
0
 /**
  * Método que define a ordenação
  * @param string|array $colunas As colunas de ordenação
  * @param int $order
  */
 public function order($colunas, $order = self::ASC)
 {
     if (!is_string($colunas) && !is_array($colunas)) {
         throw new SqlException("Query mal formatada", 52);
     }
     if (!isset($this->order[$order])) {
         throw new SqlException("Query mal formatada", 56);
     }
     if (is_string($colunas)) {
         if (!\Strings::validar($colunas)) {
             throw new SqlException("Query mal formatada", 59);
         }
         $this->queryString = "order by ({$colunas}) {$this->order[$order]}";
     } else {
         if (!count($colunas)) {
             throw new SqlException("Query mal formatada", 58);
         }
         $this->queryString = "order by (" . implode(", ", $colunas) . ") {$this->order[$order]}";
     }
     return $this;
 }
예제 #4
0
 /**
  * Método que verifica se os dados informados são válidos
  * @param boolean $isEdit Define se a validação será para editar o currículo ou inserir
  * @return boolean|string Retorna FALSE em caso de sucesso ou uma string informando o erro
  */
 public function validar($isEdit = FALSE)
 {
     if (!$isEdit) {
         if ($this->buscarCpf()) {
             return "Parece que o CPF informado já esta sendo usado em outra conta. " . "Faça login na sua conta com este CPF e edite o seu currículo";
         }
     }
     if ($this->tipo_curriculo != "profissional" && $this->tipo_curriculo != "estagiario") {
         return "Você precisa escolher entre \"Emprego\" ou \"Estágio\"";
     }
     if (!Strings::validar($this->nome)) {
         return "O nome informádo é inválido";
     }
     if (!Data::validar($this->dt_nascimento, "Y-m-d")) {
         return "A data de nascimento informada é inválida";
     }
     if (!filter_var($this->email, FILTER_VALIDATE_EMAIL)) {
         return "O e-mail informado é inválido";
     }
     if (!Strings::validar($this->estado_civil)) {
         return "O estado civil informado é inválido";
     }
     if (!$isEdit) {
         if (!PadraoBrasil::validaCPF($this->cpf)) {
             return "O CPF informado é inválido";
         }
     }
     if (!PadraoBrasil::validarRG($this->rg)) {
         return "O RG informado é inválido";
     }
     if (!Strings::validar($this->rg_emissor)) {
         return "O orgão expedidor do RG informado é inválido";
     }
     if (!PadraoBrasil::validaUF($this->rg_emissor_uf)) {
         return "O estado do orgão emissor é inválido";
     }
     if (!PadraoBrasil::validaSexo($this->sexo)) {
         return "O sexo informado é inválido";
     }
     if (!Strings::validar($this->endereco)) {
         return "O endereço informado é inválido";
     }
     if (!PadraoBrasil::validaCep($this->cep)) {
         return "O CEP informado é inválido";
     }
     if (!Strings::validar($this->bairro)) {
         return "O bairro informado é inválido";
     }
     if (!Strings::validar($this->cidade)) {
         return "A cidade informada é inválida";
     }
     if (!PadraoBrasil::validaUF($this->uf)) {
         return "O estado informado é inválido";
     }
     if (Strings::validar($this->tel)) {
         if (!PadraoBrasil::validarTelefone($this->tel)) {
             return "O telefone informado é inválido";
         }
     } else {
         $this->tel = '';
     }
     if (Strings::validar($this->cel)) {
         if (!PadraoBrasil::validarTelefone($this->cel)) {
             return "O celular informado é inválido";
         }
     } else {
         $this->cel = '';
     }
     if (!in_array($this->area_interesse, array_keys($this->arrayAreasInter))) {
         return "A área de interesse informada é inválida";
     }
     if (!Strings::validar($this->area_interesse_especificar)) {
         $this->area_interesse_especificar = '';
     }
     if (Strings::validar($this->exp_prof_ult_emprego)) {
         if (!Strings::validar($this->exp_prof_ult_cargo)) {
             return "O cargo do ultimo emprego é inválido";
         }
         if (!Data::validar($this->exp_prof_ult_dt_entrada, "Y-m-d")) {
             return "A data de entrada do ultimo emprego é inválida";
         }
         if (strlen($this->exp_prof_ult_dt_saida)) {
             if (!Data::validar($this->exp_prof_ult_dt_saida, "Y-m-d")) {
                 return "A data de saída do ultimo emprego é inválida";
             }
         } else {
             $this->exp_prof_ult_dt_saida = NULL;
         }
         if (!Strings::validar($this->exp_prof_ult_breve_descri)) {
             return "A descrição do ultimo emprego é inválida";
         }
     } else {
         $this->exp_prof_ult_cargo = "";
         $this->exp_prof_ult_dt_entrada = NULL;
         $this->exp_prof_ult_dt_saida = NULL;
         $this->exp_prof_ult_breve_descri = "";
     }
     if (Strings::validar($this->exp_prof_penul_emprego)) {
         if (!Strings::validar($this->exp_prof_penul_cargo)) {
             return "O cargo do penultimo emprego é inválido";
         }
         if (!Data::validar($this->exp_prof_penul_dt_entrada, "Y-m-d")) {
             return "A data de entrada do penultimo emprego é inválida";
         }
         if (!Data::validar($this->exp_prof_penul_dt_saida, "Y-m-d")) {
             return "A data de saída do penultimo emprego é inválida";
         }
         if (!Strings::validar($this->exp_prof_penul_breve_descri)) {
             return "A descrição do penultimo emprego é inválida";
         }
     } else {
         $this->exp_prof_penul_emprego = "";
         $this->exp_prof_penul_cargo = "";
         $this->exp_prof_penul_dt_entrada = NULL;
         $this->exp_prof_penul_dt_saida = NULL;
         $this->exp_prof_penul_breve_descri = "";
     }
     if (!Strings::validar($this->form_aca_tipo)) {
         return "O tipo da formação informada é inválida";
     }
     if (!Strings::validar($this->form_aca_instituicao)) {
         return "A instituição da formação é inválida";
     }
     if (!Strings::validar($this->form_aca_curso)) {
         return "O curso informado é inválido";
     }
     if (Strings::validar($this->form_aca_status)) {
         if ($this->form_aca_status != "completo") {
             if (!filter_var($this->form_aca_periodo, FILTER_VALIDATE_INT)) {
                 return "O periodo informado é inválido";
             }
         } else {
             $this->form_aca_periodo = 0;
         }
     } else {
         $this->form_aca_status = "";
         $this->form_aca_periodo = "";
     }
     if (!Strings::validar($this->form_aca_especializacao)) {
         $this->form_aca_especializacao = '';
     }
     if (!Strings::validar($this->curso_complemento)) {
         $this->curso_complemento = '';
     }
     if (in_array($this->ingles_nivel, array_keys($this->arrayNiveisIdiomas))) {
         if (!Strings::validar($this->ingles_instituicao)) {
             return "A instituição do curso de inglês é inválida";
         }
     } else {
         $this->ingles_nivel = "";
         $this->ingles_instituicao = "";
     }
     if (Strings::validar($this->idioma)) {
         if (!in_array($this->idioma_nivel, array_keys($this->arrayNiveisIdiomas))) {
             return "O nível do idioma secundário é inválido";
         }
         if (!Strings::validar($this->idioma_isntituicao)) {
             return "A instituição do idioma secundário é invalida";
         }
     } else {
         $this->idioma = "";
         $this->idioma_nivel = "";
         $this->idioma_isntituicao = "";
     }
     if (!Strings::validar($this->obs)) {
         $this->obs = '';
     }
     return FALSE;
 }
예제 #5
0
 /**
  * Método que envia a solicitação de alteração de dados cadastrais
  */
 public function solicita_alt()
 {
     $pkUsuario = filter_input(INPUT_POST, 'usuario', FILTER_VALIDATE_INT);
     //Recebendo o código do usuário para a validação do mesmo
     if ($this->tipoLogado != Perfil::ADMIN) {
         if ($this->usuario->get_idUsuario() != $pkUsuario) {
             $this->setMensagem('Desculpe, você não pode pedir as alterações dos dados de outro usuário')->printResposta();
             die;
         }
     }
     if (!$pkUsuario) {
         $this->setMensagem('O usuário informado é inválido.')->printResposta();
     }
     $dadosMensagem = array();
     $mensagem = '';
     $emailNews = new Kernel_Models_NewsletterContas();
     $usuarioObj = new Kernel_Models_Usuario();
     $usuario = $usuarioObj->get($pkUsuario);
     $mail = new Mail();
     $nome = filter_input(INPUT_POST, 'nome', FILTER_SANITIZE_MAGIC_QUOTES);
     $dtnascimento = filter_input(INPUT_POST, 'data_nascimento', FILTER_SANITIZE_MAGIC_QUOTES);
     $cpf = filter_input(INPUT_POST, 'cpf', FILTER_SANITIZE_MAGIC_QUOTES);
     $rg = filter_input(INPUT_POST, 'rg', FILTER_SANITIZE_MAGIC_QUOTES);
     $sexo = filter_input(INPUT_POST, 'sexo', FILTER_SANITIZE_MAGIC_QUOTES);
     $telefone = filter_input(INPUT_POST, 'telefone', FILTER_SANITIZE_MAGIC_QUOTES);
     $cep = filter_input(INPUT_POST, 'cep', FILTER_SANITIZE_MAGIC_QUOTES);
     $endereco = filter_input(INPUT_POST, 'endereco', FILTER_SANITIZE_MAGIC_QUOTES);
     $numero = filter_input(INPUT_POST, 'numero', FILTER_SANITIZE_MAGIC_QUOTES);
     $complemento = filter_input(INPUT_POST, 'complemento', FILTER_SANITIZE_MAGIC_QUOTES);
     $bairro = filter_input(INPUT_POST, 'bairro', FILTER_SANITIZE_MAGIC_QUOTES);
     $cidade = filter_input(INPUT_POST, 'cidade', FILTER_SANITIZE_MAGIC_QUOTES);
     $uf = filter_input(INPUT_POST, 'estado', FILTER_SANITIZE_MAGIC_QUOTES);
     //Validando os dados
     if ($nome) {
         if (!Strings::validar($nome)) {
             $this->setMensagem('O nome informado é inválido')->printResposta();
             die;
         }
         $dadosMensagem['nome'] = $nome;
     }
     if ($dtnascimento) {
         if (!Data::validar($dtnascimento, 'd/m/Y')) {
             $this->setMensagem('A data de nascimento é inválida')->printResposta();
             die;
         }
         $dadosMensagem['data de nascimento'] = $dtnascimento;
     }
     if ($cpf) {
         if (!PadraoBrasil::validaCPF($cpf)) {
             $this->setMensagem('O cpf informado é inválido')->printResposta();
             die;
         }
         $dadosMensagem['cpf'] = $cpf;
     }
     if ($rg) {
         if (!PadraoBrasil::validarRG($rg)) {
             $this->setMensagem('O rg informado é inválido')->printResposta();
             die;
         }
         $dadosMensagem['rg'] = $rg;
     }
     if ($sexo) {
         if (!PadraoBrasil::validaSexo($sexo)) {
             $this->setMensagem('O sexo informado é inválido')->printResposta();
             die;
         }
         $dadosMensagem['sexo'] = $sexo;
     }
     if ($telefone) {
         if (!PadraoBrasil::validarTelefone($telefone)) {
             $this->setMensagem('O telefone informado é inválido')->printResposta();
             die;
         }
         $dadosMensagem['telefone'] = $telefone;
     }
     if ($cep) {
         if (PadraoBrasil::validaCep($cep)) {
             $this->setMensagem('O cep informado é inválido')->printResposta();
             die;
         }
         $dadosMensagem['cep'] = $cep;
     }
     if ($endereco) {
         $dadosMensagem['endereço'] = $endereco;
     }
     if ($numero) {
         $dadosMensagem['número'] = $numero;
     }
     if ($complemento) {
         $dadosMensagem['complemento'] = $complemento;
     }
     if ($bairro) {
         $dadosMensagem['bairro'] = $bairro;
     }
     if ($cidade) {
         $dadosMensagem['cidade'] = $cidade;
     }
     if ($uf) {
         if (!PadraoBrasil::validaUF($uf)) {
             $this->setMensagem('O estado informado é inválido')->printResposta();
             die;
         }
         $dadosMensagem['estado'] = PadraoBrasil::getEstado($uf);
     }
     //Montando a mensagem
     foreach ($dadosMensagem as $key => $value) {
         $mensagem .= '<div class="form-group">' . '<label>Alterar ' . $key . ' para ' . $value . '</label>' . '</div>';
     }
     $mail->loadModelo()->mensagemDeModelo(array('titulo' => 'Solicitação de alteração dos dados pessoais', 'subtitulo' => 'O usuário ' . $usuario->nome . '(código ' . $usuario->pk_usuario . ')' . ' solicita alteração nos seguintes dados:', 'conteudo' => $mensagem));
     if ($emailNews->enviar('RH Colégio GGE', '*****@*****.**', 'Solicitaçao de alteração de dados cadastrais', $mail->getMensagem())) {
         $this->setMensagem('Solicitação encaminhada com sucesso ao RH')->setStatusCod(0)->statusTrue();
     } else {
         $this->setMensagem('Ocorreu o seguinte erro ao enviar a solicitação: ' . $emailNews->getErros() . '. Por favor, informe o ocorrido ao administrador do sistema e tente novamente mais tarde.');
     }
     $this->printResposta();
 }
예제 #6
0
 /**
  * Método que adiciona a clausula grou by a query
  * @param string|array $colunas As colunas da clausula grou by
  * @return \GGE\Lib\Sql\Querys\Select
  * @throws SqlException
  */
 public function groupBy($colunas)
 {
     if (!is_string($colunas) && !is_array($colunas)) {
         throw new SqlException("Query mal formatada", 55);
     }
     if (is_string($colunas)) {
         if (!\Strings::validar($colunas)) {
             throw new SqlException("Query mal formatada", 56);
         }
         $this->group = "GROUP BY({$colunas})";
     } else {
         if (!count($colunas)) {
             throw new SqlException("Query mal formatada", 57);
         }
         $this->group = "GROUP BY(" . implode(",", $colunas) . ")";
     }
     return $this;
 }
예제 #7
0
 /**
  * Método que verifica se os dados informados são válidos
  * @param boolean $editar Define se o método ira fazer a validação de um objeto a ser editado ou não
  * @return boolean|int Retorna FALSE caso os dados estejam corretos ou um código referente ao erro
  */
 public function validar($editar = FALSE)
 {
     if (!Strings::validar($this->nome_descricao)) {
         return 1;
     }
     if (!filter_var($this->email_from, FILTER_VALIDATE_EMAIL)) {
         return 2;
     }
     if (!$editar) {
         $tmp = $this->select("email_from='" . $this->email_from . "'");
         if ($tmp) {
             if ($tmp->rowCount()) {
                 return 10;
             }
         }
     }
     if (!Strings::validar($this->from_name)) {
         return 3;
     }
     if (!Strings::validar($this->senha)) {
         return 4;
     }
     if ($this->tipo_seguranca != 'ssl' && $this->tipo_seguranca != 'tsl') {
         return 5;
     }
     if (!is_int($this->porta)) {
         return 6;
     }
     if (!Strings::validar($this->host)) {
         return 7;
     }
     if ($this->envio_exclusivo != 0) {
         $tmp = explode("/", $this->envio_exclusivo);
         $acao = new ModelBase("public.acao");
         if (!$acao->select("modulo='" . $tmp[0] . "' and controle='" . $tmp[1] . "' and metodo='" . $tmp[2] . "'", array(), "", array(), array(), 1)->rowCount()) {
             return 8;
         }
     }
     return 0;
 }