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 ...@@ -433,8 +433,13 @@ class TrabalhoController extends Controller
public function edit($id) 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(); $projeto = Auth::user()->proponentes->trabalhos()->where('id', $id)->first();
}
$proponente = Proponente::where('user_id', $projeto->proponente->user_id)->first();
if (!$projeto) { if (!$projeto) {
return back()->withErrors(['Proposta não encontrada!']); return back()->withErrors(['Proposta não encontrada!']);
} }
...@@ -832,7 +837,8 @@ class TrabalhoController extends Controller ...@@ -832,7 +837,8 @@ class TrabalhoController extends Controller
$request->merge([ $request->merge([
'coordenador_id' => $evento->coordenadorComissao->id 'coordenador_id' => $evento->coordenadorComissao->id
]); ]);
$trabalho = Auth::user()->proponentes->trabalhos()->where('id', $id)->first();
$trabalho = Trabalho::find($id);
DB::beginTransaction(); DB::beginTransaction();
if (!$trabalho) { if (!$trabalho) {
...@@ -988,10 +994,14 @@ class TrabalhoController extends Controller ...@@ -988,10 +994,14 @@ class TrabalhoController extends Controller
} }
DB::commit(); DB::commit();
if(Auth::user()->tipo == 'administrador'){
return redirect(route('admin.analisarProposta',['id'=>$trabalho->id]));
}
if (!$request->has('rascunho')) { 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!']); return redirect(route('proponente.projetos'))->with(['mensagem' => 'Proposta atualizada!']);
......
...@@ -44,7 +44,14 @@ ...@@ -44,7 +44,14 @@
<hr style="border-top: 1px solid#1492E6"> <hr style="border-top: 1px solid#1492E6">
</div> </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 <div class="col-md-12"><h6
style="color: #234B8B; margin-bottom:-0.4rem; font-weight: bold">{{$evento->nome}}</h6> style="color: #234B8B; margin-bottom:-0.4rem; font-weight: bold">{{$evento->nome}}</h6>
</div> </div>
......
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
<div class=" d-flex justify-content-between align-items-center" style="margin-top: 15px; margin-bottom:18px"> <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> <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> <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> <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> <button type="submit" class="btn btn-success" id="idButtonSubmitProjeto" >{{ __('Submeter projeto') }}</button>
</div> </div>
</div> </div>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<label for="nome" class="col-form-label font-tam" style="font-weight: bold">{{ __('Nome: ') }}</label> <label for="nome" class="col-form-label font-tam" style="font-weight: bold">{{ __('Nome: ') }}</label>
</div> </div>
<div class="col-md-11"> <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>
<div class="col-md-1"> <div class="col-md-1">
...@@ -23,11 +23,16 @@ ...@@ -23,11 +23,16 @@
<br> <br>
<input class="form-control @error('linkLattesEstudante') is-invalid @enderror" type="text" name="linkLattesEstudante" <input class="form-control @error('linkLattesEstudante') is-invalid @enderror" type="text" name="linkLattesEstudante"
readonly="readonly" readonly="readonly"
@if(Auth::user()->tipo=='administrador')
value="{{ $projeto->proponente->linkLattes }}"
@else
@if(Auth()->user()->proponentes != null && Auth()->user()->proponentes->linkLattes != null) @if(Auth()->user()->proponentes != null && Auth()->user()->proponentes->linkLattes != null)
value="{{ Auth()->user()->proponentes->linkLattes }}" value="{{ Auth()->user()->proponentes->linkLattes }}"
@else @else
value="" value=""
@endif > @endif
@endif
>
@error('linkLattesEstudante') @error('linkLattesEstudante')
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block"> <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
<strong>{{ $message }}</strong> <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