From 1a944ec7ad10f34b2d2e509aa8b4fd6475e3e8e9 Mon Sep 17 00:00:00 2001 From: Gabriel-31415 Date: Sun, 20 Jun 2021 19:03:05 +0000 Subject: [PATCH] editar projeto --- app/Http/Controllers/TrabalhoController.php | 82 +- app/Trabalho.php | 7 + .../views/componentes/participante.blade.php | 1 + resources/views/layouts/app.blade.php | 2 +- .../views/projeto/Backupeditar.blade.php | 2169 ++++++++++++++ resources/views/projeto/editar.blade.php | 2499 ++++------------- .../views/projeto/formulario/anexos.blade.php | 115 + .../projeto/formulario/finalizar.blade.php | 21 + .../formulario/participantes.blade.php | 212 ++ .../projeto/formulario/projeto.blade.php | 76 + .../projeto/formulario/proponente.blade.php | 63 + resources/views/projeto/visualizar.blade.php | 8 +- routes/web.php | 5 +- 13 files changed, 3225 insertions(+), 2035 deletions(-) create mode 100644 resources/views/projeto/Backupeditar.blade.php create mode 100644 resources/views/projeto/formulario/anexos.blade.php create mode 100644 resources/views/projeto/formulario/finalizar.blade.php create mode 100644 resources/views/projeto/formulario/participantes.blade.php create mode 100644 resources/views/projeto/formulario/projeto.blade.php create mode 100644 resources/views/projeto/formulario/proponente.blade.php diff --git a/app/Http/Controllers/TrabalhoController.php b/app/Http/Controllers/TrabalhoController.php index 961b728..f1115bd 100644 --- a/app/Http/Controllers/TrabalhoController.php +++ b/app/Http/Controllers/TrabalhoController.php @@ -41,6 +41,36 @@ use Illuminate\Support\Facades\Notification; class TrabalhoController extends Controller { + + public $estados = array( + 'AC' => 'Acre', + 'AL' => 'Alagoas', + 'AP' => 'Amapá', + 'AM' => 'Amazonas', + 'BA' => 'Bahia', + 'CE' => 'Ceará', + 'DF' => 'Distrito Federal', + 'ES' => 'Espirito Santo', + 'GO' => 'Goiás', + 'MA' => 'Maranhão', + 'MS' => 'Mato Grosso do Sul', + 'MT' => 'Mato Grosso', + 'MG' => 'Minas Gerais', + 'PA' => 'Pará', + 'PB' => 'Paraíba', + 'PR' => 'Paraná', + 'PE' => 'Pernambuco', + 'PI' => 'Piauí', + 'RJ' => 'Rio de Janeiro', + 'RN' => 'Rio Grande do Norte', + 'RS' => 'Rio Grande do Sul', + 'RO' => 'Rondônia', + 'RR' => 'Roraima', + 'SC' => 'Santa Catarina', + 'SP' => 'São Paulo', + 'SE' => 'Sergipe', + 'TO' => 'Tocantins', + ); public function index($id) { @@ -52,35 +82,7 @@ class TrabalhoController extends Controller if($proponente == null){ return view('proponente.cadastro')->with(['mensagem' => 'Você não possui perfil de Proponente, para submeter algum projeto preencha o formulário.']);; } - $estados = array( - 'AC' => 'Acre', - 'AL' => 'Alagoas', - 'AP' => 'Amapá', - 'AM' => 'Amazonas', - 'BA' => 'Bahia', - 'CE' => 'Ceará', - 'DF' => 'Distrito Federal', - 'ES' => 'Espirito Santo', - 'GO' => 'Goiás', - 'MA' => 'Maranhão', - 'MS' => 'Mato Grosso do Sul', - 'MT' => 'Mato Grosso', - 'MG' => 'Minas Gerais', - 'PA' => 'Pará', - 'PB' => 'Paraíba', - 'PR' => 'Paraná', - 'PE' => 'Pernambuco', - 'PI' => 'Piauí', - 'RJ' => 'Rio de Janeiro', - 'RN' => 'Rio Grande do Norte', - 'RS' => 'Rio Grande do Sul', - 'RO' => 'Rondônia', - 'RR' => 'Roraima', - 'SC' => 'Santa Catarina', - 'SP' => 'São Paulo', - 'SE' => 'Sergipe', - 'TO' => 'Tocantins', - ); + $rascunho = Trabalho::where('proponente_id', $proponente->id)->where('evento_id',$edital->id)->where('status', 'Rascunho') ->orderByDesc('updated_at')->first(); @@ -93,7 +95,7 @@ class TrabalhoController extends Controller 'funcaoParticipantes'=> $funcaoParticipantes, 'rascunho' => $rascunho, 'enum_turno' => Participante::ENUM_TURNO, - 'estados' => $estados, + 'estados' => $this->estados, ]); } @@ -194,7 +196,6 @@ class TrabalhoController extends Controller } public function validarAnexosRascunho(Request $request, $trabalho){ - //dd($trabalho->getAttributes()); $validator = Validator::make($trabalho->getAttributes(),[ 'anexoPlanilhaPontuacao' => $request->anexoPlanilha==null?['planilha']:[], ]); @@ -321,7 +322,7 @@ class TrabalhoController extends Controller $participantesUsersIds = Participante::where('trabalho_id', $id)->select('user_id')->get(); $users = User::whereIn('id', $participantesUsersIds)->get(); $arquivos = Arquivo::where('trabalhoId', $id)->get(); - return view('projeto.visualizar')->with(['projeto' => $projeto, + return view('projeto.visualizar')->with(['projeto' => $projeto, 'grandeAreas' => $grandeAreas, 'areas' => $areas, 'subAreas' => $subareas, @@ -357,6 +358,7 @@ class TrabalhoController extends Controller public function edit($id) { + $proponente = Proponente::where('user_id', Auth::user()->id)->first(); $projeto = Trabalho::find($id); $edital = Evento::find($projeto->evento_id); $grandeAreas = GrandeArea::all(); @@ -368,6 +370,9 @@ class TrabalhoController extends Controller $users = User::whereIn('id', $participantesUsersIds)->get(); $arquivos = Arquivo::where('trabalhoId', $id)->get(); //dd(Participante::all()); + $rascunho = Trabalho::where('proponente_id', $proponente->id)->where('evento_id',$edital->id)->where('status', 'Rascunho') + ->orderByDesc('updated_at')->first(); + return view('projeto.editar')->with(['projeto' => $projeto, 'grandeAreas' => $grandeAreas, 'areas' => $areas, @@ -378,6 +383,7 @@ class TrabalhoController extends Controller 'participantes' => $participantes, 'arquivos' => $arquivos, 'enum_turno' => Participante::ENUM_TURNO, + 'estados' => $this->estados, ]); } @@ -786,6 +792,13 @@ class TrabalhoController extends Controller } return abort(404); } + public function baixarAnexoGrupoPesquisa($id) { + $projeto = Trabalho::find($id); + if (Storage::disk()->exists($projeto->anexoProjeto)) { + return Storage::download($projeto->anexoProjeto); + } + return abort(404); + } public function baixarAnexoConsu($id) { $projeto = Trabalho::find($id); @@ -920,10 +933,10 @@ class TrabalhoController extends Controller $participantes = $projeto->participantes; $participantesPermanecem = collect(); - + // dd($request->all()); foreach ($request->participante_id as $key => $id) { // Novo participante - if ($id == 0) { + if ($id == 0 || $id == null) { $userParticipante = User::where('email', $request->emailParticipante[$key])->first(); $participante = new Participante(); @@ -1196,6 +1209,7 @@ class TrabalhoController extends Controller $projeto->update(); // Salvando participantes + // dd($request->all()); $this->salvarParticipantes($request, $edital, $projeto, true); return redirect(route('proponente.projetos'))->with(['mensagem' => 'Projeto atualizado com sucesso!']); diff --git a/app/Trabalho.php b/app/Trabalho.php index e217251..5194919 100644 --- a/app/Trabalho.php +++ b/app/Trabalho.php @@ -55,6 +55,12 @@ class Trabalho extends Model public function area(){ return $this->belongsTo('App\Area'); } + public function grandeArea(){ + return $this->belongsTo('App\GrandeArea'); + } + public function subArea(){ + return $this->belongsTo('App\SubArea'); + } public function autor(){ return $this->belongsTo('App\User', 'autorId'); @@ -79,6 +85,7 @@ class Trabalho extends Model return $this->hasMany('App\PlanoTrabalho'); } public function participantes(){ + // return $this->belongsToMany('App\Trabalho', 'trabalho_participante'); return $this->hasMany('App\Participante', 'trabalho_id'); } public function proponente(){ diff --git a/resources/views/componentes/participante.blade.php b/resources/views/componentes/participante.blade.php index 69686ac..f742f90 100644 --- a/resources/views/componentes/participante.blade.php +++ b/resources/views/componentes/participante.blade.php @@ -14,6 +14,7 @@
+
Dados do discente
@component('componentes.input', ['label' => 'Nome completo']) diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 1c64c68..8531916 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -15,7 +15,7 @@ - + {{-- --}} diff --git a/resources/views/projeto/Backupeditar.blade.php b/resources/views/projeto/Backupeditar.blade.php new file mode 100644 index 0000000..96a127f --- /dev/null +++ b/resources/views/projeto/Backupeditar.blade.php @@ -0,0 +1,2169 @@ +@extends('layouts.app') + +@section('content') +
+
+ @csrf + + +
+
+ + + {{--

1º Passo

+
Preencha os campos com as informações do projeto
--}} +
+
+ +
+
+
+
Informações do projeto
+

+ +
+ + + @error('nomeProjeto') + + {{ $message }} + + @enderror +
+ +
+ + + @error('grandeArea') + + {{ $message }} + + @enderror +
+
+ + + + @error('area') + + {{ $message }} + + @enderror +
+
+ + + + + @error('subArea') + + {{ $message }} + + @enderror +
+ +
+
+
+
+
+ + + {{--

2º Passo

+
Preencha os campos com as informações do proponente
--}} +
+
+
+
+
+
Informações do proponente
+

+ +
+ + + +
+ +
+ + user()->proponentes != null && Auth()->user()->proponentes->linkLattes != null) + value="{{ Auth()->user()->proponentes->linkLattes }}" + @else + value="" + @endif required> + Ex.: http://lattes.cnpq.br/8363536830656923 + @error('linkLattesEstudante') + + {{ $message }} + + @enderror +
+
+ + + + @error('pontuacaoPlanilha') + + {{ $message }} + + @enderror +
+
+ + + + Ex.: http://dgp.cnpq.br/dgp/espelhogrupo/228363 + @error('linkGrupo') + + {{ $message }} + + @enderror +
+ +
+
+
+
+
+ + + {{--

3º Passo

+
Anexos
--}} +
+
+
+
+
+
Anexos
Para alterar os arquivos envie os novos
+

