function validaDados() { if (empty($this->tipopessoa)) { $this->erro = "Tipo de Pessoa não informado."; return false; } if ($this->tipopessoa == "F") { if (empty($this->nome)) { $this->erro = "Nome não informado."; return false; } elseif (empty($this->cpfcnpj)) { $this->erro = "CPF não informado."; return false; } elseif (!isCpf($this->cpfcnpj)) { $this->erro = "CPF inválido."; return false; } } else { if (empty($this->nome)) { $this->erro = "Nome não informado."; return false; } if (empty($this->cpfcnpj)) { $this->erro = "CNPJ não informado."; return false; } elseif (!isCnpj($this->cpfcnpj)) { $this->erro = "CNPJ inválido."; return false; } } if (empty($this->email)) { $this->erro = "E-mail não informado"; return false; } elseif (!isEmail($this->email)) { $this->erro = "E-mail inválido"; return false; } elseif (empty($this->confirmeemail)) { $this->erro = "Confirmação do e-mail não informado"; return false; } elseif (!isEmail($this->confirmeemail)) { $this->erro = "E-mail para confirmação está inválido"; return false; } elseif ($this->confirmeemail != $this->email) { $this->erro = "E-mail não confere com a confirmação"; return false; } if (empty($this->senha)) { $this->erro = "Senha de acesso não informada"; return false; } elseif (empty($this->confirmasenha)) { $this->erro = "Confirmação da senha não informada"; return false; } elseif ($this->confirmasenha != $this->senha) { $this->erro = "Senha não confere com a confirmação"; return false; } //validação de endereço /* if (empty($this->cep)) { $this->erro = "CEP não informado."; return false; } elseif (empty($this->logradouro)) { $this->erro = "Logradouro não informado"; return false; } elseif (empty($this->bairro)) { $this->erro = "Bairro não informado"; return false; } elseif (empty($this->cidade)) { $this->erro = "Cidade não informada"; return false; } elseif (empty($this->numero)) { $this->erro = "Numero não informado"; return false; } elseif (empty($this->uf)) { $this->erro = "UF não informada"; return false; } */ //verifica se ja existe registro cadastrado com o cpfcnpj --- if (!empty($this->idsolicitante)) { $sql = "select * from lda_solicitante where cpfcnpj = '{$this->cpfcnpj}' and tipopessoa = '{$this->tipopessoa}' and idsolicitante <> {$this->idsolicitante}"; } else { $sql = "select * from lda_solicitante where cpfcnpj = '{$this->cpfcnpj}' and tipopessoa = '{$this->tipopessoa}'"; } if (mysql_num_rows(execQuery($sql)) > 0) { $this->erro = "Cadastro já realizado."; return false; } //----------------------------------------------------------------------- return true; }
function validaDados() { global $erro; global $acao; global $idusuario; global $nome; global $login; global $status; global $idsecretaria; global $chave; global $matricula; global $cpfusuario; global $gruposselecionados; if (empty($nome)) { $erro = "Nome não informado."; return false; } elseif (empty($login)) { $erro = "Login não informado."; return false; } elseif (empty($status)) { $erro = "Status não informado"; return false; } elseif (empty($idsecretaria)) { $erro = "SIC não informado"; return false; } elseif (empty($cpfusuario) || !isCpf($cpfusuario)) { $erro = "CPF Inválido."; return false; } if (empty($gruposselecionados)) { $erro = "Perfil(is) não informado(s)"; return false; } if (empty($idusuario) and empty($chave)) { $erro = "Senha de acesso precisa ser informada."; return false; } //verifica se ja existe registro cadastrado com a informaçao passada --- if ($acao == "Incluir") { $sql = "select * from sis_usuario where cpfusuario = '{$cpfusuario}'"; } else { $sql = "select * from sis_usuario where cpfusuario = '{$cpfusuario}' and idusuario <> {$idusuario}"; } if (mysql_num_rows(execQuery($sql)) > 0) { //$erro = "Já existe usuario cadastrado com o login informado"; $erro = "Já existe usuario cadastrado com o CPF informados"; return false; } if ($acao == "Incluir") { $sql = "select * from sis_usuario where login = '******'"; } else { $sql = "select * from sis_usuario where login = '******' and idusuario <> {$idusuario}"; } if (mysql_num_rows(execQuery($sql)) > 0) { $erro = "Já existe usuario cadastrado com o login informado"; return false; } if ($acao == "Incluir") { $sql = "select * from sis_usuario where matricula = '{$matricula}'"; } else { $sql = "select * from sis_usuario where matricula = '{$matricula}' and idusuario <> {$idusuario}"; } if (mysql_num_rows(execQuery($sql)) > 0) { $erro = "Já existe usuario cadastrado com a matricula informada"; return false; } //----------------------------------------------------------------------- return true; }