Commit 653d68f8 authored by alinetenorio's avatar alinetenorio
Browse files

habilitando plano de trabalho e corrigindo update

parent e725aacd
......@@ -603,11 +603,14 @@ class TrabalhoController extends Controller
$participante->update();
//atualizando planos de trabalho
if (array_key_exists($key, $request->anexoPlanoTrabalho)) {
if ($request->anexoPlanoTrabalho != null && array_key_exists($key, $request->anexoPlanoTrabalho)) {
if (!(is_null($request->anexoPlanoTrabalho[$key]))) {
$arquivo = Arquivo::where('participanteId', $participante->id)->first();
Storage::delete($arquivo->nome);
$arquivo->delete();
//se plano já existir, deletar
if($arquivo != null){
Storage::delete($arquivo->nome);
$arquivo->delete();
}
$path = 'trabalhos/' . $request->editalId . '/' . $trabalho->id .'/';
$nome = $request->nomePlanoTrabalho[$key] .".pdf";
......
......@@ -318,7 +318,7 @@
</div>
</div>
<h6 class="mb-1">Possui plano de trabalho?</h6>
<button class="btn btn-primary mt-2 mb-2 simPlano">Sim</button>
<button class="btn btn-primary mt-2 mb-2 simPlano" id="simPlano">Sim</button>
<button class="btn btn-primary mt-2 mb-2 naoPlano">Não</button>
<div id="planoHabilitado" >
@foreach ($arquivos as $arquivo)
......@@ -413,20 +413,30 @@
}
});
$('#addPlanoTrabalho').click(function(e) {
e.preventDefault();
if (qtdLinhas < 4) {
linha = montarLinhaInputPlanoTrabalho();
$('#planoTrabalho').append(linha);
qtdLinhas++;
$('.simPlano').click(function(e) {
var possuiPlano = $(this).next().next()[0].firstElementChild;
if(possuiPlano == null){
e.preventDefault();
linha = linhaPlanoTrabalho();
$(this).next().next().append(linha);
}
});
// $('#addPlanoTrabalho').click(function(e) {
// e.preventDefault();
// if (qtdLinhas < 4) {
// linha = montarLinhaInputPlanoTrabalho();
// $('#planoTrabalho').append(linha);
// qtdLinhas++;
// }
// });
// Exibir modalidade de acordo com a área
// $("#area").change(function() {
// console.log($(this).val());
// addModalidade($(this).val());
// });
$(document).on('click', '.delete', function() {
if (qtdParticipantes > 1) {
qtdParticipantes--;
......@@ -461,9 +471,9 @@
});
$(document).on('click', '.simPlano', function(e) {
e.preventDefault();
var plano = $(this).next().next()[0];
plano.style.display = 'block';
$(this).next()[0].className = 'btn btn-primary mt-2 mb-2 naoPlano';
//var plano = $(this).next().next()[0];
//plano.style.display = 'block';
$(this).next()[0].className = 'btn btn-primary mt-2 mb-2 naoPlano';
console.log('button sim');
});
$(document).on('click', '.naoPlano', function(e) {
......@@ -611,6 +621,46 @@
// "</div>";
// }
function linhaPlanoTrabalho(){
return "<h5>Dados do plano de trabalho</h5>" +
"<div class="+"row"+">"+
"<div class="+"col-sm-4"+">"+
"<label>Titulo*</label>"+
"<input"+" type="+'text'+" style="+"margin-bottom:10px"+" class="+"form-control @error('nomePlanoTrabalho') is-invalid @enderror"+" name="+'nomePlanoTrabalho[]'+" placeholder="+"Nome"+">"+
"@error('nomePlanoTrabalho')" +
"<span class='invalid-feedback'" + "role='alert'" + "style='overflow: visible; display:block'>" +
"<strong>{{ $message }}</strong>" +
"</span>" +
"@enderror" +
"</div>"+
"<div class="+"col-sm-7" +">"+
"<label for="+"nomeTrabalho"+">Anexo* </label>"+
"<div class="+"input-group"+">"+
"<div class='input-group-prepend'>"+
"<span class='input-group-text' id='inputGroupFileAddon01'>Selecione um arquivo:</span>"+
"</div>"+
"<div class='custom-file'>"+
"<input type='file' class='custom-file-input @error('anexoPlanoTrabalho') is-invalid @enderror" + "id='inputGroupFile01'"+
"aria-describedby='inputGroupFileAddon01' name='anexoPlanoTrabalho[]'>"+
"<label class='custom-file-label' id='custom-file-label' for='inputGroupFile01'>O arquivo deve ser no formato PDF de até 2mb.</label>"+
"</div>"+
"</div>"+
"@error('anexoPlanoTrabalho')"+
"<span class='invalid-feedback' role='alert' style='overflow: visible; display:block'>"+
"<strong>{{ $message }}</strong>"+
"</span>"+
"@enderror"+
"</div>"+
"<div class="+"col-sm-1"+">"+
"<a class="+"delete"+">"+
"<img src="+"/img/icons/user-times-solid.svg"+" style="+"width:25px;margin-top:35px"+">"+
"</a>"+
"</div>"+
//"</div>"+
"</div>";
}
function areas() {
var grandeArea = $('#grandeArea').val();
$.getJSON("{{ config('app.url') }}/naturezas/areas/" + grandeArea,
......
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