+ +
+ Arquivo atual + @if(old('anexoProjetoPreenchido') != null || (isset($rascunho) && $rascunho->anexoProjeto != "")) + Arquivo atual + @endif + anexoProjeto != "") value="sim" @else value="{{old('anexoProjetoPreenchido')}}" @endif > +
+ +
+ + +
+
+ @error('anexoProjeto') + + {{ $message }} + + @enderror +
+ +
+ Arquivo atual + @if(old('anexoLattesPreenchido') != null || (isset($rascunho) && $rascunho->anexoLattesCoordenador != "")) + Arquivo atual + @endif + anexoLattesCoordenador != "") value="sim" @else value="{{old('anexoLattesPreenchido')}}" @endif > + +
+ +
+ + +
+
+ Dos últimos 5 anos + @error('anexoLattesCoordenador') + + {{ $message }} + + @enderror +
+
+ Arquivo atual + @if(old('anexoPlanilhaPreenchido') != null || (isset($rascunho) && $rascunho->anexoPlanilhaPontuacao != "")) + Arquivo atual + @endif + anexoPlanilhaPontuacao != "") value="sim" @else value="{{old('anexoPlanilhaPreenchido')}}" @endif > +
+ +
+ + +
+
+ @error('anexoPlanilha') + + {{ $message }} + + @enderror + @error('anexoPlanilhaPontuacao') + + {{ $message }} + + @enderror +
+
+ Arquivo atual + @if(old('anexoConsuPreenchido') != null || (isset($rascunho) && $rascunho->anexoDecisaoCONSU != "" && $rascunho->anexoDecisaoCONSU != null)) + Arquivo atual + @endif + anexoDecisaoCONSU != "") value="sim" @else value="{{old('anexoConsuPreenchido')}}" @endif required> +
+ +
+ + +
+
+ @error('anexoCONSU') + + {{ $message }} + + @enderror +
+
+ Arquivo atual
+ + + +
+ + + + + +
+ +
+
+
+
+
+ + @php + $resultado_participante_um = array_key_exists(0, $participantes->toArray()); + $resultado_participante_dois = array_key_exists(1, $participantes->toArray()); + $resultado_participante_tres = array_key_exists(2, $participantes->toArray()); + @endphp + + + {{--

4º Passo

+
Área do(s) participante(s)
--}} +
+
+
+
+
Discente(s)
+
+
+

