Skip to content

Commit

Permalink
Adição do preenchimento automático de informações para sócios existen…
Browse files Browse the repository at this point in the history
…tes que queiram atualizar seus dados [Issue #744]
  • Loading branch information
GabrielPintoSouza committed Oct 7, 2024
1 parent 7697ad6 commit 5bc531a
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 10 deletions.
2 changes: 1 addition & 1 deletion html/socio/cadastro_socio.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
<?php
for ($i = 0; $i < 5; $i++) {
if ($arrayData[$i] != 0) {
echo "<input type = 'radio' value ='" . $arrayData[$i] . "' name = 'data_vencimento' id='op" . $i . "'>" . "<span style='margin-right: 1.5em'>" . $arrayData[$i] . "</span>";
echo "<input type = 'radio' value ='" . $arrayData[$i] . "' name = 'data_vencimento' id='data_vencimento" . $arrayData[$i] . "'>" . "<span style='margin-right: 1.5em'>" . $arrayData[$i] . "</span>";
}
}
?>
Expand Down
62 changes: 54 additions & 8 deletions html/socio/js/cadastro_socio.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,60 @@ btnAvancaCpf.addEventListener('click', (ev) => {

const socio = data.retorno;

if(!socio || socio.length < 1){
if (!socio || socio.length < 1) {
acao.value = "cadastrar";
alert ('Sócio não encontrado');//remover
}else{
//adicionar preenchimento dos campos automático
console.log(socio);
alert(`Sucesso: ${data.retorno}`);//remover
mensagemDiv.innerHTML = '';
} else {
acao.value = "atualizar";
//Preenchimento automático dos campos

//informações da pag3
const nome = document.getElementById('nome');
const dataNascimento = document.getElementById('data_nascimento');
const email = document.getElementById('email');
const telefone = document.getElementById('telefone');

nome.value = socio.nome;
dataNascimento.value = socio.data_nascimento;
email.value = socio.email;
telefone.value = socio.telefone;

//informações da pag4

//posteriormente marcar a periodicidade correspondente

// Extrai o dia da data_referencia
const dataReferencia = socio.data_referencia;
const diaMarcado = dataReferencia.split('-')[2]; // Pega o dia de vencimento

// Seleciona e marca o radio button com o valor correspondente ao dia
const radioToCheck = document.querySelector("input[name='data_vencimento'][value='" + diaMarcado + "']");
if (radioToCheck) {
radioToCheck.checked = true;
}

//informações da pag5
const cep = document.getElementById('cep');
const rua = document.getElementById('rua');
const numero = document.getElementById('numero');
const bairro = document.getElementById('bairro');
const uf = document.getElementById('uf');
const cidade = document.getElementById('cidade');
const complemento = document.getElementById('complemento');

cep.value = socio.cep;
rua.value = socio.logradouro;
numero.value = socio.numero_endereco;
bairro.value = socio.bairro;
uf.value = socio.estado;
cidade.value = socio.cidade;
complemento.value = socio.complemento;

console.log(socio);//remover posteriormente

mensagemDiv.innerHTML = `<div class="alert alert-info text-center" role="alert">` +
`Verifique os dados a seguir e atualize os necessários.`
+ `</div>`;
}
}
})
Expand All @@ -68,7 +115,6 @@ btnAvancaCpf.addEventListener('click', (ev) => {
alert('Ocorreu um erro ao processar o cadastro.');//trocar para o alert do bootstrap posteriormente
});

mensagemDiv.innerHTML = '';
trocarPagina('pag3', 'pag2');
});

Expand Down Expand Up @@ -186,7 +232,7 @@ function validarValor() {
}

/**
* Valida se o CPF está no formato correto e se é válido
* Verifica se o CPF está no formato correto e se é válido
* @returns
*/
function validarCpf() {
Expand Down
3 changes: 2 additions & 1 deletion html/socio/sistema/processa_socio.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ function buscarPorCpf()
p.numero_endereco,
p.complemento,
p.ibge,
s.email
s.email,
s.data_referencia
FROM pessoa p JOIN socio s ON(s.id_pessoa=p.id_pessoa)
WHERE p.cpf=:cpf';

Expand Down

0 comments on commit 5bc531a

Please sign in to comment.