Commit 23113320 authored by Guilherme Silva's avatar Guilherme Silva
Browse files

Mudança de avaliador externo para ad hoc, mudança do arquivo Formulário de...

Mudança de avaliador externo para ad hoc, mudança do arquivo Formulário de avaliação externa, ajustes na lógica de atribuição e avaliação
parent 4c595d3c
......@@ -19,7 +19,7 @@ class Avaliador extends Model
return $this->belongsTo('App\User');
}
public function trabalhos(){
return $this->belongsToMany('App\Trabalho')->withPivot('status', 'AnexoParecer', 'parecer', 'recomendacao', 'created_at','pontuacao');
return $this->belongsToMany('App\Trabalho')->withPivot('status', 'AnexoParecer', 'parecer', 'recomendacao', 'created_at','pontuacao','acesso');
}
public function planoTrabalhos(){
return $this->belongsToMany('App\Arquivo', 'avaliadors_plano_trabalho')->withPivot('status', 'AnexoParecer', 'parecer', 'recomendacao', 'created_at');
......
......@@ -642,25 +642,47 @@ class AdministradorController extends Controller
$trabalho = Trabalho::where('id', $request->trabalho_id)->first();
$evento = Evento::where('id', $request->evento_id)->first();
if($request->avaliadores_internos_id == null){
$avaliadoresInternos = [];
}else{
$avaliadoresInternos = $request->avaliadores_internos_id;
if($request->avaliadores_internos_id != null){
foreach ($request->avaliadores_internos_id as $avaliador) {
$aval = Avaliador::find($avaliador);
if($aval->trabalhos()->where("trabalho_id",$trabalho->id)->first() != null){
$aval->trabalhos()
->updateExistingPivot($trabalho->id,['acesso'=>3]);
}else{
$trabalho->avaliadors()->attach($aval,['acesso'=>2]);
$evento->avaliadors()->syncWithoutDetaching($aval);
}
}
}
if($request->avaliadores_externos_id == null){
$avaliadoresExternos = [];
}else{
$avaliadoresExternos = $request->avaliadores_externos_id;
}
$idsAvaliadores = array_merge($avaliadoresInternos, $avaliadoresExternos);
if($idsAvaliadores == null){
redirect()->back()->with(['error' => 'Selecione ao menos um avaliador.', 'trabalho' => $trabalho->id]);
}
$avaliadores = Avaliador::whereIn('id', $idsAvaliadores)->get();
$trabalho->avaliadors()->attach($avaliadores);
$evento->avaliadors()->syncWithoutDetaching($avaliadores);
$trabalho->save();
if($request->avaliadores_externos_id != null){
foreach ($request->avaliadores_externos_id as $avaliador) {
$aval = Avaliador::find($avaliador);
if(Avaliador::where('id',$avaliador)->where('tipo',"Interno")->count()>0){
if($aval->trabalhos()->where("trabalho_id",$trabalho->id)->first() != null){
$aval->trabalhos()
->updateExistingPivot($trabalho->id,['acesso'=>3]);
}else{
$trabalho->avaliadors()->attach($aval,['acesso'=>1]);
$evento->avaliadors()->syncWithoutDetaching($aval);
}
}else{
$trabalho->avaliadors()->attach($aval,['acesso'=>1]);
$evento->avaliadors()->syncWithoutDetaching($aval);
}
}
}
if($request->avaliadores_externos_id == null & $request->avaliadores_internos_id == null ){
redirect()->back()->with(['error' => 'Selecione ao menos um avaliador.', 'trabalho' => $trabalho->id]);
}
$avaliadores = Avaliador::whereIn('id', (array)$request->avaliadores_externos_id)
->orWhereIn('id', (array)$request->avaliadores_internos_id)->get();
$trabalho->save();
foreach ($avaliadores as $avaliador){
......
......@@ -71,11 +71,22 @@ class AvaliadorController extends Controller
$user = User::find(Auth::user()->id);
$evento = Evento::where('id', $request->evento_id)->first();
$trabalhos = $user->avaliadors->where('user_id',$user->id)->first()->trabalhos->where('evento_id', $request->evento_id);
//$trabalhos = $user->avaliadors->where('user_id',$user->id)->first()->trabalhos->where('evento_id', $request->evento_id);
$trabalhosEx = [];
$trabalhosIn = [];
$aval = $user->avaliadors->where('user_id',$user->id)->first();
foreach ($aval->trabalhos as $trab){
if($aval->trabalhos()->where("trabalho_id",$trab->id)->first()->pivot->acesso == 2 || $aval->trabalhos()->where("trabalho_id",$trab->id)->first()->pivot->acesso == 3 ){
array_push($trabalhosIn,$aval->trabalhos()->where("trabalho_id",$trab->id)->first());
}
if ($aval->trabalhos()->where("trabalho_id",$trab->id)->first()->pivot->acesso == 1 || $aval->trabalhos()->where("trabalho_id",$trab->id)->first()->pivot->acesso == 3){
array_push($trabalhosEx,$aval->trabalhos()->where("trabalho_id",$trab->id)->first());
}
}
//dd();
return view('avaliador.listarTrabalhos', ['trabalhos'=>$trabalhos, 'evento'=>$evento]);
return view('avaliador.listarTrabalhos', ['trabalhosEx'=>$trabalhosEx,'trabalhosIn'=>$trabalhosIn, 'evento'=>$evento]);
}
......@@ -121,7 +132,18 @@ class AvaliadorController extends Controller
public function enviarParecerInterno(Request $request){
$user = User::find(Auth::user()->id);
$evento = Evento::where('id', $request->evento_id)->first();
$trabalhos = $user->avaliadors->where('user_id',$user->id)->first()->trabalhos->where('evento_id', $request->evento_id);
//$trabalhos = $user->avaliadors->where('user_id',$user->id)->first()->trabalhos->where('evento_id', $request->evento_id);
$trabalhosEx = [];
$trabalhosIn = [];
$aval = $user->avaliadors->where('user_id',$user->id)->first();
foreach ($aval->trabalhos as $trab){
if($aval->trabalhos()->where("trabalho_id",$trab->id)->first()->pivot->acesso == 2 || $aval->trabalhos()->where("trabalho_id",$trab->id)->first()->pivot->acesso == 3 ){
array_push($trabalhosIn,$aval->trabalhos()->where("trabalho_id",$trab->id)->first());
}
if ($aval->trabalhos()->where("trabalho_id",$trab->id)->first()->pivot->acesso == 1 || $aval->trabalhos()->where("trabalho_id",$trab->id)->first()->pivot->acesso == 3){
array_push($trabalhosEx,$aval->trabalhos()->where("trabalho_id",$trab->id)->first());
}
}
$avaliador = $user->avaliadors->where('user_id',$user->id)->first();
$trabalho = $avaliador->trabalhos->find($request->trabalho_id);
$parecerInterno = ParecerInterno::where([['avaliador_id',$avaliador->id],['trabalho_id',$trabalho->id]])->first();
......@@ -168,7 +190,7 @@ class AvaliadorController extends Controller
$parecerInterno->update();
}
return view('avaliador.listarTrabalhos', ['trabalhos'=>$trabalhos, 'evento'=>$evento]);
return view('avaliador.listarTrabalhos', ['trabalhosEx'=>$trabalhosEx,'trabalhosIn'=>$trabalhosIn, 'evento'=>$evento]);
}
public function parecerPlano(Request $request){
......@@ -188,8 +210,19 @@ class AvaliadorController extends Controller
$evento = Evento::find($request->evento_id);
$trabalhos = $user->avaliadors->where('user_id',$user->id)->first()->trabalhos->where('evento_id', $request->evento_id);
$avaliador = $user->avaliadors->where('user_id',$user->id)->first();
//$trabalhos = $user->avaliadors->where('user_id',$user->id)->first()->trabalhos->where('evento_id', $request->evento_id);
$trabalhosEx = [];
$trabalhosIn = [];
$aval = $user->avaliadors->where('user_id',$user->id)->first();
foreach ($aval->trabalhos as $trab){
if($aval->trabalhos()->where("trabalho_id",$trab->id)->first()->pivot->acesso == 2 || $aval->trabalhos()->where("trabalho_id",$trab->id)->first()->pivot->acesso == 3 ){
array_push($trabalhosIn,$aval->trabalhos()->where("trabalho_id",$trab->id)->first());
}
if ($aval->trabalhos()->where("trabalho_id",$trab->id)->first()->pivot->acesso == 1 || $aval->trabalhos()->where("trabalho_id",$trab->id)->first()->pivot->acesso == 3){
array_push($trabalhosEx,$aval->trabalhos()->where("trabalho_id",$trab->id)->first());
}
}
$avaliador = $user->avaliadors->where('user_id',$user->id)->first();
$trabalho = $avaliador->trabalhos->find($request->trabalho_id);
$trabalho->status = 'avaliado';
$trabalho->save();
......@@ -221,7 +254,7 @@ class AvaliadorController extends Controller
// dd($trabalho);
return view('avaliador.listarTrabalhos', ['trabalhos'=>$trabalhos, 'evento'=>$evento ]);
return view('avaliador.listarTrabalhos', ['trabalhosEx'=>$trabalhosEx,'trabalhosIn'=>$trabalhosIn, 'evento'=>$evento ]);
}
public function conviteResposta(Request $request){
//dd($request->all());
......
......@@ -102,7 +102,7 @@ class Trabalho extends Model
return $this->belongsTo('App\CoordenadorComissao');
}
public function avaliadors(){
return $this->belongsToMany('App\Avaliador')->withPivot('status', 'AnexoParecer', 'parecer', 'recomendacao', 'created_at','pontuacao');
return $this->belongsToMany('App\Avaliador')->withPivot('status', 'AnexoParecer', 'parecer', 'recomendacao', 'created_at','pontuacao','acesso');
}
public function substituicaos(){
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddAcessoToAvaliadorsTrabalhosTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('avaliador_trabalho', function (Blueprint $table) {
$table->string('acesso')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('avaliador_trabalho', function (Blueprint $table) {
$table->dropColumn('acesso');
});
}
}
......@@ -835,19 +835,28 @@
<select name="avaliadores_internos_id[]" multiple
class="form-control" id="exampleFormControlSelect2"
style="height: 200px;font-size: 15px">
@foreach ($trabalho->aval as $avaliador)
@if($avaliador->tipo == "Interno")
<option value="{{ $avaliador->id }}"> {{ $avaliador->user->name }}
@foreach ($trabalho->avaliadors as $avaliador)
@if($avaliador->tipo == "Interno" && $avaliador->trabalhos()->where("trabalho_id",$trabalho->id)->first()->pivot->acesso == 1)
<option value="{{ $avaliador->id }}">{{ $avaliador->user->name }}
> {{$avaliador->user->instituicao ?? 'Instituição Indefinida'}}
> {{$avaliador->area->nome ?? 'Indefinida'}}
> {{$avaliador->user->email}}</option>
@endif
@endforeach
@foreach ($trabalho->aval as $avaliador)
@if($avaliador->tipo == "Interno")
<option value="{{ $avaliador->id }}"> {{ $avaliador->user->name }}
> {{$avaliador->user->instituicao ?? 'Instituição Indefinida'}}
> {{$avaliador->area->nome ?? 'Indefinida'}}
> {{$avaliador->user->email}}</option>
@endif
@endforeach
</select>
<div class="col-md-6">
<label style="font-weight: bold;font-size: 18px">Externos</label>
<label style="font-weight: bold;font-size: 18px"><i>Ad Hoc</i></label>
</div>
<input type="hidden" id="trab" value="{{$trabalho->id}}">
......@@ -856,13 +865,19 @@
<select name="avaliadores_externos_id[]" multiple
class="form-control" id="exampleFormControlSelect3"
style="height: 200px;font-size:15px">
@foreach ($trabalho->avaliadors as $avaliador)
@if($avaliador->trabalhos()->where("trabalho_id",$trabalho->id)->first()->pivot->acesso == 2)
<option value="{{ $avaliador->id }}">{{ $avaliador->user->name }}
> {{$avaliador->user->instituicao ?? 'Instituição Indefinida'}}
> {{$avaliador->area->nome ?? 'Indefinida'}}
> {{$avaliador->user->email}}</option>
@endif
@endforeach
@foreach ($trabalho->aval as $avaliador)
@if($avaliador->tipo == "Externo")
<option value="{{ $avaliador->id }}"> {{ $avaliador->user->name }}
> {{$avaliador->user->instituicao ?? 'Instituição Indefinida'}}
> {{$avaliador->area->nome ?? 'Indefinida'}}
> {{$avaliador->user->email}}</option>
@endif
@endforeach
</select>
......@@ -893,7 +908,7 @@
</div>
<div class="row justify-content-start" style="alignment: center">
@foreach($trabalho->avaliadors as $avaliador)
@if($avaliador->tipo == 'Interno')
@if($avaliador->tipo == 'Interno' && ($avaliador->trabalhos()->where("trabalho_id",$trabalho->id)->first()->pivot->acesso == 2 || $avaliador->trabalhos()->where("trabalho_id",$trabalho->id)->first()->pivot->acesso == 3))
<div class="col-sm-1">
<img src="{{asset('img/icons/usuario.svg')}}" style="width:60px" alt="">
</div>
......@@ -921,29 +936,22 @@
<!--Comissão Externa-->
<div class="row justify-content-start" style="alignment: center">
<div class="col-md-11"><h6 style="color: #234B8B; font-weight: bold">Avaliadores -
Externos</h6></div>
<i>Ad Hoc</i></h6></div>
</div>
<div class="row justify-content-start" style="alignment: center">
@foreach($trabalho->avaliadors as $avaliador)
@if($avaliador->tipo == 'Externo' || $avaliador->tipo == null)
@if(($avaliador->trabalhos()->where("trabalho_id",$trabalho->id)->first()->pivot->acesso == 1 || $avaliador->trabalhos()->where("trabalho_id",$trabalho->id)->first()->pivot->acesso == 3) )
<div class="col-sm-1">
<img src="{{asset('img/icons/usuario.svg')}}" style="width:60px" alt="">
</div>
<div class="col-sm-5">
<h5>{{$avaliador->user->name}}</h5>
@if($avaliador->tipo == 'Externo' || $avaliador->tipo == null)
<h9>@if($avaliador->trabalhos->where('id', $trabalho->id)->first()->pivot->parecer == null)
Pendente @else <a
href="{{ route('admin.visualizarParecer', ['trabalho_id' => $trabalho->id, 'avaliador_id' => $avaliador->id]) }}">Avaliado</a> @endif
</h9>
@else
@php
$parecerInterno = App\ParecerInterno::where([['avaliador_id',$avaliador->id],['trabalho_id',$trabalho->id]])->first();
@endphp
<h9>@if($parecerInterno == null) Pendente @else <a
href="{{ route('admin.visualizarParecerInterno', ['trabalho_id' => $trabalho->id, 'avaliador_id' => $avaliador->id]) }}">Avaliado</a> @endif
</h9>
@endif
<br>
<a href="{{ route('admin.removerProjAval', ['trabalho_id' => $trabalho->id, 'avaliador_id' => $avaliador->id]) }}" >
Remover
......
......@@ -8,7 +8,7 @@
<div class="row justify-content-center" style="margin-top: 2rem;">
<div class="col-md-12 form-group" style="text-align: center">
<h5 style="color: #1492E6; margin-top:0.5rem; font-size:25px">Página inicial</h5>
<h5 style="color: #909090; margin-top:0.7rem; font-size:22px; font-weight:normal">Avaliador {{Auth::user()->avaliadors->tipo}}</h5>
<h5 style="color: #909090; margin-top:0.7rem; font-size:22px; font-weight:normal">Avaliador @if(Auth::user()->avaliadors->tipo == "Externo") <i>Ad Hoc</i>@else Interno @endif</h5>
</div>
<div class="" style="text-align: center">
<div class="form-group imagem_shadow" style="border-radius: 12px; padding:14px; height:200px; width:190px; margin:15px">
......
......@@ -22,14 +22,17 @@
<div class="row justify-content-center" style="margin-top: 3rem;">
<div class="col-md-11" style="margin-bottom: -3rem">
<div class="card card_conteudo shadow bg-white" style="border-radius:12px; border-width:0px;">
<div class="card-header" style="border-top-left-radius: 12px; border-top-right-radius: 12px; background-color: #fff">
@if($trabalhosIn != null)
<div class="card-header" style="border-top-left-radius: 12px; border-top-right-radius: 12px; background-color: #fff">
<div class="d-flex justify-content-between align-items-center" style="margin-top: 9px; margin-bottom:-1rem">
<div class="bottomVoltar" style="margin-top: -20px">
<a href="javascript:history.back()" class="btn btn-secondary" style=""><img src="{{asset('img/icons/logo_esquerda.png')}}" alt="" width="15px"></a>
</div>
<div class="form-group">
<h5 class="card-title mb-0" style="font-size:25px; font-family:Arial, Helvetica, sans-serif; color:#1492E6">Trabalhos do Edital: {{ $evento->nome }}</h5>
<h5 class="card-title mb-0" style="font-size:25px; font-family:Arial, Helvetica, sans-serif; color:#1492E6">Avaliação Interna do Edital: {{ $evento->nome }}</h5>
</div>
<div style="margin-top: -2rem">
<div class="form-group">
<div style="margin-top:30px;">
......@@ -39,8 +42,10 @@
</div>
</div>
</div>
@endif
@if($trabalhosIn != null)
<div class="card-body" >
<table class="table table-bordered table-hover" style="display: block; white-space: nowrap; border-radius:10px; margin-bottom:0px">
<thead>
......@@ -59,7 +64,7 @@
</tr>
</thead>
<tbody>
@foreach ($trabalhos as $trabalho)
@foreach ($trabalhosIn as $trabalho)
<tr>
<td style="max-width:100px; overflow-x:hidden; text-overflow:ellipsis">{{ $trabalho->titulo }}</td>
<td style="text-align: center">{{ $trabalho->created_at->format('d/m/Y') }}</td>
......@@ -132,6 +137,78 @@
</tbody>
</table>
</div>
@endif
@if($trabalhosEx != null)
<div class="form-group mb-0" style="margin-left: 20px;margin-top: 20px;">
<h5 class="card-title mb-0" style="font-size:25px; font-family:Arial, Helvetica, sans-serif; color:#1492E6">Avaliação <i>Ad Hoc</i> do Edital: {{ $evento->nome }}</h5>
</div>
<hr class="mb-0">
<div class="card-body" >
<table class="table table-bordered table-hover" style="display: block; white-space: nowrap; border-radius:10px; margin-bottom:0px">
<thead>
<tr>
<th scope="col" style="width:100%">Nome do Projeto</th>
<th scope="col">Data de Criação</th>
<th scope="col">Projeto</th>
<th scope="col">Plano de Trabalho</th>
<th scope="col">Parecer Externo</th>
</tr>
</thead>
<tbody>
@foreach ($trabalhosEx as $trabalho)
<tr>
<td style="max-width:100px; overflow-x:hidden; text-overflow:ellipsis">{{ $trabalho->titulo }}</td>
<td style="text-align: center">{{ $trabalho->created_at->format('d/m/Y') }}</td>
<td style="text-align: center">
{{-- --}}
<a href="{{route('download', ['file' => $trabalho->anexoProjeto])}}" target="_new" style="font-size: 20px; color: #114048ff;" class="btn btn-light">
<img class="" src="{{asset('img/icons/file-download-solid.svg')}}" style="width:15px">
</a>
</td>
<td style="text-align: center">
@foreach( $trabalho->participantes as $participante)
@php
if( App\Arquivo::where('participanteId', $participante->id)->first() != null){
$planoTrabalho = App\Arquivo::where('participanteId', $participante->id)->first()->nome;
}else{
$planoTrabalho = null;
}
@endphp
@if ($planoTrabalho != null)
<a href="{{route('download', ['file' => $planoTrabalho])}}" target="_new" style="font-size: 20px; color: #114048ff;" class="btn btn-light">
<img class="" src="{{asset('img/icons/file-download-solid.svg')}}" style="width:15px">
</a>
@else
Não planos de trabalho.
@endif
@endforeach
</td>
<td>
<div class="row justify-content-center">
<form action="{{ route('avaliador.parecer', ['evento' => $evento]) }}" method="POST">
@csrf
<input type="hidden" name="trabalho_id" value="{{ $trabalho->id }}" >
@if($trabalho->pivot->AnexoParecer == null)
<button type="submit" class="btn btn-primary mr-2 ml-2" >
Parecer
</button>
@else
<button type="submit" class="btn btn-secondary mr-2 ml-2" >
Enviado
</button>
@endif
</form>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</div>
</div>
</div>
......
......@@ -421,7 +421,7 @@
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="pdfFormAvalExterno">Formulário de avaliação externa:</label>
<label for="pdfFormAvalExterno">Formulário para avaliador <i>ad hoc</i>:</label>
@if(old('pdfFormAvalExternoPreenchido') != null)
<a id="pdfFormAvalExternoTemp" href="{{ route('baixar.evento.temp', ['nomeAnexo' => 'formAvaliacaoExterno' ])}}">Arquivo atual</a>
@endif
......
......@@ -401,7 +401,7 @@
<div class="col-sm-6">
<div class="form-group">
<label for="pdfEdital">Formulário de avaliação externa:</label>
<label for="pdfEdital">Formulário para avaliador <i>ad hoc</i>:</label>
<a href="{{route('download', ['file' => $evento->formAvaliacaoExterno])}}" target="_new" style="font-size: 20px; color: #114048ff;" >
<img class="" src="{{asset('img/icons/file-download-solid.svg')}}" style="width:20px">
</a>
......
......@@ -175,7 +175,7 @@
@if(Auth::user()->avaliadors->tipo == "Interno")
<a href="" class="btn navbar-text negrito " style="color: rgb(0, 140, 255);pointer-events: none;" >Comissão Interna</a>
@elseif(Auth::user()->avaliadors->tipo == "Externo")
<a href="" class="btn navbar-text negrito " style="color: rgb(0, 140, 255);pointer-events: none;" >Comissão Externa</a>
<a href="" class="btn navbar-text negrito " style="color: rgb(0, 140, 255);pointer-events: none;" >Comissão <i>Ad Hoc</i></a>
@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