+
+ +
+
Selecione o número de participantes do projeto
+
+ + + +
+
+ +
+ +
+ +
+ +
+
+
+ + + {{--

5º Passo

+
Finalizar
--}} +
+
+
+
+
+
Finalizar
+

+
+
+
* Campos obrigatórios
+ + + +
+
+
+
+
+ +
+
+
+ + + + + +
+ + +
+@endsection + +@section('javascript') + + + +@endsection diff --git a/resources/views/projeto/editar.blade.php b/resources/views/projeto/editar.blade.php index 96a127f..7bf080c 100644 --- a/resources/views/projeto/editar.blade.php +++ b/resources/views/projeto/editar.blade.php @@ -1,1198 +1,50 @@ @extends('layouts.app') @section('content') +
-
+ {{-- action="{{route('trabalho.store')}}" --}} + @csrf -
-
- - - {{--

1º Passo

-
Preencha os campos com as informações do projeto
--}} -
-
- -
-
-
-
Informações do projeto
-

- -
- - - @error('nomeProjeto') - - {{ $message }} - - @enderror -
- -
- - - @error('grandeArea') - - {{ $message }} - - @enderror -
-
- - - - @error('area') - - {{ $message }} - - @enderror -
-
- - - - - @error('subArea') - - {{ $message }} - - @enderror -
- -
-
-
-
-
- - - {{--

2º Passo

-
Preencha os campos com as informações do proponente
--}} -
-
-
-
-
-
Informações do proponente
-

