Commit 666ab493 authored by GuilhermeGz's avatar GuilhermeGz
Browse files

Permitir que administrador possa editar uma proposta

parent 706a4fea
......@@ -433,8 +433,13 @@ class TrabalhoController extends Controller
public function edit($id)
{
$proponente = Proponente::where('user_id', Auth::user()->id)->first();
if(Auth::user()->tipo=='administrador'){
$projeto = Trabalho::find($id);
}else{
$projeto = Auth::user()->proponentes->trabalhos()->where('id', $id)->first();
}
$proponente = Proponente::where('user_id', $projeto->proponente->user_id)->first();
if (!$projeto) {
return back()->withErrors(['Proposta não encontrada!']);
}
......@@ -832,7 +837,8 @@ class TrabalhoController extends Controller
$request->merge([
'coordenador_id' => $evento->coordenadorComissao->id
]);
$trabalho = Auth::user()->proponentes->trabalhos()->where('id', $id)->first();
$trabalho = Trabalho::find($id);
DB::beginTransaction();
if (!$trabalho) {
......@@ -988,10 +994,14 @@ class TrabalhoController extends Controller
}
DB::commit();
if(Auth::user()->tipo == 'administrador'){
return redirect(route('admin.analisarProposta',['id'=>$trabalho->id]));
}
if (!$request->has('rascunho')) {
Notification::send(Auth::user(), new SubmissaoNotification($id,$trabalho->titulo));
Notification::send($trabalho->proponente->user, new SubmissaoNotification($id,$trabalho->titulo));
}
return redirect(route('proponente.projetos'))->with(['mensagem' => 'Proposta atualizada!']);
......
......@@ -44,7 +44,14 @@
<hr style="border-top: 1px solid#1492E6">
</div>
<div class="col-md-12"><h5 style="color: #1492E6;">{{$trabalho->titulo}}</h5></div>
<div class="col-md-12">
<h5 style="color: #1492E6;">{{$trabalho->titulo}}
<a class="ml-2 mb-5" href="{{ route('trabalho.editar', ['id' => $trabalho->id]) }}">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#234B8B" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 14.66V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h5.34"></path><polygon points="18 2 22 6 12 16 8 16 8 12 18 2"></polygon></svg>
</a>
</h5>
</div>
<div class="col-md-12"><h6
style="color: #234B8B; margin-bottom:-0.4rem; font-weight: bold">{{$evento->nome}}</h6>
</div>
......
......@@ -10,7 +10,9 @@
<div class=" d-flex justify-content-between align-items-center" style="margin-top: 15px; margin-bottom:18px">
<h6 style="font-weight: bold"><span style="color: red; font-weight:bold">*</span> Campos obrigatórios</h6>
<button id="submeterFormProposta" type="submit" style="display: none;"></button>
@if(Auth::user()->tipo != 'administrador')
<button type="submit" class="btn btn-primary " id="idButtonSubmitRascunho" >{{ __('Salvar como rascunho') }}</button>
@endif
<button type="submit" class="btn btn-success" id="idButtonSubmitProjeto" >{{ __('Submeter projeto') }}</button>
</div>
</div>
......
......@@ -12,7 +12,7 @@
<label for="nome" class="col-form-label font-tam" style="font-weight: bold">{{ __('Nome: ') }}</label>
</div>
<div class="col-md-11">
<input class="form-control" type="text" id="nomeCompletoProponente1" name="nomeCoordenador" disabled="disabled" value="{{ Auth()->user()->name }}">
<input class="form-control" type="text" id="nomeCompletoProponente1" name="nomeCoordenador" disabled="disabled" @if(Auth::user()->tipo=='administrador') value="{{ $projeto->proponente->user->name }}" @else value="{{ Auth()->user()->name }}" @endif >
</div>
<div class="col-md-1">
......@@ -23,11 +23,16 @@
<br>
<input class="form-control @error('linkLattesEstudante') is-invalid @enderror" type="text" name="linkLattesEstudante"
readonly="readonly"
@if(Auth::user()->tipo=='administrador')
value="{{ $projeto->proponente->linkLattes }}"
@else
@if(Auth()->user()->proponentes != null && Auth()->user()->proponentes->linkLattes != null)
value="{{ Auth()->user()->proponentes->linkLattes }}"
@else
value=""
@endif >
@endif
@endif
>
@error('linkLattesEstudante')
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
<strong>{{ $message }}</strong>
......
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