//$(document).ready(function (){
//  document.formSuspen.numCods.value =  document.thisform.inputvCod;
//});

function buscarSuspen(b, a){
  const parametros = new FormData();
  parametros.append("numCod", document.formSuspen.numCod.value);

  $.ajax({
    data:  parametros,
    url:   "busSuspen/data.php",
    type:  "post",
    contentType: false,
    processData: false,
    beforeSend: function () {
      alLoad("Consultando...")
    },
    success: function (jsonPhp) {
      //console.log(jsonPhp);
      const jsonJS = JSON.parse(jsonPhp);

      tblClear("tblSuspen");
      jsonJS.suspen.forEach(function(i){
        addRowSuspen(i.sus_cod, i.sus_del, i.sus_al, i.sus_obs);
      });

      $("#tblSuspen tbody tr").dblclick(function() {
        selectSuspen(a, $(this));
      });

      $("#tblSuspen tbody #btnSelecSuspen").click(function() {
        selectSuspen(a, $(this).parents("tr"));
      });

      alClose();
    }
  });
}

function addRowSuspen(cod, del, al, obs) {
  const markup =  "<tr>"
                    +"<td id='datacod' class='text-center'>"+cod+"</td>"
                    +"<td id='datadel' class='text-center'>"+del+"</td>"
                    +"<td id='dataal' class='text-center'>"+al+"</td>"                    
                    +"<td class='text-left'>"+obs+"</td>"
                    +"<td><button class='btn btn-sm btn-warning badge' id='btnSelecSuspen'>"+textBtnSelec+"</button></td>"
                  +"</tr>";
  $("#tblSuspen tbody").append(markup);
}

function selectSuspen(a, tr) {
  $("#pills-"+a+"-tab").click();
  /*if (inputProvcp == "txtNit") {
    document.thisform.txtNit.value = tr.find("td:eq(0)").text();
    $("form[name='thisform'] #txtNit").trigger("change");
  } else {*/
    $("#"+inputEmple).val(tr.find("td:eq(0)").text());
    $("#"+inputDel).val(tr.find("td:eq(1)").text());
    $("#"+inputAl).val(tr.find("td:eq(2)").text());
    //if (!nomTF) {
    //  $("#"+inputEmple).trigger("change");
      //$("#"+inputAl).trigger("blur");
    //} else {
    //  $("#"+"txtNom1").val(tr.find("td:eq(1)").text());
    //}
  //}

  //$('html, body').animate( { scrollTop : 0 }, 500 );
  tblClear("tblSuspen");
}