- -
- - - -
- -
- - user()->proponentes != null && Auth()->user()->proponentes->linkLattes != null) - value="{{ Auth()->user()->proponentes->linkLattes }}" - @else - value="" - @endif required> - Ex.: http://lattes.cnpq.br/8363536830656923 - @error('linkLattesEstudante') - - {{ $message }} - - @enderror -
-
- - - - @error('pontuacaoPlanilha') - - {{ $message }} - - @enderror -
-
- - - - Ex.: http://dgp.cnpq.br/dgp/espelhogrupo/228363 - @error('linkGrupo') - - {{ $message }} - - @enderror -
- -
-
-
+
+ @if (session('mensagem')) + -
- - - {{--

3º Passo

-
Anexos
--}} -
-
-
-
-
-
Anexos
Para alterar os arquivos envie os novos
-

- -
- Arquivo atual - @if(old('anexoProjetoPreenchido') != null || (isset($rascunho) && $rascunho->anexoProjeto != "")) - Arquivo atual - @endif - anexoProjeto != "") value="sim" @else value="{{old('anexoProjetoPreenchido')}}" @endif > -
- -
- - -
-
- @error('anexoProjeto') - - {{ $message }} - - @enderror -
- -
- Arquivo atual - @if(old('anexoLattesPreenchido') != null || (isset($rascunho) && $rascunho->anexoLattesCoordenador != "")) - Arquivo atual - @endif - anexoLattesCoordenador != "") value="sim" @else value="{{old('anexoLattesPreenchido')}}" @endif > - -
- -
- - -
-
- Dos últimos 5 anos - @error('anexoLattesCoordenador') - - {{ $message }} - - @enderror -
-
- Arquivo atual - @if(old('anexoPlanilhaPreenchido') != null || (isset($rascunho) && $rascunho->anexoPlanilhaPontuacao != "")) - Arquivo atual - @endif - anexoPlanilhaPontuacao != "") value="sim" @else value="{{old('anexoPlanilhaPreenchido')}}" @endif > -
- -
- - -
-
- @error('anexoPlanilha') - - {{ $message }} - - @enderror - @error('anexoPlanilhaPontuacao') - - {{ $message }} - - @enderror -
-
- Arquivo atual - @if(old('anexoConsuPreenchido') != null || (isset($rascunho) && $rascunho->anexoDecisaoCONSU != "" && $rascunho->anexoDecisaoCONSU != null)) - Arquivo atual - @endif - anexoDecisaoCONSU != "") value="sim" @else value="{{old('anexoConsuPreenchido')}}" @endif required> -
- -
- - -
-
- @error('anexoCONSU') - - {{ $message }} - - @enderror -
-
- Arquivo atual
- - - -
- - - + @endif +
- -
- -
-
-
-
-
- - @php - $resultado_participante_um = array_key_exists(0, $participantes->toArray()); - $resultado_participante_dois = array_key_exists(1, $participantes->toArray()); - $resultado_participante_tres = array_key_exists(2, $participantes->toArray()); - @endphp - - - {{--

4º Passo

-
Área do(s) participante(s)
--}} -
-
-
-
-
Discente(s)
-
-
-

