Unverified Commit 8431d5eb authored by carlos1270's avatar carlos1270 Committed by GitHub
Browse files

Merge pull request #92 from carlos1270/mod_lay_6

Validando o cpf
parents 7328ccbc 17f7cc6a
...@@ -1113,7 +1113,7 @@ class TrabalhoController extends Controller ...@@ -1113,7 +1113,7 @@ class TrabalhoController extends Controller
$subject = "Participante de Projeto"; $subject = "Participante de Projeto";
Mail::to($request->emailParticipante[$key])->send(new EmailParaUsuarioNaoCadastrado(Auth()->user()->name, $projeto->titulo, 'Participante', $edital->nome, $passwordTemporario, $subject)); // Mail::to($request->emailParticipante[$key])->send(new EmailParaUsuarioNaoCadastrado(Auth()->user()->name, $projeto->titulo, 'Participante', $edital->nome, $passwordTemporario, $subject));
} else { } else {
$participante->user_id = $userParticipante->id; $participante->user_id = $userParticipante->id;
...@@ -1131,8 +1131,8 @@ class TrabalhoController extends Controller ...@@ -1131,8 +1131,8 @@ class TrabalhoController extends Controller
$participante->save(); $participante->save();
$subject = "Participante de Projeto"; $subject = "Participante de Projeto";
Mail::to($request->emailParticipante[$key]) // Mail::to($request->emailParticipante[$key])
->send(new SubmissaoTrabalho($userParticipante, $subject, $edital, $projeto)); // ->send(new SubmissaoTrabalho($userParticipante, $subject, $edital, $projeto));
} }
...@@ -1276,7 +1276,7 @@ class TrabalhoController extends Controller ...@@ -1276,7 +1276,7 @@ class TrabalhoController extends Controller
$subject = "Participante de Projeto"; $subject = "Participante de Projeto";
Mail::to($email)->send(new EmailParaUsuarioNaoCadastrado(Auth()->user()->name, $projeto->titulo, 'Participante', $edital->nome, $passwordTemporario, $subject)); // Mail::to($email)->send(new EmailParaUsuarioNaoCadastrado(Auth()->user()->name, $projeto->titulo, 'Participante', $edital->nome, $passwordTemporario, $subject));
} else { } else {
$participante->user_id = $userParticipante->id; $participante->user_id = $userParticipante->id;
...@@ -1294,8 +1294,8 @@ class TrabalhoController extends Controller ...@@ -1294,8 +1294,8 @@ class TrabalhoController extends Controller
$participante->save(); $participante->save();
$subject = "Participante de Projeto"; $subject = "Participante de Projeto";
Mail::to($email) // Mail::to($email)
->send(new SubmissaoTrabalho($userParticipante, $subject, $edital, $projeto)); // ->send(new SubmissaoTrabalho($userParticipante, $subject, $edital, $projeto));
} }
......
...@@ -411,12 +411,14 @@ ...@@ -411,12 +411,14 @@
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="cpf1">CPF <span style="color: red; font-weight:bold">*</span></label> <label for="cpf1">CPF <span style="color: red; font-weight:bold">*</span></label>
<input type="text" class="form-control @error('cpf1') is-invalid @enderror" id="cpf1" name="cpf[]" placeholder="Digite o CPF do participante" required> <input type="text" class="form-control @error('cpf1') is-invalid @enderror cpf" id="cpf1" name="cpf[]" placeholder="Digite o CPF do participante" required>
@error('cpf1')
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block"> <span id="cpf-invalido-1" class="invalid-feedback cpf-invalido" role="alert" style="overflow: visible; display:none">
<strong>{{ $message }}</strong> <strong>CPF inválido</strong>
</span>
<span id="cpf-valido-1" class="valid-feedback" role="alert" style="overflow: visible; display:none">
<strong>CPF válido!</strong>
</span> </span>
@enderror
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="rg1">RG <span style="color: red; font-weight:bold">*</span></label> <label for="rg1">RG <span style="color: red; font-weight:bold">*</span></label>
...@@ -663,12 +665,14 @@ ...@@ -663,12 +665,14 @@
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="cpf2">CPF <span style="color: red; font-weight:bold">*</span></label> <label for="cpf2">CPF <span style="color: red; font-weight:bold">*</span></label>
<input type="text" class="form-control @error('cpf2') is-invalid @enderror" id="cpf2" name="cpf[]" placeholder="Digite o CPF do participante" required> <input type="text" class="form-control @error('cpf2') is-invalid @enderror cpf" id="cpf2" name="cpf[]" placeholder="Digite o CPF do participante" required>
@error('cpf2')
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block"> <span id="cpf-invalido-2" class="invalid-feedback cpf-invalido" role="alert" style="overflow: visible; display:none">
<strong>{{ $message }}</strong> <strong>CPF inválido</strong>
</span>
<span id="cpf-valido-2" class="valid-feedback" role="alert" style="overflow: visible; display:none">
<strong>CPF válido!</strong>
</span> </span>
@enderror
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="rg2">RG <span style="color: red; font-weight:bold">*</span></label> <label for="rg2">RG <span style="color: red; font-weight:bold">*</span></label>
...@@ -915,12 +919,14 @@ ...@@ -915,12 +919,14 @@
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="cpf3">CPF <span style="color: red; font-weight:bold">*</span></label> <label for="cpf3">CPF <span style="color: red; font-weight:bold">*</span></label>
<input type="text" class="form-control @error('cpf3') is-invalid @enderror" id="cpf3" name="cpf[]" placeholder="Digite o CPF do participante" required> <input type="text" class="form-control @error('cpf3') is-invalid @enderror cpf" id="cpf3" name="cpf[]" placeholder="Digite o CPF do participante" required>
@error('cpf3')
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block"> <span id="cpf-invalido-3" class="invalid-feedback cpf-invalido" role="alert" style="overflow: visible; display:none">
<strong>{{ $message }}</strong> <strong>CPF inválido</strong>
</span>
<span id="cpf-valido-3" class="valid-feedback" role="alert" style="overflow: visible; display:none">
<strong>CPF válido!</strong>
</span> </span>
@enderror
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="rg3">RG <span style="color: red; font-weight:bold">*</span></label> <label for="rg3">RG <span style="color: red; font-weight:bold">*</span></label>
...@@ -1197,6 +1203,28 @@ ...@@ -1197,6 +1203,28 @@
</div> </div>
</div> </div>
<!-- Modal -->
<div class="modal fade" id="modalCpfInvalido" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel2" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header" style="background-color: red;">
<h5 class="modal-title" id="exampleModalLabel2" style="font-size:20px; margin-top:7px; color:white; font-weight:bold; font-family: 'Roboto', sans-serif;">Aviso</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Existe um CPF inválido em um dos participantes por favor corrija para continuar.
</div>
{{-- <div class="modal-footer">
{{-- <button type="button" class="btn btn-secondary"></button>
{{-- <button type="button" class="btn btn-primary">Certo</button>
</div> --}}
</div>
</div>
</div>
</div>
@endsection @endsection
@section('javascript') @section('javascript')
...@@ -1448,16 +1476,19 @@ function fecharModalenviarProjeto(){ ...@@ -1448,16 +1476,19 @@ function fecharModalenviarProjeto(){
function enviarModalenviarProjeto(){ function enviarModalenviarProjeto(){
if(numeroDeParticipantes == 1){ if(numeroDeParticipantes == 1){
document.getElementById("collapseParticipante1").classList.add("show"); document.getElementById("collapseParticipante1").classList.add("show");
document.getElementById("clickSubmitForm").click();
}else if(numeroDeParticipantes == 2){ }else if(numeroDeParticipantes == 2){
document.getElementById("collapseParticipante1").classList.add("show"); document.getElementById("collapseParticipante1").classList.add("show");
document.getElementById("collapseParticipante2").classList.add("show"); document.getElementById("collapseParticipante2").classList.add("show");
document.getElementById("clickSubmitForm").click();
}else if(numeroDeParticipantes == 3){ }else if(numeroDeParticipantes == 3){
document.getElementById("collapseParticipante1").classList.add("show"); document.getElementById("collapseParticipante1").classList.add("show");
document.getElementById("collapseParticipante2").classList.add("show"); document.getElementById("collapseParticipante2").classList.add("show");
document.getElementById("collapseParticipante3").classList.add("show"); document.getElementById("collapseParticipante3").classList.add("show");
}
if (checarCpfs()) {
document.getElementById("clickSubmitForm").click(); document.getElementById("clickSubmitForm").click();
} else {
$("#modalCpfInvalido").modal('show');
} }
} }
/* /*
...@@ -2029,5 +2060,84 @@ $(document).ready(()=>{ ...@@ -2029,5 +2060,84 @@ $(document).ready(()=>{
// } // }
// }); // });
// }); // });
$(document).ready(function(){
$(".cpf").change(function(){
if (validarCPF(retirarFormatacao(this.value))) {
this.parentElement.children[2].style.display = "none";
this.parentElement.children[3].style.display = "block";
} else {
this.parentElement.children[2].style.display = "block";
this.parentElement.children[3].style.display = "none";
}
});
});
function validarCPF(strCPF) {
var soma;
var resto;
soma = 0;
// Verifica se foi informado todos os digitos corretamente
if (strCPF.length != 11) {
return false;
}
// Verifica se foi informada uma sequência de digitos repetidos. Ex: 111.111.111-11
if (varificarDigitos(strCPF)) {
return false;
}
// Faz o calculo para validar o CPF
for (var t = 9; t < 11; t++) {
for (var d = 0, c = 0; c < t; c++) {
d += strCPF[c] * ((t + 1) - c);
}
d = ((10 * d) % 11) % 10;
if (strCPF[c] != d) {
return false;
}
}
return true;
}
function retirarFormatacao(strCpf) {
resultado = "";
for(var i = 0; i < strCpf.length; i++) {
if (strCpf[i] != "." && strCpf[i] != "-") {
resultado += strCpf[i];
}
}
return resultado;
}
function varificarDigitos(strCpf) {
var cont = 1;
dig1 = strCpf[0];
for(var i = 1; i < strCpf.length; i++) {
if(dig1 == strCpf[i]) {
cont++;
}
}
if (cont == strCpf.length) {
return true;
}
return false;
}
function checarCpfs() {
var validacoes = document.getElementsByClassName("cpf-invalido");
var count = validacoes.length;
var quant = 0;
for(var i = 0; i < validacoes.length; i++) {
if (validacoes[i].style.display == "none") {
quant++;
}
}
if(quant == count) {
return true;
}
return false;
}
</script> </script>
@endsection @endsection
...@@ -129,7 +129,11 @@ ...@@ -129,7 +129,11 @@
<h5>Nenhum projeto submetido!</h5> <h5>Nenhum projeto submetido!</h5>
</div> </div>
<div class="col-md-12" style="text-align: center;"> <div class="col-md-12" style="text-align: center;">
<a href="{{ route('trabalho.index', ['id' => $edital->id] )}}">Cliquei aqui para submeter um projeto.</a> @if($edital->inicioSubmissao <= $hoje && $hoje <= $edital->fimSubmissao)
<a href="{{ route('trabalho.index', ['id' => $edital->id] )}}">Cliquei aqui para submeter um projeto.</a>
@else
<a href="#">O periodo de submissão foi encerrado.</a>
@endif
</div> </div>
</div> </div>
@endif @endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment