From e845ab5140cb9d272ae1b2018ff80a1130823570 Mon Sep 17 00:00:00 2001 From: carlos Date: Thu, 4 Jun 2020 17:36:18 -0300 Subject: [PATCH] atualizando criar e editar projeto --- app/Http/Controllers/TrabalhoController.php | 83 +-- app/Participante.php | 2 +- resources/views/projeto/editar.blade.php | 568 ++++++++++++++++++++ resources/views/projeto/index.blade.php | 4 +- routes/web.php | 11 +- 5 files changed, 631 insertions(+), 37 deletions(-) create mode 100644 resources/views/projeto/editar.blade.php diff --git a/app/Http/Controllers/TrabalhoController.php b/app/Http/Controllers/TrabalhoController.php index 0704077..54b736f 100644 --- a/app/Http/Controllers/TrabalhoController.php +++ b/app/Http/Controllers/TrabalhoController.php @@ -80,7 +80,7 @@ class TrabalhoController extends Controller $proponente = Proponente::where('user_id', Auth::user()->id)->first(); //$trabalho->proponentes()->save($proponente); //dd($coordenador->id); - + $trabalho = "trabalho"; if($evento->inicioSubmissao > $mytime){ if($mytime >= $evento->fimSubmissao){ return redirect()->route('home'); @@ -179,8 +179,6 @@ class TrabalhoController extends Controller } - - //Envia email com senha temp para cada participante do projeto if($request->emailParticipante != null){ @@ -198,11 +196,10 @@ class TrabalhoController extends Controller 'usuarioTemp' => true, 'name' => $request->nomeParticipante[$key], 'tipo' => 'participante', - 'funcao_participante_id' => $request->funcaoParticipante[$key], ]); - $participante = $usuario->participantes()->create([ 'trabalho_id' => $trabalho->id, + 'funcao_participante_id' => $request->funcaoParticipante[$key], ]); $participante->trabalhos()->save($trabalho); @@ -216,30 +213,15 @@ class TrabalhoController extends Controller } } - $anexos = array( - $request->anexoCONSU, - $request->anexoProjeto, - $request->anexoComiteEtica, - $request->anexoLatterCoordenador, - $request->anexoPlanilha, - ); - - foreach ($anexos as $key => $value) { - - $file = $value; - $path = 'trabalhos/' . $request->editalId . '/' . $trabalho->id .'/'; - $nome = "1.pdf"; - Storage::putFileAs($path, $file, $nome); - - $arquivo = Arquivo::create([ - 'nome' => $path . $nome, - 'trabalhoId' => $trabalho->id, - 'data' => $mytime, - 'versaoFinal' => true, - ]); - - } - + $pasta = 'trabalhos/' . $request->editalId . '/' . $trabalho->id; + + $trabalho->anexoDecisaoCONSU = Storage::putFileAs($pasta, $request->anexoCONSU, "CONSU.pdf"); + $trabalho->anexoProjeto = Storage::putFileAs($pasta, $request->anexoProjeto, "Projeto.pdf"); + $trabalho->anexoAutorizacaoComiteEtica = Storage::putFileAs($pasta, $request->anexoComiteEtica, "Comite_de_etica.pdf"); + $trabalho->anexoLattesCoordenador = Storage::putFileAs($pasta, $request->anexoLatterCoordenador, "Latter_Coordenador.pdf"); + $trabalho->anexoPlanilhaPontuacao = Storage::putFileAs($pasta, $request->anexoPlanilha, "Planilha.pdf"); + $trabalho->update(); + if($request->anexoPlanoTrabalho != null){ foreach ($request->anexoPlanoTrabalho as $key => $value) { @@ -285,9 +267,23 @@ class TrabalhoController extends Controller * @param \App\Trabalho $trabalho * @return \Illuminate\Http\Response */ - public function edit(Trabalho $trabalho) + public function edit($id) { - // + $projeto = Trabalho::find($id); + $edital = Evento::find($projeto->evento_id); + $grandeAreas = GrandeArea::all(); + $areas = Area::all(); + $subareas = Subarea::all(); + $funcaoParticipantes = FuncaoParticipantes::all(); + $participantes = Participante::where('trabalho_id', $id)->get(); + + return view('projeto.editar')->with(['projeto' => $projeto, + 'grandeAreas' => $grandeAreas, + 'areas' => $areas, + 'subAreas' => $subareas, + 'edital' => $edital, + 'funcaoParticipantes' => $funcaoParticipantes, + 'participantes' => $participantes]); } /** @@ -451,4 +447,29 @@ class TrabalhoController extends Controller return view('projeto.index')->with(['edital' => $edital, 'projetos' => $projetos]); } + + public function baixarAnexoProjeto($id) { + $projeto = Trabalho::find($id); + return Storage::download($projeto->anexoProjeto); + } + + public function baixarAnexoConsu($id) { + $projeto = Trabalho::find($id); + return Storage::download($projeto->anexoDecisaoCONSU); + } + + public function baixarAnexoComite($id) { + $projeto = Trabalho::find($id); + return Storage::download($projeto->anexoAutorizacaoComiteEtica); + } + + public function baixarAnexoLattes($id) { + $projeto = Trabalho::find($id); + return Storage::download($projeto->anexoLattesCoordenador); + } + + public function baixarAnexoPlanilha($id) { + $projeto = Trabalho::find($id); + return Storage::download($projeto->anexoPlanilhaPontuacao); + } } diff --git a/app/Participante.php b/app/Participante.php index 5b5cb1c..5f07bef 100644 --- a/app/Participante.php +++ b/app/Participante.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model; class Participante extends Model { - protected $fillable = ['name', 'user_id', 'trabalho_id']; + protected $fillable = ['name', 'user_id', 'trabalho_id', 'participante_id']; public function user(){ return $this->belongsTo('App\User'); diff --git a/resources/views/projeto/editar.blade.php b/resources/views/projeto/editar.blade.php new file mode 100644 index 0000000..86ffdf7 --- /dev/null +++ b/resources/views/projeto/editar.blade.php @@ -0,0 +1,568 @@ +@extends('layouts.app') + +@section('content') +
+ +
+
+
+
+
Editar Projeto
+

