Commit e8ed04d2 authored by alinetenorio's avatar alinetenorio
Browse files

finalizando validação de planilha

parent 46fef0e3
......@@ -31,6 +31,7 @@ use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use App\Mail\SubmissaoTrabalho;
use App\Mail\EventoCriado;
use Illuminate\Support\Facades\Validator;
class TrabalhoController extends Controller
{
......@@ -125,24 +126,14 @@ class TrabalhoController extends Controller
'anexoComiteEtica' => [($request->anexoComitePreenchido!=='sim'&&$request->anexoJustificativaPreenchido!=='sim'?'required_without:justificativaAutorizacaoEtica':''), 'file', 'mimes:pdf', 'max:2000000'],
'justificativaAutorizacaoEtica' => [($request->anexoJustificativaPreenchido!=='sim'&&$request->anexoComitePreenchido!=='sim'?'required_without:anexoComiteEtica':''), 'file', 'mimes:pdf', 'max:2000000'],
'anexoLattesCoordenador' => [($request->anexoLattesPreenchido!=='sim'?'required': ''), 'file', 'mimes:pdf', 'max:2000000'],
'anexoPlanilha' => [($request->anexoPlanilhaPreenchido!=='sim'?'required':''), 'file', 'mimes:pdf,xls', 'max:2000000'],
'anexoPlanilha' => [($request->anexoPlanilhaPreenchido!=='sim'?'required':''), 'file', 'mimes:pdf,xls,xlsx', 'max:2000000'],
'anexoPlanoTrabalho.*' => ['nullable', 'file', 'mimes:pdf', 'max:2000000'],
]);
//dd($request->all());
// $extensions = array("xls","xlsx");
// if(isset($request->anexoPlanilha )){
// $result = array($request->file('anexoPlanilha')->getClientOriginalExtension());
// if(in_array($result[0], $extensions)){
// }else{
// $validatedData = $request->validate([
// 'anexoPlanilha' => [($request->anexoPlanilhaPreenchido!=='sim'?'required':''), 'file', 'mimes:pdf,xls,xlsx', 'max:2000000']
// ]);
// }
// }
if(gettype($this->validarAnexosRascunho($request, $trabalho)) != 'integer'){
return $this->validarAnexosRascunho($request, $trabalho);
}
//$trabalho = Trabalho::create([
$trabalho['titulo'] = $request->nomeProjeto;
$trabalho['coordenador_id'] = $coordenador->id;
......@@ -182,10 +173,13 @@ class TrabalhoController extends Controller
'nomePlanoTrabalho.*' => ['nullable', 'string'],
'anexoProjeto' => [($request->anexoProjetoPreenchido!=='sim'?'required':''), 'file', 'mimes:pdf', 'max:2000000'],
'anexoLattesCoordenador' => [($request->anexoLattesPreenchido!=='sim'?'required':''), 'file', 'mimes:pdf', 'max:2000000'],
'anexoPlanilha' => [($request->anexoPlanilhaPreenchido!=='sim'?'required':''), 'file', 'mimes:pdf,xls', 'max:2000000'],
'anexoPlanilha' => [($request->anexoPlanilhaPreenchido!=='sim'?'required':''), 'file', 'mimes:pdf,xls,xlsx', 'max:2000000'],
'anexoPlanoTrabalho.*' => ['nullable', 'file', 'mimes:pdf', 'max:2000000'],
]);
if(gettype($this->validarAnexosRascunho($request, $trabalho)) != 'integer'){
return $this->validarAnexosRascunho($request, $trabalho);
}
//$trabalho = Trabalho::create([
$trabalho['titulo'] = $request->nomeProjeto;
$trabalho['coordenador_id'] = $coordenador->id;
......@@ -316,8 +310,8 @@ class TrabalhoController extends Controller
//---Dados do Projeto
$trabalho = Trabalho::where('proponente_id', $proponente->id)->where('evento_id',$request->editalId)->where('status', 'Rascunho')
->orderByDesc('updated_at')->first();
// dd($trabalho);
if($trabalho == null){
//dd($trabalho);
if($trabalho == null){
$trabalho = new Trabalho();
$trabalho->proponente_id = $proponente->id;
$trabalho->evento_id = $request->editalId;
......@@ -330,7 +324,7 @@ class TrabalhoController extends Controller
$trabalho->fill(
array_fill_keys($stringKeys, "") + array_fill_keys($intKeys, 1)
)->save();
// dd($trabalho);
//dd($trabalho);
}
if(!(is_null($request->nomeProjeto)) ) {
......@@ -379,11 +373,24 @@ class TrabalhoController extends Controller
//---Anexos planos de trabalho
//dd($trabalho);
return $trabalho;
}
public function validarAnexosRascunho(Request $request, $trabalho){
//dd($trabalho->getAttributes());
$validator = Validator::make($trabalho->getAttributes(),[
'anexoPlanilhaPontuacao' => $request->anexoPlanilha==null?['planilha']:[],
]);
if ($validator->fails()) {
dd('asdf');
return back()->withErrors($validator)->withInput();
}
return 1;
}
public function armazenarAnexosFinais($request, $pasta, $trabalho, $evento){
// Anexo Projeto
......
......@@ -27,5 +27,6 @@ class AppServiceProvider extends ServiceProvider
Validator::extend('cpf', '\App\Utils\CpfValidation@validate');
Validator::extend('link_lattes', '\App\Utils\LattesValidation@validate', 'Link inválido');
Validator::extend('link_grupo', '\App\Utils\GrupoPesquisaValidation@validate', 'Link inválido');
Validator::extend('planilha', '\App\Utils\ExtensaoValidation@validate', 'Extensão do arquivo é inválida');
}
}
<?php namespace App\Utils;
class ExtensaoValidation
{
public function validate($attribute, $value, $parameters, $validator)
{
$extensions = array("xls","xlsx", "pdf");
$result = pathinfo($value)['extension'];
if(!in_array($result, $extensions)){
return false;
}
return true;
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@
<div class="card-body">
<h5 class="card-title">Enviar Projeto</h5>
<p class="card-text">
<form method="POST" action="{{route('trabalho.store')}}" enctype="multipart/form-data">
<form method="POST" name="formTrabalho" action="{{route('trabalho.store')}}" enctype="multipart/form-data">
@csrf
<input type="hidden" name="editalId" value="{{$edital->id}}">
......@@ -114,7 +114,7 @@
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
<strong>{{ $message }}</strong>
</span>
@enderror
@enderror
</div>
<div class="col-sm-6">
<label for="linkGrupo" class="col-form-label">{{ __('Link do grupo de pesquisa*:') }}</label>
......@@ -137,13 +137,13 @@
<div class="row justify-content-center">
{{-- Arquivo --}}
<div class="col-sm-6">
<label for="anexoProjeto" class="col-form-label">{{ __('Anexo Projeto*:') }}</label>
<label for="anexoProjeto" class="col-form-label">{{ __('Anexo Projeto*:') }}</label>
@if(old('anexoProjetoPreenchido') != null || (isset($rascunho) && $rascunho->anexoProjeto != ""))
<a id="anexoProjetoTemp" href="{{ route('baixar.anexo.temp', ['eventoId' => $edital->id,
'nomeAnexo' => 'anexoProjeto' ])}}">Arquivo atual</a>
@endif
<input type="hidden" id="anexoProjetoPreenchido" name="anexoProjetoPreenchido"
@if( isset($rascunho) && $rascunho->anexoProjeto != "") value="sim" @else value="old('anexoProjetoPreenchido')" @endif >
@if( isset($rascunho) && $rascunho->anexoProjeto != "") value="sim" @else value="{{old('anexoProjetoPreenchido')}}" @endif >
<div class="input-group">
<div class="custom-file">
......@@ -165,7 +165,7 @@
'nomeAnexo' => 'anexoLattesCoordenador' ])}}">Arquivo atual</a>
@endif
<input type="hidden" id="anexoLattesPreenchido" name="anexoLattesPreenchido"
@if( isset($rascunho) && $rascunho->anexoLattesCoordenador != "") value="sim" @else value="old('anexoLattesPreenchido')" @endif >
@if( isset($rascunho) && $rascunho->anexoLattesCoordenador != "") value="sim" @else value="{{old('anexoLattesPreenchido')}}" @endif >
<div class="input-group">
......@@ -198,7 +198,7 @@
'nomeAnexo' => 'anexoAutorizacaoComiteEtica' ])}}">Arquivo atual</a>
@endif
<input type="hidden" id="anexoComitePreenchido" name="anexoComitePreenchido"
@if( isset($rascunho) && $rascunho->anexoAutorizacaoComiteEtica != "") value="sim" @else value="old('anexoComitePreenchido')" @endif >
@if( isset($rascunho) && $rascunho->anexoAutorizacaoComiteEtica != "") value="sim" @else value="{{old('anexoComitePreenchido')}}" @endif >
<div class="input-group">
......@@ -221,7 +221,7 @@
'nomeAnexo' => 'anexoPlanilhaPontuacao' ])}}">Arquivo atual</a>
@endif
<input type="hidden" id="anexoPlanilhaPreenchido" name="anexoPlanilhaPreenchido"
@if( isset($rascunho) && $rascunho->anexoPlanilhaPontuacao != "") value="sim" @else value="old('anexoPlanilhaPreenchido')" @endif >
@if( isset($rascunho) && $rascunho->anexoPlanilhaPontuacao != "") value="sim" @else value="{{old('anexoPlanilhaPreenchido')}}" @endif >
<div class="input-group">
<div class="custom-file">
......@@ -234,6 +234,11 @@
<strong>{{ $message }}</strong>
</span>
@enderror
@error('anexoPlanilhaPontuacao')
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
<div class="col-sm-6">
......@@ -243,7 +248,7 @@
'nomeAnexo' => 'justificativaAutorizacaoEtica' ])}}">Arquivo atual</a>
@endif
<input type="hidden" id="anexoJustificativaPreenchido" name="anexoJustificativaPreenchido"
@if( isset($rascunho) && $rascunho->justificativaAutorizacaoEtica != "") value="sim" @else value="old('anexoJustificativaPreenchido')" @endif >
@if( isset($rascunho) && $rascunho->justificativaAutorizacaoEtica != "") value="sim" @else value="{{old('anexoJustificativaPreenchido')}}" @endif >
<div class="input-group">
......@@ -268,7 +273,7 @@
'nomeAnexo' => 'anexoDecisaoCONSU' ])}}">Arquivo atual</a>
@endif
<input type="hidden" id="anexoConsuPreenchido" name="anexoConsuPreenchido"
@if( isset($rascunho) && $rascunho->anexoDecisaoCONSU != "") value="sim" @else value="old('anexoConsuPreenchido')" @endif >
@if( isset($rascunho) && $rascunho->anexoDecisaoCONSU != "") value="sim" @else value="{{old('anexoConsuPreenchido')}}" @endif >
<div class="input-group">
<div class="custom-file">
......@@ -770,6 +775,11 @@
anexoPlanilhaPreenchido.value = "sim";
}
}
function removerPlanilha(){
console.log('a');
$('#anexoPlanilhaPreenchido').val("");
}
window.onload = areas();
window.onload = habilitarBotao();
</script>
......
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