-
- -
-
Selecione o número de participantes do projeto
-
- - - -
-
- -
- -
- -
- -
-
-
- - - {{--

5º Passo

-
Finalizar
--}} -
-
-
-
-
-
Finalizar
-

-
-
-
* Campos obrigatórios
- - - -
-
-
-
-
-
- - @@ -1181,10 +1184,7 @@
--}} -
-
- Baixar PDF - +
{{-- --}} diff --git a/routes/web.php b/routes/web.php index 0fbad16..f9303ef 100644 --- a/routes/web.php +++ b/routes/web.php @@ -144,11 +144,12 @@ Route::group(['middleware' => ['isTemp', 'auth', 'verified']], function(){ Route::get('/baixar/anexo-projeto/{id}', 'TrabalhoController@baixarAnexoProjeto' )->name('baixar.anexo.projeto'); Route::get('/baixar/anexo-consu/{id}', 'TrabalhoController@baixarAnexoConsu' )->name('baixar.anexo.consu'); Route::get('/baixar/anexo-comite/{id}', 'TrabalhoController@baixarAnexoComite' )->name('baixar.anexo.comite'); - Route::get('/baixar/anexo-justificativa/{id}', 'TrabalhoController@baixarAnexoJustificativa' )->name('baixar.anexo.justificativa'); + Route::get('/baixar/anexo-justificativa/{id}', 'TrabalhoController@baixarAnexoJustificativa')->name('baixar.anexo.justificativa'); Route::get('/baixar/anexo-lattes/{id}', 'TrabalhoController@baixarAnexoLattes' )->name('baixar.anexo.lattes'); Route::get('/baixar/anexo-planilha/{id}','TrabalhoController@baixarAnexoPlanilha' )->name('baixar.anexo.planilha'); Route::get('/baixar/plano-de-trabalho/{id}', 'ArquivoController@baixarPlano' )->name('baixar.plano'); - Route::get('/baixar/anexo-temp/{eventoId}/{nomeAnexo}', 'TrabalhoController@baixarAnexoTemp' )->name('baixar.anexo.temp'); + Route::get('/baixar/anexoGrupoPesquisa/{id}', 'ArquivoController@baixarAnexoGrupoPesquisa' )->name('baixar.anexoGrupoPesquisa'); + Route::get('/baixar/anexo-temp/{eventoId}/{nomeAnexo}', 'TrabalhoController@baixarAnexoTemp')->name('baixar.anexo.temp'); Route::get('/baixar/evento-temp/{nomeAnexo}', 'TrabalhoController@baixarEventoTemp' )->name('baixar.evento.temp'); }); -- GitLab