diff --git a/Procfile b/Procfile new file mode 100644 index 0000000000000000000000000000000000000000..48aab522a6524027558ff85da52d78a7b42fadd2 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: vendor/bin/heroku-php-apache2 public/ diff --git a/app/CoordenadorComissao.php b/app/CoordenadorComissao.php index edd4d694aa50e8387bcedafa8135a689d6d6cb9d..80e9e2ddf92cc40380fb3f6e80c0472c202d38c7 100644 --- a/app/CoordenadorComissao.php +++ b/app/CoordenadorComissao.php @@ -15,7 +15,7 @@ class CoordenadorComissao extends Model } public function trabalho(){ - return $this->hasMany('App\Trabalho'); + return $this->hasMany('App\Trabalho', 'coordenador_id'); } } diff --git a/app/Http/Controllers/ArquivoController.php b/app/Http/Controllers/ArquivoController.php index fa9d6b874931b5e716de0ab1251c69877a6303cd..f404cef5ec6a7b8f25c2c55beed2957a4cb4513a 100644 --- a/app/Http/Controllers/ArquivoController.php +++ b/app/Http/Controllers/ArquivoController.php @@ -88,6 +88,7 @@ class ArquivoController extends Controller $arquivo = Arquivo::find($id); if (Storage::disk()->exists($arquivo->nome)) { + ob_end_clean(); return Storage::download($arquivo->nome); } return abort(404); diff --git a/app/Http/Controllers/EventoController.php b/app/Http/Controllers/EventoController.php index 831f062423a2d8c690b345c3c034e38a418d2c5f..d17d826fa9b6a36de6d8ef9475c8a92324646786 100644 --- a/app/Http/Controllers/EventoController.php +++ b/app/Http/Controllers/EventoController.php @@ -166,6 +166,7 @@ class EventoController extends Controller $evento['coordenadorId'] = $request->coordenador_id; $evento['criador_id'] = $user_id; $evento['numParticipantes'] = $request->numParticipantes; + $evento['consu'] = $request->has('consu'); $evento['anexosStatus'] = 'final'; //dd($evento); @@ -395,7 +396,7 @@ class EventoController extends Controller $evento->resultado_preliminar = $request->resultado_preliminar; $evento->resultado_final = $request->resultado_final; $evento->coordenadorId = $request->coordenador_id; - + $evento->consu = $request->has('consu'); if($request->pdfEdital != null){ $pdfEdital = $request->pdfEdital; $path = 'pdfEdital/' . $evento->id . '/'; @@ -597,6 +598,7 @@ class EventoController extends Controller $evento = Evento::find($id); if (Storage::disk()->exists($evento->pdfEdital)) { + ob_end_clean(); return Storage::download($evento->pdfEdital); } @@ -607,6 +609,7 @@ class EventoController extends Controller $evento = Evento::find($id); if (Storage::disk()->exists($evento->modeloDocumento)) { + ob_end_clean(); return Storage::download($evento->modeloDocumento); } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 019716833fd82b45e7fdfac21de3de53a3c4b1a6..7a6751996316771ba0bc0ece53540fbf8056038b 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -54,6 +54,7 @@ class HomeController extends Controller } public function downloadArquivo(Request $request){ + ob_end_clean(); return Storage::download($request->file); } } diff --git a/app/Http/Controllers/TrabalhoController.php b/app/Http/Controllers/TrabalhoController.php index bcfb7000129132b7706b8ddb0add2f4295ad886b..3354eff6f0388e185b974053ce39d0024a98822a 100644 --- a/app/Http/Controllers/TrabalhoController.php +++ b/app/Http/Controllers/TrabalhoController.php @@ -239,12 +239,14 @@ class TrabalhoController extends Controller Storage::delete($trabalho->anexoAutorizacaoComiteEtica); } $trabalho->anexoAutorizacaoComiteEtica = Storage::putFileAs($pasta, $request->anexoAutorizacaoComiteEtica, 'Comite_de_etica.pdf'); + $trabalho->justificativaAutorizacaoEtica = null; } elseif( isset($request->justificativaAutorizacaoEtica)){ if(Storage::disk()->exists($trabalho->justificativaAutorizacaoEtica)) { Storage::delete($trabalho->justificativaAutorizacaoEtica); } $trabalho->justificativaAutorizacaoEtica = Storage::putFileAs($pasta, $request->justificativaAutorizacaoEtica, 'Justificativa.pdf'); + $trabalho->anexoAutorizacaoComiteEtica = null; } //Anexo Lattes @@ -260,6 +262,7 @@ class TrabalhoController extends Controller if(Storage::disk()->exists($trabalho->anexoPlanilhaPontuacao)) { Storage::delete($trabalho->anexoPlanilhaPontuacao); } + $trabalho->anexoPlanilhaPontuacao = Storage::putFileAs($pasta, $request->anexoPlanilhaPontuacao, "Planilha.". $request->file('anexoPlanilhaPontuacao')->extension()); } @@ -270,7 +273,7 @@ class TrabalhoController extends Controller } $trabalho->anexoGrupoPesquisa = Storage::putFileAs($pasta, $request->anexoGrupoPesquisa, "Grupo_de_pesquisa.". $request->file('anexoGrupoPesquisa')->extension()); } - + $trabalho->save(); return $trabalho; } @@ -289,9 +292,12 @@ class TrabalhoController extends Controller //Autorização ou Justificativa if( isset($request->anexoAutorizacaoComiteEtica)){ $trabalho->anexoAutorizacaoComiteEtica = Storage::putFileAs($pasta, $request->anexoAutorizacaoComiteEtica, 'Comite_de_etica.pdf'); + $trabalho->justificativaAutorizacaoEtica = null; } elseif( isset($request->justificativaAutorizacaoEtica)){ $trabalho->justificativaAutorizacaoEtica = Storage::putFileAs($pasta, $request->justificativaAutorizacaoEtica, 'Justificativa.pdf'); + $trabalho->anexoAutorizacaoComiteEtica = null; + } //Anexo Lattes @@ -314,14 +320,22 @@ class TrabalhoController extends Controller public function show($id) { - // - $projeto = Trabalho::find($id); + + $projeto = Auth::user()->proponentes->trabalhos()->where('id', $id)->first(); + if(Auth::user()->tipo == 'administrador'){ + $projeto = Trabalho::find($id); + } + if(!$projeto){ + // $projeto = Auth::user()->coordenadorComissao->trabalho()->where('id', $id)->first(); + + return back()->withErrors(['Proposta não encontrada!']); + } $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(); + $participantes = $projeto->participantes; $participantesUsersIds = Participante::where('trabalho_id', $id)->select('user_id')->get(); $users = User::whereIn('id', $participantesUsersIds)->get(); $arquivos = Arquivo::where('trabalhoId', $id)->get(); @@ -342,7 +356,10 @@ class TrabalhoController extends Controller public function exportProjeto($id) { - $projeto = Trabalho::find($id); + $projeto = Auth::user()->proponentes->trabalhos()->where('id', $id)->first(); + if(!$projeto){ + return back()->withErrors(['Proposta não encontrada!']); + } $edital = Evento::find($projeto->evento_id); $grandeAreas = GrandeArea::all(); $areas = Area::all(); @@ -364,7 +381,10 @@ class TrabalhoController extends Controller public function edit($id) { $proponente = Proponente::where('user_id', Auth::user()->id)->first(); - $projeto = Trabalho::find($id); + $projeto = Auth::user()->proponentes->trabalhos()->where('id', $id)->first(); + if(!$projeto){ + return back()->withErrors(['Proposta não encontrada!']); + } $edital = Evento::find($projeto->evento_id); $grandeAreas = GrandeArea::all(); $areas = Area::all(); @@ -392,234 +412,6 @@ class TrabalhoController extends Controller ]); } - - - // $mytime = Carbon::now('America/Recife'); - // $mytime = $mytime->toDateString(); - // $evento = Evento::find($request->editalId); - // $coordenador = CoordenadorComissao::find($evento->coordenadorId); - // //Relaciona o projeto criado com o proponente que criou o projeto - // $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'); - // } - // } - - // //O anexo de Decisão do CONSU dependo do tipo de edital - // if( $evento->tipo == 'PIBIC' || $evento->tipo == 'PIBIC-EM'){ - - // $validatedData = $request->validate([ - // 'editalId' => ['required', 'string'], - // 'nomeProjeto' => ['required', 'string'], - // 'grandeArea' => ['required', 'string'], - // 'area' => ['required', 'string'], - // 'subArea' => ['required', 'string'], - // 'pontuacaoPlanilha' => ['required', 'string'], - // 'linkGrupo' => ['required', 'string'], - // 'linkLattesEstudante' => ['required', 'string'], - // 'nomeParticipante.*' => ['required', 'string'], - // 'emailParticipante.*' => ['required', 'string'], - // 'funcaoParticipante.*' => ['required', 'string'], - // ]); - - // }else{ - // //Caso em que o anexo da Decisão do CONSU não necessário - // $validatedData = $request->validate([ - // 'editalId' => ['required', 'string'], - // 'nomeProjeto' => ['required', 'string',], - // 'grandeArea' => ['required', 'string'], - // 'area' => ['required', 'string'], - // 'subArea' => ['required', 'string'], - // 'pontuacaoPlanilha' => ['required', 'string'], - // 'linkGrupo' => ['required', 'string'], - // 'linkLattesEstudante' => ['required', 'string'], - // 'nomeCoordenador' => ['required', 'string'], - // 'nomeParticipante.*' => ['required', 'string'], - // 'emailParticipante.*' => ['required', 'string'], - // 'funcaoParticipante.*' => ['required', 'string'], - // ]); - // } - - // $trabalho = Trabalho::find($id); - // $trabalho->titulo = $request->nomeProjeto; - // $trabalho->coordenador_id = $coordenador->id; - // $trabalho->grande_area_id = $request->grandeArea; - // $trabalho->area_id = $request->area; - // $trabalho->sub_area_id = $request->subArea; - // $trabalho->pontuacaoPlanilha = $request->pontuacaoPlanilha; - // $trabalho->linkGrupoPesquisa = $request->linkGrupo; - // $trabalho->linkLattesEstudante = $request->linkLattesEstudante; - // $trabalho->data = $mytime; - // $trabalho->evento_id = $request->editalId; - // $trabalho->proponente_id = $proponente->id; - - // $pasta = 'trabalhos/' . $request->editalId . '/' . $trabalho->id; - - // if (!(is_null($request->anexoDecisaoCONSU))) { - // Storage::delete($trabalho->anexoDecisaoCONSU); - // $trabalho->anexoDecisaoCONSU = Storage::putFileAs($pasta, $request->anexoDecisaoCONSU, "CONSU.pdf"); - // } - - // if (!(is_null($request->anexoProjeto))) { - // Storage::delete($trabalho->anexoProjeto); - // $trabalho->anexoProjeto = Storage::putFileAs($pasta, $request->anexoProjeto, "Projeto.pdf"); - // } - - // if (!(is_null($request->anexoComiteEtica))) { - // Storage::delete($trabalho->anexoComiteEtica); - // $trabalho->anexoAutorizacaoComiteEtica = Storage::putFileAs($pasta, $request->anexoComiteEtica, "Comite_de_etica.pdf"); - // } - - // if (!(is_null($request->anexoLattesCoordenador))) { - // Storage::delete($trabalho->anexoLattesCoordenador); - // $trabalho->anexoLattesCoordenador = Storage::putFileAs($pasta, $request->anexoLattesCoordenador, "Latter_Coordenador.pdf"); - // } - - // if (!(is_null($request->anexoPlanilhaPontuacao))) { - // Storage::delete($trabalho->anexoLattesCoordenador); - // $trabalho->anexoPlanilhaPontuacao = Storage::putFileAs($pasta, $request->anexoPlanilhaPontuacao, "Planilha.pdf"); - // } - // //atualizando projeto - // $trabalho->update(); - - // // criando novos participantes que podem ter sido adicionados - // $participantesUsersIds = Participante::where('trabalho_id', '=', $trabalho->id)->select('user_id')->get(); - // $users = User::whereIn('id', $participantesUsersIds)->get(); - // $emailParticipantes = []; - // foreach ($users as $user) { - // array_push($emailParticipantes, $user->email); - // } - // foreach ($request->emailParticipante as $key => $value) { - // // criando novos participantes que podem ter sido adicionados - // if (!(in_array($request->emailParticipante[$key], $emailParticipantes, false))) { - // $userParticipante = User::where('email', $value)->first(); - // if($userParticipante == null){ - // $passwordTemporario = Str::random(8); - // $subject = "Participante de Projeto"; - // Mail::to($value)->send(new EmailParaUsuarioNaoCadastrado(Auth()->user()->name, ' ', 'Participante', $evento->nome, $passwordTemporario, $subject)); - // $usuario = User::create([ - // 'email' => $value, - // 'password' => bcrypt($passwordTemporario), - // 'usuarioTemp' => true, - // 'name' => $request->nomeParticipante[$key], - // 'tipo' => 'participante', - // ]); - - // $participante = new Participante(); - // $participante->user_id = $usuario->id; - // $participante->trabalho_id = $trabalho->id; - // $participante->funcao_participante_id = $request->funcaoParticipante[$key]; - // $participante->save(); - - // }else{ - // $participante = new Participante(); - // $participante->user_id = $userParticipante->id; - // $participante->trabalho_id = $trabalho->id; - // $participante->funcao_participante_id = $request->funcaoParticipante[$key]; - // $participante->save(); - - // $participante->trabalhos()->save($trabalho); - - // $subject = "Participante de Projeto"; - // $email = $value; - // Mail::to($email) - // ->send(new SubmissaoTrabalho($userParticipante, $subject, $evento, $trabalho)); - // } - - // $path = 'trabalhos/' . $request->editalId . '/' . $trabalho->id .'/'; - // $nome = $request->nomePlanoTrabalho[$key] .".pdf"; - // $file = $request->anexoPlanoTrabalho[$key]; - // Storage::putFileAs($path, $file, $nome); - - // $arquivo = new Arquivo(); - // $arquivo->titulo = $request->nomePlanoTrabalho[$key]; - // $arquivo->nome = $path . $nome; - // $arquivo->trabalhoId = $trabalho->id; - // $arquivo->data = $mytime; - // $arquivo->participanteId = $participante->id; - // $arquivo->versaoFinal = true; - // $arquivo->save(); - // } - - // //atualizando os participantes que já estão no projeto e planos de trabalho se enviados - // if (in_array($request->emailParticipante[$key], $emailParticipantes, false)) { - // $userParticipante = User::where('email', $value)->first(); - // if($userParticipante != null){ - - // $user = User::where('email', $request->emailParticipante[$key])->first(); - // $participante = Participante::where([['user_id', '=', $user->id], ['trabalho_id', '=', $trabalho->id]])->first(); - - // $user->name = $request->nomeParticipante[$key]; - // $user->update(); - - // $participante->funcao_participante_id = $request->funcaoParticipante[$key]; - // $participante->update(); - - // //atualizando planos de trabalho - // if ($request->anexoPlanoTrabalho != null && array_key_exists($key, $request->anexoPlanoTrabalho)) { - // if (!(is_null($request->anexoPlanoTrabalho[$key]))) { - // $arquivo = Arquivo::where('participanteId', $participante->id)->first(); - // //se plano já existir, deletar - // if($arquivo != null){ - // Storage::delete($arquivo->nome); - // $arquivo->delete(); - // } - - // //atualizar plano - // if($request->semPlano[$key] == null){ - // $path = 'trabalhos/' . $request->editalId . '/' . $trabalho->id .'/'; - // $nome = $request->nomePlanoTrabalho[$key] .".pdf"; - // $file = $request->anexoPlanoTrabalho[$key]; - // Storage::putFileAs($path, $file, $nome); - - // $arquivo = new Arquivo(); - // $arquivo->titulo = $request->nomePlanoTrabalho[$key]; - // $arquivo->nome = $path . $nome; - // $arquivo->trabalhoId = $trabalho->id; - // $arquivo->data = $mytime; - // $arquivo->participanteId = $participante->id; - // $arquivo->versaoFinal = true; - // $arquivo->save(); - // } - // } - // } - // //removendo planos de trabalho - // if($request->nomePlanoTrabalho != null && array_key_exists($key, $request->nomePlanoTrabalho)){ - // if($request->semPlano[$key] == 'sim'){ - // $arquivo = Arquivo::where('participanteId', $participante->id)->first(); - // //se plano já existir, deletar - // if($arquivo != null){ - // Storage::delete($arquivo->nome); - // $arquivo->delete(); - // } - // } - // } - // } - // } - // } - - // // Atualizando possiveis usuários removidos - // $participantesUsersIds = Participante::where('trabalho_id', '=', $trabalho->id)->select('user_id')->get(); - // $users = User::whereIn('id', $participantesUsersIds)->get(); - - // foreach ($users as $user) { - // if (!(in_array($user->email, $request->emailParticipante, false))) { - // $participante = Participante::where([['user_id', '=', $user->id], ['trabalho_id', '=', $trabalho->id]])->first(); - // $arquivo = Arquivo::where('participanteId', $participante->id)->first(); - // if($arquivo != null){ - // Storage::delete($arquivo->nome); - // $arquivo->delete(); - // } - // $participante->delete(); - // } - // } - - - public function destroy(Request $request) { $projeto = Trabalho::find($request->id); @@ -793,6 +585,7 @@ class TrabalhoController extends Controller $projeto = Trabalho::find($id); //dd($projeto); if (Storage::disk()->exists($projeto->anexoProjeto)) { + ob_end_clean(); return Storage::download($projeto->anexoProjeto); } return abort(404); @@ -800,6 +593,7 @@ class TrabalhoController extends Controller public function baixarAnexoGrupoPesquisa($id) { $projeto = Trabalho::find($id); if (Storage::disk()->exists($projeto->anexoGrupoPesquisa)) { + ob_end_clean(); return Storage::download($projeto->anexoGrupoPesquisa); } return abort(404); @@ -809,6 +603,7 @@ class TrabalhoController extends Controller $projeto = Trabalho::find($id); if (Storage::disk()->exists($projeto->anexoDecisaoCONSU)) { + ob_end_clean(); return Storage::download($projeto->anexoDecisaoCONSU); } return abort(404); @@ -818,6 +613,7 @@ class TrabalhoController extends Controller $projeto = Trabalho::find($id); if (Storage::disk()->exists($projeto->anexoAutorizacaoComiteEtica)) { + ob_end_clean(); return Storage::download($projeto->anexoAutorizacaoComiteEtica); } return abort(404); @@ -827,6 +623,7 @@ class TrabalhoController extends Controller $projeto = Trabalho::find($id); if (Storage::disk()->exists($projeto->anexoLattesCoordenador)) { + ob_end_clean(); return Storage::download($projeto->anexoLattesCoordenador); } return abort(404); @@ -836,7 +633,32 @@ class TrabalhoController extends Controller $projeto = Trabalho::find($id); if (Storage::disk()->exists($projeto->anexoPlanilhaPontuacao)) { - return Storage::download($projeto->anexoPlanilhaPontuacao); + ob_end_clean(); + $file = $projeto->anexoPlanilhaPontuacao; + $ext = explode(".", $file); + + switch ($ext[1]) { + case 'xlsx': + $hearder = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; + break; + case 'xls': + $hearder = 'application/vnd.ms-excel'; + break; + case 'ods': + $hearder = 'application/vnd.oasis.opendocument.spreadsheet'; + break; + + default: + $hearder = 'application/vnd.ms-excel'; + break; + } + + $headers = array( + "Content-type: {$hearder}", + ); + + + return Storage::download($projeto->anexoPlanilhaPontuacao, "Planilha.{$ext[1]}",$headers); } return abort(404); } @@ -845,6 +667,7 @@ class TrabalhoController extends Controller $projeto = Trabalho::find($id); if (Storage::disk()->exists($projeto->justificativaAutorizacaoEtica)) { + ob_end_clean(); return Storage::download($projeto->justificativaAutorizacaoEtica); } @@ -858,6 +681,7 @@ class TrabalhoController extends Controller ->orderByDesc('updated_at')->first(); if (Storage::disk()->exists($trabalho->$nomeAnexo)) { + ob_end_clean(); return Storage::download($trabalho->$nomeAnexo); } return abort(404); @@ -868,68 +692,17 @@ class TrabalhoController extends Controller ->orderByDesc('updated_at')->first(); if (Storage::disk()->exists($eventoTemp->$nomeAnexo)) { + ob_end_clean(); return Storage::download($eventoTemp->$nomeAnexo); } return abort(404); } - // try { - // $edital = Evento::find($request->editalId); - // $hoje = now(); - // if (!($edital->inicioSubmissao < $hoje && $edital->fimSubmissao >= $hoje)) { - // return redirect()->route('inicial')->with(['error'=> 0, 'mensagem' => 'As submissões para o edital '. $edital->titulo .' foram encerradas.']); - // } - - - // $projeto = $this->atribuirDados($request, $edital); - // $projeto->save(); - // // Email de submissão - // // $subject = "Submissão de Trabalho"; - // // $proponente = Auth()->user(); - // // Mail::to($proponente->email)->send(new SubmissaoTrabalho($proponente, $subject, $edital, $projeto)); - // $id = $projeto->id; - // Notification::send(Auth::user(), new SubmissaoNotification($id)); - - // // Salvando participantes - // $this->salvarParticipantes($request, $edital, $projeto); - - - // return redirect(route('proponente.projetos'))->with(['mensagem' => 'Projeto submetido com sucesso!']); - // } catch (\Throwable $th) { - // return back()->with(['mensagem' => $th->getMessage()]); - // } - // foreach ($request->marcado as $key => $value) { - // $user = User::firstOrCreate([ - // ['email' => $request->email[$value]], - // [ - // 'name' => $request->name[$value], 'instituicao' => $request->instituicao[$value], - // 'cpf' => $request->cpf[$value], 'celular' => $request->celular[$value], - // ] - // ]); - // $participante = Participante::create([ - // 'rg' => $request->rg[$value], 'data_de_nascimento'=> $request->data_de_nascimento[$value], - // 'curso' => $request->curso[$value], 'turno' => $request->turno[$value], - // 'ordem_prioridade'=> $request->ordem_prioridade[$value],'periodo_atual' => $request->periodo_atual[$value], - // 'total_periodos' => $request->total_periodos[$value],'media_do_curso'=> $request->media_do_curso[$value] - // ]); - // $user->endereco()->create([ - // 'rua' => $request->rua[$value], - // 'numero' => $request->numero[$value], - // 'bairro' => $request->bairro[$value], - // 'cidade' => $request->cidade[$value], - // 'uf' => $request->uf[$value], - // 'cep' => $request->cep[$value], - // 'complemento' => $request->complemento[$value], - // ]); - // $user->participantes()->save($participante); - // $trabalho->participantes()->save($participante); - // } public function update(UpdateTrabalho $request, $id) { - // dd($request->participante_id); - // dd( $request->all() ); + try { if (!$request->has('rascunho') ) { $request->merge([ @@ -944,31 +717,36 @@ class TrabalhoController extends Controller $request->merge([ 'coordenador_id' => $evento->coordenadorComissao->id ]); + $trabalho = Auth::user()->proponentes->trabalhos()->where('id', $id)->first(); DB::beginTransaction(); - - $trabalho = Auth::user()->proponentes->trabalhos()->where('id', $id)->first(); + if(!$trabalho){ + return back()->withErrors(['Proposta não encontrada']); + } + $trabalho->update($request->except([ - 'anexoProjeto', 'anexoDecisaoCONSU','anexoPlanilhaPontuacao', - 'anexoLattesCoordenador','anexoGrupoPesquisa','anexoAutorizacaoComiteEtica', - 'justificativaAutorizacaoEtica' - ])); + 'anexoProjeto', 'anexoDecisaoCONSU','anexoPlanilhaPontuacao', + 'anexoLattesCoordenador','anexoGrupoPesquisa','justificativaAutorizacaoEtica','anexoAutorizacaoComiteEtica' + + ])); + $pasta = 'trabalhos/' . $evento->id . '/' . $trabalho->id; + $trabalho = $this->armazenarAnexosFinais($request, $pasta, $trabalho, $evento); + $trabalho->save(); + if ($request->marcado == null) { $idExcluido = $trabalho->participantes->pluck('id'); }else{ $idExcluido = []; } - // dd($idExcluido); - // dd(array_search( 2, $request->marcado)); + foreach ($request->participante_id as $key => $value) { - // $value = intval($value); if($request->marcado != null && array_search( $key, $request->marcado) === false){ if($value !== null) array_push($idExcluido, $value); } } - // dd($idExcluido); + foreach ($idExcluido as $key => $value) { $trabalho->participantes()->find($value)->delete(); } @@ -1070,9 +848,7 @@ class TrabalhoController extends Controller } - $pasta = 'trabalhos/' . $evento->id . '/' . $trabalho->id; - $trabalho = $this->armazenarAnexosFinais($request, $pasta, $trabalho, $evento); - $trabalho->save(); + DB::commit(); diff --git a/app/Http/Requests/StoreTrabalho.php b/app/Http/Requests/StoreTrabalho.php index 1d0dcd350b4644e74bafd6f118667643947f2e75..093157eb70c6f466d4a3692e84c972dc07285805 100644 --- a/app/Http/Requests/StoreTrabalho.php +++ b/app/Http/Requests/StoreTrabalho.php @@ -2,9 +2,10 @@ namespace App\Http\Requests; -use Illuminate\Foundation\Http\FormRequest; -use Illuminate\Support\Facades\Auth; +use App\Evento; use Illuminate\Validation\Rule; +use Illuminate\Support\Facades\Auth; +use Illuminate\Foundation\Http\FormRequest; class StoreTrabalho extends FormRequest { @@ -25,8 +26,8 @@ class StoreTrabalho extends FormRequest */ public function rules() { - - + + $evento = Evento::find($this->editalId); $rules = [ 'editalId' => ['required', 'string'], 'marcado.*' => ['required'], @@ -37,7 +38,7 @@ class StoreTrabalho extends FormRequest 'pontuacaoPlanilha' => ['required', 'string'], 'linkGrupoPesquisa' => ['required', 'string'], 'anexoProjeto' => ['required', 'mimes:pdf'], - 'anexoDecisaoCONSU' => ['required', 'mimes:pdf'], + 'anexoDecisaoCONSU' => [Rule::requiredIf($evento->consu), 'mimes:pdf'], 'anexoPlanilhaPontuacao' => ['required'], 'anexoLattesCoordenador' => ['required', 'mimes:pdf'], 'anexoGrupoPesquisa' => ['required', 'mimes:pdf'], @@ -62,7 +63,6 @@ class StoreTrabalho extends FormRequest $rules['cidade.'.$value] = ['required', 'string']; $rules['uf.'.$value] = ['required', 'string']; $rules['cep.'.$value] = ['required', 'string']; - $rules['complemento.'.$value] = ['required', 'string']; //participante $rules['rg.'.$value] = ['required', 'string']; $rules['data_de_nascimento.'.$value] = ['required', 'string']; diff --git a/app/Http/Requests/UpdateTrabalho.php b/app/Http/Requests/UpdateTrabalho.php index b9f5ed54014d74a2e706f71db8881b04b2e78f11..0ba147f73b313b32b5d9fa1a5bd0602062c2f13a 100644 --- a/app/Http/Requests/UpdateTrabalho.php +++ b/app/Http/Requests/UpdateTrabalho.php @@ -2,10 +2,11 @@ namespace App\Http\Requests; +use App\Evento; use App\Trabalho; -use Illuminate\Foundation\Http\FormRequest; -use Illuminate\Support\Facades\Auth; use Illuminate\Validation\Rule; +use Illuminate\Support\Facades\Auth; +use Illuminate\Foundation\Http\FormRequest; class UpdateTrabalho extends FormRequest { @@ -27,7 +28,7 @@ class UpdateTrabalho extends FormRequest public function rules() { $projeto = Trabalho::find($this->id); - + $evento = Evento::find($this->editalId); $rules = [ 'editalId' => ['required', 'string'], 'marcado.*' => ['required'], @@ -38,15 +39,15 @@ class UpdateTrabalho extends FormRequest 'pontuacaoPlanilha' => ['required', 'string'], 'linkGrupoPesquisa' => ['required', 'string'], 'anexoProjeto' => [[Rule::requiredIf(!$this->has('rascunho') && $projeto->anexoProjeto == null)], 'mimes:pdf'], - 'anexoDecisaoCONSU' => ['mimes:pdf'], + 'anexoDecisaoCONSU' => [Rule::requiredIf($evento->consu && $projeto->anexoDecisaoCONSU == null), 'mimes:pdf'], 'anexoPlanilhaPontuacao' => [[Rule::requiredIf(!$this->has('rascunho') && $projeto->anexoPlanilhaPontuacao == null)]], 'anexoLattesCoordenador' => [[Rule::requiredIf(!$this->has('rascunho') && $projeto->anexoLattesCoordenador == null)], 'mimes:pdf'], 'anexoGrupoPesquisa' => [[Rule::requiredIf(!$this->has('rascunho') && $projeto->anexoGrupoPesquisa == null)], 'mimes:pdf'], 'anexoAutorizacaoComiteEtica' => [ - Rule::requiredIf((!$this->has('rascunho') && $projeto->anexoAutorizacaoComiteEtica == null) ) + Rule::requiredIf((!$this->has('rascunho') && $projeto->justificativaAutorizacaoEtica == null && $projeto->anexoAutorizacaoComiteEtica == null) ) ], 'justificativaAutorizacaoEtica' => [ - Rule::requiredIf((!$this->has('rascunho') && $projeto->anexoAutorizacaoComiteEtica == null)) + Rule::requiredIf((!$this->has('rascunho') && $projeto->anexoAutorizacaoComiteEtica == null && $projeto->justificativaAutorizacaoEtica == null)) ], ]; @@ -66,7 +67,6 @@ class UpdateTrabalho extends FormRequest $rules['cidade.'.$value] = ['required', 'string']; $rules['uf.'.$value] = ['required', 'string']; $rules['cep.'.$value] = ['required', 'string']; - $rules['complemento.'.$value] = ['required', 'string']; //participante $rules['rg.'.$value] = ['required', 'string']; $rules['data_de_nascimento.'.$value] = ['required', 'string']; @@ -91,4 +91,14 @@ class UpdateTrabalho extends FormRequest return $rules; } } + public function messages() + { + + return [ + 'titulo.required' => 'O :attribute é obrigatório', + 'justificativaAutorizacaoEtica.required' => 'O campo justificativa Autorizacao Etica é obrigatório', + 'anexoAutorizacaoComiteEtica.required' => 'O campo anexoAutorizacao Comite Etica é obrigatório', + + ]; + } } diff --git a/composer.lock b/composer.lock index 38d64678681e60de867ff12c6cc9654eb2028431..6dd1c53ba7ca273053839653b3eb68bdf0e66bdb 100644 --- a/composer.lock +++ b/composer.lock @@ -1643,16 +1643,16 @@ }, { "name": "monolog/monolog", - "version": "2.2.0", + "version": "2.3.0", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "1cb1cde8e8dd0f70cc0fe51354a59acad9302084" + "reference": "df991fd88693ab703aa403413d83e15f688dae33" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/1cb1cde8e8dd0f70cc0fe51354a59acad9302084", - "reference": "1cb1cde8e8dd0f70cc0fe51354a59acad9302084", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/df991fd88693ab703aa403413d83e15f688dae33", + "reference": "df991fd88693ab703aa403413d83e15f688dae33", "shasum": "" }, "require": { @@ -1671,7 +1671,7 @@ "php-amqplib/php-amqplib": "~2.4", "php-console/php-console": "^3.1.3", "phpspec/prophecy": "^1.6.1", - "phpstan/phpstan": "^0.12.59", + "phpstan/phpstan": "^0.12.91", "phpunit/phpunit": "^8.5", "predis/predis": "^1.1", "rollbar/rollbar": "^1.3", @@ -1723,7 +1723,7 @@ ], "support": { "issues": "https://github.com/Seldaek/monolog/issues", - "source": "https://github.com/Seldaek/monolog/tree/2.2.0" + "source": "https://github.com/Seldaek/monolog/tree/2.3.0" }, "funding": [ { @@ -1735,7 +1735,7 @@ "type": "tidelift" } ], - "time": "2020-12-14T13:15:25+00:00" + "time": "2021-07-05T11:34:13+00:00" }, { "name": "nesbot/carbon", @@ -1832,16 +1832,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.10.5", + "version": "v4.11.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "4432ba399e47c66624bc73c8c0f811e5c109576f" + "reference": "fe14cf3672a149364fb66dfe11bf6549af899f94" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4432ba399e47c66624bc73c8c0f811e5c109576f", - "reference": "4432ba399e47c66624bc73c8c0f811e5c109576f", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/fe14cf3672a149364fb66dfe11bf6549af899f94", + "reference": "fe14cf3672a149364fb66dfe11bf6549af899f94", "shasum": "" }, "require": { @@ -1882,9 +1882,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.10.5" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.11.0" }, - "time": "2021-05-03T19:11:20+00:00" + "time": "2021-07-03T13:36:55+00:00" }, { "name": "opis/closure", @@ -7321,5 +7321,5 @@ "php": "^7.2" }, "platform-dev": [], - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.0.0" } diff --git a/config/database.php b/config/database.php index b42d9b30a5463e6f1c739724d5debdc487f94748..e0bb0f1c05afb970d7a1c3a6bc7b268647437941 100644 --- a/config/database.php +++ b/config/database.php @@ -1,7 +1,7 @@ env('DB_CONNECTION', 'mysql'), + 'default' => env('DB_CONNECTION', 'pgsql'), /* |-------------------------------------------------------------------------- @@ -78,6 +78,20 @@ return [ 'sslmode' => 'prefer', ], + // 'pgsql' => array( + // 'driver' => 'pgsql', + // 'host' => $DATABASE_URL['host'], + // 'port' => $DATABASE_URL['port'], + // 'database' => ltrim($DATABASE_URL['path'], "/"), + // 'username' => $DATABASE_URL['user'], + // 'password' => $DATABASE_URL['pass'], + // 'charset' => 'utf8', + // 'prefix' => '', + // 'prefix_indexes' => true, + // 'schema' => 'public', + // 'sslmode' => 'prefer', + // ), + 'sqlsrv' => [ 'driver' => 'sqlsrv', 'url' => env('DATABASE_URL'), diff --git a/database/migrations/2021_07_01_123506_alter_table_eventos.php b/database/migrations/2021_07_01_123506_alter_table_eventos.php new file mode 100644 index 0000000000000000000000000000000000000000..214610e618f44113d330998c7917cece88aaca09 --- /dev/null +++ b/database/migrations/2021_07_01_123506_alter_table_eventos.php @@ -0,0 +1,32 @@ +boolean('consu')->default(false); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('eventos', function (Blueprint $table) { + $table->dropColumn('consu'); + }); + } +} diff --git a/resources/views/evento/criarEvento.blade.php b/resources/views/evento/criarEvento.blade.php index b0b7fd230581a5513b88fa3673fc29a58c841d2f..efe4636065b4eea1843a4c9c151f65fe5e07a17a 100644 --- a/resources/views/evento/criarEvento.blade.php +++ b/resources/views/evento/criarEvento.blade.php @@ -15,7 +15,7 @@ {{-- nome | Participantes | Tipo--}}
-
+
@@ -26,7 +26,7 @@ @enderror
-
+
@error('numParticipantes') @@ -65,6 +66,18 @@ @enderror
+
+ +
+ + {{-- --}} + + @error('consu') + + {{ $message }} + + @enderror +
{{-- end nome | Participantes | Tipo--}} {{-- Descricao Edital --}} diff --git a/resources/views/evento/editarEvento.blade.php b/resources/views/evento/editarEvento.blade.php index 416375c9b99aaba26a810c7984c190ebc456cb15..4845da008ef745109bb29bccc4b23922d7802f82 100644 --- a/resources/views/evento/editarEvento.blade.php +++ b/resources/views/evento/editarEvento.blade.php @@ -15,7 +15,7 @@
{{-- nome | Tipo--}}
-
{{--Nome do evento--}} +
{{--Nome do evento--}} @@ -27,7 +27,7 @@
{{--End Nome do evento--}} {{-- Tipo do evento --}} -
+
consu) checked @endif name="consu" id="consu"> + {{-- --}} + + @error('consu') + + {{ $message }} + + @enderror +
{{-- end nome | Participantes | Tipo--}} {{-- Descricao Evento --}} diff --git a/resources/views/evento/formulario/anexos.blade.php b/resources/views/evento/formulario/anexos.blade.php index ec31528eed7b6de05fdaee73eb07401602775187..fb896dcfc1c506ddc59ecdc96e16e8850e4da2d0 100644 --- a/resources/views/evento/formulario/anexos.blade.php +++ b/resources/views/evento/formulario/anexos.blade.php @@ -41,15 +41,28 @@ @enderror @endcomponent
-
- - - @error('anexoDecisaoCONSU') - - {{ $message }} - - @enderror -
+ @if($edital->consu) +
+ + + @error('anexoDecisaoCONSU') + + {{ $message }} + + @enderror +
+ @else +
+ + + @error('anexoDecisaoCONSU') + + {{ $message }} + + @enderror +
+ + @endif
@component('componentes.input', ['label' => 'Grupo de Pesquisa (.pdf)']) diff --git a/resources/views/evento/formulario/participantes.blade.php b/resources/views/evento/formulario/participantes.blade.php index 1f3d222a5b65e7dd3ded9834a085462cadfdb47d..f80296cd8ed709c63e9a997121632eb046ad1fcf 100644 --- a/resources/views/evento/formulario/participantes.blade.php +++ b/resources/views/evento/formulario/participantes.blade.php @@ -102,7 +102,7 @@
Endereço
@component('componentes.input', ['label' => 'CEP']) - + @error('cep.'.$i) {{ $message }} @@ -167,14 +167,15 @@ @endcomponent
- @component('componentes.input', ['label' => 'Complemento',]) - +
+ + @error('complemento.'.$i) {{ $message }} @enderror - @endcomponent +
Dados do curso
diff --git a/resources/views/evento/formulario/proponente.blade.php b/resources/views/evento/formulario/proponente.blade.php index c4141f7423b1e7da4b976b0c692bb08614fd1925..f85a4976706e2b2dfff5e44fd3e5a0a99c603e7a 100644 --- a/resources/views/evento/formulario/proponente.blade.php +++ b/resources/views/evento/formulario/proponente.blade.php @@ -45,7 +45,7 @@
- @error('pontuacaoPlanilha') diff --git a/resources/views/evento/submeterTrabalho.blade.php b/resources/views/evento/submeterTrabalho.blade.php index 4312b99cdb320b00cc7de66afa1c7cb4e3ce9395..cb316df8b7fe489160d4038798f30e950f318f62 100644 --- a/resources/views/evento/submeterTrabalho.blade.php +++ b/resources/views/evento/submeterTrabalho.blade.php @@ -29,20 +29,20 @@
- @component('evento.formulario.projeto', ['grandeAreas' => $grandeAreas]) - @endcomponent + @include('evento.formulario.projeto') - @component('evento.formulario.proponente') - @endcomponent - @component('evento.formulario.anexos') - @endcomponent + @include('evento.formulario.proponente') - @component('evento.formulario.participantes', ['estados' => $estados, 'enum_turno' => $enum_turno, 'edital'=>$edital]) - @endcomponent - @component('evento.formulario.finalizar') - @endcomponent + @include('evento.formulario.anexos') + + + @include('evento.formulario.participantes') + + + @include('evento.formulario.finalizar') +
diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index 3a44bab9c3d5121e94d6c25382c0532d6dcf0692..f428a6917d1b2413639f2f6db9aee676f568a8c3 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -13,10 +13,22 @@ O Submeta é um sistema de submissão de projetos acadêmicos, que pode ser adotado para os diferentes propósitos de Ensino, Pesquisa e Extensão. O sistema abrange todas as principais etapas relacionadas à submissão de projetos, permitindo o lançamento e configuração de editais, além de gerenciar a distribuição das avaliações e os pareceres técnicos dos avaliadores, como também, visualizar os projetos submetidos pelos proponentes.

