D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
rosario
/
adm
/
app
/
gre
/
Views
/
Trade
/
Filename :
VieTradeAcaoContratoCadastrar.php
back
Copy
<?php if (isset($this->Dados['form'])) { $valorForm = $this->Dados['form']; } if (isset($this->Dados['form'][0])) { $valorForm = $this->Dados['form'][0]; } //var_dump($this->Dados['select']['acao']); //var_dump($this->Dados['select']['distr'][0]['dist_id']); //var_dump($_SESSION['usuario_tipo']); //echo '<br>tipo: '.$_SESSION['usuario_tipo'].'<br>'; // $qtde_fabricantes = count($this->Dados['select']['inds']); //echo ('qtde_fabricantes: '.$qtde_fabricantes); ?> <style> .ff { width: 150px; } .fff { width: 400px; } .ffff { width: 550px; } .mm { width: 100px; } .mmm { width: 50px; } .mmmm { width: 150px; } input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; } table .filial { border-collapse: collapse; max-width: 100%; margin-left: 100% !important; } .inacao { border: 0; } .acoes { border-collapse: collapse; max-width:100%; } table th { position: -webkit-sticky; position: sticky; top: 0; } tbody { display:block; max-height:150px; max-width:100%; overflow-y:auto; } #resto{ line-height: 0.5; } #distr_id { background-color: rgba(255, 255, 128, .5); } #preco_venda_tabela { background-color: #E0F8F1; } #razao_social { background-color: rgba(255, 255, 128, .5); } #contato { background-color: #E0F8F1; } #distr_nome{ background-color: #E0F8F1; } #celular_contratante { background-color: #E0F8F1; } #cnpj { background-color: rgba(255, 255, 128, .5); } </style> <div class="content p-1"> <div class="list-group-item"> <div class="d-flex"> <div class="mr-auto p-2"> <h2 class="display-4 titulo">Incluir Ações de Trade </h2> </div> <?php if ($this->Dados['botao']['vol_contr']) { ?> <div id="voltar" class="p-2"> <a href="<?php echo URLADM . 'con-trade-acao-contrato/listar'?>" class="btn btn-outline-info btn-sm">Voltar</a> </div> <?php } ?> </div> <?php if (isset($_SESSION['msg'])) { echo $_SESSION['msg']; unset($_SESSION['msg']); } ?> <!-- Nav tabs --> <ul id="aba" class="nav nav-tabs" role="tablist"> <li class="nav-item"> <a class="nav-link active" data-toggle="tab" href="#home" role="tab" onclick="javascript:habilitavolta()">Ação</a> </li> <li class="nav-item"> <a class="nav-link" data-toggle="tab" href="#profile" role="tab" onclick="javascript:desabilitavolta()" >Ações Incluídas</a> </li> </ul> <!-- Tab panes --> <form method="POST" action="" enctype="multipart/form-data"> <input type="hidden" name="hoje" id="hoje" class="form-control" value="<?php echo date('Y-m-d'); ?>" > <input type="hidden" name="urladm" id="urladm" class="form-control" value="<?php echo URLADM; ?>" > <input type="hidden" name="base_id" id="base_id" class="form-control" > <input type="hidden" name="base_sigla" id="base_sigla" class="form-control" > <input type="hidden" name="controla_prod" id="controla_prod" class="form-control" > <input type="hidden" name="abrangencia" id="abrangencia" class="form-control" > <input type="hidden" name="filial_controle" id="filial_controle" class="form-control" > <input type="hidden" name="vigencia_num" id="vigencia_num" class="form-control" > <input type="hidden" name="tipo_forn" id="tipo_forn" class="form-control" value="<?php echo $_SESSION['usuario_tipo']?>" > <input type="hidden" name="meses_max" id="meses_max" class="form-control" > <input type="hidden" name="qtde_lojas" id="qtde_lojas" class="form-control" > <input type="hidden" name="contr_id" id="contr_id" class="form-control" > <div class="tab-content"> <div class="tab-pane active" id="home" role="tabpanel"> <div class="form-row"> <div class="form-group col-md-3"> <label><span class="text-danger">*</span>Fabricante:</label> <select name="inds_id" id="inds_id" class="form-control" required onchange='limpaformarepasse()'> <option value=''>Selecione</option> <?php foreach ($this->Dados['select']['inds'] as $inds) { extract($inds); echo "<option value='$inds_id'>$nome_inds</option>"; } ?> </select> </div> <div class="form-group col-md-2"> <label><span class="text-danger">*</span>Forma Repasse:</label> <select name="forma_repasse" id="forma_repasse" class="form-control" onchange="javascript:verRepasse(this.value)" > <option value="">Selecione</option>; <option value="1">Verba</option>; <option value="2">Distribuidor</option>; </select> </div>   <div id="inds_distr" class="form-group col-md-2" > <label><span class="text-danger">*</span>Distrib. Repasse:</label> <select name="distr_repasse" id="distr_repasse" class="form-control" required> </select> </div> <div class="form-group col-md-3"> <label><span class="text-danger">* </span>Inicio do Acordo</label> <input name="data_inicio" type="month" id="data_inicio" class="form-control" required onchange="javascript:checadata()"> </div> </div> <div class="form-row"> <div class="form-group col-md-3"> <label><span class="text-danger">*</span>Tipo</label> <select name="tipo_id" id="tipo_id" class="form-control" onchange="javascript:buscasubtipo(this.value)" required > <option value="">Selecione</option> <?php foreach ($this->Dados['select']['tipo'] as $tipo) { extract($tipo); echo "<option value='$tipo_id'>$tipo_nome</option>"; } ?> </select> </div> <div class="form-group col-md-3"> <label><span class="text-danger">*</span>Sub-Tipo</label> <select name="sub_tipo_id" id="sub_tipo_id" class="form-control" onchange="javascript:buscaacao(this.value)"> </select> </div> <div class="form-group col-md-3"> <label><span class="text-danger">*</span>Ação</label> <!-- <select name="acao_id" id="acao_id" list="qtde_disp" class="form-control" onchange="javascript:trade_disp(this.value)"> --> <select name="acao_id" id="acao_id" class="form-control" onchange="javascript:pega_disp()"> </select> </div> <div class="form-group col-md-3"> <label id="lptab">Preço Tabela:</label> <input name="preco_venda_tabela" type="text" id="preco_venda_tabela" class="form-control" readonly> </div> </div> <div class="form-row"> <div id="tabmesacao" class="table-responsive col-md-2"> <table id="mesesacao" class="mesesacao" cellspacing="1" border="1" > <thead> </thead> <tbody> </tbody> </table> </div>          <div id="tabfil" class="table-responsive col-md-6"> <table id="example-crm" class="filial" cellspacing="1" border="0" > </table> </div> </div> <div id="acao"> <div class="form-row"> <div class="form-group col-md-1"> <label></label> <!-- <input name="CadAcao" id="CadAcao" type="submit" class="btn btn-success" value="Incluir" > --> <input name="CadAcao" id="CadAcao" type='button' class="btn btn-primary" value="Incluir Ação do Acordo" onclick="javascript:inclui_acao(this.value)" > </div> </div> </div> <div class="form-row"> <div class="form-group col-md-2" id="qparcelas"> <label>Parcelas Pagto:</label> <input name="parcelas" type="number" value="1" class="form-control col-sm-8" id="parcelas" min="1" > </div> <div class="form-group col-md-6"> <label>Observações:</label> <input name="observacao" type="text" maxlength="600" id="observacao" class="form-control"> </div> <div class="form-group col-md-2"> <label>Contato Contratante:</label> <input name="contato" type="text" maxlength="30" id="contato" class="form-control" value="<?php echo $this->Dados['select']['usu'][0]['apelido']; ?>" readonly> </div> <div class="form-group col-md-2"> <label>Celular Contratante:</label> <input name="celular_contratante" type="text" id="celular_contratante" class="form-control" value="<?php echo $this->Dados['select']['usu'][0]['celular']; ?>" readonly> </div> </div> <div class="form-row"> <p> <span class="text-danger">*</span>Campo obrigatório </p> </div> <div class="form-row"> <div class="form-group col-md-1"> <input name="Limpar" id="Limpar" type="reset" class="btn btn-success" onclick="javascript:limpar()" value="Limpar"> <!-- <div class="form-group col-md-0.5"> </div> <input name="CadEstResid" id="CadEstResid" type="submit" class="btn btn-warning" value="Salvar"> --> </div> <div class="form-group col-md-2"> <input name="CadContr" id="CadContr" type="submit" class="btn btn-warning" value="Gravar Acordo" > </div> </div> </div> <div class="tab-pane" id="profile" role="tabpanel"> <font size="2"> <div class="table-responsive"> <table id="tabacoes" class="acoes " cellspacing="1" border="1" style="width:100%" > <thead> <tr> <td align='center' colspan="11"><font color="blue"><b>AÇÕES SOLICITADAS</b></td> </tr> <tr> <td align='center' style="width:50px" ><font color="blue"><b>#ID</b></td> <td align='center' style="width:50px" ><font color="blue"><b>Contr</b></td> <td align='center' style="width:250px" ><font color="blue"><b>Sub-Tipo</b></td> <td align='center' style="width:250px" ><font color="blue"><b>Ação</b></td> <td align='center' style="width:100px" ><font color="blue"><b>Unit Tabela</b></td> <td align='center' style="width:50px" ><font color="blue"><b>Meses</b></td> <td align='center' style="width:50px" ><font color="blue"><b>Lojas</b></td> <td align='center' style="width:70px" ><font color="blue"><b>Qt.Ações</b></td> <td align='center' style="width:100px" ><font color="blue"><b>Total</b></td> <td align='center' colspan="2" style="width:60px" ><font color="blue"><b>Opção</b></td> <!-- <td align='center' style="width:700px" ><b>Sub-Tipo</b></td> <td align='center' style="width:250px" ><font color="blue"><b></b></td> --> </tr> </thead> <tbody> </tbody> </table> </div> </font> </div> </div> </form> </div> </div> <span id="conteudo_acao"</span> </div> <div class="modal fade " id="visuAcaoModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog" role="table"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalLabel">Detalhes da Ação</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <span id="visul_Acao"></span> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Fechar</button> </div> </div> </div> </div> <script> document.getElementById("CadContr").disabled =true; document.onload(carrega_pagina()) function limpaformarepasse(){ document.getElementById("forma_repasse").value = ""; document.getElementById("distr_repasse").value == ''; document.getElementById("inds_distr").style.display = 'none'; } function carrega_pagina(){ var tipo_forn = document.getElementById("tipo_forn").value; document.getElementById("inds_distr").style.display = 'none'; if (tipo_forn === 'I') { document.getElementById("distr_marca").style.display = 'none'; }else{ document.getElementById("distr_marca").style.display = 'block'; } document.getElementById("CadAcao").disabled =true; document.getElementById("CadContr").disabled =true; document.getElementById("tabfil").style.display = 'none'; document.getElementById("mesesacao").style.display = 'none'; } function limpar(){ document.getElementById("tabfil").style.display = 'none'; document.getElementById("mesesacao").style.display = 'none'; document.getElementById("CadContr").disabled = true; } function verRepasse(tipo_repasse){ var select = document.getElementById('inds_id'); // alert(select); var option = select.options[select.selectedIndex]; var fabr_id = option.value; // alert(fabr_id); if(tipo_repasse == 1){ $('#distr_repasse').prop('required', false); // alert(tipo_repasse+' Verba' + ' Marca_id '+ marca_id); document.getElementById("inds_distr").style.display = 'none'; }else{ //alert(fabr_id ); var endereco = document.getElementById("urladm").value; $(document).ready(function() { var responsef = ''; $.ajax({ type: "POST", data : { fabr_id: fabr_id }, url: endereco + "vendor/api/ler_distr_trade.php", async: false, success: function(text) { responsef = text; if(responsef !== ""){ document.getElementById("distr_repasse").innerHTML = responsef; document.getElementById("inds_distr").style.display = 'block'; }else{ alert('Nenhum Distribuidor encontrado para esse Fabricante !!'); document.getElementById("distr_repasse").value == ''; document.getElementById("inds_distr").style.display = 'none'; document.getElementById("forma_repasse").value = ""; document.getElementById("forma_repasse").focus(); } //console.log(responsef); } }); }) } } function habilitavolta(){ document.getElementById("voltar").style.display = 'block'; } function desabilitavolta(){ document.getElementById("voltar").style.display = 'none'; } function pega_disp() { busca_preco(document.getElementById("acao_id").value); var abrangencia = document.getElementById("abrangencia").value; var endereco = document.getElementById("urladm").value; var base_sigla = document.getElementById("base_sigla").value; if(abrangencia === 'L') { if (base_sigla != 'U' ) { $(document).ready(function() { var response = ''; // document.getElementById("qtde").value = 1; document.getElementById("tabfil").style.display = 'block'; $.ajax({ type: "POST", data : { tipo_id : document.getElementById("tipo_id").value, sub_tipo_id : document.getElementById("sub_tipo_id").value, acao_id : document.getElementById("acao_id").value }, url: endereco + "vendor/api/pega_trade_filial_disp.php", async: false, success: function(text) { response = text; if(response != ''){ $('#example-crm').prop('border', true); } // alert(response); document.getElementById("example-crm").innerHTML = response; // console.log(response); } }); }); }else{ document.getElementById("tabfil").style.display = 'none'; alert(base_sigla); } } } function busca_preco() { var obj = <?php echo json_encode($this->Dados['select']['acao']); ?>; var tipo = document.getElementById("tipo_id").value; //alert(document.getElementById("plano_id").value); var sub_tipo = document.getElementById("sub_tipo_id").value; var acao = document.getElementById("acao_id").value; for (var i = 0; i < obj.length; i++){ if ( obj[i].tipo_id == tipo && obj[i].sub_tipo_id == sub_tipo && obj[i].acao_id == acao) { document.getElementById("preco_venda_tabela").value = 'R$ ' + obj[i].preco_venda; document.getElementById("base_id").value = obj[i].base_id; document.getElementById("base_sigla").value = obj[i].base_sigla; document.getElementById("lptab").innerHTML = "Preço/"+obj[i].base_nome; document.getElementById("controla_prod").value = obj[i].controla_prod; document.getElementById("filial_controle").value = obj[i].filial_controle; document.getElementById("abrangencia").value = obj[i].abrangencia; // console.log(obj[i].base_nome); } } document.getElementById("CadAcao").disabled = false; document.getElementById("tabfil").style.display = 'none'; } function exibe_mes($mes) { switch ($mes) { case "1": return "Janeiro"; break; case "2": return "Fevereiro"; break; case "3": return "Março"; break; case "4": return "Abril"; break; case "5": return "Maio"; break; case "6": return "Junho"; break; case "7": return "Julho"; break; case "8": return "Agosto"; break; case "9": return "Setembro"; break; case "10": return "Outubro"; break; case "11": return "Novembro"; break; case "12": return "Dezembro"; break; default: return ""; } } function buscasubtipo(tipo) { var obj = <?php echo json_encode($this->Dados['select']['sub_tipo']); ?>; element = document.getElementById("sub_tipo_id"); element.innerHTML = ''; var node = document.createElement("option"); var textnode = document.createTextNode('Selecione'); node.setAttribute("value", ""); node.appendChild(textnode); element.appendChild(node); for (var i = 0; i < obj.length; i++){ if (obj[i].tipo_id === tipo){ var node = document.createElement("option"); var textnode = document.createTextNode(obj[i].sub_tipo_nome); node.setAttribute("value", obj[i].sub_tipo_id); node.appendChild(textnode); element.appendChild(node); } } // meses_acao(document.getElementById("vigencia_num").value); } function buscaacao(subtipo) { var enderecoa = document.getElementById("urladm").value; var contrato_id = document.getElementById("contr_id").value; var tipo_plano = document.getElementById("tipo_id").value; console.log('contrato_id: '+contrato_id); console.log('tipo_plano: '+tipo_plano); console.log('sub_tipo_id: '+subtipo); $(document).ready(function() { var responsef = ''; $.ajax({ type: "POST", data : { contr_id: contrato_id , tipo_id : tipo_plano, sub_tipo_id : subtipo }, url: enderecoa + "vendor/api/ler_acoes.php", async: false, success: function(text) { responsef = text; document.getElementById("acao_id").innerHTML = responsef; // console.log(responsef); } }); }); } function inclui_acao(){ if(document.getElementById("data_inicio").value == '') { alert("Mes do Inicio Obrigatorio!"); document.getElementById("data_inicio").focus(); exit; } if(document.getElementById("tipo_forn").value == 'I') { var tipo_forn = '0'; var marca_id = document.getElementById("distr_repasse").value; var contratante_id = document.getElementById("inds_id").value; }else{ var marca_id = document.getElementById("marca_id").value; var contratante_id = document.getElementById("distr_id").value; var tipo_forn = '1'; }; var wacao = document.getElementById("acao_id").value; var wtipo = document.getElementById("tipo_id").value; var wsubtipo = document.getElementById("sub_tipo_id").value; var wbase = document.getElementById("base_id").value; var wprecotab = document.getElementById("preco_venda_tabela").value; var wsigla = document.getElementById("base_sigla").value; //alert(wsigla); var wcontprod = document.getElementById("controla_prod").value; // alert(wcontprod); var fil_controle = document.getElementById("filial_controle").value; // alert(fil_controle); var data_inicio = document.getElementById("data_inicio").value+'-01'; var endereco = document.getElementById("urladm").value; var meses = document.getElementsByClassName('mesescheck'); var array_meses = meses; // alert(array_meses); //console.log('array_meses: '+array_meses.length); var newArraymeses = []; console.log('array_meses.length: '+array_meses.length); for(var x = 0; x <= array_meses.length; x++){ if(typeof array_meses[x] == 'object'){ if(array_meses[x].checked){ newArraymeses.push(array_meses[x].name); } } } console.log('newArraymeses: '+newArraymeses); // alert(newArraymeses[0]); if(newArraymeses.length == 0){ alert("Selecione um pelo menos UM MES DA AÇÃO!"); exit; } var qtde_mes= newArraymeses.length; // console.log('qtde_mes: '+qtde_mes); var resultado = data_inicio.split('-'); var ndata_inicio = new Date(resultado[0],resultado[1], 1, 0, 0, 0, 0); var month = ndata_inicio.getMonth(); var a = array_meses.length - parseInt(2) ; var n_date = new Date(ndata_inicio.getFullYear(), eval(a+month), 1); var n_date = new Date(n_date.getFullYear(), n_date.getMonth() + 1, 0); var dia = String(n_date.getDate()).padStart(2, '0'); var mes = String(n_date.getMonth() + 1).padStart(2, '0'); var ano = n_date.getFullYear(); var vigencia_num = ano+'-'+mes+'-'+dia; var vigencia_data = dia+'/'+mes+'/'+ano; // alert(vigencia_num+'#'+vigencia_data); if(document.getElementById("abrangencia").value !== 'L') { document.getElementById("qtde_lojas").value = 1; }else{ var ids = document.getElementsByClassName('editar'); var array_dados = ids; var newArray = []; for(var x = 0; x <= array_dados.length; x++){ if(typeof array_dados[x] == 'object'){ if(array_dados[x].checked){ newArray.push(array_dados[x].name); } } } if(newArray.length <= 0){ alert("Selecione pelo menos UMA FILIAL!"); exit; }else{ document.getElementById("qtde_lojas").value = newArray.length; var wqtlojas = document.getElementById("qtde_lojas").value; } } var qtde_acao = 1; $(document).ready(function() { var response = ''; var tab= document.getElementById("tabacoes"); var numLinhas = tab.rows.length; var parte = document.getElementById("data_inicio").value.split("-"); var mesi = parte[1]+'/'+parte[0]; console.log('wtipo: '+wtipo); console.log('wsubtipo: '+wsubtipo); console.log('wacao: '+wacao); console.log('wbase: '+wbase); console.log('wprecotab: '+wprecotab); console.log('data_inicio: '+data_inicio); console.log('vigencia_num: '+vigencia_num); console.log('wsigla: '+wsigla); console.log('wcontprod: '+wcontprod); console.log('wqtlojas: '+wqtlojas); console.log('newArraymeses.lenght: '+newArraymeses.lenght); console.log('tipo_forn: '+tipo_forn); console.log('marca_id: '+marca_id); console.log('contratante_id: '+contratante_id); console.log('mesi: '+mesi); console.log('numLinhas: '+numLinhas); console.log(newArray); $.ajax({ type: "POST", data : { tipo_id : wtipo, sub_tipo_id : wsubtipo, acao_id : wacao, base_id : wbase, preco_venda_tabela: wprecotab, data_inicio : data_inicio, final_vigencia : vigencia_num, base_sigla: wsigla, controla_prod: wcontprod, qtde_lojas: wqtlojas, qtde_meses: qtde_mes, arr_filial: newArray, arr_meses: newArraymeses, mesi: mesi, num_linha: numLinhas, qtde: qtde_acao, filial_controle: fil_controle, tipo_forn: tipo_forn, marca_id: marca_id, contratante_id: contratante_id }, url: endereco + "vendor/api/incluir_trade_acao.php", async: false, success: function(text) { response = text; // } }); adicionaLinha("tabacoes", response); }); document.getElementById("tipo_id").value = ""; document.getElementById("sub_tipo_id").value= ""; document.getElementById("acao_id").value = ""; document.getElementById("base_id").value = ""; document.getElementById("preco_venda_tabela").value = ""; // document.getElementById("preco_venda_negociado").value = ""; document.getElementById("base_sigla").value = ""; document.getElementById("controla_prod").value= ""; document.getElementById("qtde_lojas").value = ""; document.getElementById("CadAcao").disabled =true; // document.getElementById("meses_acao").style.display = 'none'; document.getElementById("tabfil").style.display = 'none'; document.getElementById("tipo_id").focus(); document.getElementById("qtde").value = '1'; document.getElementById("tabacoes").style.display = 'block'; } /*function coletaIDs(dados) { // alert(dados); var array_dados = dados; var newArray = [ ]; var y =0; for(var x =0; x <= array_dados.length; x++) { if(array_dados[x].checked) { newArray.push(array_dados[x].id) } if(newArray.length <= 0) { alert ("Selecione pelo menos um item"); exit; }else{ newArray.length; // alert ("Seu novo array de IDs tem ["+newArray+" ]"); } } //alert('qtde = '+ qtde); } */ function adicionaLinha(idTabela, response) { var tabela = document.getElementById(idTabela); var nomes = response.split("#"); var numeroLinhas = tabela.rows.length; var linha = tabela.insertRow(numeroLinhas); var celula0 = linha.insertCell(0); var celula1 = linha.insertCell(1); var celula2 = linha.insertCell(2); var celula3 = linha.insertCell(3); var celula4 = linha.insertCell(4); var celula5 = linha.insertCell(5); var celula6 = linha.insertCell(6); var celula7 = linha.insertCell(7); var celula8 = linha.insertCell(8); var celula9 = linha.insertCell(9); var celula10 = linha.insertCell(10); //var celula7 = linha.insertCell(6); celula0.innerHTML = nomes[0]; celula1.innerHTML = nomes[1]; celula2.innerHTML = nomes[2]; celula3.innerHTML = nomes[3]; celula4.innerHTML = nomes[4]; celula5.innerHTML = nomes[5]; celula6.innerHTML = nomes[6]; celula7.innerHTML = nomes[7]; celula8.innerHTML = nomes[9]; document.getElementById("contr_id").value = nomes[1]; celula9.innerHTML = "<button class='btn btn-danger' onclick='removeLinha(this)' >Remover</button>"; celula10.innerHTML = "<button class='btn btn-primary' onclick='visualizaAcao(this)' >Detalhes</button>"; //<button type='button' class='btn btn-outline-primary btn-sm view_data' id='".$id."'>Visualizar</button> "; //alert(idTabela); $('#tipo_id').prop('required', false); $('#sub_tipo_id').prop('required', false); $('#acao_id').prop('required', false); document.getElementById("CadContr").disabled =false; } function removeLinha(linha) { var linhas = linha.parentNode.parentNode.children; var id_acao = linhas[0].innerText; var endereco = document.getElementById("urladm").value; var response = ''; $.ajax({ type: "POST", data : { acao_id : id_acao}, url: endereco + "vendor/api/excluir_trade_acao.php", async: false, success: function(text) { response = text; } }); var valores = document.querySelectorAll("tabacoes tr td "); var i=linha.parentNode.parentNode.rowIndex; document.getElementById('tabacoes').deleteRow(i); if(i == 1) { $('#tipo_id').prop('required', false); $('#sub_tipo_id').prop('required',false); $('#acao_id').prop('required', false); } // alert(response); } function checadata() { var inicio = document.getElementById("data_inicio").value; if (inicio==''){ alert('Data Inicio Obrigatoria !!'); document.getElementById("data_inicio").focus(); exit; } var inicio = document.getElementById("data_inicio").value+'-01'; var resultado = inicio.split('-'); var mes_inicio = resultado[1]; var qtde_meses = 13 - mes_inicio; //document.getElementById("meses_max").value = qtde_meses; // document.getElementById("mesesacao").style.display = 'block'; var data_inicio = document.getElementById("data_inicio").value+'-01'; var enderecoa = document.getElementById("urladm").value; var resultado = data_inicio.split('-'); var ndata_inicio = new Date(resultado[0],resultado[1], 1, 0, 0, 0, 0); var month = ndata_inicio.getMonth(); var a = qtde_meses - parseInt(2) ; var n_date = new Date(ndata_inicio.getFullYear(), eval(a+month), 1); var n_date = new Date(n_date.getFullYear(), n_date.getMonth() + 1, 0); var dia = String(n_date.getDate()).padStart(2, '0'); var mes = String(n_date.getMonth() + 1).padStart(2, '0'); var ano = n_date.getFullYear(); var vigencia_num = ano+'-12-31'; var vigencia_data = 31+'/'+12+'/'+ano; var data_fim = vigencia_num; // alert(data_inicio+'-'+data_fim); // // document.getElementById("data_vigencia").value = vigencia_data; $(document).ready(function() { var responsef = ''; $.ajax({ type: "POST", data : { tipo: 'A', qtde : qtde_meses, data_inicio : data_inicio, data_fim : data_fim }, url: enderecoa + "vendor/api/monta_meses_meta.php", async: false, success: function(text) { responsef = text; // console.log(responsef); document.getElementById("mesesacao").innerHTML = responsef; document.getElementById("mesesacao").style.display = 'block'; } }); }); document.getElementById("tipo_id").focus(); } function visualizaAcao(linha){ // É AQUI !!! var linhas = linha.parentNode.parentNode.children; var id = linhas[1].innerText; // alert(id); // console.log(id); // console.log(filial_id); if(id !== ''){ var dados = { id: id }; // console.log(dados); // alert(dados); $.post('../../adm/ver-acao-modal/ver-acao/?id=' + id , dados, function(retorna){ //console.log(retorna); //Carregar o conteúdo para o usuário $("#visul_Acao").html(retorna); $('#visuAcaoModal').modal('show'); }); } } </script>