+

+ @csrf + + + {{-- Nome do Projeto --}} +
+
+ + + + @error('nomeTrabalho') + + {{ $message }} + + @enderror +
+
+ + {{-- Grande Area --}} +
+
+ + + + @error('grandeArea') + + {{ $message }} + + @enderror +
+
+ + + + @error('area') + + {{ $message }} + + @enderror +
+
+ + + + @error('subArea') + + {{ $message }} + + @enderror +
+
+ + + + + + + + + +
+

Coordenador

+ + {{-- Coordenador --}} +
+ +
+ + +
+
+ + user()->proponentes->linkLattes != null) + value="{{ Auth()->user()->proponentes->linkLattes }}" + @else + value="" + @endif > + + @error('linkLattesEstudante') + + {{ $message }} + + @enderror +
+
+ + + + @error('pontuacaoPlanilha') + + {{ $message }} + + @enderror +
+
+ + + + @error('linkGrupo') + + {{ $message }} + + @enderror +
+ +
+ +
+

Anexos

+ + {{-- Anexo do Projeto --}} +
+ {{-- Arquivo --}} +
+ Arquivo atual + +
+ +
+ + +
+
+ @error('anexoProjeto') + + {{ $message }} + + @enderror +
+ +
+ Arquivo atual + +
+ +
+ + +
+
+ @error('anexoLatterCoordenador') + + {{ $message }} + + @enderror +
+ + + + + +
+ Arquivo atual +
+ + +
+ + +
+ + +
+
+ @error('anexoComiteEtica') + + {{ $message }} + + @enderror +
+ +
+ Arquivo atual + +
+ +
+ + +
+
+ @error('anexoPlanilha') + + {{ $message }} + + @enderror +
+ +
+ + +
+ + +
+ + +
+
+ @error('justificativaAutorizacaoEtica') + + {{ $message }} + + @enderror +
+ + @if($edital->tipo == 'PIBIC' || $edital->tipo == 'PIBIC-EM') + {{-- Decisão do CONSU --}} +
+ Arquivo atual + +
+ +
+ + +
+
+ @error('anexoCONSU') + + {{ $message }} + + @enderror +
+ @endif + +
+ +
+

Participantes

+ + {{-- Participantes --}} +
+
+
+ @foreach($participantes as $participante) +
+
+
Dados do participante
+
+
+ + + @error('nomeParticipante') + + {{ $message }} + + @enderror +
+
+ + + @error('emailParticipante') + + {{ $message }} + + @enderror +
+
+ + +
+
+
Dados do plano de trabalho
+
+
+
+
+
+ + + + @error('nomePlanoTrabalho') + + {{ $message }} + + @enderror +
+ {{-- Arquivo --}} +
+ +
+
+ Selecione um arquivo: +
+
+ + +
+
+ @error('anexoPlanoTrabalho') + + {{ $message }} + + @enderror +
+
+ + + +
+
+
+
+
+
+ @endforeach +
+ Participantes + +
+
+ +

+
+
+ Cancelar +
+
+ +
+
+
+
+
+
+
+ +
+@endsection + +@section('javascript') + +@endsection \ No newline at end of file diff --git a/resources/views/projeto/index.blade.php b/resources/views/projeto/index.blade.php index eeeaf95..6a30e24 100644 --- a/resources/views/projeto/index.blade.php +++ b/resources/views/projeto/index.blade.php @@ -35,14 +35,14 @@ @else Submetido @endif - {{$projeto->update}} + {{ date('d-m-Y', strtotime($projeto->updated_at)) }}