+
- {{-- --}} +

diff --git a/resources/views/projeto/editaFormulario/anexos.blade.php b/resources/views/projeto/editaFormulario/anexos.blade.php index 9cb5a32c40df68ea8ffa77f63543b6e9db345a4f..de12c15526ad20205b9e47d5c9df716855369eba 100644 --- a/resources/views/projeto/editaFormulario/anexos.blade.php +++ b/resources/views/projeto/editaFormulario/anexos.blade.php @@ -61,7 +61,7 @@
@component('componentes.input', ['label' => 'Planilha de Pontuação (.xlsx,.xls,.ods)']) - + @error('anexoPlanilhaPontuacao') {{ $message }} @@ -83,33 +83,65 @@
{{-- Anexo da Decisão do CONSU --}} -
-
-
-
- + @if($edital->consu) +
+
+
+
+ + + + @error('anexoDecisaoCONSU') + + {{ $message }} + + @enderror +
- - @error('anexoDecisaoCONSU') - - {{ $message }} - - @enderror
+ @if($projeto->anexoDecisaoCONSU) +
+ +
+ @else +
+

+
+ @endif
- @if($projeto->anexoDecisaoCONSU) -
- -
- @else -
-

+
+ @else +
+
+
+
+ + + + @error('anexoDecisaoCONSU') + + {{ $message }} + + @enderror +
+
- @endif - + @if($projeto->anexoDecisaoCONSU) +
+ +
+ @else +
+

+
+ @endif + +
-
+ + @endif + {{-- Anexo do Grupo de Pesquisa --}}
@@ -140,26 +172,26 @@
- + anexoAutorizacaoComiteEtica) checked @endif name="sim" onchange="displayAutorizacoesEspeciais('sim')"> - + justificativaAutorizacaoEtica) checked @endif name="nao" onchange="displayAutorizacoesEspeciais('nao')">
-
+
anexoAutorizacaoComiteEtica) style="display: block; margin-top:-1rem" @else style="display: none; margin-top:-1rem" @endif > @component('componentes.input', ['label' => 'Sim, declaro que necessito de autorizações especiais (.pdf)'])
- @if($projeto->justificativaAutorizacaoEtica || $projeto->anexoAutorizacaoComiteEtica ) + @if($projeto->anexoAutorizacaoComiteEtica )
@else -
+

@endif @@ -173,17 +205,17 @@ @endcomponent
-