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
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)
......@@ -66,6 +83,21 @@ class UserController extends Controller
'celular' => ['required', 'string'],
'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 {
$validated = $request->validate([
'name' => ['required', 'string', 'max:255'],
......@@ -113,7 +145,7 @@ class UserController extends Controller
}
switch ($request->tipo) {
switch ($user->tipo) {
case "administradorResponsavel":
$adminResp = AdministradorResponsavel::where('user_id', '=', $id)->first();
$adminResp->user_id = $user->id;
......@@ -156,22 +188,30 @@ class UserController extends Controller
$proponente->update();
break;
case "participante":
$participante = Participante::where('user_id', '=', $id)->first();
//$participante = $user->participantes->where('user_id', Auth::user()->id)->first();
$participante->user_id = $user->id;
//dd($participante);
if ($user->usuarioTemp == true) {
$user->usuarioTemp = false;
$participante = $user->participantes()->first();
$participante->data_de_nascimento = $request->data_de_nascimento;
$participante->linkLattes = $request->linkLattes;
$participante->rg = $request->rg;
if ($request->outroCursoEstudante != null) {
$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();
break;
}
$user->name = $request->name;
$user->tipo = $request->tipo;
// $user->email = $request->email;
$user->cpf = $request->cpf;
$user->celular = $request->celular;
if ($request->instituicao != null) {
......@@ -209,24 +249,34 @@ class UserController extends Controller
{
$id = Auth::user()->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();
$avaliador = Avaliador::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();
$cursos = Curso::orderBy('nome')->get();
$areaTematica = AreaTematica::orderBy('nome')->get();
$view = 'user.perfilUser';
if ($user->tipo == 'participante')
$view = 'user.perfilParticipante';
return view('user.perfilUser')->with(['user' => $user,
return view($view)
->with([
'user' => $user,
'adminResp' => $adminResp,
'avaliador' => $avaliador,
'proponente' => $proponente,
'participante' => $participante,
'cursos' => $cursos,
'naturezas' => $naturezas,
'areaTematica' => $areaTematica]);
}
'cursoPart' => $cursoPart,
'areaTematica' => $areaTematica
]);
}
}
......@@ -6,6 +6,7 @@ use App\Evento;
use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\Auth;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Contracts\Validation\Validator;
class StoreTrabalho extends FormRequest
{
......@@ -19,6 +20,17 @@ class StoreTrabalho extends FormRequest
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.
*
......@@ -31,6 +43,7 @@ class StoreTrabalho extends FormRequest
$rules = [];
if($this->has('marcado')){
$rules['cpfs.*.cpf'] = ['distinct', 'nullable'];
foreach ($this->get('marcado') as $key => $value) {
if( intval($value) == $key){
//user
......@@ -139,6 +152,7 @@ class StoreTrabalho extends FormRequest
'anexoPlanoTrabalho.*.required' => 'O :attribute é obrigatório',
'anexoProjeto.required' => 'O :attribute é 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',
'email.*.required' => 'O :attribute é obrigatório',
'instituicao.*.required' => 'O :attribute é obrigatório',
......
......@@ -89,7 +89,7 @@ class User extends Authenticatable implements MustVerifyEmail
return $this->hasOne('App\AdministradorResponsavel');
}
public function participantes(){
return $this->hasMany('App\Participante');
return $this->hasMany('App\Participante')->orderBy('id', 'asc');
}
public function avaliadors(){
return $this->hasOne('App\Avaliador');
......
......@@ -190,7 +190,7 @@
$('#aviso-modal-limite-de-integrantes').modal('show');
}
let modal_id = 0;
let modal_id = Number(document.getElementById('quantidadeModais').value);
function exibirUsuarioAdicionado(data) {
$('#modalIntegrante').modal('hide');
......
......@@ -359,6 +359,7 @@
</div>
@endif
<div style="display: block" @if(old('funcaoParticipante') == null || !array_key_exists($i, old('funcaoParticipante')) || old('funcaoParticipante')[$i] == 'Bolsista') @else hidden @endif>
@if($edital->tipo != "CONTINUO")
<div class="col-md-12" id="plano-titulo{{$i}}">
<h5>Plano de trabalho</h5>
......@@ -391,6 +392,7 @@
@endcomponent
</div>
@endif
</div>
{{-- <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>
......
......@@ -7,6 +7,7 @@
<form method="POST" id="criarProjetoForm" action="{{route('trabalho.store')}}" enctype="multipart/form-data" >
@csrf
<input type="hidden" name="editalId" value="{{$edital->id}}">
<input type="hidden" name="quantidadeModais" id="quantidadeModais" value="{{old('quantidadeModais', 0)}}" >
<div class="container">
......@@ -232,16 +233,16 @@
if(nome.value != ""){
estudante.value = true;
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>Plano: </strong>${planoTrabalho.value}<br>
<strong>CPF: </strong>${cpf.value} <br>
<strong>Função: </strong>${nome_funcao}</p>`;
<strong>Função: </strong>${nome_funcao}`;
}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>CPF: </strong>${cpf.value} <br>
<strong>Função: </strong>${nome_funcao}</p>`;
<strong>Função: </strong>${nome_funcao}`;
}
}else if(data != null) {
estudante.value = false;
......@@ -265,6 +266,7 @@
document.getElementById("checkB"+id).checked = true;
//$("#atribuir1").attr('data-target','#modalIntegrante'+(id+1));
modal_id = id+1;
document.getElementById("quantidadeModais").value = modal_id;
document.getElementById("part"+id).removeAttribute("hidden");
//document.getElementById("exampleModal"+id).modal('hide');
......@@ -279,6 +281,7 @@
document.getElementById("part"+id).setAttribute("hidden",true);
//$("#atribuir1").attr('data-target','#exampleModal'+(id));
modal_id -= 1;
document.getElementById("quantidadeModais").value = modal_id;
document.getElementById("exampleModal"+id).modal('hide');
}
@endif
......
......@@ -272,6 +272,7 @@
if(<?php echo json_encode($trabalho_user) ?>['funcao']){
modal_id += 1;
document.getElementById("quantidadeModais").value = modal_id;
}
$('#integrante').append(`
......
......@@ -260,6 +260,8 @@
document.getElementById("checkB"+id).checked = true;
// $("#atribuir1").attr('data-target','#exampleModal'+(id+1));
modal_id += 1;
document.getElementById("quantidadeModais").value = modal_id;
document.getElementById("part"+id).removeAttribute("hidden");
// document.getElementById("exampleModal"+id).modal('hide');
}
......@@ -274,6 +276,7 @@
// $("#atribuir1").attr('data-target','#exampleModal'+(id));
// document.getElementById("exampleModal"+id).modal('hide');
modal_id -= 1;
document.getElementById("quantidadeModais").value = modal_id;
console.log(modal_id);
}
@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