Commit 218cc851 authored by alinetenorio's avatar alinetenorio
Browse files

salvando anexos

parent 19cb5cc3
...@@ -106,12 +106,12 @@ class TrabalhoController extends Controller ...@@ -106,12 +106,12 @@ class TrabalhoController extends Controller
'nomePlanoTrabalho.*' => ['required', 'string'], 'nomePlanoTrabalho.*' => ['required', 'string'],
//--Verificando se anexos já foram submetidos //--Verificando se anexos já foram submetidos
'anexoProjeto' => [($request->anexoProjetoPreenchido!=='sim'?'required':''), 'file', 'mimes:pdf', 'max:2000000'], 'anexoProjeto' => [($request->anexoProjetoPreenchido!=='sim'?'required':''), 'file', 'mimes:pdf', 'max:2000000'],
'anexoCONSU' => ['required', 'file', 'mimes:pdf', 'max:2000000'], 'anexoCONSU' => [($request->anexoConsuPreenchido!=='sim'?'required':''), 'file', 'mimes:pdf', 'max:2000000'],
'botao' => ['required'], 'botao' => ['required'],
'anexoComiteEtica' => ['required_without:justificativaAutorizacaoEtica', 'file', 'mimes:pdf', 'max:2000000'], 'anexoComiteEtica' => [($request->anexoComitePreenchido!=='sim'&&$request->anexoJustificativaPreenchido!=='sim'?'required_without:justificativaAutorizacaoEtica':''), 'file', 'mimes:pdf', 'max:2000000'],
'justificativaAutorizacaoEtica' => ['required_without:anexoComiteEtica', 'file', 'mimes:pdf', 'max:2000000'], 'justificativaAutorizacaoEtica' => [($request->anexoJustificativaPreenchido!=='sim'&&$request->anexoComitePreenchido!=='sim'?'required_without:anexoComiteEtica':''), 'file', 'mimes:pdf', 'max:2000000'],
'anexoLattesCoordenador' => ['required', 'file', 'mimes:pdf', 'max:2000000'], 'anexoLattesCoordenador' => [($request->anexoLattesPreenchido!=='sim'?'required':''), 'file', 'mimes:pdf', 'max:2000000'],
'anexoPlanilha' => ['required', 'file', 'mimes:pdf', 'max:2000000'], 'anexoPlanilha' => [($request->anexoPlanilhaPreenchido!=='sim'?'required':''), 'file', 'mimes:pdf', 'max:2000000'],
'anexoPlanoTrabalho.*' => ['required', 'file', 'mimes:pdf', 'max:2000000'], 'anexoPlanoTrabalho.*' => ['required', 'file', 'mimes:pdf', 'max:2000000'],
]); ]);
//dd($request->all()); //dd($request->all());
...@@ -131,12 +131,12 @@ class TrabalhoController extends Controller ...@@ -131,12 +131,12 @@ class TrabalhoController extends Controller
'status' => 'Submetido' , 'status' => 'Submetido' ,
'proponente_id' => $proponente->id, 'proponente_id' => $proponente->id,
//Anexos //Anexos
'anexoCONSU' => $request->anexoCONSU, 'anexoCONSU' => $request->anexoCONSU != null ? $request->anexoCONSU : "",
'anexoProjeto' => $request->anexoProjeto != null ? $request->anexoProjeto : "", 'anexoProjeto' => $request->anexoProjeto != null ? $request->anexoProjeto : "",
'anexoAutorizacaoComiteEtica' => $request->anexoComiteEtica, 'anexoAutorizacaoComiteEtica' => $request->anexoComiteEtica != null ? $request->anexoComiteEtica : "",
'justificativaAutorizacaoEtica' => $request->justificativaAutorizacaoEtica, 'justificativaAutorizacaoEtica' => $request->justificativaAutorizacaoEtica != null ? $request->justificativaAutorizacaoEtica : "",
'anexoLattesCoordenador' => $request->anexoLattesCoordenador, 'anexoLattesCoordenador' => $request->anexoLattesCoordenador != null ? $request->anexoLattesCoordenador : "",
'anexoPlanilhaPontuacao' => $request->anexoPlanilha, 'anexoPlanilhaPontuacao' => $request->anexoPlanilha != null ? $request->anexoPlanilha : "",
]); ]);
//dd($trabalho); //dd($trabalho);
} else { } else {
...@@ -242,33 +242,38 @@ class TrabalhoController extends Controller ...@@ -242,33 +242,38 @@ class TrabalhoController extends Controller
} }
} }
//-- Salvando anexos no storage ---//
$pasta = 'trabalhos/' . $request->editalId . '/' . $trabalho->id; $pasta = 'trabalhos/' . $request->editalId . '/' . $trabalho->id;
if( $evento->tipo == 'PIBIC' || $evento->tipo == 'PIBIC-EM') { //-- Se existem anexos temporários, utilizá-los
$trabalho->anexoDecisaoCONSU = Storage::putFileAs($pasta, $request->anexoCONSU, "CONSU.pdf"); $anexosTemp = AnexosTemp::where('eventoId', $request->editalId)->where('proponenteId', Auth::user()->id)
} ->orderByDesc('updated_at')->first();
if (!(is_null($request->anexoComiteEtica))) { if($anexosTemp != null){
$trabalho->anexoAutorizacaoComiteEtica = Storage::putFileAs($pasta, $request->anexoComiteEtica, "Comite_de_etica.pdf"); $this->armazenarAnexosFinais($anexosTemp, $request, $pasta, $trabalho, $evento);
} else {
$trabalho->justificativaAutorizacaoEtica = Storage::putFileAs($pasta, $request->justificativaAutorizacaoEtica, "Justificativa.pdf");
}
if(!isset($request->anexoProjeto) && $request->anexoProjetoPreenchido == 'sim'){
$anexosTemp = AnexosTemp::where('eventoId', $request->editalId)->where('proponenteId', Auth::user()->id)
->orderByDesc('updated_at')->first();
Storage::move($anexosTemp->anexoProjeto, $pasta . '/Projeto.pdf');
$trabalho->anexoProjeto = $pasta . '/Projeto.pdf';
}else{ }else{
$trabalho->anexoProjeto = Storage::putFileAs($pasta, $request->anexoProjeto, "Projeto.pdf");
if( $evento->tipo == 'PIBIC' || $evento->tipo == 'PIBIC-EM') {
$trabalho->anexoDecisaoCONSU = Storage::putFileAs($pasta, $request->anexoCONSU, "CONSU.pdf");
}
if (!(is_null($request->anexoComiteEtica))) {
$trabalho->anexoAutorizacaoComiteEtica = Storage::putFileAs($pasta, $request->anexoComiteEtica, "Comite_de_etica.pdf");
} else {
$trabalho->justificativaAutorizacaoEtica = Storage::putFileAs($pasta, $request->justificativaAutorizacaoEtica, "Justificativa.pdf");
}
$trabalho->anexoProjeto = Storage::putFileAs($pasta, $request->anexoProjeto, "Projeto.pdf");
$trabalho->anexoLattesCoordenador = Storage::putFileAs($pasta, $request->anexoLattesCoordenador, "Latter_Coordenador.pdf");
$trabalho->anexoPlanilhaPontuacao = Storage::putFileAs($pasta, $request->anexoPlanilha, "Planilha.pdf");
} }
$trabalho->anexoLattesCoordenador = Storage::putFileAs($pasta, $request->anexoLattesCoordenador, "Latter_Coordenador.pdf");
$trabalho->anexoPlanilhaPontuacao = Storage::putFileAs($pasta, $request->anexoPlanilha, "Planilha.pdf");
$trabalho->update(); $trabalho->update();
//Deletando arquivos temporários //Deletando arquivos temporários
Storage::deleteDirectory('anexosTemp/' . $request->editalId . '/' . Auth::user()->id); Storage::deleteDirectory('anexosTemp/' . $request->editalId . '/' . Auth::user()->id);
$anexosTemp->delete();
//dd($trabalho); //dd($trabalho);
$subject = "Submissão de Trabalho"; $subject = "Submissão de Trabalho";
...@@ -285,13 +290,15 @@ class TrabalhoController extends Controller ...@@ -285,13 +290,15 @@ class TrabalhoController extends Controller
//---Anexos do Projeto //---Anexos do Projeto
$anexosTemp = AnexosTemp::where('eventoId', $request->editalId)->where('proponenteId', $proponenteId) $anexosTemp = AnexosTemp::where('eventoId', $request->editalId)->where('proponenteId', $proponenteId)
->orderByDesc('updated_at')->first(); ->orderByDesc('updated_at')->first();
//dd($anexosTemp);
if($anexosTemp == null){ if($anexosTemp == null){
$anexosTemp = new AnexosTemp(); $anexosTemp = new AnexosTemp();
$jaExiste = false; $jaExiste = false;
}else{ }else{
$jaExiste = true; $jaExiste = true;
} }
//dd($jaExiste);
$pasta = 'anexosTemp/' . $request->editalId . '/' . $proponenteId; $pasta = 'anexosTemp/' . $request->editalId . '/' . $proponenteId;
...@@ -327,6 +334,45 @@ class TrabalhoController extends Controller ...@@ -327,6 +334,45 @@ class TrabalhoController extends Controller
} }
public function armazenarAnexosFinais($anexosTemp, $request, $pasta, $trabalho, $evento){
//dd($anexosTemp);
// Anexo Projeto
if(!isset($request->anexoProjeto) && $request->anexoProjetoPreenchido == 'sim'){
Storage::move($anexosTemp->anexoProjeto, $pasta . '/Projeto.pdf');
$trabalho->anexoProjeto = $pasta . '/Projeto.pdf';
}
//Anexo Decisão CONSU
if( $evento->tipo == 'PIBIC' || $evento->tipo == 'PIBIC-EM') {
if(!isset($request->anexoCONSU) && $request->anexoConsuPreenchido == 'sim'){
Storage::move($anexosTemp->anexoDecisaoCONSU, $pasta . '/CONSU.pdf');
$trabalho->anexoDecisaoCONSU = $pasta . '/CONSU.pdf';
}
}
//Autorização ou Justificativa
if(!isset($request->anexoComiteEtica) && $request->anexoComitePreenchido == 'sim'){
Storage::move($anexosTemp->anexoAutorizacaoComiteEtica, $pasta . '/Comite_de_etica.pdf');
$trabalho->anexoAutorizacaoComiteEtica = $pasta . '/Comite_de_etica.pdf';
} elseif(!isset($request->justificativaAutorizacaoEtica) && $request->anexoJustificativaPreenchido == 'sim'){
Storage::move($anexosTemp->justificativaAutorizacaoEtica, $pasta . '/Justificativa.pdf');
$trabalho->justificativaAutorizacaoEtica = $pasta . '/Justificativa.pdf';
}
//Anexo Lattes
if(!isset($request->anexoLattesCoordenador) && $request->anexoLattesPreenchido == 'sim'){
Storage::move($anexosTemp->anexoLattesCoordenador, $pasta . '/Latter_Coordenador.pdf');
$trabalho->anexoLattesCoordenador = $pasta . '/Latter_Coordenador.pdf';
}
//Anexo Planilha
if(!isset($request->anexoPlanilha) && $request->anexoPlanilhaPreenchido == 'sim'){
Storage::move($anexosTemp->anexoPlanilhaPontuacao, $pasta . '/Planilha.pdf');
$trabalho->anexoPlanilhaPontuacao = $pasta . '/Planilha.pdf';
}
}
/** /**
* Display the specified resource. * Display the specified resource.
* *
......
...@@ -153,12 +153,17 @@ ...@@ -153,12 +153,17 @@
<div class="col-sm-6"> <div class="col-sm-6">
<label for="anexoLattesCoordenador" class="col-form-label">{{ __('Anexo do Lattes do Coordenador*:') }}</label> <label for="anexoLattesCoordenador" class="col-form-label">{{ __('Anexo do Lattes do Coordenador*:') }}</label>
@if(old('anexoLattesPreenchido') != null)
<a id="anexoLattesTemp" href="{{ route('baixar.anexo.temp', ['eventoId' => $edital->id,
'nomeAnexo' => 'anexoLattesCoordenador' ])}}">Arquivo atual</a>
@endif
<input type="hidden" id="anexoLattesPreenchido" name="anexoLattesPreenchido" value="{{ old('anexoLattesPreenchido') }}" >
<div class="input-group"> <div class="input-group">
<div class="custom-file"> <div class="custom-file">
<input type="file" class="custom-file-input @error('anexoLattesCoordenador') is-invalid @enderror" id="inputGroupFile01" aria-describedby="anexoLattesCoordenador" name="anexoLattesCoordenador"> <input type="file" class="custom-file-input @error('anexoLattesCoordenador') is-invalid @enderror" id="anexoLattesCoordenador" aria-describedby="anexoLattesCoordenador" name="anexoLattesCoordenador" onchange="exibirAnexoTemp(this)">
<label class="custom-file-label" id="custom-file-label" for="inputGroupFile01">O arquivo deve ser no formato PDF de até 2mb.</label> <label class="custom-file-label" id="custom-file-label" for="anexoLattesCoordenador">O arquivo deve ser no formato PDF de até 2mb.</label>
</div> </div>
</div> </div>
@error('anexoLattesCoordenador') @error('anexoLattesCoordenador')
...@@ -179,12 +184,17 @@ ...@@ -179,12 +184,17 @@
<strong>{{ $message }}</strong> <strong>{{ $message }}</strong>
</span> </span>
@enderror @enderror
<br/>
@if(old('anexoComitePreenchido') != null)
<a id="anexoComiteTemp" href="{{ route('baixar.anexo.temp', ['eventoId' => $edital->id,
'nomeAnexo' => 'anexoAutorizacaoComiteEtica' ])}}">Arquivo atual</a>
@endif
<input type="hidden" id="anexoComitePreenchido" name="anexoComitePreenchido" value="{{ old('anexoComitePreenchido') }}" >
<div class="input-group"> <div class="input-group">
<div class="custom-file"> <div class="custom-file">
<input disabled type="file" class="custom-file-input @error('anexoComiteEtica') is-invalid @enderror" id="inputEtica" aria-describedby="inputGroupFileAddon01" name="anexoComiteEtica"> <input disabled type="file" class="custom-file-input @error('anexoComiteEtica') is-invalid @enderror" id="inputEtica" aria-describedby="inputGroupFileAddon01" name="anexoComiteEtica" onchange="exibirAnexoTemp(this)">
<label class="custom-file-label" id="custom-file-label" for="inputGroupFile01">O arquivo deve ser no formato PDF de até 2mb.</label> <label class="custom-file-label" id="custom-file-label" for="inputEtica">O arquivo deve ser no formato PDF de até 2mb.</label>
</div> </div>
</div> </div>
@error('anexoComiteEtica') @error('anexoComiteEtica')
...@@ -196,11 +206,15 @@ ...@@ -196,11 +206,15 @@
<div class="col-sm-6 mt-3"> <div class="col-sm-6 mt-3">
<label for="anexoPlanilha" class="col-form-label">{{ __('Anexo do Planilha de Pontuação*:') }}</label> <label for="anexoPlanilha" class="col-form-label">{{ __('Anexo do Planilha de Pontuação*:') }}</label>
@if(old('anexoPlanilhaPreenchido') != null)
<a id="anexoPlanilhaTemp" href="{{ route('baixar.anexo.temp', ['eventoId' => $edital->id,
'nomeAnexo' => 'anexoPlanilhaPontuacao' ])}}">Arquivo atual</a>
@endif
<input type="hidden" id="anexoPlanilhaPreenchido" name="anexoPlanilhaPreenchido" value="{{ old('anexoPlanilhaPreenchido') }}" >
<div class="input-group"> <div class="input-group">
<div class="custom-file"> <div class="custom-file">
<input type="file" class="custom-file-input @error('anexoPlanilha') is-invalid @enderror" id="anexoPlanilha" aria-describedby="anexoPlanilhaDescribe" name="anexoPlanilha"> <input type="file" class="custom-file-input @error('anexoPlanilha') is-invalid @enderror" id="anexoPlanilha" aria-describedby="anexoPlanilhaDescribe" name="anexoPlanilha" onchange="exibirAnexoTemp(this)">
<label class="custom-file-label" id="custom-file-label" for="anexoPlanilha">O arquivo deve ser no formato PDF de até 2mb.</label> <label class="custom-file-label" id="custom-file-label" for="anexoPlanilha">O arquivo deve ser no formato PDF de até 2mb.</label>
</div> </div>
</div> </div>
...@@ -213,13 +227,17 @@ ...@@ -213,13 +227,17 @@
<div class="col-sm-6"> <div class="col-sm-6">
<label for="nomeTrabalho" class="col-form-label">{{ __('Justificativa*:') }}</label> <label for="nomeTrabalho" class="col-form-label">{{ __('Justificativa*:') }}</label>
@if(old('anexoJustificativaPreenchido') != null)
<a id="anexoJustificativaTemp" href="{{ route('baixar.anexo.temp', ['eventoId' => $edital->id,
'nomeAnexo' => 'justificativaAutorizacaoEtica' ])}}">Arquivo atual</a>
@endif
<input type="hidden" id="anexoJustificativaPreenchido" name="anexoJustificativaPreenchido" value="{{ old('anexoJustificativaPreenchido') }}" >
<div class="input-group"> <div class="input-group">
<div class="custom-file"> <div class="custom-file">
<input type="file" class="custom-file-input @error('justificativaAutorizacaoEtica') is-invalid @enderror" id="inputJustificativa" aria-describedby="inputGroupFileAddon01" disabled name="justificativaAutorizacaoEtica"> <input type="file" class="custom-file-input @error('justificativaAutorizacaoEtica') is-invalid @enderror" id="inputJustificativa" aria-describedby="inputGroupFileAddon01" disabled name="justificativaAutorizacaoEtica" onchange="exibirAnexoTemp(this)">
<label class="custom-file-label" id="custom-file-label" for="inputGroupFile01">O arquivo deve ser no formato PDF de até 2mb.</label> <label class="custom-file-label" id="custom-file-label" for="inputJustificativa">O arquivo deve ser no formato PDF de até 2mb.</label>
</div> </div>
</div> </div>
@error('justificativaAutorizacaoEtica') @error('justificativaAutorizacaoEtica')
...@@ -233,12 +251,17 @@ ...@@ -233,12 +251,17 @@
{{-- Decisão do CONSU --}} {{-- Decisão do CONSU --}}
<div class="col-sm-6"> <div class="col-sm-6">
<label for="anexoCONSU" class="col-form-label">{{ __('Decisão do CONSU*:') }}</label> <label for="anexoCONSU" class="col-form-label">{{ __('Decisão do CONSU*:') }}</label>
@if(old('anexoConsuPreenchido') != null)
<a id="anexoConsuTemp" href="{{ route('baixar.anexo.temp', ['eventoId' => $edital->id,
'nomeAnexo' => 'anexoDecisaoCONSU' ])}}">Arquivo atual</a>
@endif
<input type="hidden" id="anexoConsuPreenchido" name="anexoConsuPreenchido" value="{{ old('anexoConsuPreenchido') }}" >
<div class="input-group"> <div class="input-group">
<div class="custom-file"> <div class="custom-file">
<input type="file" class="custom-file-input @error('anexoCONSU') is-invalid @enderror" id="anexoCONSU" aria-describedby="inputGroupFileAddon01" name="anexoCONSU"> <input type="file" class="custom-file-input @error('anexoCONSU') is-invalid @enderror" id="anexoCONSU" aria-describedby="inputGroupFileAddon01" name="anexoCONSU" onchange="exibirAnexoTemp(this)">
<label class="custom-file-label" id="custom-file-label" for="inputGroupFile01">O arquivo deve ser no formato PDF de até 2mb.</label> <label class="custom-file-label" id="custom-file-label" for="anexoCONSU">O arquivo deve ser no formato PDF de até 2mb.</label>
</div> </div>
</div> </div>
@error('anexoCONSU') @error('anexoCONSU')
...@@ -361,7 +384,7 @@ ...@@ -361,7 +384,7 @@
<a href="{{route('evento.visualizar',['id'=>$edital->id])}}" class="btn btn-secondary" style="width:100%">Cancelar</a> <a href="{{route('evento.visualizar',['id'=>$edital->id])}}" class="btn btn-secondary" style="width:100%">Cancelar</a>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<button type="submit" class="btn btn-primary" style="width:100%" onclick="setParticipanteDiv()"> <button type="submit" class="btn btn-primary" style="width:100%">
{{ __('Enviar') }} {{ __('Enviar') }}
</button> </button>
</div> </div>
...@@ -439,12 +462,14 @@ ...@@ -439,12 +462,14 @@
$('#inputEtica').prop('disabled', false); $('#inputEtica').prop('disabled', false);
$('#inputJustificativa').prop('disabled', true); $('#inputJustificativa').prop('disabled', true);
exibirErro('comite'); exibirErro('comite');
// $('#anexoJustificativaPreenchido').val("");
}); });
$('#buttonNao').on('click', function(e) { $('#buttonNao').on('click', function(e) {
e.preventDefault(); e.preventDefault();
$('#inputEtica').prop('disabled', true); $('#inputEtica').prop('disabled', true);
$('#inputJustificativa').prop('disabled', false); $('#inputJustificativa').prop('disabled', false);
exibirErro('justificativa'); exibirErro('justificativa');
//$('#anexoComitePreenchido').val("");
}); });
}); });
...@@ -454,12 +479,29 @@ ...@@ -454,12 +479,29 @@
var comiteErro = document.getElementById('comiteErro'); var comiteErro = document.getElementById('comiteErro');
var justificativaErro = document.getElementById('justificativaErro'); var justificativaErro = document.getElementById('justificativaErro');
if (campo === 'comite') { if(comiteErro != null || justificativaErro != null){
comiteErro.style.display = "block"; if (campo === 'comite') {
justificativaErro.style.display = "none"; comiteErro.style.display = "block";
} else if (campo === 'justificativa') { justificativaErro.style.display = "none";
comiteErro.style.display = "none"; } else if (campo === 'justificativa') {
justificativaErro.style.display = "block"; comiteErro.style.display = "none";
justificativaErro.style.display = "block";
}
}
}
function habilitarBotao(){
var anexoComitePreenchido = document.getElementById('anexoComitePreenchido');
var anexoJustificativaPreenchido = document.getElementById('anexoJustificativaPreenchido');
if(anexoComitePreenchido.value == "sim"){
$('#inputEtica').prop('disabled', false);
$('#inputJustificativa').prop('disabled', true);
exibirErro('comite');
} else if(anexoJustificativaPreenchido.value == "sim"){
$('#inputEtica').prop('disabled', true);
$('#inputJustificativa').prop('disabled', false);
exibirErro('justificativa');
} }
} }
// Remover Coautor // Remover Coautor
...@@ -637,7 +679,32 @@ ...@@ -637,7 +679,32 @@
var anexoProjetoPreenchido = document.getElementById('anexoProjetoPreenchido'); var anexoProjetoPreenchido = document.getElementById('anexoProjetoPreenchido');
anexoProjetoPreenchido.value = "sim"; anexoProjetoPreenchido.value = "sim";
} }
if(file.id === "anexoLattesCoordenador"){
var anexoLattesPreenchido = document.getElementById('anexoLattesPreenchido');
anexoLattesPreenchido.value = "sim";
}
if(file.id === "inputEtica"){
var anexoComitePreenchido = document.getElementById('anexoComitePreenchido');
var anexoJustificativaPreenchido = document.getElementById('anexoJustificativaPreenchido');
anexoComitePreenchido.value = "sim";
anexoJustificativaPreenchido.value = "";
}
if(file.id === "inputJustificativa"){
var anexoComitePreenchido = document.getElementById('anexoComitePreenchido');
var anexoJustificativaPreenchido = document.getElementById('anexoJustificativaPreenchido');
anexoJustificativaPreenchido.value = "sim";
anexoComitePreenchido.value = "";
}
if(file.id === "anexoCONSU"){
var anexoConsuPreenchido = document.getElementById('anexoConsuPreenchido');
anexoConsuPreenchido.value = "sim";
}
if(file.id === "anexoPlanilha"){
var anexoPlanilhaPreenchido = document.getElementById('anexoPlanilhaPreenchido');
anexoPlanilhaPreenchido.value = "sim";
}
} }
window.onload = areas(); window.onload = areas();
window.onload = habilitarBotao();
</script> </script>
@endsection @endsection
\ No newline at end of file
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