diff --git a/app/Http/Controllers/TrabalhoController.php b/app/Http/Controllers/TrabalhoController.php index 15bbf80f33b568443ced8b2b6797584fc488881b..f4117d5f67e90f4cd266879ff94ac3ca0e92f963 100755 --- a/app/Http/Controllers/TrabalhoController.php +++ b/app/Http/Controllers/TrabalhoController.php @@ -459,6 +459,9 @@ class TrabalhoController extends Controller } } + $hoje = Carbon::today('America/Recife'); + $hoje = $hoje->toDateString(); + return view('projeto.visualizar')->with(['projeto' => $projeto, @@ -478,7 +481,8 @@ class TrabalhoController extends Controller 'trabalhos_user' => $trabalhos_user, 'AvalRelatParcial' => $AvalRelatParcial, 'AvalRelatFinal' => $AvalRelatFinal, - 'proponente' => $proponente + 'proponente' => $proponente, + 'hoje' => $hoje ]); } @@ -1215,6 +1219,10 @@ class TrabalhoController extends Controller return redirect(route('trabalho.show', ['id' => $id]))->with(['mensagem' => "Já existe um Integrante com esse CPF."]); } + if(!$this->validarDataResultadoFinalPibex($id)) { + return redirect(route('trabalho.show', ['id' => $id]))->with(['mensagem' => "Só é possivel adicionar integrantes após a data do Resultado final"]); + } + $atributos = ['user_id' => $usuario->id, 'funcao_participante_id' => $request->funcao_participante, @@ -1275,6 +1283,19 @@ class TrabalhoController extends Controller return true; } + private function validarDataResultadoFinalPibex($id) { + $hoje = Carbon::today('America/Recife'); + $hoje = $hoje->toDateString(); + $edital = Trabalho::where('id', $id)->first()->evento; + + if($edital->tipo == "PIBEX" && $hoje <= $edital->resultado_final){ + return false; + } + + return true; + + } + public function buscarUsuario(Request $request) { $usuario = User::where('cpf', $request->cpf_consulta)->first(); $funcao = FuncaoParticipantes::where('id', $request->funcao)->first(); diff --git a/resources/views/projeto/formularioVisualizar/integrantes.blade.php b/resources/views/projeto/formularioVisualizar/integrantes.blade.php index c4c61f1b1cf41b5649823e61fa4280043873931c..0e4322a1b2baa91dfd71286175ee1162986245a9 100644 --- a/resources/views/projeto/formularioVisualizar/integrantes.blade.php +++ b/resources/views/projeto/formularioVisualizar/integrantes.blade.php @@ -9,9 +9,11 @@ Solicitar Substituições/Desligamentos -
- Adicionar Participante -
+ @if(($projeto->evento->tipo == "PIBEX" && $hoje > $projeto->evento->resultado_final) || $projeto->evento->tipo == "CONTINUO") +
+ Adicionar Participante +
+ @endif
diff --git a/resources/views/projeto/visualizar.blade.php b/resources/views/projeto/visualizar.blade.php index 451209262e67f131f4c2b8fc2007ca39d68eb936..6c1eed1ba18c57067bc1ff0599802f3ffb3f60c9 100755 --- a/resources/views/projeto/visualizar.blade.php +++ b/resources/views/projeto/visualizar.blade.php @@ -38,7 +38,7 @@ @endif @if($edital->natureza_id == 3) - @component('projeto.formularioVisualizar.integrantes', ['projeto' => $projeto, 'edital' => $edital, 'trabalhos_user' => $trabalhos_user,'funcaoParticipantes' =>$funcaoParticipantes]) + @component('projeto.formularioVisualizar.integrantes', ['projeto' => $projeto, 'edital' => $edital, 'trabalhos_user' => $trabalhos_user,'funcaoParticipantes' =>$funcaoParticipantes, 'hoje' => $hoje]) @endcomponent @endif