Unverified Commit 063fa04a authored by Yuri Resende's avatar Yuri Resende Committed by GitHub
Browse files

Merge branch 'master' into master

parents c3ad1952 b8f663c3
...@@ -48,9 +48,26 @@ class UserController extends Controller ...@@ -48,9 +48,26 @@ class UserController extends Controller
function perfil() function perfil()
{ {
$user = User::find(Auth::user()->id); $user = Auth::user();
$cursoPart = null;
if ($user->participantes()->exists() && $user->participantes()->first()->curso_id)
$cursoPart = Curso::find($user->participantes()->first()->curso_id);
$view = 'user.perfilUser';
if ($user->tipo == 'participante')
$view = 'user.perfilParticipante';
return view('user.perfilUser', ['user' => $user]); $naturezas = Natureza::orderBy('nome')->get();
$cursos = Curso::orderBy('nome')->get();
$areaTematica = AreaTematica::orderBy('nome')->get();
return view($view)
->with([
'user' => $user,
'cursos' => $cursos,
'naturezas' => $naturezas,
'cursoPart' => $cursoPart,
'areaTematica' => $areaTematica
]);
} }
function editarPerfil(Request $request) function editarPerfil(Request $request)
...@@ -66,6 +83,21 @@ class UserController extends Controller ...@@ -66,6 +83,21 @@ class UserController extends Controller
'celular' => ['required', 'string'], 'celular' => ['required', 'string'],
'cpf' => ['required', 'cpf'], 'cpf' => ['required', 'cpf'],
]); ]);
} else if ($user->tipo == 'participante') {
$validated = $request->validate([
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
'cpf' => ['required', 'cpf', 'unique:users'],
'rg' => ['required', 'unique:participantes'],
'celular' => ['required', 'string', 'telefone'],
'instituicao' => ['required_if:instituicaoSelect,Outra', 'max:255'],
'instituicaoSelect' => ['required_without:instituicao'],
'outroCursoEstudante' => ['required_if:cursoEstudante,Outro', 'max:255'],
'cursoEstudante' => ['required_without:outroCursoEstudante'],
'perfil' => ['required'],
'linkLattes' => ['required'],
]);
} else { } else {
$validated = $request->validate([ $validated = $request->validate([
'name' => ['required', 'string', 'max:255'], 'name' => ['required', 'string', 'max:255'],
...@@ -113,7 +145,7 @@ class UserController extends Controller ...@@ -113,7 +145,7 @@ class UserController extends Controller
} }
switch ($request->tipo) { switch ($user->tipo) {
case "administradorResponsavel": case "administradorResponsavel":
$adminResp = AdministradorResponsavel::where('user_id', '=', $id)->first(); $adminResp = AdministradorResponsavel::where('user_id', '=', $id)->first();
$adminResp->user_id = $user->id; $adminResp->user_id = $user->id;
...@@ -156,22 +188,30 @@ class UserController extends Controller ...@@ -156,22 +188,30 @@ class UserController extends Controller
$proponente->update(); $proponente->update();
break; break;
case "participante": case "participante":
$participante = Participante::where('user_id', '=', $id)->first(); $participante = $user->participantes()->first();
//$participante = $user->participantes->where('user_id', Auth::user()->id)->first(); $participante->data_de_nascimento = $request->data_de_nascimento;
$participante->user_id = $user->id; $participante->linkLattes = $request->linkLattes;
//dd($participante); $participante->rg = $request->rg;
if ($user->usuarioTemp == true) { if ($request->outroCursoEstudante != null) {
$user->usuarioTemp = false; $participante->curso = $request->outroCursoEstudante;
} else if (isset($request->cursoEstudante) && $request->cursoEstudante != "Outro") {
$participante->curso_id = $request->cursoEstudante;
} }
$user->usuarioTemp = false;
$endereco = $user->endereco;
$endereco->cep = $request->cep;
$endereco->uf = $request->uf;
$endereco->cidade = $request->cidade;
$endereco->rua = $request->rua;
$endereco->numero = $request->numero;
$endereco->bairro = $request->bairro;
$endereco->complemento = $request->complemento;
$endereco->update();
$participante->update(); $participante->update();
break; break;
} }
$user->name = $request->name; $user->name = $request->name;
$user->tipo = $request->tipo;
// $user->email = $request->email;
$user->cpf = $request->cpf; $user->cpf = $request->cpf;
$user->celular = $request->celular; $user->celular = $request->celular;
if ($request->instituicao != null) { if ($request->instituicao != null) {
...@@ -209,24 +249,34 @@ class UserController extends Controller ...@@ -209,24 +249,34 @@ class UserController extends Controller
{ {
$id = Auth::user()->id; $id = Auth::user()->id;
$user = User::find($id); $user = User::find($id);
$cursoPart = null;
if ($user->participantes()->exists() && $user->participantes()->first()->curso_id)
$cursoPart = Curso::find($user->participantes()->first()->curso_id);
$adminResp = AdministradorResponsavel::where('user_id', '=', $id)->first(); $adminResp = AdministradorResponsavel::where('user_id', '=', $id)->first();
$avaliador = Avaliador::where('user_id', '=', $id)->first(); $avaliador = Avaliador::where('user_id', '=', $id)->first();
$proponente = Proponente::where('user_id', '=', $id)->first(); $proponente = Proponente::where('user_id', '=', $id)->first();
$participante = Participante::where('user_id', '=', $id)->first(); $participante = $user->participantes()->first();
$naturezas = Natureza::orderBy('nome')->get(); $naturezas = Natureza::orderBy('nome')->get();
$cursos = Curso::orderBy('nome')->get(); $cursos = Curso::orderBy('nome')->get();
$areaTematica = AreaTematica::orderBy('nome')->get(); $areaTematica = AreaTematica::orderBy('nome')->get();
$view = 'user.perfilUser';
return view('user.perfilUser')->with(['user' => $user, if ($user->tipo == 'participante')
'adminResp' => $adminResp, $view = 'user.perfilParticipante';
'avaliador' => $avaliador,
'proponente' => $proponente, return view($view)
'participante' => $participante, ->with([
'cursos' => $cursos, 'user' => $user,
'naturezas' => $naturezas, 'adminResp' => $adminResp,
'areaTematica' => $areaTematica]); 'avaliador' => $avaliador,
} 'proponente' => $proponente,
'participante' => $participante,
'cursos' => $cursos,
'naturezas' => $naturezas,
'cursoPart' => $cursoPart,
'areaTematica' => $areaTematica
]);
}
} }
...@@ -6,6 +6,7 @@ use App\Evento; ...@@ -6,6 +6,7 @@ use App\Evento;
use Illuminate\Validation\Rule; use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Contracts\Validation\Validator;
class StoreTrabalho extends FormRequest class StoreTrabalho extends FormRequest
{ {
...@@ -19,6 +20,17 @@ class StoreTrabalho extends FormRequest ...@@ -19,6 +20,17 @@ class StoreTrabalho extends FormRequest
return Auth::check(); return Auth::check();
} }
protected function prepareForValidation()
{
$func = function($value) {
return ['cpf' => $value];
};
$this->merge([
'cpfs' => array_map($func, $this->cpf),
]);
}
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
...@@ -31,6 +43,7 @@ class StoreTrabalho extends FormRequest ...@@ -31,6 +43,7 @@ class StoreTrabalho extends FormRequest
$rules = []; $rules = [];
if($this->has('marcado')){ if($this->has('marcado')){
$rules['cpfs.*.cpf'] = ['distinct', 'nullable'];
foreach ($this->get('marcado') as $key => $value) { foreach ($this->get('marcado') as $key => $value) {
if( intval($value) == $key){ if( intval($value) == $key){
//user //user
...@@ -139,6 +152,7 @@ class StoreTrabalho extends FormRequest ...@@ -139,6 +152,7 @@ class StoreTrabalho extends FormRequest
'anexoPlanoTrabalho.*.required' => 'O :attribute é obrigatório', 'anexoPlanoTrabalho.*.required' => 'O :attribute é obrigatório',
'anexoProjeto.required' => 'O :attribute é obrigatório', 'anexoProjeto.required' => 'O :attribute é obrigatório',
'cpf.*.required' => 'O cpf é obrigatório', 'cpf.*.required' => 'O cpf é obrigatório',
'cpfs.*.cpf.distinct' => 'O integrante com CPF :input não pode ser adicionado mais de uma vez',
'name.*.required' => 'O :attribute é obrigatório', 'name.*.required' => 'O :attribute é obrigatório',
'email.*.required' => 'O :attribute é obrigatório', 'email.*.required' => 'O :attribute é obrigatório',
'instituicao.*.required' => 'O :attribute é obrigatório', 'instituicao.*.required' => 'O :attribute é obrigatório',
......
...@@ -89,7 +89,7 @@ class User extends Authenticatable implements MustVerifyEmail ...@@ -89,7 +89,7 @@ class User extends Authenticatable implements MustVerifyEmail
return $this->hasOne('App\AdministradorResponsavel'); return $this->hasOne('App\AdministradorResponsavel');
} }
public function participantes(){ public function participantes(){
return $this->hasMany('App\Participante'); return $this->hasMany('App\Participante')->orderBy('id', 'asc');
} }
public function avaliadors(){ public function avaliadors(){
return $this->hasOne('App\Avaliador'); return $this->hasOne('App\Avaliador');
......
...@@ -190,7 +190,7 @@ ...@@ -190,7 +190,7 @@
$('#aviso-modal-limite-de-integrantes').modal('show'); $('#aviso-modal-limite-de-integrantes').modal('show');
} }
let modal_id = 0; let modal_id = Number(document.getElementById('quantidadeModais').value);
function exibirUsuarioAdicionado(data) { function exibirUsuarioAdicionado(data) {
$('#modalIntegrante').modal('hide'); $('#modalIntegrante').modal('hide');
......
...@@ -359,38 +359,40 @@ ...@@ -359,38 +359,40 @@
</div> </div>
@endif @endif
@if($edital->tipo != "CONTINUO") <div style="display: block" @if(old('funcaoParticipante') == null || !array_key_exists($i, old('funcaoParticipante')) || old('funcaoParticipante')[$i] == 'Bolsista') @else hidden @endif>
<div class="col-md-12" id="plano-titulo{{$i}}"> @if($edital->tipo != "CONTINUO")
<h5>Plano de trabalho</h5> <div class="col-md-12" id="plano-titulo{{$i}}">
</div> <h5>Plano de trabalho</h5>
<div class="col-12" id="plano-nome{{$i}}"> </div>
@component('componentes.input', ['label' => 'Título']) <div class="col-12" id="plano-nome{{$i}}">
<input type="text" class="form-control" value="{{old('nomePlanoTrabalho')[$i] ?? "" }}" name="nomePlanoTrabalho[{{$i}}]" placeholder="Digite o título do plano de trabalho" maxlength="255" id="nomePlanoTrabalho{{$i}}"> @component('componentes.input', ['label' => 'Título'])
<span style="color: red; font-size: 12px" id="caracsRestantesnomePlanoTrabalho{{$i}}"> <input type="text" class="form-control" value="{{old('nomePlanoTrabalho')[$i] ?? "" }}" name="nomePlanoTrabalho[{{$i}}]" placeholder="Digite o título do plano de trabalho" maxlength="255" id="nomePlanoTrabalho{{$i}}">
</span> <span style="color: red; font-size: 12px" id="caracsRestantesnomePlanoTrabalho{{$i}}">
@error('nomePlanoTrabalho.'.$i) </span>
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block"> @error('nomePlanoTrabalho.'.$i)
<strong>{{ $message }}</strong> <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
</span> <strong>{{ $message }}</strong>
@enderror </span>
@endcomponent @enderror
</div> @endcomponent
<div class="col-12" id="plano-anexo{{$i}}"> </div>
@component('componentes.input', ['label' => 'Anexo (.pdf)']) <div class="col-12" id="plano-anexo{{$i}}">
<input type="file" class="input-group-text" value="{{old('anexoPlanoTrabalho')[$i] ?? "" }}" name="anexoPlanoTrabalho[{{$i}}]" accept=".pdf" placeholder="Anexo do Plano de Trabalho" /> @component('componentes.input', ['label' => 'Anexo (.pdf)'])
@error('anexoPlanoTrabalho.'.$i) <input type="file" class="input-group-text" value="{{old('anexoPlanoTrabalho')[$i] ?? "" }}" name="anexoPlanoTrabalho[{{$i}}]" accept=".pdf" placeholder="Anexo do Plano de Trabalho" />
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block"> @error('anexoPlanoTrabalho.'.$i)
<strong>{{ $message }}</strong> <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
</span> <strong>{{ $message }}</strong>
@enderror </span>
@error('anexoPlanoTrabalho') @enderror
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block"> @error('anexoPlanoTrabalho')
<strong>{{ $message }}</strong> <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
</span> <strong>{{ $message }}</strong>
@enderror </span>
@endcomponent @enderror
</div> @endcomponent
@endif </div>
@endif
</div>
{{-- <div class="col-6"> {{-- <div class="col-6">
<button data-dismiss="modal" type="button" id="cancelar{{$i}}" class=" btn btn-danger" style="font-size: 16px" onclick="desmarcar({{$i}})" @if(isset(old('marcado')[$i+1])) disabled @endif>Cancelar</button> <button data-dismiss="modal" type="button" id="cancelar{{$i}}" class=" btn btn-danger" style="font-size: 16px" onclick="desmarcar({{$i}})" @if(isset(old('marcado')[$i+1])) disabled @endif>Cancelar</button>
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<form method="POST" id="criarProjetoForm" action="{{route('trabalho.store')}}" enctype="multipart/form-data" > <form method="POST" id="criarProjetoForm" action="{{route('trabalho.store')}}" enctype="multipart/form-data" >
@csrf @csrf
<input type="hidden" name="editalId" value="{{$edital->id}}"> <input type="hidden" name="editalId" value="{{$edital->id}}">
<input type="hidden" name="quantidadeModais" id="quantidadeModais" value="{{old('quantidadeModais', 0)}}" >
<div class="container"> <div class="container">
...@@ -232,16 +233,16 @@ ...@@ -232,16 +233,16 @@
if(nome.value != ""){ if(nome.value != ""){
estudante.value = true; estudante.value = true;
if(planoTrabalho != null && planoTrabalho.value != ""){ if(planoTrabalho != null && planoTrabalho.value != ""){
nomePlano.innerHTML = ` <p style='font-weight: normal; line-height: normal;'><strong>Nome: </strong>${nome.value}<br> nomePlano.innerHTML = ` <strong>Nome: </strong>${nome.value}<br>
<strong>E-mail: </strong>${email.value} <br> <strong>E-mail: </strong>${email.value} <br>
<strong>Plano: </strong>${planoTrabalho.value}<br> <strong>Plano: </strong>${planoTrabalho.value}<br>
<strong>CPF: </strong>${cpf.value} <br> <strong>CPF: </strong>${cpf.value} <br>
<strong>Função: </strong>${nome_funcao}</p>`; <strong>Função: </strong>${nome_funcao}`;
}else { }else {
nomePlano.innerHTML = ` <p style='font-weight: normal; line-height: normal;'><strong>Nome: </strong>${nome.value}<br> nomePlano.innerHTML = ` <strong>Nome: </strong>${nome.value}<br>
<strong>E-mail: </strong>${email.value} <br> <strong>E-mail: </strong>${email.value} <br>
<strong>CPF: </strong>${cpf.value} <br> <strong>CPF: </strong>${cpf.value} <br>
<strong>Função: </strong>${nome_funcao}</p>`; <strong>Função: </strong>${nome_funcao}`;
} }
}else if(data != null) { }else if(data != null) {
estudante.value = false; estudante.value = false;
...@@ -265,6 +266,7 @@ ...@@ -265,6 +266,7 @@
document.getElementById("checkB"+id).checked = true; document.getElementById("checkB"+id).checked = true;
//$("#atribuir1").attr('data-target','#modalIntegrante'+(id+1)); //$("#atribuir1").attr('data-target','#modalIntegrante'+(id+1));
modal_id = id+1; modal_id = id+1;
document.getElementById("quantidadeModais").value = modal_id;
document.getElementById("part"+id).removeAttribute("hidden"); document.getElementById("part"+id).removeAttribute("hidden");
//document.getElementById("exampleModal"+id).modal('hide'); //document.getElementById("exampleModal"+id).modal('hide');
...@@ -279,6 +281,7 @@ ...@@ -279,6 +281,7 @@
document.getElementById("part"+id).setAttribute("hidden",true); document.getElementById("part"+id).setAttribute("hidden",true);
//$("#atribuir1").attr('data-target','#exampleModal'+(id)); //$("#atribuir1").attr('data-target','#exampleModal'+(id));
modal_id -= 1; modal_id -= 1;
document.getElementById("quantidadeModais").value = modal_id;
document.getElementById("exampleModal"+id).modal('hide'); document.getElementById("exampleModal"+id).modal('hide');
} }
@endif @endif
......
...@@ -272,6 +272,7 @@ ...@@ -272,6 +272,7 @@
if(<?php echo json_encode($trabalho_user) ?>['funcao']){ if(<?php echo json_encode($trabalho_user) ?>['funcao']){
modal_id += 1; modal_id += 1;
document.getElementById("quantidadeModais").value = modal_id;
} }
$('#integrante').append(` $('#integrante').append(`
......
...@@ -260,6 +260,8 @@ ...@@ -260,6 +260,8 @@
document.getElementById("checkB"+id).checked = true; document.getElementById("checkB"+id).checked = true;
// $("#atribuir1").attr('data-target','#exampleModal'+(id+1)); // $("#atribuir1").attr('data-target','#exampleModal'+(id+1));
modal_id += 1; modal_id += 1;
document.getElementById("quantidadeModais").value = modal_id;
document.getElementById("part"+id).removeAttribute("hidden"); document.getElementById("part"+id).removeAttribute("hidden");
// document.getElementById("exampleModal"+id).modal('hide'); // document.getElementById("exampleModal"+id).modal('hide');
} }
...@@ -274,6 +276,7 @@ ...@@ -274,6 +276,7 @@
// $("#atribuir1").attr('data-target','#exampleModal'+(id)); // $("#atribuir1").attr('data-target','#exampleModal'+(id));
// document.getElementById("exampleModal"+id).modal('hide'); // document.getElementById("exampleModal"+id).modal('hide');
modal_id -= 1; modal_id -= 1;
document.getElementById("quantidadeModais").value = modal_id;
console.log(modal_id); console.log(modal_id);
} }
@endif @endif
......
This diff is collapsed.
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