/***
 * @param Accion
 * @param archivo
 * @param div
 * @return
 */
/***Modal Box  */
/*******************************************/
function newMaux() {
  document.getElementById("myDropdown").classList.toggle("show");
  document.getElementById('chevron').classList.toggle('fa-rotate-90');
}

// Close the dropdown menu if the user clicks outside of it
window.onclick = function (event) {
  if (!event.target.matches('.dropbtn')) {
    var dropdowns = document.getElementsByClassName("dropdown-content");
    var i;
    for (i = 0; i < dropdowns.length; i++) {
      var openDropdown = dropdowns[i];
      if (openDropdown.classList.contains('show')) {

        openDropdown.classList.remove('fa-rotate-90');
      }
    }
  }
}

/*******************************************/
function newMauxR() {
  document.getElementById("myDropdownR").classList.toggle("showR");
  document.getElementById('chevronR').classList.toggle('fa-rotate-90');
}

// Close the dropdown menu if the user clicks outside of it
window.onclick = function (event) {
  if (!event.target.matches('.dropbtnR')) {
    var dropdowns = document.getElementsByClassName("dropdown-contentR");
    var i;
    for (i = 0; i < dropdowns.length; i++) {
      var openDropdown = dropdowns[i];
      if (openDropdown.classList.contains('showR')) {

        openDropdown.classList.remove('fa-rotate-90');
      }
    }
  }
}
document.addEventListener('DOMContentLoaded', function() {
  const preloader = document.getElementById('preloader');
  
  if (preloader) {
      // Asegurar que el preloader esté visible
      preloader.style.display = 'flex';
      
      // Simular tiempo de carga realista
      let progress = 0;
      const interval = setInterval(() => {
          progress += Math.random() * 30;
          if (progress >= 100) {
              progress = 100;
              clearInterval(interval);
              
              // Esperar un momento antes de ocultar
              setTimeout(() => {
                  preloader.classList.add('hide');
              }, 1800);
          }
      }, 100);
      
      // Tiempo máximo de 3 segundos por seguridad
      setTimeout(() => {
          preloader.classList.add('hide');
      }, 6000);
  }
});

$(function () {
  $("#menu").menu();
});


$(function () {
  $("#tabs").tabs();
});



$(function () {
  $("#draggable").draggable();
});

$(function () {
  $("#draggable2").draggable();
});

$(function () {
  $("#draggable3").draggable();
});
$(function () {
  $("#draggable4").draggable();
});

$(function () {
  $("#draggable5").draggable();
});

$(function () {
  $("#draggable6").draggable();
});


$(document).ready(function () {
  $("#btnxs1").click(function () {
    $("#box").animate({ left: '250px' });
  });
});

function printFunc() {
  var divToPrint = document.getElementById('printarea');
  var htmlToPrint = '<head><title>Linea</title></head>' +
    '<style type="text/css">' +
    'table th, table td {' +
    'border:0px solid #000;' +
    'padding;0.5em;' +
    '}' +
    '</style>';
  //var titulo = '<head><title>Linea</title></head>';
  htmlToPrint += divToPrint.outerHTML;
  newWin = window.open("");

  newWin.document.write(htmlToPrint);
  newWin.print();
  newWin.close();
}

function printFunc2() {
  var divToPrint = document.getElementById('printsellos');
  var htmlToPrint = '<head><title>Linea</title></head>' +
    '<style type="text/css">' +
    'table th, table td {' +
    'border:0px solid #000;' +
    'padding;0.5em;' +
    '}' +
    '</style>';
  //var titulo = '<head><title>Linea</title></head>';
  htmlToPrint += divToPrint.outerHTML;
  newWin = window.open("");

  newWin.document.write(htmlToPrint);
  newWin.print();
  newWin.close();
}




/*******************************************/
$(document).ready(function () {

  $('#example').DataTable({
    "language": {
      "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
    },
    "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
    "order": [[1, 'asc']]

  });
  $('#examplexrs').DataTable({
    "language": {
      "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
    },
    "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
    "order": [[1, 'asc']]

  });
  $('#examplexrs3').DataTable({
    "language": {
      "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
    },
    "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
    "order": [[1, 'asc']]

  });
  $('#examplexrs4').DataTable({
    "language": {
      "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
    },
    "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
    "order": [[4, 'desc']]

  });
  $('#examplexrs5').DataTable({
    "language": {
      "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
    },
    "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
    "order": [[4, 'asc']]

  });
  $('#examplexrs6').DataTable({
    "language": {
      "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
    },
    "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
    "order": [[4, 'desc']]

  });
  $('#examplexrs7').DataTable({
    "language": {
      "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
    },
    "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
    "order": [[0, 'desc']]

  });
  $('#examplexrs8').DataTable({
    "language": {
      "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
    },
    "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
    "order": [[4, 'desc']]

  });
  $('#examplexrsx').DataTable({
    "language": {
      "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
    },
    "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
    "order": [[1, 'asc']],
    "aoColumnDefs": [
      { "sWidth": "10%", "aTargets": [-1] }
    ]

  });

  $('#exampleabs').DataTable({
    fixedHeader: {
      header: true,
      footer: true
    },
    columnDefs: [
      { width: 200, targets: 0 }
    ],
    fixedColumns: true,
    scrollY: '37vh',
    scrollCollapse: true,
    "language": {
      "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json",
      buttons: {
        'pageLength': {
          _: "Mostrar %d registros",
          '-1': "Mostrar Todo"
        },
        "copySuccess": {
          "1": "Copiada 1 fila al portapapeles",
          "_": "Copiadas %d filas al portapapeles"
        },
        "copyTitle": "Copiar al portapapeles",
        "pdf": "",
        "print": "",
        "excel": "",
        "copy": "",

      }
    },


    dom: 'Bfrtip',
    lengthMenu: [
      [25, 50, -1],
      ['25 registros', '50 registros', 'Mostrar todo']
    ],
    buttons: {
      buttons: [
        { extend: 'pageLength', className: 'btn btn-datatble-mostrar' },

        { extend: 'excel', className: 'btn btn-datatble-excel' },
        { extend: 'pdf', className: 'btn btn-datatble-pdf' },
        { extend: 'copy', className: 'btn btn-datatble-copiar' },
        { extend: 'print', className: 'btn btn-datatble-imprimir' },


      ],

    },

    initComplete: function () {
      this.api()
        .columns(3)
        .every(function () {
          var column = this;
          var select = $('<select><option value="">Seleccióne Filtro</option></select>')
            .appendTo($(column.footer()).empty())
            .on('change', function () {
              var val = $.fn.dataTable.util.escapeRegex($(this).val());

              column.search(val ? '^' + val + '$' : '', true, false).draw();
            });

          column
            .data()
            .unique()
            .sort()
            .each(function (d, j) {
              select.append('<option value="' + d + '">' + d + '</option>');
            });
        });
    },


  });













});
/*******************************************/
$(document).ready(function () {
  $('#example2').DataTable({
    "language": {
      "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
    },
    "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
    "aaSorting": [[0, "DESC"]],
    "bAutoWidth": false,

    "columnDefs": [

      {

        "targets": 0,
        "width": "5%"
      },
      {

        "targets": 1,
        "width": "9%"
      },
      {
        "targets": 2,
        "width": "18%"
      },
      {
        "targets": 3,
        "width": "7%"
      },
      {
        "targets": 4,
        "width": "15%"

      },
      {
        "targets": 5,
        "width": "15%"

      },
      {
        "targets": 6,
        "width": "9%"

      },
      {
        "targets": 7,
        "width": "2%"

      }
    ],
  });
});
/*******************************************/
/*******************************************/
$(document).ready(function () {
  $('#example3').DataTable({
    "language": {
      "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
    },
    "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
    "aaSorting": [[0, "DESC"]],
    "bAutoWidth": false,

    "columnDefs": [

      {

        "targets": 0,
        "width": "5%"
      },
      {

        "targets": 1,
        "width": "9%"
      },
      {
        "targets": 2,
        "width": "18%"
      },
      {
        "targets": 3,
        "width": "7%"
      },
      {
        "targets": 4,
        "width": "15%"

      },
      {
        "targets": 5,
        "width": "15%"

      },
      {
        "targets": 6,
        "width": "9%"

      },
      {
        "targets": 7,
        "width": "2%"

      }
    ],
  });
});
/*******************************************/
/*******************************************/
$(document).ready(function () {
  $('#comparativoRespuestas').DataTable({
    "language": {
      "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
    },
    "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
    "aaSorting": [[0, "DESC"]],
    "bAutoWidth": false,

    "columnDefs": [

      {

        "targets": 0,
        "width": "55%"
      },
      {

        "targets": 1,
        "width": "20%"
      },
      {
        "targets": 2,
        "width": "20%"
      }
    ],
  });
});
/*******************************************/
$(document).ready(function () {
  $('#reporte').DataTable({
    "language": {
      "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
    },
    "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
    "dom": '<lf<t>ip>',
    "aaSorting": [[5, "desc"]], // Sort by first column descending 
    scrollY: '53.5vh',
    scrollCollapse: true,
    paging: true

  });

});



/*******************************************/
var exprecionRegularCorreo = ",/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,",
  mensaje1 = "Desea deshabilitar este usuario?",
  mensaje2 = "Desea cambiar el estatus de la solicitud de Credito?";

/*******************************************/
function Resetpas(id) {
  //alert(id);	
  var x = document.getElementById(id);
  if (x.type === "password") {
    x.type = "text";
  } else {
    x.type = "password";
  }
}
/**************Change*****************************/
function opnd(id) {

  $("#expand" + id).dialog('open');
}

/**************Change*****************************/
function opndcom(id) {

  $("#comunicacion" + id).dialog('open');
}
/**************Change*****************************/
function opndcap(id) {

  $("#comunicacion" + id).dialog('open');
}
/**************Change*****************************/
function opndinf(id) {

  $("#ingreso" + id).dialog('open');
}
/**************Change*****************************/
function quest(id) {

  $("#quest" + id).dialog('open');
}
/**************Configuracion*****************************/
function resultados(id) {

  $("#resultados" + id).dialog('open');
}

/**************Configuracion*****************************/
function configuracion(id) {

  $("#configuracion" + id).dialog('open');
}
/**************Change*****************************/
function opndadminmenu(id) {
  $('#adminmenu').dialog('open');
  $("#admin16").dialog('open');


}
/**************Change*****************************/
function opndadmin(id) {

  $("#admin" + id).dialog('open');
}
/**************Change*****************************/
function opndadminR(id) {

  $("#admin" + id).dialog('open');

  $("#admin9").dialog('open');
  $("#admin4").dialog('open');
}
/**************Change*****************************/
function opndadminRG(id) {

  $("#admin" + id).dialog('open');


}
/**************Change*****************************/
function opndadminRGRI(id) {

  $("#adminRGRI" + id).dialog('open');


}
/**************Change*****************************/
function opndadminRGRIes(id) {

  $("#adminRGRIes" + id).dialog('open');


}
/**************Change*****************************/
function opndadminRGRIcheck(id) {

  $("#adminRGRIcheck" + id).dialog('open');


}
/**************Change*****************************/
function opndadminRGRIcheckD(id) {

  $("#adminRGRIcheckD" + id).dialog('open');


}
/**************Change*****************************/
function opndadminRGRIcheckE(id) {

  $("#adminRGRIcheckE" + id).dialog('open');


}
/**************Change*****************************/
function opndadminRGRIII(id) {

  $("#adminRGRIII" + id).dialog('open');


}
/**************Change*****************************/
function opndadmingr3F(id) {

  $("#admingr3F" + id).dialog('open');


}
/**************Change*****************************/
function opndadmingr3C(id) {

  $("#admingr3C" + id).dialog('open');


}


/*******************************************/
function enviar() {
  var formulario = document.getElementById("myform");
  var dato = formulario[0];

  if (dato.value == "enviar") {
    alert("Enviando el formulario");
    formulario.submit();
    return true;
  } else {
    alert("No se envía el formulario");
    return false;
  }
}
/*********************CONTROLLER ALTA**********************/
/*****************DEPENDENCIA*****************************/

function imprSelec(muestra) { var ficha = document.getElementById(muestra); var ventimp = window.open(' ', 'popimpr'); ventimp.document.write(ficha.innerHTML); ventimp.document.close(); ventimp.print(); ventimp.close(); }
/*********************CONTROLLER ALTA**********************/
/*****************DEPENDENCIA*****************************/

function imprSelecgr3() { var ficha = document.getElementById('myPrintArea'); var ventimp = window.open(' ', 'popimpr'); ventimp.document.write(ficha.innerHTML); ventimp.document.close(); ventimp.print(); ventimp.close(); }

/*********************CONTROLLER ALTA**********************/
/*****************DEPENDENCIA*****************************/
function SendFRM(id, setul) {
  //var setul = $('#setul').val();
  var msj = 'Los datos son correctos, Desea Continuar?';
  //alert(setul);	
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          //alert(json.descr);
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $("#" + id)[0].reset();

        } catch (e) {
          //alert('Exception while request..');
        }
      },
      error: function () {
        //alert('Error while request..');
      }
    });
  }
  else {
    return false;
  }


}
/**************Capacitacion lista*****************************/
function SendCAPM1(id, setul) {
  //var id = $('#setul').val();
  var msj = 'Los datos son correctos, Desea Continuar?';
  //alert(id);	
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          //alert(json.descr);
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $("#" + id)[0].reset();
          $('#serial').load(location.href + " #serial");
          $('#expand4').load(" #expand4", function () {
            $("#example").dataTable().fnDestroy();
            var table = $('#example').DataTable({
              "language": {
                "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
              },
              "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
              "aaSorting": [[0, "DESC"]],
              "bAutoWidth": false,
              "columnDefs": [
                { "targets": 0, "width": "16%" },
                { "targets": 1, "width": "16%" },
                { "targets": 2, "width": "16%" },
                { "targets": 3, "width": "16%" },
                { "targets": 4, "width": "16%" },
                { "targets": 5, "width": "16%" }
              ],
            })
          });

        } catch (e) {
          //alert('Exception while request..');
        }
      },
      error: function () {
        //alert('Error while request..');
      }
    });
  }
  else {
    return false;
  }


}















/**************COnsulta Publica*****************************/
function SendCFRM13(id, setul) {
  //var id = $('#setul').val();
  var msj = 'Los datos son correctos, Desea Continuar?';
  //alert(id);	
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          //alert(json.descr);
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('sellos').innerHTML = json.descr;
          $('#sellos').dialog('open');
          $('#change').dialog('close');
          $("#" + id)[0].reset();
          $('#expand3').load(location.href + " #expand3");

        } catch (e) {
          //alert('Exception while request..');
        }
      },
      error: function () {
        //alert('Error while request..');
      }
    });
  }
  else {
    return false;
  }


}
/**************COnsulta Publica*****************************/
function SendCFRM205(id, setul) {
  //var id = $('#setul').val();
  var msj = 'Los datos son correctos, Desea Continuar?';
  //alert(id);	
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {

      },
      success: function (json) {

        try {
          //alert(json.descr);
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('sellos').innerHTML = json.descr;
          $('#sellos').dialog('open');
          $('.preloader').fadeIn(100);
          $('.preloader').fadeOut(2500);
          $("#" + id)[0].reset();
          $('#serial').load(location.href + " #serial");
          $('#expand205').load(" #expand205", function () {
            $('#examplexrs3').DataTable({
              "language": {
                "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
              },
              "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
              "order": [[1, 'asc']]

            });
          });
        } catch (e) {
          //alert('Exception while request..');
        }
      },
      error: function () {
        //alert('Error while request..');
      }
    });
  }
  else {
    return false;
  }


}
/**************COnsulta Publica*****************************/
function SendCFRM12(id, setul) {
  //var id = $('#setul').val();
  var msj = 'Los datos son correctos, Desea Continuar?';
  //alert(id);	
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          //alert(json.descr);
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $("#" + id)[0].reset();
          $('#expand3').load(location.href + " #expand3");

        } catch (e) {
          //alert('Exception while request..');
        }
      },
      error: function () {
        //alert('Error while request..');
      }
    });
  }
  else {
    return false;
  }


}
/**************COORDINADOR*****************************/
function SendFRM2(id, setul) {
  //var id = $('#setul').val();
  var msj = 'Los datos son correctos, Desea Continuar?';
  //alert(id);	
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          //alert(json.descr);
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $("#" + id)[0].reset();
          $('#expand3').load(location.href + " #expand3");

        } catch (e) {
          //alert('Exception while request..');
        }
      },
      error: function () {
        //alert('Error while request..');
      }
    });
  }
  else {
    return false;
  }


}
/**************ADMINISTRADOR*****************************/
function SendFRM3(id, setul) {
  //var id = $('#setul').val();
  var msj = 'Los datos son correctos, Desea Continuar?';
  //alert(setul);	
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          //alert(json.descr);
          console.log(json.nombre);
          console.log(json.id);

          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $("#" + id)[0].reset();
          $('#expand4').load(location.href + " #expand4");
          console.log("#id_administrador");
          $("#id_administrador").append("<option value=" + json.id + ">" + json.nombre + "</option>");

        } catch (e) {
          //alert('Exception while request..');
        }
      },
      error: function () {
        //alert('Error while request..');
      }
    });
  }
  else {
    return false;
  }


}

/**************ADMINISTRADOR*****************************/
function SendFRM105(id, setul) {
  //var id = $('#setul').val();
  var msj = 'Los datos son correctos, Desea Continuar?';
  //alert(setul);	
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          //alert(json.descr);
          console.log(json.nombre);
          console.log(json.id);

          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $("#" + id)[0].reset();
          $('#expand4').load(location.href + " #expand4");
          console.log("#id_administrador");
          $("#id_administrador").append("<option value=" + json.id + ">" + json.nombre + "</option>");

        } catch (e) {
          //alert('Exception while request..');
        }
      },
      error: function () {
        //alert('Error while request..');
      }
    });
  }
  else {
    return false;
  }


}




/**************ALTA DE LUGAR*****************************/
function SendFRM4(id, setul) {
  //var id = $('#setul').val();
  var msj = 'Los datos son correctos, Desea Continuar?';
  //alert(setul);	
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          //alert(json.descr);
          console.log(json.lugar);
          console.log(json.id);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $("#" + id)[0].reset();
          $('#seriecampus').load(location.href + " #seriecampus");
          $("#id_campus").append("<option value=" + json.id + ">" + json.lugar + "</option>");
          $('#expand7').load(" #expand7", function () {
            $("#example").dataTable().fnDestroy();
            var table = $('#example').DataTable({
              "language": {
                "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
              },
              "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
              "aaSorting": [[0, "DESC"]],
              "bAutoWidth": false,
              "columnDefs": [
                { "targets": 0, "width": "16%" },
                { "targets": 1, "width": "16%" },
                { "targets": 2, "width": "16%" },
                { "targets": 3, "width": "16%" },
                { "targets": 4, "width": "16%" },
                { "targets": 5, "width": "16%" }
              ],
            })
          });

        } catch (e) {
          //alert('Exception while request..');
        }
      },
      error: function () {
        //alert('Error while request..');
      }
    });
  }
  else {
    return false;
  }


}
/**************ALTA DE OPERADOR DE CAMPUS*****************************/
function SendFRM5(id, setul) {
  //var id = $('#setul').val();
  var msj = 'Los datos son correctos, Desea Continuar?';
  //alert(setul);	
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          //alert(json.descr);
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $("#" + id)[0].reset();
          $('#expand7').load(" #expand7", function () {
            $("#example").dataTable().fnDestroy();
            var table = $('#example').DataTable({
              "language": {
                "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
              },
              "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
              "aaSorting": [[0, "DESC"]],
              "bAutoWidth": false,
              "columnDefs": [
                { "targets": 0, "width": "16%" },
                { "targets": 1, "width": "16%" },
                { "targets": 2, "width": "16%" },
                { "targets": 3, "width": "16%" },
                { "targets": 4, "width": "16%" },
                { "targets": 5, "width": "16%" }
              ],
            })
          });

        } catch (e) {
          //alert('Exception while request..');
        }
      },
      error: function () {
        //alert('Error while request..');
      }
    });
  }
  else {
    return false;
  }


}
/**************ALTA DE ASIGNACION DE LUGAR*****************************/
function SendFRM6(id, id2) {
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/alta/select_lugares_return/" + id + "/" + id2,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#change').dialog('open');
    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('placeselect').innerHTML = json.descr;
        $('#placeselect').dialog('open');
        $('#change').dialog('close');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/**************asignacion alumno*****************************/
function SendCRM6(id, id2) {
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/capacitacion/ingresar_participante/" + id + "/" + id2,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#change').dialog('open');
    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('Cplaceselect').innerHTML = json.descr;
        $('#Cplaceselect').dialog('open');
        $('#change').dialog('close');

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/**************asignacion alumno*****************************/
function SendCRM7(id, id2) {
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/capacitacion/busqueda_lista/" + id + "/" + id2,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('Cplaceselect2').innerHTML = json.descr;
        $('#Cplaceselect2').dialog('open');
        $('.preloader').fadeIn(100);
        $('.preloader').fadeOut(2500);
        $('#expand5').load(" #expand5", function () {

          $('#examplexrs').DataTable({
            "language": {
              "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
            },
            "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
            "order": [[1, 'asc']]

          });
          $('#examplexrs6').DataTable({
            "language": {
              "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
            },
            "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
            "order": [[1, 'asc']]

          });


        });
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/**************asignacion alumno*****************************/
function SendCRM8(id, id2) {
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/capacitacion/imprimir_participante/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#change').dialog('open');
    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('Cplaceselect3').innerHTML = json.descr;
        $('#Cplaceselect3').dialog('open');
        $('#change').dialog('close');

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/**************asignacion alumno*****************************/
function SendCRM88(id, id2) {
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/capacitacion/ingresar_participanteOLD/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('Cplaceselect').innerHTML = json.descr;
        $('#Cplaceselect').dialog('open');
        $('.preloader').fadeIn(100);
        $('.preloader').fadeOut(2500);

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/**************asignacion alumno*****************************/
function SendCRM8CP(id, id2) {
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/capacitacion/imprimir_participanteCP/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#change').dialog('open');
    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('Cplaceselect3').innerHTML = json.descr;
        $('#Cplaceselect3').dialog('open');
        $('#change').dialog('close');

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/**************asignacion alumno*****************************/
function SendCRM8CP_old(id, id2) {
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/capacitacion/imprimir_participanteCP_old/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#change').dialog('open');
    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('Cplaceselect3').innerHTML = json.descr;
        $('#Cplaceselect3').dialog('open');
        $('#change').dialog('close');

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/**************Lista Participantes LC Cambio Nestor*****************************/
function SendCRM9(id, id2) {
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/capacitacion/busqueda_listaLC/" + id + "/" + id2,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#change').dialog('open');
    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('Cplaceselect4').innerHTML = json.descr;
        $('#Cplaceselect4').dialog('open');
        $('#change').dialog('close');
        $('#expand8').load(" #expand8", function () {
          $("#examplexrs8").dataTable().fnDestroy();
          var table = $('#examplexrs8').DataTable({
            "language": {
              "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
            },
            "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
            "aaSorting": [[0, "DESC"]],
            "bAutoWidth": false,
            "columnDefs": [
              { "targets": 0, "width": "16%" },
              { "targets": 1, "width": "16%" },
              { "targets": 2, "width": "16%" },
              { "targets": 3, "width": "16%" },
              { "targets": 4, "width": "16%" },
              { "targets": 5, "width": "16%" }
            ],
          })
        });
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/**************Imprimir Linea Cambio Nestor*****************************/
function SendCRM10(id, id2) {
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/capacitacion/imprimir_lc/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#change').dialog('open');
    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('Cplaceselect5').innerHTML = json.descr;
        $('#Cplaceselect5').dialog('open');
        $('#change').dialog('close');

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/**************ALTA DE ASIGNACION DE LUGAR*****************************/
function SendFRM6(id, id2) {
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/alta/select_lugares_return/" + id + "/" + id2,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#change').dialog('open');
    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('placeselect').innerHTML = json.descr;
        $('#placeselect').dialog('open');
        $('#change').dialog('close');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/********************MODULO DE PRUEBA***********************/
function SendFRMX7(id, clave, claveP) {

  var msj = 'El registro sera eliminado desea continuar?';

  if (confirm(msj)) {

    document.getElementById("formdata6").submit();
  }
  else {
    return false;
  }
}

/*************************************************************/
/*************************************************************/
/**************Registro de lugares*****************************/
function SendFRM7() {
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: "https://aplicacionesasig.com/alta/register_lugares_asignados",
      cache: false,
      data: $("#formdata6").serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $("#formdata6")[0].reset();

        } catch (e) {
        }
      },
      error: function () {
      }
    });
  }
  else {
    return false;
  }
}
/**************ALTA DE CARGO DE CONSTANCIA*****************************/
function SendFRM8(id, setul) {
  //var id = $('#setul').val();
  var msj = 'Los datos son correctos, Desea Continuar?';
  //alert(setul);	
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          //alert(json.descr);
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $("#" + id)[0].reset();
          $('#expand7').load(" #expand7", function () {
            $("#example").dataTable().fnDestroy();
            var table = $('#example').DataTable({
              "language": {
                "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
              },
              "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
              "aaSorting": [[0, "DESC"]],
              "bAutoWidth": false,
              "columnDefs": [
                { "targets": 0, "width": "16%" },
                { "targets": 1, "width": "16%" },
                { "targets": 2, "width": "16%" },
                { "targets": 3, "width": "16%" },
                { "targets": 4, "width": "16%" },
                { "targets": 5, "width": "16%" }
              ],
            })
          });

        } catch (e) {
          //alert('Exception while request..');
        }
      },
      error: function () {
        //alert('Error while request..');
      }
    });
  }
  else {
    return false;
  }
}
/**************ALTA DE CARGO DE CONSTANCIA*****************************/
function SendFRM9(id, setul) {
  var paqueteDeDatos = new FormData();
  paqueteDeDatos.append('foto', $('#foto')[0].files[0]);
  paqueteDeDatos.append('id', $('#id').prop('value'));
  paqueteDeDatos.append('nombre', $('#nombre').prop('value'));
  paqueteDeDatos.append('autorizacion', $('#autorizacion').prop('value'));
  paqueteDeDatos.append('email', $('#email').prop('value'));
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      contentType: false,
      data: paqueteDeDatos,
      processData: false,
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {
        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $("#" + id)[0].reset();
          $('#expand9').load(location.href + " #expand9");

        } catch (e) {
        }
      },
      error: function () {
        //alert('Error while request..');
      }
    });
  }
  else {
    return false;
  }


}
/**************ALTA DE CURSO*****************************/
function SendFRM10(id, setul) {
  var msj = 'Los datos son correctos, Deseaasd Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $("#" + id)[0].reset();
          $('#seriecurso').load(location.href + " #seriecurso");

        } catch (e) {
        }
      },
      error: function () {
      }
    });
  }
  else {
    return false;
  }
}
/**************ALTA MODELO*****************************/
function SendFRM11(id, setul) {
  var msj = 'Los datos son correctos, Desea Continuar?';
  //alert(setul);	
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          //alert(json.descr);
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $("#" + id)[0].reset();
          $('#expand7').load(" #expand7", function () {
            $("#example").dataTable().fnDestroy();
            var table = $('#example').DataTable({
              "language": {
                "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
              },
              "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
              "aaSorting": [[0, "DESC"]],
              "bAutoWidth": false,
              "columnDefs": [
                { "targets": 0, "width": "16%" },
                { "targets": 1, "width": "16%" },
                { "targets": 2, "width": "16%" },
                { "targets": 3, "width": "16%" },
                { "targets": 4, "width": "16%" },
                { "targets": 5, "width": "16%" }
              ],
            })
          });

        } catch (e) {
          //alert('Exception while request..');
        }
      },
      error: function () {
        //alert('Error while request..');
      }
    });
  }
  else {
    return false;
  }
}
/**************ALTA DE ASIGNACION DE LUGAR*****************************/
function SendFRM12(id, id2) {
  //alert(id2);	
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/nom035/ingreso_participante_nom/" + id + "/" + id2,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('registroparticipantes').innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/*************************************************************/
/*************************************************************/
/**************Registro de Participantes*****************************/
function SendFRM13() {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/nom035/register_participantes",
    cache: false,
    data: $("#formdata13").serialize(),
    dataType: 'json',
    beforeSend: function () {
      $('#al-warning-succes').modal('show');
      $('#al-warning-alert').modal('hide');

    },
    success: function (json) {

      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('response').innerHTML = json.descr;


        /*****$("#formdata13")[0].reset();*****/

      } catch (e) {
      }
    },
    error: function () {
    }
  });

}
/*************************************************************/
/*************************************************************/
/**************Cuestionario1*****************************/
function SendFRM14(id, setul) {
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#cuestio2').dialog('open');
          $('#confirm').dialog('open');
          $('#cuestio1').dialog('close');
          $('#change').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}

/**************Cuestionario1 p2*****************************/
function SendFRM15(id, setul) {
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#cuestio3').dialog('open');
          $('#confirm').dialog('open');
          $('#cuestio2').dialog('close');
          $('#change').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}

/**************Cuestionario1 p3*****************************/
function SendFRM16(id, setul) {
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#cuestio4').dialog('open');
          $('#confirm').dialog('open');
          $('#cuestio3').dialog('close');
          $('#change').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}


/**************Cuestionario1 p4*****************************/
function SendFRM17(id, setul) {
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#cuestio5').dialog('open');
          $('#confirm').dialog('open');
          $('#cuestio4').dialog('close');
          $('#change').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}

/**************Cuestionario1 p5*****************************/
function SendFRM18(id, setul) {
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#cuestio6').dialog('open');
          $('#confirm').dialog('open');
          $('#cuestio5').dialog('close');
          $('#change').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}

/**************Cuestionario1 p6*****************************/
function SendFRM19(id, setul) {
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#cuestio7').dialog('open');
          $('#confirm').dialog('open');
          $('#cuestio6').dialog('close');
          $('#change').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}

/**************Cuestionario1 p6*****************************/
function SendFRM20(id, setul) {
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#cuestio8').dialog('open');
          $('#confirm').dialog('open');
          $('#cuestio7').dialog('close');
          $('#change').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}

/**************Cuestionario1 p6*****************************/
function SendFRM21(id, setul) {
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#cuestio9').dialog('open');
          $('#confirm').dialog('open');
          $('#cuestio8').dialog('close');
          $('#change').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}

/**************Cuestionario1 p6*****************************/
function SendFRM22(id, setul) {
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#cuestio10').dialog('open');
          $('#confirm').dialog('open');
          $('#cuestio9').dialog('close');
          $('#change').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}

/**************Cuestionario1 p6*****************************/
function SendFRM23(id, setul) {
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#cuestio11').dialog('open');
          $('#confirm').dialog('open');
          $('#cuestio10').dialog('close');
          $('#change').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}

/**************Cuestionario1 p6*****************************/
function SendFRM24(id, setul) {
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#cuestio12').dialog('open');
          $('#confirm').dialog('open');
          $('#cuestio11').dialog('close');
          $('#change').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}

/**************Cuestionario1 p6*****************************/
function SendFRM25(id, setul) {
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#cuestio13').dialog('open');
          $('#confirm').dialog('open');
          $('#cuestio12').dialog('close');
          $('#change').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}

/**************Cuestionario1 p6*****************************/
function SendFRM26(id, setul) {
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('placeselect3').innerHTML = json.descr;
          $('#placeselect3').dialog('open');
          $('#change').dialog('close');
          $('#cuestio13').dialog('close');

          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}

function SendFRM27() {
  var msj = '¿Los datos proporcionados, son correctos?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: "https://aplicacionesasig.com/nom035/guardar_cuestionario1pe2",
      cache: false,
      data: $("#formdata27").serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('placeselect3').innerHTML = json.descr;
          $('#placeselect3').dialog('open');
          $('#change').dialog('close');
          $('#cuestio13').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}

function SendFRM28() {
  var msj = 'Los datos son correctos, Deseass Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: "https://aplicacionesasig.com/nom035/guardar_cuestionario1pe3",
      cache: false,
      data: $("#formdata28").serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#cuestio14').dialog('open');
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $('#cuestio13').dialog('close');
          $('#placeselect3').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}

function SendFRM29(id, setul) {
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('placeselect3').innerHTML = json.descr;
          $('#placeselect3').dialog('open');
          $('#change').dialog('close');
          $('#cuestio14').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}

function SendFRM30() {
  var msj = 'Los datos son correctos, Deseass Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: "https://aplicacionesasig.com/nom035/guardar_cuestionario1pe5",
      cache: false,
      data: $("#formdata30").serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#cuestio15').dialog('open');
          $('#confirm').dialog('open');
          $('#cuestio14').dialog('close');
          $('#placeselect3').dialog('close');
          $('#change').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}
/**************ALTA DE ASIGNACION DE LUGAR*****************************/
function SendFRM312g(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/buscar_answer_2gquest/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#al-warning-charging').modal('show');
      $('#resultados3').dialog('open');
    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('catcherRP3').innerHTML = json.descr;
        setTimeout(function () {
          $('#al-warning-charging').modal('hide');
        }, 500);
        /*****$("#formdata13")[0].reset();*****/
        var table = $('#example2').DataTable({
          "rowReorder": true,
          "paging": false,
          fixedHeader: {
            header: true,
            footer: true
          },
          "columnDefs": [

            { "targets": [0], "width": "2%" },
            { "targets": [1], "width": "20%" },
            { "targets": [2], "width": "2%", orderable: false, },
            { "targets": [3], "width": "7%" },
            { "targets": [4], "width": "2%", orderable: false, },
            { "targets": [5], "width": "7%" },
          ],
          fixedColumns: true,
          scrollY: '45vh',
          scrollCollapse: true,
          "language": {
            "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json",
            buttons: {
              'pageLength': {
                _: "Mostrar %d registros",
                '-1': "Mostrar Todo"
              },
              "copySuccess": {
                "1": "Copiada 1 fila al portapapeles",
                "_": "Copiadas %d filas al portapapeles"
              },
              "copyTitle": "Copiar al portapapeles",
              "pdf": "",
              "print": "",
              "excel": "",
              "copy": "",

            }
          },


          dom: 'Bfrtip',
          lengthMenu: [
            [100, -1],
            ['25 registros', '50 registros', 'Mostrar todo']
          ],
          buttons: {
            buttons: [


              { extend: 'excel', className: 'btn btn-datatble-excel' },
              { extend: 'pdf', className: 'btn btn-datatble-pdf' },
              { extend: 'copy', className: 'btn btn-datatble-copiar' },
              { extend: 'print', className: 'btn btn-datatble-imprimir' },


            ],

          },

          initComplete: function () {
            this.api()
              .columns([3, 5])
              .every(function () {
                var column = this;
                var select = $('<select ><option value="">Seleccione</option></select>')
                  .appendTo($(column.header()).empty())
                  .on('change', function () {
                    var val = $.fn.dataTable.util.escapeRegex($(this).val());

                    column.search(val ? '^' + val + '$' : '', true, false).draw();
                  });

                column
                  .data()
                  .unique()
                  .sort()
                  .each(function (d, j) {
                    select.append('<option value="' + d + '">' + d + '</option>');
                  });
              });
          },


        });

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/**************Cuestionario1 p6*****************************/
function SendFRM32(id, setul) {
  var msj = '¿Los datos proporcionados, son correctos?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('placeselect3').innerHTML = json.descr;
          $('#placeselect3').dialog('open');
          $('#change').dialog('close');
          $('#quest1').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');

      }
    });
  }
  else {
    return false;
  }
}
function SendFRM34() {
  var msj = 'Los datos son correctos, Deseass Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: "https://aplicacionesasig.com/nom035/guardar_cuestionario2pa2",
      cache: false,
      data: $("#formdata34").serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#quest3').dialog('open');
          $('#confirm').dialog('open');
          $('#placeselect3').dialog('close');
          $('#change').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}
function SendFRM35(id, setul) {
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#quest4').dialog('open');
          $('#confirm').dialog('open');
          $('#quest3').dialog('close');
          $('#change').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}
function SendFRM36(id, setul) {
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#quest5').dialog('open');
          $('#confirm').dialog('open');
          $('#quest4').dialog('close');
          $('#change').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$setTimeout(function(){
                window.open('https://aplicacionesasig.com/nom035/quest1', '_self');
                 },2800); 
          ("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}
/**************ALTA DE ASIGNACION DE LUGAR*****************************/
function SendFRM372g(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/buscar_answer_quest22g/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#al-warning-charging').modal('show');
      $('#resultados3').dialog('open');
    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('catcherRP3').innerHTML = json.descr;
        setTimeout(function () {
          $('#al-warning-charging').modal('hide');
        }, 500);
        /*****$("#formdata13")[0].reset();*****/
        var table = $('#example2').DataTable({
          "rowReorder": true,
          "paging": false,
          fixedHeader: {
            header: true,
            footer: true
          },
          "columnDefs": [

            { "targets": [0], "width": "2%" },
            { "targets": [1], "width": "20%" },
            { "targets": [2], "width": "2%", orderable: false, },
            { "targets": [3], "width": "7%" },
            { "targets": [4], "width": "2%", orderable: false, },
            { "targets": [5], "width": "7%" },
          ],
          fixedColumns: true,
          scrollY: '45vh',
          scrollCollapse: true,
          "language": {
            "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json",
            buttons: {
              'pageLength': {
                _: "Mostrar %d registros",
                '-1': "Mostrar Todo"
              },
              "copySuccess": {
                "1": "Copiada 1 fila al portapapeles",
                "_": "Copiadas %d filas al portapapeles"
              },
              "copyTitle": "Copiar al portapapeles",
              "pdf": "",
              "print": "",
              "excel": "",
              "copy": "",

            }
          },


          dom: 'Bfrtip',
          lengthMenu: [
            [25, 50, -1],
            ['25 registros', '50 registros', 'Mostrar todo']
          ],
          buttons: {
            buttons: [


              { extend: 'excel', className: 'btn btn-datatble-excel' },
              { extend: 'pdf', className: 'btn btn-datatble-pdf' },
              { extend: 'copy', className: 'btn btn-datatble-copiar' },
              { extend: 'print', className: 'btn btn-datatble-imprimir' },


            ],

          },

          initComplete: function () {
            this.api()
              .columns([3, 5])
              .every(function () {
                var column = this;
                var select = $('<select><option value="">Seleccióne Filtro</option></select>')
                  .appendTo($(column.header()).empty())
                  .on('change', function () {
                    var val = $.fn.dataTable.util.escapeRegex($(this).val());

                    column.search(val ? '^' + val + '$' : '', true, false).draw();
                  });

                column
                  .data()
                  .unique()
                  .sort()
                  .each(function (d, j) {
                    select.append('<option value="' + d + '">' + d + '</option>');
                  });
              });
          },


        });

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/**************ALTA DE ASIGNACION DE LUGAR*****************************/
function SendFRM37(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/buscar_answer_quest2/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#change').dialog('open');
    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('placeselect4').innerHTML = json.descr;
        $('#placeselect4').dialog('open');
        $('#change').dialog('close');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

/**************ALTA DE ASIGNACION DE LUGAR*****************************/
function SendFRM3722g(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/buscar_answer_quest222g/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#change').dialog('open');
    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('placeselect4').innerHTML = json.descr;
        $('#placeselect4').dialog('open');
        $('#change').dialog('close');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

/**************Modificar Participantes*****************************/


function SendFRM38(id, id2) {
  //alert(id2);	
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/nom035/modificar_participante/" + id + "/" + id2,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('modificarparticipantes').innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/*************************************************************/
/*************************************************************/
/**************Registro de Participantes*****************************/
function SendFRM39() {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/nom035/change_participantes",
    cache: false,
    data: $("#formdata39").serialize(),
    dataType: 'json',
    beforeSend: function () {
      $('#al-warning-succesM').modal('show');
      $('#al-warning-alert').modal('hide');

    },
    success: function (json) {

      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('responseM').innerHTML = json.descr;


        /*****$("#formdata13")[0].reset();*****/

      } catch (e) {
      }
    },
    error: function () {
    }
  });

}
/*************************************************************/
/*************************************************************/
/************** Modificacion de Participantes*****************************/
function SendFRM39old() {
  var msj = 'Los datos son correctos, Deseass Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: "https://aplicacionesasig.com/nom035/change_participantes",
      cache: false,
      data: $("#formdata39").serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
        /**$ $("#example2").load(" #example2"); 
        ("#expand13").load(" #expand13");**/
      },
      success: function (json) {

        try {

          console.log(json.code);
          console.log(json.descr);


          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $('#expand13').load(" #expand13", function () {
            $("#example2").dataTable().fnDestroy();
            var table = $('#example2').DataTable({
              "language": {
                "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
              },
              "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
              "aaSorting": [[0, "DESC"]],
              "bAutoWidth": false,
              "columnDefs": [
                { "targets": 0, "width": "5%" },
                { "targets": 1, "width": "9%" },
                { "targets": 2, "width": "18%" },
                { "targets": 3, "width": "7%" },
                { "targets": 4, "width": "15%" },
                { "targets": 5, "width": "15%" },
                { "targets": 6, "width": "9%" },
                { "targets": 7, "width": "2%" }
              ],
            })
          });

          /** $('#example2').DataTable().ajax.reload();***/

          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 3000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);

        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}
/**************CERRAR ALTA DE ROOT*****************************/
function SendFRM40(id) {
  var msj = 'Esta seguro de eliminar los datos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: "https://aplicacionesasig.com/nom035/deleParticipante/" + id,
      cache: false,
      data: id,
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {

          console.log(json.code);
          console.log(json.descr);

          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $('#expand13').load(" #expand13", function () {
            $("#example2").dataTable().fnDestroy();
            var table = $('#example2').DataTable({
              "language": {
                "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
              },
              "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
              "aaSorting": [[0, "DESC"]],
              "bAutoWidth": false,
              "columnDefs": [
                { "targets": 0, "width": "5%" },
                { "targets": 1, "width": "9%" },
                { "targets": 2, "width": "18%" },
                { "targets": 3, "width": "7%" },
                { "targets": 4, "width": "15%" },
                { "targets": 5, "width": "15%" },
                { "targets": 6, "width": "9%" },
                { "targets": 7, "width": "2%" }
              ],
            })
          });
          /**$("#expand13").load(location.href + " #expand13");***/
          /**$('#example').DataTable().ajax.reload();***/
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 3000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}
/**************CERRAR ALTA DE ROOT*****************************/
function SendFRM41(id) {
  var msj = 'Activar al participante, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: "https://aplicacionesasig.com/nom035/ActivaParticipante/" + id,
      cache: false,
      data: id,
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {

          console.log(json.code);
          console.log(json.descr);

          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $('#expand14').load(" #expand14", function () {
            $("#example3").dataTable().fnDestroy();
            var table = $('#example3').DataTable({
              "language": {
                "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
              },
              "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
              "aaSorting": [[0, "DESC"]],
              "bAutoWidth": false,
              "columnDefs": [
                { "targets": 0, "width": "5%" },
                { "targets": 1, "width": "9%" },
                { "targets": 2, "width": "18%" },
                { "targets": 3, "width": "7%" },
                { "targets": 4, "width": "15%" },
                { "targets": 5, "width": "15%" },
                { "targets": 6, "width": "9%" },
                { "targets": 7, "width": "2%" }
              ],
            })
          });
          /**$("#expand13").load(location.href + " #expand13");***/
          /**$('#example').DataTable().ajax.reload();***/
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 3000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}
/**************CERRAR ALTA DE ROOT*****************************/
function SendFRM42(id) {
  var msj = 'Activar al participante, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: "https://aplicacionesasig.com/nom035/ActivaParticipante2/" + id,
      cache: false,
      data: id,
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {

          console.log(json.code);
          console.log(json.descr);

          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $('#expand14').load(" #expand14", function () {
            $("#example3").dataTable().fnDestroy();
            var table = $('#example3').DataTable({
              "language": {
                "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
              },
              "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
              "aaSorting": [[0, "DESC"]],
              "bAutoWidth": false,
              "columnDefs": [
                { "targets": 0, "width": "5%" },
                { "targets": 1, "width": "9%" },
                { "targets": 2, "width": "18%" },
                { "targets": 3, "width": "7%" },
                { "targets": 4, "width": "15%" },
                { "targets": 5, "width": "15%" },
                { "targets": 6, "width": "9%" },
                { "targets": 7, "width": "2%" }
              ],
            })
          });
          /**$("#expand13").load(location.href + " #expand13");***/
          /**$('#example').DataTable().ajax.reload();***/
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 3000);
          /*****$("#formdata13")[0].reset();*****/

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');
      }
    });
  }
  else {
    return false;
  }
}

/**************Cuestionario NOM035*****************************/
function SendFRM43(id, setul) {
  var msj = 'Los datos son correctos, Desea Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: setul,
      cache: false,
      data: $("#" + id).serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('examenNom035').innerHTML = json.descr;
          $('#examenNom035').dialog('open');
          $('#comunicacion43').dialog('close');
          $('#change').dialog('close');
          $('#quest1').dialog('close');
          setTimeout(function () {
            $('#confirm').dialog('close');
          }, 1000);
          /*****$("#formdata13")[0].reset();*****/

          $('#expand').load(location.href + " #expand");
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('confirm').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#confirm').dialog('open');

      }
    });
  }
  else {
    return false;
  }
}
/**************ALTA DE ASIGNACION DE LUGAR*****************************/
function SendFRM44(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/buscar_answer_questE/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#change').dialog('open');
    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('placeselect2').innerHTML = json.descr;
        $('#placeselect2').dialog('open');
        $('#change').dialog('close');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/**************ALTA DE ASIGNACION DE LUGAR*****************************/
function SendFRMC45(id) {

  var msj = 'Los datos son correctos, Deseass Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: "https://aplicacionesasig.com/capacitacion/guardar_alumnos",
      cache: false,
      data: $("#formdataC6").serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $("#formdataC6")[0].reset();

        } catch (e) {
        }
      },
      error: function () {
      }
    });
  }
  else {
    return false;
  }
}
/**************ALTA DE ASIGNACION DE LUGAR*****************************/
function SendFRMC450(id) {

  var msj = 'Los datos son correctos, Deseass Continuar?';
  if (confirm(msj)) {
    $.ajax({
      type: "post",
      url: "https://aplicacionesasig.com/capacitacion/guardar_alumnosOLD",
      cache: false,
      data: $("#formdataC60").serialize(),
      dataType: 'json',
      beforeSend: function () {
        $('#change').dialog('open');
      },
      success: function (json) {

        try {
          console.log(json.code);
          console.log(json.descr);
          document.getElementById('confirm').innerHTML = json.descr;
          $('#confirm').dialog('open');
          $('#change').dialog('close');
          $("#formdataC60")[0].reset();

        } catch (e) {
        }
      },
      error: function () {
      }
    });
  }
  else {
    return false;
  }
}










/*********************************************************************************************************************************************/
/***************************************************************Cambio a APIL*****************************************************************/
/*********************************************************************************************************************************************/


/*********************************************************************************************************************************************/
/***************************************************************Funcion Implementacion********************************************************/
/*********************************************************************************************************************************************/

function implementacion0(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/help/implementacion/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('catcher').innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementacion1(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/implementacion1/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('catcher'+ id).innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
function implementacion2(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/implementacion2/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('catcher'+ id).innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
function implementacion3(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/implementacion3/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('catcher'+ id).innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementacion4(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/implementacion4/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('catcher'+ id).innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
function implementacion5(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/implementacion5/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('catcher'+ id).innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementacion6(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/implementacion6/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('catcher'+ id).innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementacion7(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/implementacion7/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('catcher'+ id).innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementacion8(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/implementacion8/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('catcher'+ id).innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementacion9(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/implementacion9/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code); 
        //console.log(json.descr);
        document.getElementById('catcher'+ id).innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

/*********************************************************************************************************************************************/
/***************************************************Documentos implementacion*****************************************************************/
/*********************************************************************************************************************************************/

function implementaciondocs1(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs1/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('documentacion1').innerHTML = json.descr;
        $('#documentacion1').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs2(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs2/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion2').innerHTML = json.descr;
        $('#documentacion2').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs3(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs3/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion3').innerHTML = json.descr;
        $('#documentacion3').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs4(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs4/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion4').innerHTML = json.descr;
        $('#documentacion4').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs5(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs5/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion5').innerHTML = json.descr;
        $('#documentacion5').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs6(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs6/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion6').innerHTML = json.descr;
        $('#documentacion6').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs7(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs7/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion7').innerHTML = json.descr;
        $('#documentacion7').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs8(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs8/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion8').innerHTML = json.descr;
        $('#documentacion8').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
function implementaciondocs9(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs9/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion9').innerHTML = json.descr;
        $('#documentacion9').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs10(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs10/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion10').innerHTML = json.descr;
        $('#documentacion10').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}


function implementaciondocs11(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs11/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion11').innerHTML = json.descr;
        $('#documentacion11').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}


function implementaciondocs12(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs12/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion12').innerHTML = json.descr;
        $('#documentacion12').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs13(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs13/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion13').innerHTML = json.descr;
        $('#documentacion13').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs14(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs14/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion14').innerHTML = json.descr;
        $('#documentacion14').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs15(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs15/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion15').innerHTML = json.descr;
        $('#documentacion15').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs16(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs16/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion16').innerHTML = json.descr;
        $('#documentacion16').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs17(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs17/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion17').innerHTML = json.descr;
        $('#documentacion17').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs18(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs18/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion18').innerHTML = json.descr;
        $('#documentacion18').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs19(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs19/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion19').innerHTML = json.descr;
        $('#documentacion19').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs20(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs20/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion20').innerHTML = json.descr;
        $('#documentacion20').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs21(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs21/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion21').innerHTML = json.descr;
        $('#documentacion21').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs22(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs22/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion22').innerHTML = json.descr;
        $('#documentacion22').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs23(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs23/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion23').innerHTML = json.descr;
        $('#documentacion23').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs24(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs24/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion24').innerHTML = json.descr;
        $('#documentacion24').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs25(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs25/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion25').innerHTML = json.descr;
        $('#documentacion25').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs26(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs26/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion26').innerHTML = json.descr;
        $('#documentacion26').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs27(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs27/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion27').innerHTML = json.descr;
        $('#documentacion27').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs28(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs28/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion28').innerHTML = json.descr;
        $('#documentacion28').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function implementaciondocs29(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/idocs29/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('documentacion29').innerHTML = json.descr;
        $('#documentacion29').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}


/*********************************************************************************************************************************************/
/***************************************************************Funcion Capacitación********************************************************/
/*********************************************************************************************************************************************/

function capacitacion0(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/capacitacion/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('catcher'+ id).innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function capacitaciondocs1(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/cdocs1/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('capacitacion1').innerHTML = json.descr;
        $('#capacitacion1').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}


function capacitaciondocs2(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/cdocs2/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('capacitacion1').innerHTML = json.descr;
        $('#capacitacion1').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}


function capacitaciondocs3(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/cdocs3/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('capacitacion1').innerHTML = json.descr;
        $('#capacitacion1').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}


function capacitaciondocs4(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/cdocs4/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('capacitacion1').innerHTML = json.descr;
        $('#capacitacion1').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}


function capacitaciondocs5(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/cdocs5/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('capacitacion1').innerHTML = json.descr;
        $('#capacitacion1').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}


function capacitaciondocs6(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/cdocs6/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('capacitacion1').innerHTML = json.descr;
        $('#capacitacion1').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function capacitaciondocs7(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/cdocs7/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('capacitacion1').innerHTML = json.descr;
        $('#capacitacion1').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}


function capacitaciondocs8(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/cdocs8/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('capacitacion1').innerHTML = json.descr;
        $('#capacitacion1').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}



function helpdocs1(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/hdocs1/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('capacitacion1').innerHTML = json.descr;
        $('#capacitacion1').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}



function helpdocs2(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/hdocs2/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('capacitacion1').innerHTML = json.descr;
        $('#capacitacion1').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}



function helpdocs3(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/hdocs3/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('capacitacion1').innerHTML = json.descr;
        $('#capacitacion1').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}



function helpdocs4(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/hdocs4/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('capacitacion1').innerHTML = json.descr;
        $('#capacitacion1').dialog('open');
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/*********************************************************************************************************************************************/
/***************************************************************Funcion configuracion ar********************************************************/
/*********************************************************************************************************************************************/
function Miconfiguracion1(id) {
  //alert(id);
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/miconfiguracion/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        
        document.getElementById('catcher'+ id).innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function configuracion1(id) {
  //alert(id);

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/configuracion1/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('catcher'+ id).innerHTML = json.descr;

        $('#examplecon2').DataTable({
          searching: false, 
          paging: false, 
          info: false,
          "language": {
            "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
          },
          "lengthMenu": [[25, 50, 75, 100, -1], [25, 50, 75, 100, "Todos"]],
          "order": [[1, 'asc']],


        });
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}




function configuracion2(id) {
 //alert(id);

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/configuracion2/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
     
    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
       
        $("#conf_file_export").dataTable().fnDestroy();
        var tabla = $('#conf_file_export').DataTable({

          fixedHeader: {
            header: true,
            footer: true
          },
          columnDefs: [
            { width: 200, targets: 0 }
          ],
          fixedColumns: true,
          scrollY: '37vh',
          scrollCollapse: true,
          "language": {
            "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json",
            buttons: {
              'pageLength': {
                _: "Mostrar %d registros",
                '-1': "Mostrar Todo"
              },
              "copySuccess": {
                "1": "Copiada 1 fila al portapapeles",
                "_": "Copiadas %d filas al portapapeles"
              },
              "copyTitle": "Copiar al portapapeles",
              
              "print": "",
              "excel": "",
              "copy": "",

            }
          },


          dom: 'Bfrtip',
          lengthMenu: [
            [25, 50, -1],
            ['25 registros', '50 registros', 'Mostrar todo']
          ],
          buttons: {
            buttons: [
              { extend: 'pageLength', className: 'btn btn-datatble-mostrar' },

              { extend: 'excel', className: 'btn btn-datatble-excel' },
             
              { extend: 'copy', className: 'btn btn-datatble-copiar' },
              { extend: 'print', className: 'btn btn-datatble-imprimir' },


            ],

          },

          initComplete: function () {
            this.api()
              .columns([2, 3])
              .every(function () {
                var column = this;
                var select = $('<select><option value="">Seleccione Filtro </option></select>')
                  .appendTo($(column.header()).empty())
                  .on('change', function () {
                    var val = $.fn.dataTable.util.escapeRegex($(this).val());

                    column.search(val ? '^' + val + '$' : '', true, false).draw();
                  });

                column
                  .data()
                  .unique()
                  .sort()
                  .each(function (d, j) {
                    select.append('<option value="' + d + '">' + d + '</option>');
                  });
              });
          },

        });
      }, 300);
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/*********************************************************************************************************************************************/
/***************************************************************Funcion MASIVA********************************************************/
/*********************************************************************************************************************************************/

function masiva(id) {
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/masiva/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#al-warning-charging').modal('show');
    },
    success: function (json) {
      try {
        if (!json || !json.descr) {
          throw new Error('Respuesta inválida del servidor');
        }

        document.getElementById('catcher' + id).innerHTML = json.descr;
        inicializarDataTable();
        inicializarSeleccionMasiva();
        
      } catch (e) {
        console.error('Error procesando respuesta:', e);
        alert('Error procesando los datos');
      }
    },
    error: function (xhr, status, error) {
      console.error('Error AJAX:', error);
      alert('Error de conexión con el servidor');
    },
    complete: function() {
      setTimeout(function() {
        $('#al-warning-charging').modal('hide');
      }, 500);
    }
  });
}

function inicializarDataTable() {
  if ($.fn.DataTable.isDataTable('#conf_file_export')) {
    $('#conf_file_export').DataTable().destroy();
    $('#conf_file_export').empty(); // Limpiar completamente
  }

  setTimeout(function() {
    var tabla = $('#conf_file_export').DataTable({
      // Configuración básica
      responsive: false, // Desactivamos responsive automático
      scrollY: '60vh',
      scrollCollapse: true,
      scrollX: true, // Scroll horizontal si es necesario
      
      // Configuración de columnas con anchos fijos
      columnDefs: [
        { 
          width: "60px", 
          targets: 0, 
          orderable: false, 
          className: 'excel-checkbox-cell text-center',
          searchable: false
        },
        { 
          width: "40%", // Más espacio para nombre
          targets: 1,
          className: 'nombre-participante-cell'
          // Quitamos el render que estaba causando el problema
        },
        { 
          width: "25%", 
          targets: 2,
          className: 'usuario-cell'
        },
        { 
          width: "15%", 
          targets: 3,
          className: 'periodo-cell text-center'
        },
        { 
          width: "20%", 
          targets: 4,
          className: 'estado-cell'
        }
      ],
      
      // Forzar anchos fijos
      autoWidth: false,
      
      // Idioma en español
      "language": {
        "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json",
        buttons: {
          'pageLength': {
            _: "Mostrar %d registros",
            '-1': "Mostrar Todo"
          },
          "copySuccess": {
            "1": "Copiada 1 fila al portapapeles",
            "_": "Copiadas %d filas al portapapeles"
          },
          "copyTitle": "Copiar al portapapeles",
          "print": "Imprimir",
          "excel": "Exportar Excel", 
          "copy": "Copiar"
        }
      },
      
      // Configuración de botones y layout
      dom: 'Bfrtip',
      lengthMenu: [
        [25, 50, 100, -1],
        ['25 registros', '50 registros', '100 registros', 'Mostrar todo']
      ],
      buttons: [
        { 
          extend: 'pageLength', 
          className: 'excel-button',
          text: '<i class="fa fa-list"></i> Mostrar'
        },
        { 
          extend: 'excel', 
          className: 'excel-button',
          text: '<i class="fa fa-file-excel-o"></i> Excel'
        },
        { 
          extend: 'copy', 
          className: 'excel-button',
          text: '<i class="fa fa-copy"></i> Copiar'
        },
        { 
          extend: 'print', 
          className: 'excel-button',
          text: '<i class="fa fa-print"></i> Imprimir'
        }
      ],
      
      // Paginación
      pageLength: 25,
      
      // Búsqueda
      search: {
        "caseInsensitive": true
      },
      
      initComplete: function () {
        console.log('DataTable inicializada con anchos fijos');
        
        // Aplicar estilos personalizados a los botones de DataTables
        $('.dt-buttons .excel-button').css({
          'margin-right': '5px',
          'margin-bottom': '10px'
        });
        
        // Personalizar el wrapper de DataTables
        $('.dataTables_wrapper').addClass('excel-datatable-wrapper');
        
        // Forzar anchos después de inicialización
        this.api().columns.adjust().draw();
        
        // Añadir tooltip para nombres truncados
        $(document).on('mouseenter', '.nombre-truncado', function() {
          var nombreCompleto = $(this).attr('title');
          if (typeof Swal !== 'undefined') {
            $(this).attr('data-bs-toggle', 'tooltip');
            $(this).attr('data-bs-placement', 'top');
            $(this).attr('data-bs-title', nombreCompleto);
          }
        });
      },
      
      // Callback después de cada dibujado
      drawCallback: function() {
        // Mantener anchos después de cada redibujado
        this.api().columns.adjust();
      }
    });
  }, 300);
}

function inicializarSeleccionMasiva() {
  // Seleccionar/deseleccionar todos
  $('#selectAll, #selectAllHeader').on('change', function() {
    var isChecked = $(this).is(':checked');
    $('.user-checkbox').prop('checked', isChecked);
    $('#selectAll, #selectAllHeader').prop('checked', isChecked);
    actualizarContador();
    actualizarEstadoFilas();
  });

  // Manejar selección individual
  $(document).on('change', '.user-checkbox', function() {
    actualizarContador();
    actualizarEstadoFilas();
    
    // Actualizar estado del "seleccionar todos"
    var totalCheckboxes = $('.user-checkbox').length;
    var checkedCheckboxes = $('.user-checkbox:checked').length;
    $('#selectAll, #selectAllHeader').prop('checked', totalCheckboxes === checkedCheckboxes);
  });
}

function actualizarContador() {
  var seleccionados = $('.user-checkbox:checked').length;
  $('#contadorSeleccionados').text(seleccionados + ' seleccionados');
}

function actualizarEstadoFilas() {
  $('.user-checkbox').each(function() {
    var fila = $(this).closest('tr');
    var estadoCell = fila.find('td:last-child');
    
    if ($(this).is(':checked')) {
      fila.addClass('selected');
      estadoCell.html('<span class="excel-status-badge status-pending">Pendiente</span><div class="excel-preview">Se actualizará la contraseña</div>');
    } else {
      fila.removeClass('selected');
      var nuevaPassword = fila.data('nueva-password');
      estadoCell.html('<span class="excel-status-badge status-inactive">Sin cambios</span><div class="excel-preview">Nueva contraseña: <strong>' + nuevaPassword + '</strong></div>');
    }
  });
}

function actualizarSeleccionados() {
  var usuariosSeleccionados = [];

  var periodo = document.getElementById('selectPeriodo').value;

  if (periodo === '0') {
    alert('Selecciona periodo');
    return;
  }

  $('.user-checkbox:checked').each(function() {
    var fila = $(this).closest('tr');
    
    // DEBUG: Ver qué está undefined
    console.log('user_id:', $(this).val());
    console.log('nombre:', $(this).data('nombre'));
    console.log('nueva_password:', fila.data('nueva-password'));
    console.log('periodo:', fila.find('.periodo-cell').text().trim());
    
    usuariosSeleccionados.push({
      user_id: $(this).val(),
      nombre: $(this).data('nombre'),
      nueva_password: fila.data('nueva-password'),
      periodo: periodo      
    });

  });

  console.log('Array completo:', usuariosSeleccionados);

  if (usuariosSeleccionados.length === 0) {
    alert('Debe seleccionar al menos un usuario para actualizar.');
    return;
  }

  var mensaje = '¿Está seguro de actualizar las contraseñas de ' + usuariosSeleccionados.length + ' usuarios?';
  
  if (confirm(mensaje)) {
    ejecutarActualizacionMasiva(usuariosSeleccionados);
  }
}
function ejecutarActualizacionMasiva(usuarios) {
  $.ajax({
    type: "POST",
    url: "https://aplicacionesasig.com/index/actualizar_passwords_masivo",
    data: {
      usuarios: usuarios
    },
    dataType: 'json',
    beforeSend: function() {
      $('#al-warning-charging').modal('show');
    },
    success: function(response) {
      if (response.success) {
        alert('Contraseñas actualizadas correctamente: ' + response.actualizados + ' usuarios');
        // Recargar la tabla
        masiva(1); // o el ID que corresponda
      } else {
        alert('Error: ' + response.mensaje);
      }      
    },
    error: function() {
      alert('Error de conexión al actualizar contraseñas');
    },
    complete: function() {
      $('#al-warning-charging').modal('hide');
    }
  });
}








/*********************************************************************************************************************************************/
/***************************************************************Funcion configuracion ar********************************************************/
/*********************************************************************************************************************************************/

function configuracion3(id) {
  //alert(id);

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/configuracion3/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        //$("#configuracion1").dialog("open");
        document.getElementById('catcher'+ id).innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function help(id) {
  //alert(id);

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/help/implementacion/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        $("#help1").dialog("open");
        document.getElementById('catcher'+ id).innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function helpCap(id) {
  //alert(id);

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/help/capacitacion/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        $("#help1").dialog("open");
        document.getElementById('catcher'+ id).innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}


function configuracion31(id, id2) {
 //alert(id);

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/configuracion31/" + id + "/" + id2,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
    $('#al-warning-charging').modal('show');
    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('catcher'+ id2).innerHTML = json.descr;
        $('#classes').fadeOut('slow', function(){
          $('#classes').load(location.href + " #classes", function(){
           
            setTimeout(() => {
              $('#al-warning-charging').modal('hide');
          }, 300);
          

            
          });
      });
     
       
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

/*********************************************************************************************************************************************/
/***************************************************************Funcion Resultados********************************************************/
/*********************************************************************************************************************************************/
function MisResultados1(id) {
  //alert(id);
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/misresultados/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('catcherR').innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
//*********************************************************************************************************************************************/
/***************************************************************Funcion Resultados********************************************************/
/*********************************************************************************************************************************************/
function resultadoseje1(id) {
  //alert(id);
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/resultados2021/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('catcherR').innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/*********************************************************************************************************************************************/
/***************************************************************Funcion Resultados********************************************************/
/*********************************************************************************************************************************************/
function resultadoseje2(id) {
  //alert(id);
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/resultados1/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('catcherR').innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

/*********************************************************************************************************************************************/


function resultadosdatat1(id) {
  //alert(id);

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/resultadosdatat1/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#al-warning-charging').modal('show');
    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        document.getElementById('catcherR').innerHTML = json.descr;
        setTimeout(function () {
          $('#al-warning-charging').modal('hide');
        }, 500);
        $("#data1_file_export").dataTable().fnDestroy();
        var tabla = $('#data1_file_export').DataTable({

          fixedHeader: {
            header: true,
            footer: true
          },
          columnDefs: [
            { width: 200, targets: 0 }
          ],
          
          scrollY: '37vh',
          scrollCollapse: true,
          "language": {
            "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json",
            buttons: {
              'pageLength': {
                _: "Mostrar %d registros",
                '-1': "Mostrar Todo"
              },
              "copySuccess": {
                "1": "Copiada 1 fila al portapapeles",
                "_": "Copiadas %d filas al portapapeles"
              },
              "copyTitle": "Copiar al portapapeles",
              "print": "",
              "excel": "",
              "copy": "",

            }
          },


          dom: 'Bfrtip',
          lengthMenu: [
            [25, 50, -1],
            ['25 registros', '50 registros', 'Mostrar todo']
          ],
          buttons: {
            buttons: [
              { extend: 'pageLength', className: 'btn btn-datatble-mostrar' },

              { extend: 'excel', className: 'btn btn-datatble-excel' },
             
              { extend: 'copy', className: 'btn btn-datatble-copiar' },
              { extend: 'print', className: 'btn btn-datatble-imprimir' },


            ],

          },

          initComplete: function () {
            this.api()
              .columns(4)
              .every(function () {
                var column = this;
                var select = $('<select><option value="">Seleccióne Filtro</option></select>')
                  .appendTo($(column.header()).empty())
                  .on('change', function () {
                    var val = $.fn.dataTable.util.escapeRegex($(this).val());

                    column.search(val ? '^' + val + '$' : '', true, false).draw();
                  });

                column
                  .data()
                  .unique()
                  .sort()
                  .each(function (d, j) {
                    select.append('<option value="' + d + '">' + d + '</option>');
                  });
              });
          },

        });
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}


/**************ALTA DE ASIGNACION DE LUGAR*****************************/
function SendFRM3723(id, id2) {
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/buscar_answer_quest2/" + id + "/" + id2,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#al-warning-charging').modal('show');
      $('#resultados2').dialog('open');
    },
    success: function (json) {
      try {
        document.getElementById('catcherRP').innerHTML = json.descr;
        setTimeout(function () {
          $('#al-warning-charging').modal('hide');
        }, 500);
        
        var nombreParticipante = $('#catcherRP .CabezalForm').text().trim();
        
        $("#dataR1_file_export1").dataTable().fnDestroy();
        var tabla = $('#dataR1_file_export1').DataTable({
          fixedHeader: {
            header: true,
            footer: true
          },
          columnDefs: [
            { width: 200, targets: 0 }
          ],
          scrollY: '37vh',
          scrollCollapse: true,
          "language": {
            "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json",
            buttons: {
              'pageLength': {
                _: "Mostrar %d registros",
                '-1': "Mostrar Todo"
              },
              "copySuccess": {
                "1": "Copiada 1 fila al portapapeles",
                "_": "Copiadas %d filas al portapapeles"
              },
              "copyTitle": "Copiar al portapapeles",
              "pdf": "",
              "print": "",
              "excel": "",
              "copy": "",
            }
          },
          dom: 'Bfrtip',
          lengthMenu: [
            [25, 50, -1],
            ['25 registros', '50 registros', 'Mostrar todo']
          ],
          buttons: {
            buttons: [
              { extend: 'pageLength', className: 'btn btn-datatble-mostrar' },
              { extend: 'excel', className: 'btn btn-datatble-excel', title: nombreParticipante },
              { extend: 'pdf', className: 'btn btn-datatble-pdf', title: nombreParticipante },
              { extend: 'copy', className: 'btn btn-datatble-copiar' },
              { extend: 'print', className: 'btn btn-datatble-imprimir', title: nombreParticipante },
            ],
          },
          initComplete: function () {
            this.api()
              .columns(3)
              .every(function () {
                var column = this;
                var select = $('<select><option value="">Seleccióne Filtro</option></select>')
                  .appendTo($(column.header()).empty())
                  .on('change', function () {
                    var val = $.fn.dataTable.util.escapeRegex($(this).val());
                    column.search(val ? '^' + val + '$' : '', true, false).draw();
                  });
                column
                  .data()
                  .unique()
                  .sort()
                  .each(function (d, j) {
                    select.append('<option value="' + d + '">' + d + '</option>');
                  });
              });
          },
        });
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

function SendFRM3123(id, id2) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/buscar_answer_quest2023/" + id + "/" + id2,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#al-warning-charging').modal('show');
      $('#resultados3').dialog('open');
    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);


        document.getElementById('catcherRP3').innerHTML = json.descr;
        setTimeout(function () {
          $('#al-warning-charging').modal('hide');
        }, 500);
        /*****$("#formdata13")[0].reset();*****/
        $("#dataR1_file_export2").dataTable().fnDestroy();
        var tabla = $('#dataR1_file_export2').DataTable({

          fixedHeader: {
            header: true,
            footer: true
          },
          columnDefs: [
            { width: 200, targets: 0 }
          ],
          
          scrollY: '37vh',
          scrollCollapse: true,
          "language": {
            "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json",
            buttons: {
              'pageLength': {
                _: "Mostrar %d registros",
                '-1': "Mostrar Todo"
              },
              "copySuccess": {
                "1": "Copiada 1 fila al portapapeles",
                "_": "Copiadas %d filas al portapapeles"
              },
              "copyTitle": "Copiar al portapapeles",
              "pdf": "",
              "print": "",
              "excel": "",
              "copy": "",

            }
          },


          dom: 'Bfrtip',
          lengthMenu: [
            [25, 50, -1],
            ['25 registros', '50 registros', 'Mostrar todo']
          ],
          buttons: {
            buttons: [
              { extend: 'pageLength', className: 'btn btn-datatble-mostrar' },

              { extend: 'excel', className: 'btn btn-datatble-excel' },
              { extend: 'pdf', className: 'btn btn-datatble-pdf' },
              { extend: 'copy', className: 'btn btn-datatble-copiar' },
              { extend: 'print', className: 'btn btn-datatble-imprimir' },


            ],

          },

          initComplete: function () {
            this.api()
              .columns(3)
              .every(function () {
                var column = this;
                var select = $('<select><option value="">Seleccióne Filtro</option></select>')
                  .appendTo($(column.header()).empty())
                  .on('change', function () {
                    var val = $.fn.dataTable.util.escapeRegex($(this).val());

                    column.search(val ? '^' + val + '$' : '', true, false).draw();
                  });

                column
                  .data()
                  .unique()
                  .sort()
                  .each(function (d, j) {
                    select.append('<option value="' + d + '">' + d + '</option>');
                  });
              });
          },

        });


      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

/**************ALTA DE ASIGNACION DE LUGAR*****************************/
function SendFRM4423(id) {

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/buscar_answer_questE2023/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#al-warning-charging').modal('show');
      $('#resultados4').dialog('open');
    },
    success: function (json) {
      try {
        console.log(json.code);
        console.log(json.descr);


        document.getElementById('catcherRP4').innerHTML = json.descr;
        setTimeout(function () {
          $('#al-warning-charging').modal('hide');
        }, 500);
        /*****$("#formdata13")[0].reset();*****/
        var table = $('#example3').DataTable({
          "rowReorder": true,
          "paging": false,
          fixedHeader: {
            header: true,
            footer: true
          },
          "columnDefs": [

            { "targets": [0], "width": "20%" },
            { "targets": [1], "width": "20%" },
            { "targets": [2], "width": "2%", orderable: false, },
            { "targets": [3], "width": "7%" },

          ],
          fixedColumns: true,
          scrollY: '45vh',
          scrollCollapse: true,
          "language": {
            "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json",
            buttons: {
              'pageLength': {
                _: "Mostrar %d registros",
                '-1': "Mostrar Todo"
              },
              "copySuccess": {
                "1": "Copiada 1 fila al portapapeles",
                "_": "Copiadas %d filas al portapapeles"
              },
              "copyTitle": "Copiar al portapapeles",
              "pdf": "",
              "print": "",
              "excel": "",
              "copy": "",

            }
          },


          dom: 'Bfrtip',
          lengthMenu: [
            [25, 50, -1],
            ['25 registros', '50 registros', 'Mostrar todo']
          ],
          buttons: {
            buttons: [


              { extend: 'excel', className: 'btn btn-datatble-excel' },
              { extend: 'pdf', className: 'btn btn-datatble-pdf' },
              { extend: 'copy', className: 'btn btn-datatble-copiar' },
              { extend: 'print', className: 'btn btn-datatble-imprimir' },


            ],

          },

          initComplete: function () {
            this.api()
              .columns(3)
              .every(function () {
                var column = this;
                var select = $('<select><option value="">Seleccióne Filtro</option></select>')
                  .appendTo($(column.header()).empty())
                  .on('change', function () {
                    var val = $.fn.dataTable.util.escapeRegex($(this).val());

                    column.search(val ? '^' + val + '$' : '', true, false).draw();
                  });

                column
                  .data()
                  .unique()
                  .sort()
                  .each(function (d, j) {
                    select.append('<option value="' + d + '">' + d + '</option>');
                  });
              });
          },


        });


      } catch (e) {
      }
    },
    error: function () {
    }
  });
}





/*************************************************************/
/*************************************************************/
/**************modales*****************************/
function Sendmodal1() {

  $('#al-warning-modal1').modal('show');

}



/*************************************************************/
/*************************************************************/
/***************************GRI*****************************/
function resultadosdatat2(id) {
  //alert(id);

  $.ajax({
    type: "post",
    url: "../index/resultadosdatat2/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#al-warning-charging').modal('show');
    },
    success: function (json) {
      try {

        //console.log(json.code);
        //console.log(json.descr);
        //console.log(json.seccion1down);
        document.getElementById('catcherR').innerHTML = json.descr;
        $("#target").on("click", function () {

          var numero_aleatorio = Math.random();
          var css = "https://aplicacionesasig.com/public/css/force_impresion.css?" + numero_aleatorio;
          var ventana = window.open('', 'PRINT', 'height=600,width=800');
          var ficha = document.getElementById('myPrintArea');
          ventana.document.write('<html><head><title>' + document.title + '</title>');
          ventana.document.write('<link rel="stylesheet" href="' + css + '">'); //Aquí agregué la hoja de estilos
          ventana.document.write('</head><body style="background: url(https://aplicacionesasig.com/public/img/fondo2.jpg) repeat-y !important;  background-size:  100% 100% !important;  " >');
          ventana.document.write(ficha.innerHTML);
          ventana.document.write('</body></html>');
          ventana.document.close();
          ventana.focus();
          ventana.onload = function () {
            ventana.print();
            ventana.close();
          };
          return true;

        });


        // ------------------------------
        // Basic bar chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var myChart = echarts.init(document.getElementById("basic-bar"), null, { renderer: 'svg' });

        // specify chart configuration item and data
        var option = {
          // Setup grid
          grid: {
            left: "1%",
            right: "5%",
            bottom: "10%",
            containLabel: true,
          },

          // Add Tooltip
          tooltip: {
            trigger: "axis",
          },
          legend: {
            y: "bottom",
            data: ["Nulo", "Observación"],
          },
          toolbox: {
            show: true,
            feature: {
              magicType: { show: true, type: ["line", "bar"] },
              restore: { show: true },
              saveAsImage: { show: true },
            },
          },
          color: ["#3366cc", "#FF0000"],
          calculable: true,
          xAxis: [
            {
              type: "category",
              data: [
                "Sección I",
                "Sección II",
                "Sección III",
                "Sección IV",

              ],
            },
          ],
          yAxis: [
            {
              type: "value",
              borderColor: "rgba(0,0,0,.1)",
            },
          ],
          series: [
            {
              name: "Nulo",
              type: "bar",
              data: [
                json.seccion1down, json.seccion2down, json.seccion3down, json.seccion4down,
              ],
              markPoint: {
                data: [
                  { type: "max", name: "Max" },
                  { type: "min", name: "Min" },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
            {
              name: "Observación",
              type: "bar",
              data: [
                json.seccion1up, json.seccion2up, json.seccion3up, json.seccion4up,
              ],
              markPoint: {
                data: [
                  {
                    name: "The highest year",
                    value: json.seccion2up,
                    xAxis: 7,
                    yAxis: json.seccion2up,
                    symbolSize: 18,
                  },
                  { name: "Year minimum", value: 2.3, xAxis: 11, yAxis: 3 },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
          ],
        };
        // use configuration item and data specified to show chart
        myChart.setOption(option);
        //------------------------------------------------------
        // Resize chart on menu width change and window resize
        //------------------------------------------------------
        $(function () {
          // Resize chart on menu width change and window resize
          $(window).on("resize", resize);
          $(".sidebartoggler").on("click", resize);

          // Resize function
          function resize() {
            setTimeout(function () {
              // Resize chart
              myChart.resize();
              stackedChart.resize();
              stackedbarcolumnChart.resize();
              barbasicChart.resize();
            }, 200);
          }
        });

        setTimeout(function () {
          $('#al-warning-charging').modal('hide');
        }, 500);
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}



/*************************************************************/
/*************************************************************/
/***************************GRII*****************************/
function resultadosdatat3(id) {
  //alert(id);

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/resultadosdatat3/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#al-warning-charging').modal('show');

    },
    success: function (json) {
      try {

        console.log(json.code);
        console.log(json.descr);


        document.getElementById('catcherR').innerHTML = json.descr;

        $("#target").on("click", function () {

          var numero_aleatorio = Math.random();
          var css = "https://aplicacionesasig.com/public/css/force_impresion.css?" + numero_aleatorio;
          var ventana = window.open('', 'PRINT', 'height=600,width=800');
          var ficha = document.getElementById('myPrintArea');
          ventana.document.write('<html><head><title>' + document.title + '</title>');
          ventana.document.write('<link rel="stylesheet" href="' + css + '">'); //Aquí agregué la hoja de estilos
          ventana.document.write('</head><body style="background: url(https://aplicacionesasig.com/public/img/fondo2.jpg) repeat-y !important;  background-size:  100% 100% !important;  " >');
          ventana.document.write(ficha.innerHTML);
          ventana.document.write('</body></html>');
          ventana.document.close();
          ventana.focus();
          ventana.onload = function () {
            ventana.print();
            ventana.close();
          };
          return true;

        });
        // ------------------------------
        // Basic pie chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-pie"), null, { renderer: 'svg' });

        var option = {
          // Add title
          title: {
            text: "General",
            subtext: json.reportePie,
            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            orient: "vertical",
            x: "left",
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            orient: "vertical",
            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "70%",
              center: ["50%", "57.5%"],
              data: [
                { value: json.nulo, name: "Nulo" },
                { value: json.bajo, name: "Bajo" },
                { value: json.medio, name: "Medio" },
                { value: json.alto, name: "Alto" },
                { value: json.muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };
        basicpieChart.setOption(option);

        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // ------------------------------
        // Basic bar chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var myChart = echarts.init(document.getElementById("basic-bar"), null, { renderer: 'svg' });

        // specify chart configuration item and data
        var option = {
          // Setup grid
          grid: {
            left: "1%",
            right: "5%",
            bottom: "10%",
            containLabel: true,
          },

          // Add Tooltip
          tooltip: {
            trigger: "axis",
          },
          legend: {
            y: "bottom",

            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },
          toolbox: {
            show: true,
            feature: {

              restore: { show: true },
              saveAsImage: { show: true },
            },
          },
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],
          calculable: true,
          xAxis: [
            {
              type: "category",
              data: [json.reportePie],
            },
          ],
          yAxis: [
            {
              type: "value",
              borderColor: "rgba(0,0,0,.1)",
            },
          ],
          series: [
            {
              name: "Nulo",
              color: ["#1e88e5 "],
              type: "bar",
              data: [
                json.nulo,
              ],


            },
            {
              name: "Bajo",
              type: "bar",
              color: ["#00acc1"],

              data: [
                json.bajo
              ],


            },
            {
              name: "Medio",
              type: "bar",
              color: ["#ffbc34"],

              data: [
                json.medio
              ],


            },
            {
              name: "Alto",
              type: "bar",
              color: ["#E89608"],

              data: [
                json.alto
              ],


            },
            {
              name: "Muy Alto",
              type: "bar",
              color: ["#f62d51"],

              data: [
                json.muyalto
              ],


            },

          ],
        };
        // use configuration item and data specified to show chart
        myChart.setOption(option);

        // ------------------------------
        // Basic bar chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var myChart = echarts.init(document.getElementById("basic-bar1"), null, { renderer: 'svg' });

        // specify chart configuration item and data
        var option = {
          // Setup grid
          grid: {
            left: "1%",
            right: "5%",
            bottom: "10%",
            containLabel: true,
          },

          // Add Tooltip
          tooltip: {
            trigger: "axis",
          },
          legend: {
            y: "bottom",

            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },
          toolbox: {
            show: true,
            feature: {
              magicType: { show: true, type: ["line", "bar"] },
              restore: { show: true },
              saveAsImage: { show: true },
            },
          },
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],
          calculable: true,
          xAxis: [
            {
              type: "category",
              data: [
                "Ambiente",
                "Factores",
                "Organización",
                "Liderazgo",
                "Entorno",

              ],
            },
          ],
          yAxis: [
            {
              type: "value",
              borderColor: "rgba(0,0,0,.1)",
            },
          ],
          series: [
            {
              name: "Nulo",
              type: "bar",
              data: [
                json.ambiente_nulo, json.factores_nulo, json.organizacion_nulo, json.liderazgo_nulo, json.entorno_nulo,
              ],
              markPoint: {
                data: [
                  { type: "max", name: "Max" },
                  { type: "min", name: "Min" },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
            {
              name: "Bajo",
              type: "bar",
              data: [
                json.ambiente_bajo, json.factores_bajo, json.organizacion_bajo, json.liderazgo_bajo, json.entorno_bajo,
              ],
              markPoint: {
                data: [
                  {
                    name: "The highest year",
                    value: 182.2,
                    xAxis: 7,
                    yAxis: 183,
                    symbolSize: 18,
                  },
                  { name: "Year minimum", value: 2.3, xAxis: 11, yAxis: 3 },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
            {
              name: "Medio",
              type: "bar",
              data: [
                json.ambiente_medio, json.factores_medio, json.organizacion_medio, json.liderazgo_medio, json.entorno_medio,
              ],
              markPoint: {
                data: [
                  {
                    name: "The highest year",
                    value: 182.2,
                    xAxis: 7,
                    yAxis: 183,
                    symbolSize: 18,
                  },
                  { name: "Year minimum", value: 2.3, xAxis: 11, yAxis: 3 },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
            {
              name: "Alto",
              type: "bar",
              data: [
                json.ambiente_alto, json.factores_alto, json.organizacion_alto, json.liderazgo_alto, json.entorno_alto,
              ],
              markPoint: {
                data: [
                  {
                    name: "The highest year",
                    value: 182.2,
                    xAxis: 7,
                    yAxis: 183,
                    symbolSize: 18,
                  },
                  { name: "Year minimum", value: 2.3, xAxis: 11, yAxis: 3 },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
            {
              name: "Muy Alto",
              type: "bar",
              data: [
                json.ambiente_muyalto, json.factores_muyalto, json.organizacion_muyalto, json.liderazgo_muyalto, json.entorno_muyalto,
              ],
              markPoint: {
                data: [
                  {
                    name: "The highest year",
                    value: 182.2,
                    xAxis: 7,
                    yAxis: 183,
                    symbolSize: 18,
                  },
                  { name: "Year minimum", value: 2.3, xAxis: 11, yAxis: 3 },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
          ],
        };
        // use configuration item and data specified to show chart
        myChart.setOption(option);

        // ------------------------------
        // Basic pie chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-piea"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.ambiente_nulo, name: "Nulo" },
                { value: json.ambiente_bajo, name: "Bajo" },
                { value: json.ambiente_medio, name: "Medio" },
                { value: json.ambiente_alto, name: "Alto" },
                { value: json.ambiente_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-pief"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.factores_nulo, name: "Nulo" },
                { value: json.factores_bajo, name: "Bajo" },
                { value: json.factores_medio, name: "Medio" },
                { value: json.factores_alto, name: "Alto" },
                { value: json.factores_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------// ------------------------------
        // Basic pie chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-pieo"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.organizacion_nulo, name: "Nulo" },
                { value: json.organizacion_bajo, name: "Bajo" },
                { value: json.organizacion_medio, name: "Medio" },
                { value: json.organizacion_alto, name: "Alto" },
                { value: json.organizacion_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-piel"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.liderazgo_nulo, name: "Nulo" },
                { value: json.liderazgo_bajo, name: "Bajo" },
                { value: json.liderazgo_medio, name: "Medio" },
                { value: json.liderazgo_alto, name: "Alto" },
                { value: json.liderazgo_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-piee"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.entorno_nulo, name: "Nulo" },
                { value: json.entorno_bajo, name: "Bajo" },
                { value: json.entorno_medio, name: "Medio" },
                { value: json.entorno_alto, name: "Alto" },
                { value: json.entorno_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------
        // ------------------------------
        // Basic bar chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var myChart = echarts.init(document.getElementById("basic-bar2"), null, { renderer: 'svg' });

        // specify chart configuration item and data
        var option = {
          // Setup grid
          grid: {
            left: "1%",
            right: "5%",
            bottom: "10%",
            containLabel: true,
          },

          // Add Tooltip
          tooltip: {
            trigger: "axis",
          },
          legend: {
            y: "bottom",

            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },
          toolbox: {
            show: true,
            feature: {
              magicType: { show: true, type: ["line", "bar"] },
              restore: { show: true },
              saveAsImage: { show: true },
            },
          },
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],
          calculable: true,
          xAxis: [
            {
              type: "category",

              data: [
                "Cond..",
                "Trab..",
                "Con..",
                "Jor..",
                "Inter..",
                "Lider..",
                "Rel..",
                "Viol..",
                "Reco..",
                "Insu..",

              ],
            },
          ],
          yAxis: [
            {
              type: "value",
              borderColor: "rgba(0,0,0,.1)",
            },
          ],
          series: [
            {
              name: "Nulo",
              type: "bar",
              data: [
                json.ambiente_nulo, json.trabajo_nulo, json.control_nulo, json.jornada_nulo, json.interferencia_nulo, json.liderazgo2_nulo, json.relaciones_nulo, json.violencia_nulo, json.reconocimiento_nulo, json.insuficiente_nulo,
              ],
              markPoint: {
                data: [
                  { type: "max", name: "Max" },
                  { type: "min", name: "Min" },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
            {
              name: "Bajo",
              type: "bar",
              data: [
                json.ambiente_bajo, json.trabajo_bajo, json.control_bajo, json.jornada_bajo, json.interferencia_bajo, json.liderazgo2_bajo, json.relaciones_bajo, json.violencia_bajo, json.reconocimiento_bajo, json.insuficiente_bajo,
              ],
              markPoint: {
                data: [
                  {
                    name: "The highest year",
                    value: 182.2,
                    xAxis: 7,
                    yAxis: 183,
                    symbolSize: 18,
                  },
                  { name: "Year minimum", value: 2.3, xAxis: 11, yAxis: 3 },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
            {
              name: "Medio",
              type: "bar",
              data: [
                json.ambiente_medio, json.trabajo_medio, json.control_medio, json.jornada_medio, json.interferencia_medio, json.liderazgo2_medio, json.relaciones_medio, json.violencia_medio, json.reconocimiento_medio, json.insuficiente_medio,
              ],
              markPoint: {
                data: [
                  {
                    name: "The highest year",
                    value: 182.2,
                    xAxis: 7,
                    yAxis: 183,
                    symbolSize: 18,
                  },
                  { name: "Year minimum", value: 2.3, xAxis: 11, yAxis: 3 },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
            {
              name: "Alto",
              type: "bar",
              data: [
                json.ambiente_alto, json.trabajo_alto, json.control_alto, json.jornada_alto, json.interferencia_alto, json.liderazgo2_alto, json.relaciones_alto, json.violencia_alto, json.reconocimiento_alto, json.insuficiente_alto,
              ],
              markPoint: {
                data: [
                  {
                    name: "The highest year",
                    value: 182.2,
                    xAxis: 7,
                    yAxis: 183,
                    symbolSize: 18,
                  },
                  { name: "Year minimum", value: 2.3, xAxis: 11, yAxis: 3 },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
            {
              name: "Muy Alto",
              type: "bar",
              data: [
                json.ambiente_muyalto, json.trabajo_muyalto, json.control_muyalto, json.jornada_muyalto, json.interferencia_muyalto, json.liderazgo2_muyalto, json.relaciones_muyalto, json.violencia_muyalto, json.reconocimiento_muyalto, json.insuficiente_muyalto,
              ],
              markPoint: {
                data: [
                  {
                    name: "The highest year",
                    value: 182.2,
                    xAxis: 7,
                    yAxis: 183,
                    symbolSize: 18,
                  },
                  { name: "Year minimum", value: 2.3, xAxis: 11, yAxis: 3 },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
          ],
        };
        // use configuration item and data specified to show chart
        myChart.setOption(option);

        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-piec"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.ambiente_nulo, name: "Nulo" },
                { value: json.ambiente_bajo, name: "Bajo" },
                { value: json.ambiente_medio, name: "Medio" },
                { value: json.ambiente_alto, name: "Alto" },
                { value: json.ambiente_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-piet"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.trabajo_nulo, name: "Nulo" },
                { value: json.trabajo_bajo, name: "Bajo" },
                { value: json.trabajo_medio, name: "Medio" },
                { value: json.trabajo_alto, name: "Alto" },
                { value: json.trabajo_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------// ------------------------------
        // Basic pie chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-pief2"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.control_nulo, name: "Nulo" },
                { value: json.control_bajo, name: "Bajo" },
                { value: json.control_medio, name: "Medio" },
                { value: json.control_alto, name: "Alto" },
                { value: json.control_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-piej"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.jornada_nulo, name: "Nulo" },
                { value: json.jornada_bajo, name: "Bajo" },
                { value: json.jornada_medio, name: "Medio" },
                { value: json.jornada_alto, name: "Alto" },
                { value: json.jornada_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-piein"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.interferencia_nulo, name: "Nulo" },
                { value: json.interferencia_bajo, name: "Bajo" },
                { value: json.interferencia_medio, name: "Medio" },
                { value: json.interferencia_alto, name: "Alto" },
                { value: json.interferencia_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-pieli"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.liderazgo2_nulo, name: "Nulo" },
                { value: json.liderazgo2_bajo, name: "Bajo" },
                { value: json.liderazgo2_medio, name: "Medio" },
                { value: json.liderazgo2_alto, name: "Alto" },
                { value: json.liderazgo2_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------// ------------------------------
        // Basic pie chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-piere"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.relaciones_nulo, name: "Nulo" },
                { value: json.relaciones_bajo, name: "Bajo" },
                { value: json.relaciones_medio, name: "Medio" },
                { value: json.relaciones_alto, name: "Alto" },
                { value: json.relaciones_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-pievi"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.violencia_nulo, name: "Nulo" },
                { value: json.violencia_bajo, name: "Bajo" },
                { value: json.violencia_medio, name: "Medio" },
                { value: json.violencia_alto, name: "Alto" },
                { value: json.violencia_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------
        // ------------------------------// ------------------------------
        // Basic pie chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-pierec"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.reconocimiento_nulo, name: "Nulo" },
                { value: json.reconocimiento_bajo, name: "Bajo" },
                { value: json.reconocimiento_medio, name: "Medio" },
                { value: json.reconocimiento_alto, name: "Alto" },
                { value: json.reconocimiento_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-pieins"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.insuficiente_nulo, name: "Nulo" },
                { value: json.insuficiente_bajo, name: "Bajo" },
                { value: json.insuficiente_medio, name: "Medio" },
                { value: json.insuficiente_alto, name: "Alto" },
                { value: json.insuficiente_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        setTimeout(function () {
          $('#al-warning-charging').modal('hide');
        }, 500);









      } catch (e) {
      }
    },
    error: function () {
    }
  });
}



/**************Cuestionario1 p6*****************************/
function datapies(id) {
  // based on prepared DOM, initialize echarts instance
  alert(id);
  var basicpieChart = echarts.init(document.getElementById("basic-pie"));
  var option = {
    // Add title
    title: {
      text: "Browser popularity",
      subtext: "Open source information",
      x: "center",
    },

    // Add tooltip
    tooltip: {
      trigger: "item",
      formatter: "{a} <br/>{b}: {c} ({d}%)",
    },

    // Add legend
    legend: {
      orient: "vertical",
      x: "left",
      data: ["IE", "Opera", "Safari", "Firefox", "Chrome"],
    },

    // Add custom colors
    color: ["#ffbc34", "#00acc1", "#212529", "#f62d51", "#1e88e5"],

    // Display toolbox
    toolbox: {
      show: true,
      orient: "vertical",
      feature: {
        mark: {
          show: true,
          title: {
            mark: "Markline switch",
            markUndo: "Undo markline",
            markClear: "Clear markline",
          },
        },
        dataView: {
          show: true,
          readOnly: false,
          title: "View data",
          lang: ["View chart data", "Close", "Update"],
        },
        magicType: {
          show: true,
          title: {
            pie: "Switch to pies",
            funnel: "Switch to funnel",
          },
          type: ["pie", "funnel"],
          option: {
            funnel: {
              x: "25%",
              y: "20%",
              width: "50%",
              height: "70%",
              funnelAlign: "left",
              max: 1548,
            },
          },
        },
        restore: {
          show: true,
          title: "Restore",
        },
        saveAsImage: {
          show: true,
          title: "Same as image",
          lang: ["Save"],
        },
      },
    },

    // Enable drag recalculate
    calculable: true,

    // Add series
    series: [
      {
        name: "Browsers",
        type: "pie",
        radius: "70%",
        center: ["50%", "57.5%"],
        data: [
          { value: 335, name: "IE" },
          { value: 310, name: "Opera" },
          { value: 234, name: "Safari" },
          { value: 135, name: "Firefox" },
          { value: 1548, name: "Chrome" },
        ],
      },
    ],
  };

  basicpieChart.setOption(option);
  // ------------------------------
  // Basic pie chart
}


/*************************************************************/
/*************************************************************/
/***************************DICTAMEN*****************************/
function resultadosdatat4(id) {
  //alert(id);

  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/resultadosdatat4/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      $('#al-warning-charging').modal('show');

    },
    success: function (json) {
      try {

        console.log(json.code);
        console.log(json.descr);


        document.getElementById('catcherR').innerHTML = json.descr;

        $("#target").on("click", function () {

          var numero_aleatorio = Math.random();
          var css = "https://aplicacionesasig.com/public/css/force_impresion.css?" + numero_aleatorio;
          var ventana = window.open('', 'PRINT', 'height=600,width=800');
          var ficha = document.getElementById('myPrintArea');
          ventana.document.write('<html><head><title>' + document.title + '</title>');
          ventana.document.write('<link rel="stylesheet" href="' + css + '">'); //Aquí agregué la hoja de estilos
          ventana.document.write('</head><body style="background: url(https://aplicacionesasig.com/public/img/fondo2.jpg) repeat-y !important;  background-size:  100% 100% !important;  " >');
          ventana.document.write(ficha.innerHTML);
          ventana.document.write('</body></html>');
          ventana.document.close();
          ventana.focus();
          ventana.onload = function () {
            ventana.print();
            ventana.close();
          };
          return true;

        });

        // ------------------------------
        // Basic bar chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var myChart = echarts.init(document.getElementById("basic-bar0"), null, { renderer: 'svg' });

        // specify chart configuration item and data
        var option = {
          // Setup grid
          grid: {
            left: "1%",
            right: "5%",
            bottom: "10%",
            containLabel: true,
          },

          // Add Tooltip
          tooltip: {
            trigger: "axis",
          },
          legend: {
            y: "bottom",
            data: ["Nulo", "Observación"],
          },
          toolbox: {
            show: true,
            feature: {
              magicType: { show: true, type: ["line", "bar"] },
              restore: { show: true },
              saveAsImage: { show: true },
            },
          },
          color: ["#3366cc", "#FF0000"],
          calculable: true,
          xAxis: [
            {
              type: "category",
              data: [
                "Sección I",
                "Sección II",
                "Sección III",
                "Sección IV",

              ],
            },
          ],
          yAxis: [
            {
              type: "value",
              borderColor: "rgba(0,0,0,.1)",
            },
          ],
          series: [
            {
              name: "Nulo",
              type: "bar",
              data: [
                json.seccion1down, json.seccion2down, json.seccion3down, json.seccion4down,
              ],
              markPoint: {
                data: [
                  { type: "max", name: "Max" },
                  { type: "min", name: "Min" },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
            {
              name: "Observación",
              type: "bar",
              data: [
                json.seccion1up, json.seccion2up, json.seccion3up, json.seccion4up,
              ],
              markPoint: {
                data: [
                  {
                    name: "The highest year",
                    value: json.seccion2up,
                    xAxis: 7,
                    yAxis: json.seccion2up,
                    symbolSize: 18,
                  },
                  { name: "Year minimum", value: 2.3, xAxis: 11, yAxis: 3 },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
          ],
        };
        // use configuration item and data specified to show chart
        myChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-pie"), null, { renderer: 'svg' });

        var option = {
          // Add title
          title: {
            text: "General",
            subtext: json.reportePie,
            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            orient: "vertical",
            x: "left",
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            orient: "vertical",
            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "70%",
              center: ["50%", "57.5%"],
              data: [
                { value: json.nulo, name: "Nulo" },
                { value: json.bajo, name: "Bajo" },
                { value: json.medio, name: "Medio" },
                { value: json.alto, name: "Alto" },
                { value: json.muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };
        basicpieChart.setOption(option);

        // ------------------------------
        // Basic pie chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var myChart = echarts.init(document.getElementById("basic-bar1"), null, { renderer: 'svg' });

        // specify chart configuration item and data
        var option = {
          // Setup grid
          grid: {
            left: "1%",
            right: "5%",
            bottom: "10%",
            containLabel: true,
          },

          // Add Tooltip
          tooltip: {
            trigger: "axis",
          },
          legend: {
            y: "bottom",

            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },
          toolbox: {
            show: true,
            feature: {
              magicType: { show: true, type: ["line", "bar"] },
              restore: { show: true },
              saveAsImage: { show: true },
            },
          },
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],
          calculable: true,
          xAxis: [
            {
              type: "category",
              data: [
                "Ambiente",
                "Factores",
                "Organización",
                "Liderazgo",
                "Entorno",

              ],
            },
          ],
          yAxis: [
            {
              type: "value",
              borderColor: "rgba(0,0,0,.1)",
            },
          ],
          series: [
            {
              name: "Nulo",
              type: "bar",
              data: [
                json.ambiente_nulo, json.factores_nulo, json.organizacion_nulo, json.liderazgo_nulo, json.entorno_nulo,
              ],
              markPoint: {
                data: [
                  { type: "max", name: "Max" },
                  { type: "min", name: "Min" },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
            {
              name: "Bajo",
              type: "bar",
              data: [
                json.ambiente_bajo, json.factores_bajo, json.organizacion_bajo, json.liderazgo_bajo, json.entorno_bajo,
              ],
              markPoint: {
                data: [
                  {
                    name: "The highest year",
                    value: 182.2,
                    xAxis: 7,
                    yAxis: 183,
                    symbolSize: 18,
                  },
                  { name: "Year minimum", value: 2.3, xAxis: 11, yAxis: 3 },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
            {
              name: "Medio",
              type: "bar",
              data: [
                json.ambiente_medio, json.factores_medio, json.organizacion_medio, json.liderazgo_medio, json.entorno_medio,
              ],
              markPoint: {
                data: [
                  {
                    name: "The highest year",
                    value: 182.2,
                    xAxis: 7,
                    yAxis: 183,
                    symbolSize: 18,
                  },
                  { name: "Year minimum", value: 2.3, xAxis: 11, yAxis: 3 },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
            {
              name: "Alto",
              type: "bar",
              data: [
                json.ambiente_alto, json.factores_alto, json.organizacion_alto, json.liderazgo_alto, json.entorno_alto,
              ],
              markPoint: {
                data: [
                  {
                    name: "The highest year",
                    value: 182.2,
                    xAxis: 7,
                    yAxis: 183,
                    symbolSize: 18,
                  },
                  { name: "Year minimum", value: 2.3, xAxis: 11, yAxis: 3 },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
            {
              name: "Muy Alto",
              type: "bar",
              data: [
                json.ambiente_muyalto, json.factores_muyalto, json.organizacion_muyalto, json.liderazgo_muyalto, json.entorno_muyalto,
              ],
              markPoint: {
                data: [
                  {
                    name: "The highest year",
                    value: 182.2,
                    xAxis: 7,
                    yAxis: 183,
                    symbolSize: 18,
                  },
                  { name: "Year minimum", value: 2.3, xAxis: 11, yAxis: 3 },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
          ],
        };
        // use configuration item and data specified to show chart
        myChart.setOption(option);

        // ------------------------------
        // Basic pie chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-piea"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.ambiente_nulo, name: "Nulo" },
                { value: json.ambiente_bajo, name: "Bajo" },
                { value: json.ambiente_medio, name: "Medio" },
                { value: json.ambiente_alto, name: "Alto" },
                { value: json.ambiente_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-pief"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.factores_nulo, name: "Nulo" },
                { value: json.factores_bajo, name: "Bajo" },
                { value: json.factores_medio, name: "Medio" },
                { value: json.factores_alto, name: "Alto" },
                { value: json.factores_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------// ------------------------------
        // Basic pie chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-pieo"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.organizacion_nulo, name: "Nulo" },
                { value: json.organizacion_bajo, name: "Bajo" },
                { value: json.organizacion_medio, name: "Medio" },
                { value: json.organizacion_alto, name: "Alto" },
                { value: json.organizacion_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-piel"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.liderazgo_nulo, name: "Nulo" },
                { value: json.liderazgo_bajo, name: "Bajo" },
                { value: json.liderazgo_medio, name: "Medio" },
                { value: json.liderazgo_alto, name: "Alto" },
                { value: json.liderazgo_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-piee"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.entorno_nulo, name: "Nulo" },
                { value: json.entorno_bajo, name: "Bajo" },
                { value: json.entorno_medio, name: "Medio" },
                { value: json.entorno_alto, name: "Alto" },
                { value: json.entorno_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------
        // ------------------------------
        // Basic bar chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var myChart = echarts.init(document.getElementById("basic-bar2"), null, { renderer: 'svg' });

        // specify chart configuration item and data
        var option = {
          // Setup grid
          grid: {
            left: "1%",
            right: "5%",
            bottom: "10%",
            containLabel: true,
          },

          // Add Tooltip
          tooltip: {
            trigger: "axis",
          },
          legend: {
            y: "bottom",

            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },
          toolbox: {
            show: true,
            feature: {
              magicType: { show: true, type: ["line", "bar"] },
              restore: { show: true },
              saveAsImage: { show: true },
            },
          },
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],
          calculable: true,
          xAxis: [
            {
              type: "category",

              data: [
                "Cond..",
                "Trab..",
                "Con..",
                "Jor..",
                "Inter..",
                "Lider..",
                "Rel..",
                "Viol..",
                "Reco..",
                "Insu..",

              ],
            },
          ],
          yAxis: [
            {
              type: "value",
              borderColor: "rgba(0,0,0,.1)",
            },
          ],
          series: [
            {
              name: "Nulo",
              type: "bar",
              data: [
                json.ambiente_nulo, json.trabajo_nulo, json.control_nulo, json.jornada_nulo, json.interferencia_nulo, json.liderazgo2_nulo, json.relaciones_nulo, json.violencia_nulo, json.reconocimiento_nulo, json.insuficiente_nulo,
              ],
              markPoint: {
                data: [
                  { type: "max", name: "Max" },
                  { type: "min", name: "Min" },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
            {
              name: "Bajo",
              type: "bar",
              data: [
                json.ambiente_bajo, json.trabajo_bajo, json.control_bajo, json.jornada_bajo, json.interferencia_bajo, json.liderazgo2_bajo, json.relaciones_bajo, json.violencia_bajo, json.reconocimiento_bajo, json.insuficiente_bajo,
              ],
              markPoint: {
                data: [
                  {
                    name: "The highest year",
                    value: 182.2,
                    xAxis: 7,
                    yAxis: 183,
                    symbolSize: 18,
                  },
                  { name: "Year minimum", value: 2.3, xAxis: 11, yAxis: 3 },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
            {
              name: "Medio",
              type: "bar",
              data: [
                json.ambiente_medio, json.trabajo_medio, json.control_medio, json.jornada_medio, json.interferencia_medio, json.liderazgo2_medio, json.relaciones_medio, json.violencia_medio, json.reconocimiento_medio, json.insuficiente_medio,
              ],
              markPoint: {
                data: [
                  {
                    name: "The highest year",
                    value: 182.2,
                    xAxis: 7,
                    yAxis: 183,
                    symbolSize: 18,
                  },
                  { name: "Year minimum", value: 2.3, xAxis: 11, yAxis: 3 },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
            {
              name: "Alto",
              type: "bar",
              data: [
                json.ambiente_alto, json.trabajo_alto, json.control_alto, json.jornada_alto, json.interferencia_alto, json.liderazgo2_alto, json.relaciones_alto, json.violencia_alto, json.reconocimiento_alto, json.insuficiente_alto,
              ],
              markPoint: {
                data: [
                  {
                    name: "The highest year",
                    value: 182.2,
                    xAxis: 7,
                    yAxis: 183,
                    symbolSize: 18,
                  },
                  { name: "Year minimum", value: 2.3, xAxis: 11, yAxis: 3 },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
            {
              name: "Muy Alto",
              type: "bar",
              data: [
                json.ambiente_muyalto, json.trabajo_muyalto, json.control_muyalto, json.jornada_muyalto, json.interferencia_muyalto, json.liderazgo2_muyalto, json.relaciones_muyalto, json.violencia_muyalto, json.reconocimiento_muyalto, json.insuficiente_muyalto,
              ],
              markPoint: {
                data: [
                  {
                    name: "The highest year",
                    value: 182.2,
                    xAxis: 7,
                    yAxis: 183,
                    symbolSize: 18,
                  },
                  { name: "Year minimum", value: 2.3, xAxis: 11, yAxis: 3 },
                ],
              },
              markLine: {
                data: [{ type: "average", name: "Average" }],
              },
            },
          ],
        };
        // use configuration item and data specified to show chart
        myChart.setOption(option);

        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-piec"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.ambiente_nulo, name: "Nulo" },
                { value: json.ambiente_bajo, name: "Bajo" },
                { value: json.ambiente_medio, name: "Medio" },
                { value: json.ambiente_alto, name: "Alto" },
                { value: json.ambiente_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-piet"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.trabajo_nulo, name: "Nulo" },
                { value: json.trabajo_bajo, name: "Bajo" },
                { value: json.trabajo_medio, name: "Medio" },
                { value: json.trabajo_alto, name: "Alto" },
                { value: json.trabajo_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------// ------------------------------
        // Basic pie chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-pief2"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.control_nulo, name: "Nulo" },
                { value: json.control_bajo, name: "Bajo" },
                { value: json.control_medio, name: "Medio" },
                { value: json.control_alto, name: "Alto" },
                { value: json.control_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-piej"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.jornada_nulo, name: "Nulo" },
                { value: json.jornada_bajo, name: "Bajo" },
                { value: json.jornada_medio, name: "Medio" },
                { value: json.jornada_alto, name: "Alto" },
                { value: json.jornada_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-piein"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.interferencia_nulo, name: "Nulo" },
                { value: json.interferencia_bajo, name: "Bajo" },
                { value: json.interferencia_medio, name: "Medio" },
                { value: json.interferencia_alto, name: "Alto" },
                { value: json.interferencia_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-pieli"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.liderazgo2_nulo, name: "Nulo" },
                { value: json.liderazgo2_bajo, name: "Bajo" },
                { value: json.liderazgo2_medio, name: "Medio" },
                { value: json.liderazgo2_alto, name: "Alto" },
                { value: json.liderazgo2_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------// ------------------------------
        // Basic pie chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-piere"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.relaciones_nulo, name: "Nulo" },
                { value: json.relaciones_bajo, name: "Bajo" },
                { value: json.relaciones_medio, name: "Medio" },
                { value: json.relaciones_alto, name: "Alto" },
                { value: json.relaciones_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-pievi"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.violencia_nulo, name: "Nulo" },
                { value: json.violencia_bajo, name: "Bajo" },
                { value: json.violencia_medio, name: "Medio" },
                { value: json.violencia_alto, name: "Alto" },
                { value: json.violencia_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------
        // ------------------------------// ------------------------------
        // Basic pie chart
        // ------------------------------
        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-pierec"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.reconocimiento_nulo, name: "Nulo" },
                { value: json.reconocimiento_bajo, name: "Bajo" },
                { value: json.reconocimiento_medio, name: "Medio" },
                { value: json.reconocimiento_alto, name: "Alto" },
                { value: json.reconocimiento_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        // based on prepared DOM, initialize echarts instance
        var basicpieChart = echarts.init(document.getElementById("basic-pieins"), null, { renderer: 'svg' });
        var option = {
          // Add title
          title: {

            x: "center",
          },

          // Add tooltip
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b}: {c} ({d}%)",
          },

          // Add legend
          legend: {
            // orient: "vertical",
            //x: "left",
            y: "bottom",
            padding: 0,
            itemGap: 3,
            textStyle: {
              fontSize: '10',
            },
            data: ["Nulo", "Bajo", "Medio", "Alto", "Muy Alto"],
          },

          // Add custom colors
          color: ["#1e88e5 ", "#00acc1", "#ffbc34", "#E89608", "#f62d51"],

          // Display toolbox
          toolbox: {
            show: true,
            //orient: "vertical",
            y: "top",

            feature: {
              mark: {
                show: true,
                title: {
                  mark: "Markline switch",
                  markUndo: "Undo markline",
                  markClear: "Clear markline",
                },
              },
              dataView: {
                show: true,
                readOnly: false,
                title: "View data",
                lang: ["View chart data", "Close", "Update"],
              },
              magicType: {
                show: true,
                title: {
                  pie: "Switch to pies",
                  funnel: "Switch to funnel",
                },
                type: ["pie", "funnel"],
                option: {
                  funnel: {
                    x: "25%",
                    y: "20%",
                    width: "50%",
                    height: "70%",
                    funnelAlign: "left",
                    max: 1548,
                  },
                },
              },
              restore: {
                show: true,
                title: "Restore",
              },
              saveAsImage: {
                show: true,
                title: "Same as image",
                lang: ["Save"],
              },
            },
          },

          // Enable drag recalculate
          calculable: true,

          // Add series
          series: [
            {
              name: "Participantes",
              type: "pie",
              radius: "65%",
              center: ["50%", "52.5%"],
              data: [
                { value: json.insuficiente_nulo, name: "Nulo" },
                { value: json.insuficiente_bajo, name: "Bajo" },
                { value: json.insuficiente_medio, name: "Medio" },
                { value: json.insuficiente_alto, name: "Alto" },
                { value: json.insuficiente_muyalto, name: "Muy Alto" },
              ],
            },
          ],
        };

        basicpieChart.setOption(option);
        // ------------------------------
        // Basic pie chart
        // ------------------------------

        setTimeout(function () {
          $('#al-warning-charging').modal('hide');
        }, 500);









      } catch (e) {
      }
    },
    error: function () {
    }
  });
}



/**************Cuestionario1 p6*****************************/
function datapies(id) {
  // based on prepared DOM, initialize echarts instance
  alert(id);
  var basicpieChart = echarts.init(document.getElementById("basic-pie"));
  var option = {
    // Add title
    title: {
      text: "Browser popularity",
      subtext: "Open source information",
      x: "center",
    },

    // Add tooltip
    tooltip: {
      trigger: "item",
      formatter: "{a} <br/>{b}: {c} ({d}%)",
    },

    // Add legend
    legend: {
      orient: "vertical",
      x: "left",
      data: ["IE", "Opera", "Safari", "Firefox", "Chrome"],
    },

    // Add custom colors
    color: ["#ffbc34", "#00acc1", "#212529", "#f62d51", "#1e88e5"],

    // Display toolbox
    toolbox: {
      show: true,
      orient: "vertical",
      feature: {
        mark: {
          show: true,
          title: {
            mark: "Markline switch",
            markUndo: "Undo markline",
            markClear: "Clear markline",
          },
        },
        dataView: {
          show: true,
          readOnly: false,
          title: "View data",
          lang: ["View chart data", "Close", "Update"],
        },
        magicType: {
          show: true,
          title: {
            pie: "Switch to pies",
            funnel: "Switch to funnel",
          },
          type: ["pie", "funnel"],
          option: {
            funnel: {
              x: "25%",
              y: "20%",
              width: "50%",
              height: "70%",
              funnelAlign: "left",
              max: 1548,
            },
          },
        },
        restore: {
          show: true,
          title: "Restore",
        },
        saveAsImage: {
          show: true,
          title: "Same as image",
          lang: ["Save"],
        },
      },
    },

    // Enable drag recalculate
    calculable: true,

    // Add series
    series: [
      {
        name: "Browsers",
        type: "pie",
        radius: "70%",
        center: ["50%", "57.5%"],
        data: [
          { value: 335, name: "IE" },
          { value: 310, name: "Opera" },
          { value: 234, name: "Safari" },
          { value: 135, name: "Firefox" },
          { value: 1548, name: "Chrome" },
        ],
      },
    ],
  };

  basicpieChart.setOption(option);
  // ------------------------------
  // Basic pie chart
}




/***************************************************************Funcion Comparación********************************************************/
/*********************************************************************************************************************************************/




function comparacion0(id) {
  //alert(id);
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/index/comparacion0/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      
      $('#al-warning-charging').modal('show');
    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        setTimeout(function () {
          $('#al-warning-charging').modal('hide');
        }, 500);
       
        document.getElementById('catcherR').innerHTML = json.descr;
        $('#al-warning-charging').modal('hide');
        $("#file_export").dataTable().fnDestroy();
        var tabla = $('#file_export').DataTable({

          "rowReorder": true,
          scrollX: true,
          scrollY: '45vh',
          "scrollCollapse": true,

          fixedColumns: {
            left: 50,

          },

          fixedHeader: {
            header: true,
            footer: true
          },
          "columnDefs": [

            { "targets": [0], "width": "10%" },
            { "targets": [1], "width": "10%", orderable: false, },
            { "targets": [2], "width": "10%" },
            { "targets": [3], "width": "10%", orderable: false, },
            { "targets": [4], "width": "10%" },
            { "targets": [5], "width": "10%", orderable: false, },
            { "targets": [6], "width": "10%" },
            { "targets": [7], "width": "10%", orderable: false, },
            { "targets": [8], "width": "10%" },
            { "targets": [9], "width": "10%", orderable: false, },
            { "targets": [10], "width": "10%" },
            { "targets": [11], "width": "10%" },
            { "targets": [12], "width": "10%" },
            { "targets": [13], "width": "10%" },
          ],

          "language": {
            "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json",
            buttons: {
              'pageLength': {
                _: "Mostrar %d registros",
                '-1': "Mostrar Todo"
              },
              "copySuccess": {
                "1": "Copiada 1 fila al portapapeles",
                "_": "Copiadas %d filas al portapapeles"
              },
              "copyTitle": "Copiar al portapapeles",
              "print": "",
              "excel": "",
              "copy": "",

            }
          },


          dom: 'Bfrtip',
          lengthMenu: [
            [25, 50, -1],
            ['25 registros', '50 registros', 'Mostrar todo']
          ],
          buttons: {
            buttons: [
              { extend: 'pageLength', className: 'btn btn-datatble-mostrar' },

              { extend: 'excel', className: 'btn btn-datatble-excel', filename: "Comparación APIL", },
             
              { extend: 'copy', className: 'btn btn-datatble-copiar' },
              { extend: 'print', className: 'btn btn-datatble-imprimir' },


            ],

          },

          initComplete: function () {
            this.api()
              .columns([2, 4, 6, 8, 10, 11, 12, 13])
              .every(function () {
                var column = this;
                var select = $('<select  style="width:100px !important;"><option value="">Seleccióne Filtro</option></select>')
                  .appendTo($(column.header()).empty())
                  .on('change', function () {
                    var val = $.fn.dataTable.util.escapeRegex($(this).val());

                    column.search(val ? '^' + val + '$' : '', true, false).draw();
                  });

                column
                  .data()
                  .unique()
                  .sort()
                  .each(function (d, j) {
                    select.append('<option value="' + d + '">' + d + '</option>');
                  });
              });
          },

        });
      } catch (e) {
      }
    },
    error: function () {
    }
  });
}

/*********************************************************************************************************************************************/
/***************************************************************Configuracion Cuestrionario********************************************************/
/*********************************************************************************************************************************************/

function configuracionquest(id) {
  //alert(id);
  $.ajax({
    type: "post",
    url: "../index/configuracionquest/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        $("#configuracion1").dialog("open");
        document.getElementById('catcher'+ id).innerHTML = json.descr;

      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/*********************************************************************************************************************************************/
/***************************************************************Quest 2 NEW********************************************************/
/*********************************************************************************************************************************************/
function quest2(id) {
  // *** EVALUACIÓN PREVIA: VERIFICAR SI YA FUE CONTESTADO ***
  
  $.ajax({
    type: "post",
    url: "../quest2/answers1/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      console.log('Verificando estado del cuestionario...');
    },
    success: function (json) {
      // Verificar si el cuestionario ya fue completado
      const yaCompletado = json.completado || 
                          json.status === 'completed' || 
                          json.estado === 'completado' ||
                          (json.descr && json.descr.includes('Completado satisfactoriamente'));
      
      if (yaCompletado) {
        // Si ya está completado, cargar SweetAlert solo para mostrar el mensaje
        cargarSweetAlertParaCompletado();
        return;
      }
      
      // Si NO está completado, proceder con la carga dinámica de SweetAlert2
      cargarYMostrarSweetAlert(id, json);
    },
    error: function (xhr, status, error) {
      console.error('Error verificando estado:', error);
      alert('Error al verificar el estado del cuestionario: ' + error);
    }
  });
}

// *** FUNCIÓN PARA MOSTRAR SWEETALERT CUANDO YA ESTÁ COMPLETADO ***
function cargarSweetAlertParaCompletado() {
  // Función para cargar SweetAlert2 dinámicamente
  function cargarSweetAlert2() {
    return new Promise(function(resolve, reject) {
      if (typeof Swal !== 'undefined') {
        resolve();
        return;
      }
      
      var link = document.createElement('link');
      link.rel = 'stylesheet';
      link.href = 'https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css';
      document.head.appendChild(link);
      
      var script = document.createElement('script');
      script.src = 'https://cdn.jsdelivr.net/npm/sweetalert2@11';
      script.onload = function() {
        resolve();
      };
      script.onerror = function() {
        reject(new Error('Error al cargar SweetAlert2'));
      };
      document.head.appendChild(script);
    });
  }
  
  cargarSweetAlert2()
    .then(function() {
      Swal.fire({
        title: 'Registro Satisfactorio',
        html: '<div style="text-align: center; margin: 20px 0;">' +
              '<div style="font-size: 48px; margin-bottom: 20px;"></div>' +
              '<p style="margin-bottom: 20px;">Este cuestionario ya ha sido completado anteriormente.</p>' +
              '<div style="background-color: #d4edda; padding: 15px; border-radius: 8px; border: 1px solid #c3e6cb; margin: 20px 0;">' +
              '<strong style="color: #155724;">CUESTIONARIO GR-I.</strong>' +
              '</div>' +
              '<p style="color: #6c757d; font-size: 14px;">No es necesario volver a completarlo.</p>' +
              '</div>',
        icon: 'success',
        confirmButtonText: 'Entendido',
        confirmButtonColor: '#28a745',
        width: 500,
        customClass: {
          popup: 'swal-wide-popup',
          htmlContainer: 'swal-form-container',
          container: 'custom-swal-container'
        }
      });
    })
    .catch(function() {
      // Si falla cargar SweetAlert2, usar alert como respaldo
      alert('Este cuestionario ya ha sido completado anteriormente.\n\n**CUESTIONARIO GR-I.** Completado satisfactoriamente.');
    });
}

// *** FUNCIÓN SEPARADA PARA CARGAR SWEETALERT ***
function cargarYMostrarSweetAlert(id, datosIniciales) {
  
  // Función para cargar SweetAlert2 dinámicamente
  function cargarSweetAlert2() {
    return new Promise(function(resolve, reject) {
      // Verificar si ya está cargado
      if (typeof Swal !== 'undefined') {
        resolve();
        return;
      }
      
      // Cargar CSS dinámicamente
      var link = document.createElement('link');
      link.rel = 'stylesheet';
      link.href = 'https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css';
      document.head.appendChild(link);
      
      // Cargar JS dinámicamente
      var script = document.createElement('script');
      script.src = 'https://cdn.jsdelivr.net/npm/sweetalert2@11';
      script.onload = function() {
        resolve();
      };
      script.onerror = function() {
        reject(new Error('Error al cargar SweetAlert2'));
      };
      document.head.appendChild(script);
    });
  }
  
  // Cargar SweetAlert2 y mostrar el modal
  cargarSweetAlert2()
    .then(function() {
      // Una vez cargado SweetAlert2, mostrar el modal
      Swal.fire({
        title: 'Cuestionario GR-I',
        html: '<div style="text-align: left; margin: 20px 0;">' +
              '<p><strong>📋 Información del Cuestionario:</strong></p>' +
              '<ul style="list-style-type: none; padding-left: 0;">' +
              '<li>• El cuestionario consta de <strong>20 reactivos</strong> que deberán ser llenados</li>' +
              '<li>• Todos los campos son obligatorios</li>' +
              '<li>• El cuestionario no termina hasta que el sistema muestre la leyenda:</li>' +
              '</ul>' +
              '<div style="background-color: #e8f5e8; padding: 10px; border-left: 4px solid #28a745; margin: 15px 0;">' +
              '<strong>**CUESTIONARIO GR-I.** Completado satisfactoriamente.</strong>' +
              '</div>' +
              '<p><em>¿Deseas continuar con el cuestionario?</em></p>' +
              '</div>',
        icon: 'info',
        showCancelButton: true,
        confirmButtonText: 'Continuar',
        cancelButtonText: 'Cancelar',
        confirmButtonColor: '#3085d6',
        cancelButtonColor: '#d33',
        width: 600,
        customClass: {
          popup: 'swal-wide-popup',
          htmlContainer: 'swal-form-container',
          container: 'custom-swal-container'
        }
      }).then(function(result) {
        if (result.isConfirmed) {
          // Si el usuario confirma, abrir el cuestionario
          $("#quest2").dialog("open");
          document.getElementById('catcher' + id).innerHTML = datosIniciales.descr;
          
          // Mostrar mensaje de éxito
          Swal.fire({
            title: '¡Cuestionario Cargado!',
            text: 'El cuestionario se ha cargado correctamente. Completa los 20 reactivos.',
            icon: 'success',
            timer: 3000,
            timerProgressBar: true,
            showConfirmButton: false,
            customClass: {
              popup: 'swal-wide-popup',
              htmlContainer: 'swal-form-container',
              container: 'custom-swal-container'
            }
          });
        } else if (result.dismiss === Swal.DismissReason.cancel) {
          // Si el usuario cancela
          Swal.fire({
            title: 'Cancelado',
            text: 'El cuestionario no fue cargado.',
            icon: 'info',
            timer: 2000,
            showConfirmButton: false,
            customClass: {
              popup: 'swal-wide-popup',
              htmlContainer: 'swal-form-container',
              container: 'custom-swal-container'
            }
          });
        }
      });
    })
    .catch(function(error) {
      // Si falla la carga de SweetAlert2, usar confirm básico como respaldo
      console.warn('No se pudo cargar SweetAlert2, usando confirm básico:', error);
      
      var continuar = confirm(
        "CUESTIONARIO GR-I\n\n" +
        "• El cuestionario consta de 20 reactivos que deberán ser llenados\n" +
        "• Todos los campos son obligatorios\n" +
        "• El cuestionario no termina hasta que el sistema muestre:\n" +
        "**CUESTIONARIO GR-I.** Completado satisfactoriamente.\n\n" +
        "¿Deseas continuar con el cuestionario?"
      );
      
      if (continuar) {
        $("#quest2").dialog("open");
        document.getElementById('catcher' + id).innerHTML = datosIniciales.descr;
        alert('¡Cuestionario cargado correctamente! Completa los 20 reactivos.');
      }
    });
}

// *** FUNCIÓN PARA MOSTRAR MENSAJE DE FINALIZACIÓN ***
function showCompletionMessage() {
  // Función para cargar SweetAlert2 dinámicamente
  function cargarSweetAlert2() {
    return new Promise(function(resolve, reject) {
      if (typeof Swal !== 'undefined') {
        resolve();
        return;
      }
      
      var link = document.createElement('link');
      link.rel = 'stylesheet';
      link.href = 'https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css';
      document.head.appendChild(link);
      
      var script = document.createElement('script');
      script.src = 'https://cdn.jsdelivr.net/npm/sweetalert2@11';
      script.onload = function() {
        resolve();
      };
      script.onerror = function() {
        reject(new Error('Error al cargar SweetAlert2'));
      };
      document.head.appendChild(script);
    });
  }
  
  cargarSweetAlert2()
    .then(function() {
      Swal.fire({
        title: '¡Felicidades!',
        html: '<div style="text-align: center; margin: 20px 0;">' +
              '<div style="font-size: 48px; margin-bottom: 20px;">🎉</div>' +
              '<div style="background-color: #d4edda; padding: 15px; border-radius: 8px; border: 1px solid #c3e6cb; margin: 20px 0;">' +
              '<strong style="color: #155724;">**CUESTIONARIO GR-I.** Completado satisfactoriamente.</strong>' +
              '</div>' +
              '<p>Has completado exitosamente todos los 20 reactivos del cuestionario.</p>' +
              '</div>',
        icon: 'success',
        confirmButtonText: 'Excelente',
        confirmButtonColor: '#28a745',
        width: 500,
        customClass: {
          popup: 'swal-wide-popup',
          htmlContainer: 'swal-form-container',
          container: 'custom-swal-container'
        }
      });
    })
    .catch(function() {
      alert('**CUESTIONARIO GR-I.** Completado satisfactoriamente.\n\nHas completado exitosamente todos los 20 reactivos del cuestionario.');
    });
}
/*********************************************************************************************************************************************/
/***************************************************************Quest 2-1 NEW*****************************************************************/
/*********************************************************************************************************************************************/
function quest21(id) {

  $.ajax({
    type: "post",
    url: "../quest2/guardar_cuestionario2",
    cache: false,
    data: $("#formdata33").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest2').modal('hide');
       
      },
      success: function (json) {

        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
         

         
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}
/*********************************************************************************************************************************************/
/***************************************************************Quest 2-2 NEW*****************************************************************/
/*********************************************************************************************************************************************/
function quest22(id) {

  $.ajax({
    type: "post",
    url: "../quest2/guardar_cuestionario2pa2",
    cache: false,
    data: $("#formdata34").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest2').modal('hide');
         
      },
      success: function (json) {

        try {
          //console.log(json.code);
          //console.log(json.descr);
           $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}

/*********************************************************************************************************************************************/
/***************************************************************Quest 2-3 NEW*****************************************************************/
/*********************************************************************************************************************************************/
function quest23(id) {

  $.ajax({
    type: "post",
    url: "../quest2/guardar_cuestionario2pa3",
    cache: false,
    data: $("#formdata35").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest2').modal('hide');
         
      },
      success: function (json) {

        try {
          //console.log(json.code);
          //console.log(json.descr);
           $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}

/*********************************************************************************************************************************************/
/***************************************************************Quest 2-3 NEW*****************************************************************/
/*********************************************************************************************************************************************/
function quest24(id) {

  $.ajax({
    type: "post",
    url: "../quest2/guardar_cuestionario2pa4",
    cache: false,
    data: $("#formdata36").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest2').modal('hide');
         
      },
      success: function (json) {

        try {
          //console.log(json.code);
          //console.log(json.descr);
           $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);

        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#change').dialog('close');
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}


/*********************************************************************************************************************************************/
/***************************************************************Quest 1 NEW********************************************************/
/*********************************************************************************************************************************************/
function questN1(id) {
  // *** EVALUACIÓN PREVIA: VERIFICAR SI YA FUE CONTESTADO ***
  
  $.ajax({
    type: "post",
    url: "../quest1/answers1/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {
      console.log('Verificando estado del cuestionario...');
    },
    success: function (json) {
      // Verificar si el cuestionario ya fue completado
      const yaCompletado = json.completado || 
                          json.status === 'completed' || 
                          json.estado === 'completado' ||
                          (json.descr && json.descr.includes('Completado satisfactoriamente'));
      
      if (yaCompletado) {
        // Si ya está completado, cargar SweetAlert solo para mostrar el mensaje
        cargarSweetAlertParaCompletadoN1();
        return;
      }
      
      // Si NO está completado, proceder con la carga dinámica de SweetAlert2
      cargarYMostrarSweetAlertN1(id, json);
    },
    error: function (xhr, status, error) {
      console.error('Error verificando estado:', error);
      alert('Error al verificar el estado del cuestionario: ' + error);
    }
  });
}

// *** FUNCIÓN PARA MOSTRAR SWEETALERT CUANDO YA ESTÁ COMPLETADO ***
function cargarSweetAlertParaCompletadoN1() {
  // Función para cargar SweetAlert2 dinámicamente
  function cargarSweetAlert2() {
    return new Promise(function(resolve, reject) {
      if (typeof Swal !== 'undefined') {
        resolve();
        return;
      }
      
      var link = document.createElement('link');
      link.rel = 'stylesheet';
      link.href = 'https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css';
      document.head.appendChild(link);
      
      var script = document.createElement('script');
      script.src = 'https://cdn.jsdelivr.net/npm/sweetalert2@11';
      script.onload = function() {
        resolve();
      };
      script.onerror = function() {
        reject(new Error('Error al cargar SweetAlert2'));
      };
      document.head.appendChild(script);
    });
  }
  
  cargarSweetAlert2()
    .then(function() {
      Swal.fire({
        title: 'Registro Satisfactorio',
        html: '<div style="text-align: center; margin: 20px 0;">' +
              '<div style="font-size: 48px; margin-bottom: 20px;"></div>' +
              '<p style="margin-bottom: 20px;">Este cuestionario ya ha sido completado anteriormente.</p>' +
              '<div style="background-color: #d4edda; padding: 15px; border-radius: 8px; border: 1px solid #c3e6cb; margin: 20px 0;">' +
              '<strong style="color: #155724;">CUESTIONARIO GR-III.</strong>' +
              '</div>' +
              '<p style="color: #6c757d; font-size: 14px;">No es necesario volver a completarlo.</p>' +
              '</div>',
        icon: 'success',
        confirmButtonText: 'Entendido',
        confirmButtonColor: '#28a745',
        width: 500,
        customClass: {
          popup: 'swal-wide-popup',
          htmlContainer: 'swal-form-container',
          container: 'custom-swal-container'
        }
      });
    })
    .catch(function() {
      // Si falla cargar SweetAlert2, usar alert como respaldo
      alert('Este cuestionario ya ha sido completado anteriormente.\n\n**CUESTIONARIO N1.** Completado satisfactoriamente.');
    });
}

// *** FUNCIÓN SEPARADA PARA CARGAR SWEETALERT ***
function cargarYMostrarSweetAlertN1(id, datosIniciales) {
  
  // Función para cargar SweetAlert2 dinámicamente
  function cargarSweetAlert2() {
    return new Promise(function(resolve, reject) {
      // Verificar si ya está cargado
      if (typeof Swal !== 'undefined') {
        resolve();
        return;
      }
      
      // Cargar CSS dinámicamente
      var link = document.createElement('link');
      link.rel = 'stylesheet';
      link.href = 'https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css';
      document.head.appendChild(link);
      
      // Cargar JS dinámicamente
      var script = document.createElement('script');
      script.src = 'https://cdn.jsdelivr.net/npm/sweetalert2@11';
      script.onload = function() {
        resolve();
      };
      script.onerror = function() {
        reject(new Error('Error al cargar SweetAlert2'));
      };
      document.head.appendChild(script);
    });
  }
  
  // Cargar SweetAlert2 y mostrar el modal
  cargarSweetAlert2()
    .then(function() {
      // Una vez cargado SweetAlert2, mostrar el modal
      Swal.fire({
        title: 'Cuestionario N1',
        html: '<div style="text-align: left; margin: 20px 0;">' +
              '<p><strong>📋 Información del Cuestionario:</strong></p>' +
              '<ul style="list-style-type: none; padding-left: 0;">' +
              '<li>• El cuestionario consta de reactivos que deberán ser llenados</li>' +
              '<li>• Todos los campos son obligatorios</li>' +
              '<li>• El cuestionario no termina hasta que el sistema muestre la leyenda:</li>' +
              '</ul>' +
              '<div style="background-color: #e8f5e8; padding: 10px; border-left: 4px solid #28a745; margin: 15px 0;">' +
              '<strong>**CUESTIONARIO N1.** Completado satisfactoriamente.</strong>' +
              '</div>' +
              '<p><em>¿Deseas continuar con el cuestionario?</em></p>' +
              '</div>',
        icon: 'info',
        showCancelButton: true,
        confirmButtonText: 'Continuar',
        cancelButtonText: 'Cancelar',
        confirmButtonColor: '#3085d6',
        cancelButtonColor: '#d33',
        width: 600,
        customClass: {
          popup: 'swal-wide-popup',
          htmlContainer: 'swal-form-container',
          container: 'custom-swal-container'
        }
      }).then(function(result) {
        if (result.isConfirmed) {
          // Si el usuario confirma, abrir el cuestionario
          $("#questN1").dialog("open");
          document.getElementById('catcher' + id).innerHTML = datosIniciales.descr;
          
          // Mostrar mensaje de éxito
          Swal.fire({
            title: '¡Cuestionario Cargado!',
            text: 'El cuestionario se ha cargado correctamente. Completa todos los reactivos.',
            icon: 'success',
            timer: 3000,
            timerProgressBar: true,
            showConfirmButton: false,
            customClass: {
              popup: 'swal-wide-popup',
              htmlContainer: 'swal-form-container',
              container: 'custom-swal-container'
            }
          });
        } else if (result.dismiss === Swal.DismissReason.cancel) {
          // Si el usuario cancela
          Swal.fire({
            title: 'Cancelado',
            text: 'El cuestionario no fue cargado.',
            icon: 'info',
            timer: 2000,
            showConfirmButton: false,
            customClass: {
              popup: 'swal-wide-popup',
              htmlContainer: 'swal-form-container',
              container: 'custom-swal-container'
            }
          });
        }
      });
    })
    .catch(function(error) {
      // Si falla la carga de SweetAlert2, usar confirm básico como respaldo
      console.warn('No se pudo cargar SweetAlert2, usando confirm básico:', error);
      
      var continuar = confirm(
        "CUESTIONARIO N1\n\n" +
        "• El cuestionario consta de reactivos que deberán ser llenados\n" +
        "• Todos los campos son obligatorios\n" +
        "• El cuestionario no termina hasta que el sistema muestre:\n" +
        "**CUESTIONARIO GR-III.** Completado satisfactoriamente.\n\n" +
        "¿Deseas continuar con el cuestionario?"
      );
      
      if (continuar) {
        $("#questN1").dialog("open");
        document.getElementById('catcher' + id).innerHTML = datosIniciales.descr;
        alert('¡Cuestionario cargado correctamente! Completa todos los reactivos.');
      }
    });
}

// *** FUNCIÓN PARA MOSTRAR MENSAJE DE FINALIZACIÓN N1 ***
function showCompletionMessageN1() {
  // Función para cargar SweetAlert2 dinámicamente
  function cargarSweetAlert2() {
    return new Promise(function(resolve, reject) {
      if (typeof Swal !== 'undefined') {
        resolve();
        return;
      }
      
      var link = document.createElement('link');
      link.rel = 'stylesheet';
      link.href = 'https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css';
      document.head.appendChild(link);
      
      var script = document.createElement('script');
      script.src = 'https://cdn.jsdelivr.net/npm/sweetalert2@11';
      script.onload = function() {
        resolve();
      };
      script.onerror = function() {
        reject(new Error('Error al cargar SweetAlert2'));
      };
      document.head.appendChild(script);
    });
  }
  
  cargarSweetAlert2()
    .then(function() {
      Swal.fire({
        title: '¡Felicidades!',
        html: '<div style="text-align: center; margin: 20px 0;">' +
              '<div style="font-size: 48px; margin-bottom: 20px;">🎉</div>' +
              '<div style="background-color: #d4edda; padding: 15px; border-radius: 8px; border: 1px solid #c3e6cb; margin: 20px 0;">' +
              '<strong style="color: #155724;">**CUESTIONARIO GR-III.** Completado satisfactoriamente.</strong>' +
              '</div>' +
              '<p>Has completado exitosamente todos los reactivos del cuestionario.</p>' +
              '</div>',
        icon: 'success',
        confirmButtonText: 'Excelente',
        confirmButtonColor: '#28a745',
        width: 500,
        customClass: {
          popup: 'swal-wide-popup',
          htmlContainer: 'swal-form-container',
          container: 'custom-swal-container'
        }
      });
    })
    .catch(function() {
      alert('**CUESTIONARIO N1.** Completado satisfactoriamente.\n\nHas completado exitosamente todos los reactivos del cuestionario.');
    });
}
/*********************************************************************************************************************************************/
/***************************************************************Quest 1-1 NEW*****************************************************************/
/*********************************************************************************************************************************************/
function questN11(id) {

  $.ajax({
    type: "post",
    url: "../quest1/guardar_cuestionario1",
    cache: false,
    data: $("#formdata14").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest1').modal('hide');
       
      },
      success: function (json) {

        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
         

         
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}


/*********************************************************************************************************************************************/
/***************************************************************Quest 1-2 NEW*****************************************************************/
/*********************************************************************************************************************************************/
function questN12(id) {

  $.ajax({
    type: "post",
    url: "../quest1/guardar_cuestionario1p2",
    cache: false,
    data: $("#formdata15").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest1').modal('hide');
       
      },
      success: function (json) {

        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
         

         
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}
/*********************************************************************************************************************************************/
/***************************************************************Quest 1-3 NEW*****************************************************************/
/*********************************************************************************************************************************************/
function questN13(id) {

  $.ajax({
    type: "post",
    url: "../quest1/guardar_cuestionario1p3",
    cache: false,
    data: $("#formdata16").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest1').modal('hide');
       
      },
      success: function (json) {

        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
         

         
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}
/*********************************************************************************************************************************************/
/***************************************************************Quest 1-3 NEW*****************************************************************/
/*********************************************************************************************************************************************/
function questN14(id) {

  $.ajax({
    type: "post",
    url: "../quest1/guardar_cuestionario1p4",
    cache: false,
    data: $("#formdata17").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest1').modal('hide');
      },
      success: function (json) {
        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}
/*********************************************************************************************************************************************/
/***************************************************************Quest 1-3 NEW*****************************************************************/
/*********************************************************************************************************************************************/
function questN15(id) {

  $.ajax({
    type: "post",
    url: "../quest1/guardar_cuestionario1p5",
    cache: false,
    data: $("#formdata18").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest1').modal('hide');
      },
      success: function (json) {
        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}

/*********************************************************************************************************************************************/
/***************************************************************Quest 1-3 NEW*****************************************************************/
/*********************************************************************************************************************************************/
function questN16(id) {

  $.ajax({
    type: "post",
    url: "../quest1/guardar_cuestionario1p6",
    cache: false,
    data: $("#formdata19").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest1').modal('hide');
      },
      success: function (json) {
        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}


/*********************************************************************************************************************************************/
/***************************************************************Quest 1-3 NEW*****************************************************************/
/*********************************************************************************************************************************************/
function questN17(id) {

  $.ajax({
    type: "post",
    url: "../quest1/guardar_cuestionario1p7",
    cache: false,
    data: $("#formdata20").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest1').modal('hide');
      },
      success: function (json) {
        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}

/*********************************************************************************************************************************************/
/***************************************************************Quest 1-3 NEW*****************************************************************/
/*********************************************************************************************************************************************/
function questN18(id) {

  $.ajax({
    type: "post",
    url: "../quest1/guardar_cuestionario1p8",
    cache: false,
    data: $("#formdata21").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest1').modal('hide');
      },
      success: function (json) {
        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}


/*********************************************************************************************************************************************/
/***************************************************************Quest 1-3 NEW*****************************************************************/
/*********************************************************************************************************************************************/
function questN19(id) {

  $.ajax({
    type: "post",
    url: "../quest1/guardar_cuestionario1p9",
    cache: false,
    data: $("#formdata22").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest1').modal('hide');
      },
      success: function (json) {
        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}
/*********************************************************************************************************************************************/
/***************************************************************Quest 1-3 NEW*****************************************************************/
/*********************************************************************************************************************************************/
function questN20(id) {

  $.ajax({
    type: "post",
    url: "../quest1/guardar_cuestionario1p10",
    cache: false,
    data: $("#formdata23").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest1').modal('hide');
      },
      success: function (json) {
        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}
/*********************************************************************************************************************************************/
/***************************************************************Quest 1-3 NEW*****************************************************************/
/*********************************************************************************************************************************************/
function questN21(id) {

  $.ajax({
    type: "post",
    url: "../quest1/guardar_cuestionario1p11",
    cache: false,
    data: $("#formdata24").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest1').modal('hide');
      },
      success: function (json) {
        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}

/*********************************************************************************************************************************************/
/***************************************************************Quest 1-3 NEW*****************************************************************/
/*********************************************************************************************************************************************/
function questN22(id) {

  $.ajax({
    type: "post",
    url: "../quest1/guardar_cuestionario1p12",
    cache: false,
    data: $("#formdata25").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest1').modal('hide');
      },
      success: function (json) {
        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}
/*********************************************************************************************************************************************/
/***************************************************************Quest 1-3 NEW*****************************************************************/
/*********************************************************************************************************************************************/
function questN23(id) {

  $.ajax({
    type: "post",
    url: "../quest1/guardar_cuestionario1pe1",
    cache: false,
    data: $("#formdata26").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest1').modal('hide');
      },
      success: function (json) {
        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}
/*********************************************************************************************************************************************/
/***************************************************************Quest 1-3 Adicional 2 *****************************************************************/
/*********************************************************************************************************************************************/
function questN26(id) {

  $.ajax({
    type: "post",
    url: "../quest1/guardar_cuestionario1pe2",
    cache: false,
    data: $("#formdata27").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest1').modal('hide');
      },
      success: function (json) {
        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}


/*********************************************************************************************************************************************/
/***************************************************************Quest 1-3 Adicional 1 NO*****************************************************************/
/*********************************************************************************************************************************************/
function questN27(id) {

  $.ajax({
    type: "post",
    url: "../quest1/guardar_cuestionario1pe1",
    cache: false,
    data: $("#formdata26").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest1').modal('hide');
      },
      success: function (json) {
        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}


/*********************************************************************************************************************************************/
/***************************************************************Quest 1-3 Adicional 1 Si*****************************************************************/
/*********************************************************************************************************************************************/
function questN28(id) {

  $.ajax({
    type: "post",
    url: "../quest1/guardar_cuestionario1p13",
    cache: false,
    data: $("#formdata28").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest1').modal('hide');
      },
      success: function (json) {
        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}

/*********************************************************************************************************************************************/
/***************************************************************Quest 1-3 Adicional 2 *****************************************************************/
/*********************************************************************************************************************************************/
function questN29(id) {

  $.ajax({
    type: "post",
    url: "../quest1/guardar_cuestionario1pe2",
    cache: false,
    data: $("#formdata29").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest1').modal('hide');
      },
      success: function (json) {
        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}

/*********************************************************************************************************************************************/
/***************************************************************Quest 1-3 Adicional 2 *****************************************************************/
/*********************************************************************************************************************************************/
function questN30(id) {

  $.ajax({
    type: "post",
    url: "../quest1/guardar_cuestionario1pe5",
    cache: false,
    data: $("#formdata30").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest1').modal('hide');
      },
      success: function (json) {
        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
          }, 1000);
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest2').innerHTML = responseText.messages;
        $('#al-warning-alertquest2R').modal('show');

      }
    });

}
/*********************************************************************************************************************************************/
/***************************************************************Quest 3 NEW********************************************************/
/*********************************************************************************************************************************************/

function quest3(id) {
  //alert(id);
  $.ajax({
    type: "post",
    url: "../quest3/answers1/" + id,
    cache: false,
    data: id,
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (json) {
      try {
        //console.log(json.code);
        //console.log(json.descr);
        $("#quest3").dialog("open");
        document.getElementById('catcher'+ id).innerHTML = json.descr;
        $("#examplerespuestasC").dataTable().fnDestroy();
        var table = $('#examplerespuestasC').DataTable({
          "rowReorder": true,
          "paging": false,
          fixedHeader: {
            header: true,
            footer: true
          },
          "columnDefs": [

            { "targets": [0], "width": "20%" },
            { "targets": [1], "width": "20%" },
           
          ],
          fixedColumns: true,
          scrollY: '45vh',
          scrollCollapse: true,
          "language": {
            "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json",
            buttons: {
              'pageLength': {
                _: "Mostrar %d registros",
                '-1': "Mostrar Todo"
              },
              "copySuccess": {
                "1": "Copiada 1 fila al portapapeles",
                "_": "Copiadas %d filas al portapapeles"
              },
              "copyTitle": "Copiar al portapapeles",
              "pdf": "",
              "print": "",
              "excel": "",
              "copy": "",

            }
          },


          dom: 'Bfrtip',
          lengthMenu: [
            [25, 50, -1],
            ['25 registros', '50 registros', 'Mostrar todo']
          ],
          buttons: {
            buttons: [


              { extend: 'excel', className: 'btn btn-datatble-excel' },
              { extend: 'pdf', className: 'btn btn-datatble-pdf' },
              { extend: 'copy', className: 'btn btn-datatble-copiar' },
              { extend: 'print', className: 'btn btn-datatble-imprimir' },


            ],
 
          },

        


        });


      } catch (e) {
      }
    },
    error: function () {
    }
  });
}
/*********************************************************************************************************************************************/
/***************************************************************Quest 3 NEW********************************************************/
/*********************************************************************************************************************************************/


function quest31(id) {

  $.ajax({
    type: "post",
    url: "../quest3/guardar_cuestionario3",
    cache: false,
    data: $("#formdata1").serialize(),
    dataType: 'json',
      beforeSend: function () {
        $('#al-warning-succes').modal('show');
        $('#al-warning-alertquest3').modal('hide');
      },
      success: function (json) {
        try {
          //console.log(json.code);
          //console.log(json.descr);
          $('#al-warning-charging').modal('show');
          setTimeout(function () {
            $('#al-warning-charging').modal('hide');
          }, 500);
          setTimeout(function () {
            document.getElementById('catcher'+ id).innerHTML = json.descr;
            $("#examplerespuestasC2").dataTable().fnDestroy();
            var table = $('#examplerespuestasC2').DataTable({
              "rowReorder": true,
              "paging": false,
              fixedHeader: {
                header: true,
                footer: true
              },
              "columnDefs": [
    
                { "targets": [0], "width": "20%" },
                { "targets": [1], "width": "20%" },
                
    
              ],
              fixedColumns: true,
              scrollY: '45vh',
              scrollCollapse: true,
              "language": {
                "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json",
                buttons: {
                  'pageLength': {
                    _: "Mostrar %d registros",
                    '-1': "Mostrar Todo"
                  },
                  "copySuccess": {
                    "1": "Copiada 1 fila al portapapeles",
                    "_": "Copiadas %d filas al portapapeles"
                  },
                  "copyTitle": "Copiar al portapapeles",
                  "pdf": "",
                  "print": "",
                  "excel": "",
                  "copy": "",
    
                }
              },
    
    
              dom: 'Bfrtip',
              lengthMenu: [
                [25, 50, -1],
                ['25 registros', '50 registros', 'Mostrar todo']
              ],
              buttons: {
                buttons: [
    
    
                  { extend: 'excel', className: 'btn btn-datatble-excel' },
                  { extend: 'pdf', className: 'btn btn-datatble-pdf' },
                  { extend: 'copy', className: 'btn btn-datatble-copiar' },
                  { extend: 'print', className: 'btn btn-datatble-imprimir' },
    
    
                ],
     
              },
    
             
    
            });
          }, 1000);

       
        } catch (e) {
        }
      },
      error: function (data) {

        var responseText = JSON.parse(data.responseText);
        //alert("Error(s) while building the ZIP file:\n"+responseText.messages);
        document.getElementById('responsequest3').innerHTML = responseText.messages;
        $('#al-warning-alertquest3R').modal('show');

      }
    });

}
/*********************************************************************************************************************************************/
/***************************************************************Quest 3 NEW********************************************************/
/*********************************************************************************************************************************************/

  
/**************ALTA DE ASIGNACION DE LUGAR*****************************/
function CoFal(id) {
  //alert(id);
   $.ajax({
     type: "post",
     url: "https://aplicacionesasig.com/index/cofal/" + id,
     cache: false,
     data: id,
     dataType: 'json',
     beforeSend: function () {
       //$('#al-warning-charging').modal('show');
       $('#al-warning-charging').modal('show');
     },
     success: function (json) {
       try {
         //console.log(json.code);
         //console.log(json.descr);
 
 
         document.getElementById('catcherex3').innerHTML = json.descr;
         $('#admin11').dialog('open');
         setTimeout(function () {
           $('#al-warning-charging').modal('hide');
         }, 500);
         $("#dataR1_file_export3").dataTable().fnDestroy();
         var tabla = $('#dataR1_file_export3').DataTable({
 
           fixedHeader: {
             header: true,
             footer: true
           },
           columnDefs: [
             { width: 200, targets: 0 }
           ],
           
           scrollY: '37vh',
           scrollCollapse: true,
           "language": {
             "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json",
             buttons: {
               'pageLength': {
                 _: "Mostrar %d registros",
                 '-1': "Mostrar Todo"
               },
               "copySuccess": {
                 "1": "Copiada 1 fila al portapapeles",
                 "_": "Copiadas %d filas al portapapeles"
               },
               "copyTitle": "Copiar al portapapeles",
               "pdf": "",
               "print": "",
               "excel": "",
               "copy": "",
 
             }
           },
 
 
           dom: 'Bfrtip',
           lengthMenu: [
             [25, 50, -1],
             ['25 registros', '50 registros', 'Mostrar todo']
           ],
           buttons: {
             buttons: [
               { extend: 'pageLength', className: 'btn btn-datatble-mostrar' },
 
               { extend: 'excel', className: 'btn btn-datatble-excel' },
               { extend: 'pdf', className: 'btn btn-datatble-pdf' },
               { extend: 'copy', className: 'btn btn-datatble-copiar' },
               { extend: 'print', className: 'btn btn-datatble-imprimir' },
 
 
             ],
 
           },
 
           initComplete: function () {
             this.api()
               .columns([1, 2])
               .every(function () {
                 var column = this;
                 var select = $('<select><option value="">Seleccióne Filtro</option></select>')
                   .appendTo($(column.header()).empty())
                   .on('change', function () {
                     var val = $.fn.dataTable.util.escapeRegex($(this).val());
 
                     column.search(val ? '^' + val + '$' : '', true, false).draw();
                   });
 
                 column
                   .data()
                   .unique()
                   .sort()
                   .each(function (d, j) {
                     select.append('<option value="' + d + '">' + d + '</option>');
                   });
               });
           },
 
         });
 
 
       } catch (e) {
       }
     },
     error: function () {
     }
   });
 }

/**************ALTA DE ASIGNACION DE LUGAR*****************************/
function CoCom(id) {
  //alert(id);
   $.ajax({
     type: "post",
     url: "https://aplicacionesasig.com/index/cocom/" + id,
     cache: false,
     data: id,
     dataType: 'json',
     beforeSend: function () {
       //$('#al-warning-charging').modal('show');
       $('#al-warning-charging').modal('show');
     },
     success: function (json) {
       try {
         //console.log(json.code);
         //console.log(json.descr);
 
 
         document.getElementById('catcherex4').innerHTML = json.descr;
         $('#admin13').dialog('open');
         setTimeout(function () {
           $('#al-warning-charging').modal('hide');
         }, 500);
         $("#dataR1_file_export4").dataTable().fnDestroy();
         var tabla = $('#dataR1_file_export4').DataTable({
 
           fixedHeader: {
             header: true,
             footer: true
           },
           columnDefs: [
             { width: 200, targets: 0 }
           ],
           
           scrollY: '37vh',
           scrollCollapse: true,
           "language": {
             "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json",
             buttons: {
               'pageLength': {
                 _: "Mostrar %d registros",
                 '-1': "Mostrar Todo"
               },
               "copySuccess": {
                 "1": "Copiada 1 fila al portapapeles",
                 "_": "Copiadas %d filas al portapapeles"
               },
               "copyTitle": "Copiar al portapapeles",
               "pdf": "",
               "print": "",
               "excel": "",
               "copy": "",
 
             }
           },
 
 
           dom: 'Bfrtip',
           lengthMenu: [
             [25, 50, -1],
             ['25 registros', '50 registros', 'Mostrar todo']
           ],
           buttons: {
             buttons: [
               { extend: 'pageLength', className: 'btn btn-datatble-mostrar' },
 
               { extend: 'excel', className: 'btn btn-datatble-excel' },
               { extend: 'pdf', className: 'btn btn-datatble-pdf' },
               { extend: 'copy', className: 'btn btn-datatble-copiar' },
               { extend: 'print', className: 'btn btn-datatble-imprimir' },
 
 
             ],
 
           },
 
           initComplete: function () {
             this.api()
               .columns([2, 3,4])
               .every(function () {
                 var column = this;
                 var select = $('<select><option value="">Seleccióne Filtro</option></select>')
                   .appendTo($(column.header()).empty())
                   .on('change', function () {
                     var val = $.fn.dataTable.util.escapeRegex($(this).val());
 
                     column.search(val ? '^' + val + '$' : '', true, false).draw();
                   });
 
                 column
                   .data()
                   .unique()
                   .sort()
                   .each(function (d, j) {
                     select.append('<option value="' + d + '">' + d + '</option>');
                   });
               });
           },
 
         });
 
 
       } catch (e) {
       }
     },
     error: function () {
     }
   });
 }























































/**************CERRAR ALTA DE ROOT*****************************/
function myFunction() {
  document.getElementById("myForm").submit();
}
/**************MASTER AJAX*****************************/
function masterAJAX() {
  $.ajax({
    type: "post",
    url: "https://aplicacionesasig.com/alta/register_dependencia",
    cache: false,
    data: $('#formdata').serialize(),
    dataType: 'json',
    success: function (json) {

      try {
        //var obj = jQuery.parseJSON(json);
        //alert( obj['STATUS']);
        //alert(json.descr);
        console.log(json.code);
        console.log(json.descr);
        document.getElementById('confirm').innerHTML = json.descr;
        $('#confirm').dialog('open');

      } catch (e) {
        //alert('Exception while request..');
        var texto = 'Su solicitud ha sido Guardada con Exito';
        document.getElementById('confirm').innerHTML = json;
        $('#confirm').dialog('open');
      }


    },
    error: function () {
      //alert('Error while request..');
      //var texto = 'El rfc ya se envuentra registrado';
      //document.getElementById('confirm').innerHTML = texto;
      $('#confirm').dialog('open');
    }
  });
}

/**************DATEPICKER*****************************/


function showPicker(element) {
  $('.wickedpicker__title').contents().first().replaceWith(((this.options !== undefined)
    ? this.options.title
    : this.title));
}

$(function () {
  var options = {
    twentyFour: true, //Display 24 hour format, defaults to false
    timeSeparator: ':',
    title: 'Inicio de Curso', //The Wickedpicker's title,

    show: showPicker
  };
  $('#timepicker-one').wickedpicker(options);
});


$(function () {
  var options = {
    twentyFour: true, //Display 24 hour format, defaults to false
    timeSeparator: ':',
    title: 'Término de Curso', //The Wickedpicker's title,
    show: showPicker
  };
  $('#timepicker-two').wickedpicker(options);
});
$(function () {
  $("#datepicker").datepicker();
  $(".out").datepicker({
    minDate: "-0D",
    maxDate: "+1Y, +2M, -10D"
  });
  $(".fechas").datepicker({
    minDate: "-0D",
    maxDate: "+20D"
  });
  $(".fechaD").datepicker({
    minDate: "-0D",
    maxDate: "+7d"
  });
  $.datepicker.regional['es'] = {
    closeText: 'Cerrar',
    prevText: '<Ant',
    nextText: 'Sig>',
    currentText: 'Hoy',
    monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
    monthNamesShort: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'],
    dayNames: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'],
    dayNamesShort: ['Dom', 'Lun', 'Mar', 'Mié', 'Juv', 'Vie', 'Sáb'],
    dayNamesMin: ['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sá'],
    weekHeader: 'Sm',
    dateFormat: 'yy-mm-dd',
    firstDay: 1,
    isRTL: false,
    showMonthAfterYear: false,
    yearSuffix: ''
  };
  $.datepicker.setDefaults($.datepicker.regional['es']);
  $('.setTimeExample').timepicker();
  var timepickers = $('.timepicker').wickedpicker({ twentyFour: true, timeSeparator: ':', closeOnEscape: true, closeOnClick: true, });
  //console.log(timepickers.wickedpicker('time', 1));
  //JS console: time of timepicker-two
  $('.timepicker').wickedpicker({ twentyFour: true, timeSeparator: ':' });
  $('.timepickerin').wickedpicker({
    twentyFour: true, timeSeparator: ':',
    title: 'Inicio',
  });
  $('#timepickerout').wickedpicker({
    twentyFour: true, timeSeparator: ':',
    title: 'Termino',
  });
  $("#anim").on("change", function () {
    $("#datepicker").datepicker("option", "showAnim", $(this).val());
  });
});

$(function () {
  setTimeout(function () {
    $('#loader').dialog('close');
  }, 1000);
});

$(function () {
  $("#chkToggle2").bootstrapToggle();
});

$(function () {
  $("#toggle-two").bootstrapToggle({
    on: "Enabled",
    off: "Disabled",
  });
});

/**
 * FUNCIÓN CARGADORA REPORTAI - VERSIÓN CODEIGNITER
 * Agregar este código a tu archivo JS existente del controlador
 * Optimizado para el sistema de rutas de CodeIgniter
 */

// Variable global para controlar carga
window.reportAI_loaded = false;

/**
 * Función principal que activa desde el botón ReportAI_2025
 * @param {number} ejercicio_num - Número del ejercicio (1, 2, etc.)
 */
function ReportAI_2025(ejercicio_num) {
    console.log('🤖 Activando ReportAI CodeIgniter para ejercicio:', ejercicio_num);
    
    // Si ya está cargado, ejecutar directamente
    if (window.reportAI_loaded && window.ReportAI_Core) {
        window.ReportAI_Core.iniciar(ejercicio_num);
        return;
    }
    
    // Definir pasos de carga
    const pasosCarga = [
        {
            message: '🔍 Verificando dependencias del sistema...',
            action: (callback) => {
                verificarDependenciasReportAI();
                callback();
            }
        },
        {
            message: '📦 Cargando estilos CSS de ReportAI...',
            action: (callback) => {
                const timestamp = new Date().getTime();
                cargarCSS(`../public/css/reportai-styles.css?t=${timestamp}`, callback);
            }
        },
        {
            message: '⚡ Cargando plantillas de ReportAI...',
            action: (callback) => {
                const timestamp = new Date().getTime();
                cargarJS(`../public/js/reportai-templates.js?t=${timestamp}`, callback);
            }
        },
        {
            message: '🧠 Cargando núcleo de ReportAI...',
            action: (callback) => {
                const timestamp = new Date().getTime();
                cargarJS(`../public/js/reportai-core.js?t=${timestamp}`, callback);
            }
        },
        {
            message: '🔗 Validando conexión con CodeIgniter...',
            action: (callback) => {
                validarConexionCI(() => {
                    window.reportAI_loaded = true;
                    if (window.ReportAI_Core) {
                        window.ReportAI_Core.iniciar(ejercicio_num);
                    }
                    callback();
                });
            }
        }
    ];
    
    // Iniciar barra de progreso
    iniciarBarraProgresoReportAI(pasosCarga);
}

/**
 * Carga todos los módulos necesarios para ReportAI (DEPRECATED - usar barra de progreso)
 * @param {number} ejercicio_num - Número del ejercicio
 */
function cargarModulosReportAI(ejercicio_num) {
    console.warn('⚠️ cargarModulosReportAI está deprecated. Usar ReportAI_2025 con barra de progreso.');
    
    const timestamp = new Date().getTime();
    
     const baseUrlJS = '../public/js/';
   const baseUrlCSS = '../public/css/';
   console.log('📂 Base URL JS:', baseUrlJS);
   console.log('📂 Base URL CSS:', baseUrlCSS);
   
   // Recursos a cargar (orden importante)
   const recursos = [
       { tipo: 'css', url: `${baseUrlCSS}reportai-styles.css?t=${timestamp}` },
       { tipo: 'js', url: `${baseUrlJS}reportai-templates.js?t=${timestamp}` },
       { tipo: 'js', url: `${baseUrlJS}reportai-core.js?t=${timestamp}` }
   ];
    
    let cargados = 0;
    const total = recursos.length;
    
    // Función callback cuando termine de cargar
    const onRecursoCargado = () => {
        cargados++;
        console.log(`📦 Cargado ${cargados}/${total} módulos ReportAI`);
        
        if (cargados === total) {
            window.reportAI_loaded = true;
            ocultarLoadingReportAI();
            
            // Verificar que se cargó correctamente
            if (window.ReportAI_Core && window.ReportAI_Templates) {
                console.log('✅ ReportAI CodeIgniter cargado exitosamente');
                
                // Validar conexión con CodeIgniter
                validarConexionCI(() => {
                    window.ReportAI_Core.iniciar(ejercicio_num);
                });
            } else {
                console.error('❌ Error: Módulos ReportAI no disponibles');
                mostrarErrorReportAI('Error al cargar los módulos principales');
            }
        }
    };
    
    // Cargar cada recurso secuencialmente
    cargarRecursoSecuencial(recursos, 0, onRecursoCargado);
}

/**
 * Carga recursos de forma secuencial para evitar problemas de dependencias
 * @param {Array} recursos - Array de recursos a cargar
 * @param {number} indice - Índice actual
 * @param {function} callback - Callback final
 */
function cargarRecursoSecuencial(recursos, indice, callback) {
    if (indice >= recursos.length) {
        return;
    }
    
    const recurso = recursos[indice];
    
    const onCargado = () => {
        const siguienteIndice = indice + 1;
        if (siguienteIndice < recursos.length) {
            cargarRecursoSecuencial(recursos, siguienteIndice, callback);
        }
        callback();
    };
    
    if (recurso.tipo === 'css') {
        cargarCSS(recurso.url, onCargado);
    } else {
        cargarJS(recurso.url, onCargado);
    }
}

/**
 * Carga un archivo CSS dinámicamente
 * @param {string} url - URL del archivo CSS
 * @param {function} callback - Función a ejecutar cuando cargue
 */
function cargarCSS(url, callback) {
    // Verificar si ya existe
    const urlSinTimestamp = url.split('?')[0];
    if (document.querySelector(`link[href*="${urlSinTimestamp}"]`)) {
        console.log(`📋 CSS ya cargado: ${urlSinTimestamp}`);
        callback();
        return;
    }
    
    const link = document.createElement('link');
    link.rel = 'stylesheet';
    link.type = 'text/css';
    link.href = url;
    link.onload = () => {
        console.log(`✅ CSS cargado: ${urlSinTimestamp}`);
        callback();
    };
    link.onerror = () => {
        console.warn(`⚠️ CSS no encontrado: ${url}`);
        console.warn('💡 Tip: Verifica que el archivo esté en assets/js/ de tu proyecto CodeIgniter');
        callback(); // Continuar aunque falle
    };
    document.head.appendChild(link);
}

/**
 * Carga un archivo JavaScript dinámicamente
 * @param {string} url - URL del archivo JS
 * @param {function} callback - Función a ejecutar cuando cargue
 */
function cargarJS(url, callback) {
    // Verificar si ya existe
    const urlSinTimestamp = url.split('?')[0];
    if (document.querySelector(`script[src*="${urlSinTimestamp}"]`)) {
        console.log(`📋 JS ya cargado: ${urlSinTimestamp}`);
        callback();
        return;
    }
    
    const script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = url;
    script.onload = () => {
        console.log(`✅ JS cargado: ${urlSinTimestamp}`);
        callback();
    };
    script.onerror = () => {
        console.warn(`⚠️ JS no encontrado: ${url}`);
        console.warn('💡 Tip: Verifica que el archivo esté en assets/js/ de tu proyecto CodeIgniter');
        callback(); // Continuar aunque falle
    };
    document.body.appendChild(script);
}

/**
 * Valida conexión con CodeIgniter
 * @param {function} callback - Función a ejecutar si todo está OK
 */
function validarConexionCI(callback) {
    const baseUrlCI = 'https://aplicacionesasig.com/reportnom035/';
    
    $.ajax({
        type: "post",
        url: baseUrlCI + "obtener_empresas",
        cache: false,
        dataType: 'json',
        timeout: 10000,
        success: function(response) {
            if (response.success) {
                console.log('✅ Conexión con CodeIgniter validada');
                console.log('🏢 Empresas disponibles:', response.empresas.length);
                callback();
            } else {
                console.warn('⚠️ Respuesta inesperada de CodeIgniter:', response.message);
                mostrarAdvertenciaCI(response.message, callback);
            }
        },
        error: function(xhr, status, error) {
            console.warn('⚠️ No se pudo conectar con CodeIgniter:', error);
            console.warn('🔍 Status:', status, 'Response:', xhr.responseText);
            
            if (xhr.status === 404) {
                mostrarAdvertenciaCI('Método del controller no encontrado. Verifica que hayas agregado los métodos ReportAI a tu controller.', callback);
            } else if (xhr.status === 500) {
                mostrarAdvertenciaCI('Error del servidor CodeIgniter. Revisa los logs de PHP.', callback);
            } else {
                mostrarAdvertenciaCI('Error de conexión. El sistema continuará con datos demo.', callback);
            }
        }
    });
}

/**
 * Muestra advertencia sobre CodeIgniter pero permite continuar
 * @param {string} mensaje - Mensaje de advertencia
 * @param {function} callback - Función para continuar
 */
function mostrarAdvertenciaCI(mensaje, callback) {
    if (typeof Swal !== 'undefined') {
        Swal.fire({
            icon: 'warning',
            title: 'Advertencia CodeIgniter',
            text: mensaje,
            footer: 'El sistema continuará con datos demo',
            confirmButtonText: 'Continuar',
            timer: 8000,
            timerProgressBar: true,
            allowOutsideClick: false
        }).then(() => {
            callback();
        });
    } else {
        console.warn('CodeIgniter:', mensaje);
        callback();
    }
}

/**
 * Carga SweetAlert2 dinámicamente si no está disponible
 * @param {function} callback - Función a ejecutar cuando esté listo
 */
function cargarSweetAlert2(callback) {
    // Si ya está cargado, ejecutar callback directamente
    if (typeof Swal !== 'undefined') {
        callback();
        return;
    }
    
    console.log('📦 Cargando SweetAlert2 dinámicamente...');
    
    // Cargar CSS primero
    const cssLink = document.createElement('link');
    cssLink.rel = 'stylesheet';
    cssLink.href = '../public/css/sweetalert2.min.css';
    document.head.appendChild(cssLink);
    
    // Cargar JS
    const script = document.createElement('script');
    script.src = 'https://cdn.jsdelivr.net/npm/sweetalert2@11';
    script.onload = () => {
        console.log('✅ SweetAlert2 cargado exitosamente');
        callback();
    };
    script.onerror = () => {
        console.warn('⚠️ Error al cargar SweetAlert2 desde CDN, intentando local...');
        // Fallback a archivo local si existe
        const localScript = document.createElement('script');
        localScript.src = '../public/js/sweetalert2.min.js';
        localScript.onload = () => {
            console.log('✅ SweetAlert2 local cargado');
            callback();
        };
        localScript.onerror = () => {
            console.error('❌ No se pudo cargar SweetAlert2');
            callback(); // Continuar sin SweetAlert2
        };
        document.body.appendChild(localScript);
    };
    document.body.appendChild(script);
}

/**
 * Sistema de barra de progreso para ReportAI
 */
let reportAI_ProgressState = {
    currentStep: 0,
    totalSteps: 0,
    messages: []
};

/**
 * Inicia la barra de progreso con pasos definidos
 * @param {Array} steps - Array de pasos con {message, action}
 */
function iniciarBarraProgresoReportAI(steps) {
    // Usar la función cargarSweetAlert2 que ya existe
    cargarSweetAlert2(() => {
        reportAI_ProgressState.totalSteps = steps.length;
        reportAI_ProgressState.currentStep = 0;
        reportAI_ProgressState.messages = steps;
        
        Swal.fire({
            title: 'Cargando ReportAI',
            html: crearHTMLBarraProgreso(),
            allowOutsideClick: false,
            allowEscapeKey: false,
            showConfirmButton: false,
            customClass: {
                popup: 'reportai-progress-popup'
            }
        });
        
        // Iniciar el primer paso
        ejecutarSiguientePaso();
    });
}

/**
 * Crea el HTML de la barra de progreso
 */
function crearHTMLBarraProgreso() {
    return `
        <div id="reportai-progress-container" style="
            width: 100%;
            max-width: 420px;
            margin: 0 auto;
            text-align: center;
        ">
            <div style="
                display: flex;
                align-items: center;
                justify-content: center;
                margin-bottom: 12px;
            ">
                <div style="
                    width: 32px;
                    height: 32px;
                    border-radius: 50%;
                    background: linear-gradient(135deg, #3498db, #2980b9);
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    margin-right: 10px;
                    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
                ">
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="white">
                        <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/>
                    </svg>
                </div>
                <div style="
                    font-size: 16px;
                    color: #2c3e50;
                    font-weight: 600;
                ">Cargando módulos ReportAI</div>
            </div>
            
            <div style="
                width: 100%;
                height: 6px;
                background: #ecf0f1;
                border-radius: 3px;
                overflow: hidden;
                margin-bottom: 12px;
                box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
            ">
                <div id="reportai-progress-bar" style="
                    width: 0%;
                    height: 100%;
                    background: linear-gradient(90deg, #3498db, #2980b9);
                    border-radius: 3px;
                    transition: width 0.3s ease;
                    position: relative;
                "></div>
            </div>
            
            <div id="reportai-progress-text" style="
                font-size: 13px;
                color: #7f8c8d;
                min-height: 18px;
                display: flex;
                align-items: center;
                justify-content: center;
            ">0%</div>
        </div>
    `;
}

/**
 * Obtiene el mensaje del paso actual
 */
function getCurrentMessage() {
    if (reportAI_ProgressState.currentStep === 0) {
        return '🔄 Preparando carga de módulos...';
    }
    
    const currentMsg = reportAI_ProgressState.messages[reportAI_ProgressState.currentStep - 1];
    return currentMsg ? currentMsg.message : 'Procesando...';
}

/**
 * Actualiza la barra de progreso
 * @param {number} porcentaje - Porcentaje de progreso
 * @param {string} mensaje - Mensaje a mostrar
 */
function actualizarBarraProgreso(porcentaje, mensaje = '') {
    const progressBar = document.getElementById('reportai-progress-bar');
    const progressText = document.getElementById('reportai-progress-text');
    const iconContainer = progressBar?.parentElement?.parentElement?.querySelector('div[style*="border-radius: 50%"]');
    
    if (progressBar && progressText) {
        // Actualización más rápida y suave
        progressBar.style.width = porcentaje + '%';
        
        // Actualizar icono según el progreso
        if (iconContainer) {
            const svg = iconContainer.querySelector('svg');
            if (porcentaje < 100) {
                // Icono de carga (spinner)
                svg.innerHTML = `
                    <circle cx="12" cy="12" r="10" stroke="white" stroke-width="2" fill="none" stroke-dasharray="31.416" stroke-dashoffset="${31.416 - (31.416 * porcentaje / 100)}" transform="rotate(-90 12 12)" style="transition: stroke-dashoffset 0.3s ease;"/>
                    <circle cx="12" cy="12" r="3" fill="white"/>
                `;
            } else {
                // Icono de éxito (check)
                svg.innerHTML = `
                    <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/>
                `;
                iconContainer.style.background = 'linear-gradient(135deg, #27ae60, #229954)';
                iconContainer.style.boxShadow = '0 2px 8px rgba(39, 174, 96, 0.3)';
            }
        }
        
        // Mostrar mensaje si se proporciona, sino solo el porcentaje
        if (mensaje && mensaje.trim()) {
            progressText.innerHTML = `
                <span style="margin-right: 8px;">${porcentaje}%</span>
                <span style="color: #3498db; font-weight: 500;">${mensaje}</span>
            `;
        } else {
            progressText.textContent = `${porcentaje}%`;
        }
        
        // Cambiar color cuando esté completo
        if (porcentaje >= 100) {
            progressBar.style.background = 'linear-gradient(90deg, #27ae60, #229954)';
            progressText.innerHTML = `
                <span style="color: #27ae60; font-weight: 600; display: flex; align-items: center;">
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="#27ae60" style="margin-right: 6px;">
                        <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/>
                    </svg>
                    100% - Completado
                </span>
            `;
        }
    }
}

/**
 * Ejecuta el siguiente paso del progreso
 */
function ejecutarSiguientePaso() {
    if (reportAI_ProgressState.currentStep < reportAI_ProgressState.totalSteps) {
        reportAI_ProgressState.currentStep++;
        
        const step = reportAI_ProgressState.messages[reportAI_ProgressState.currentStep - 1];
        const porcentaje = Math.round((reportAI_ProgressState.currentStep / reportAI_ProgressState.totalSteps) * 100);
        
        // Limpiar mensaje de emojis para mostrar solo texto
        const mensajeLimpio = step.message.replace(/🔄|📦|🔍|⚡|🧠|🔗/g, '').trim();
        
        actualizarBarraProgreso(porcentaje, mensajeLimpio);
        
        // Tiempo de carga más rápido
        setTimeout(() => {
            if (step.action) {
                step.action(() => {
                    // Continuar al siguiente paso
                    if (reportAI_ProgressState.currentStep < reportAI_ProgressState.totalSteps) {
                        ejecutarSiguientePaso();
                    } else {
                        finalizarBarraProgreso();
                    }
                });
            } else {
                ejecutarSiguientePaso();
            }
        }, 200); // Reducido de 500ms a 200ms
    }
}

/**
 * Finaliza la barra de progreso
 * @param {boolean} exito - Si la carga fue exitosa
 * @param {string} mensajeError - Mensaje de error si falló
 */
function finalizarBarraProgreso(exito = true, mensajeError = '') {
    return new Promise((resolve) => {
        cargarSweetAlert2(() => {
            if (exito) {
                // Actualizar a 100% antes de cerrar
                actualizarBarraProgreso(100, 'Completado');
                
                setTimeout(() => {
                    Swal.close();
                    resolve();
                }, 1200); // Mostrar completado un poco más tiempo para apreciar el icono
            } else {
                // Mostrar error con icono de SweetAlert
                Swal.fire({
                    icon: 'error',
                    title: 'Error al cargar ReportAI',
                    text: mensajeError || 'No se pudieron cargar todos los módulos necesarios.',
                    confirmButtonText: 'Entendido',
                    confirmButtonColor: '#e74c3c',
                    background: '#fff',
                    showClass: {
                        popup: 'swal2-show',
                        backdrop: 'swal2-backdrop-show',
                        icon: 'swal2-icon-show'
                    },
                    customClass: {
                        popup: 'swal2-popup-error',
                        title: 'swal2-title-error',
                        content: 'swal2-content-error'
                    }
                }).then(() => {
                    resolve();
                });
            }
        });
    });
}

/**
 * Muestra loading básico para ReportAI (versión simplificada)
 * @param {string} mensaje - Mensaje a mostrar
 */
function mostrarLoadingReportAI(mensaje) {
    // Usar la función cargarSweetAlert2 que ya existe
    cargarSweetAlert2(() => {
        mostrarSweetAlertLoading(mensaje);
    });
}

/**
 * Función interna para mostrar el SweetAlert de loading
 * @param {string} mensaje - Mensaje a mostrar
 */
function mostrarSweetAlertLoading(mensaje) {
    Swal.fire({
        title: mensaje,
        html: `
            <div style="text-align: center; padding: 20px;">
                <div class="spinner-border text-primary" style="width: 3rem; height: 3rem; margin-bottom: 15px;"></div>
                <p style="margin: 0; color: #666;">Cargando módulos AI...</p>
            </div>
        `,
        allowOutsideClick: false,
        allowEscapeKey: false,
        showConfirmButton: false,
        background: '#fff',
        customClass: {
            popup: 'reportai-loading-popup'
        }
    });
}

/**
 * Oculta el loading de ReportAI
 */
function ocultarLoadingReportAI() {
    if (typeof Swal !== 'undefined') {
        Swal.close();
    }
}

/**
 * Muestra error de carga de ReportAI
 * @param {string} mensaje - Mensaje de error
 */
function mostrarErrorReportAI(mensaje) {
    if (typeof Swal !== 'undefined') {
        Swal.fire({
            icon: 'error',
            title: 'Error ReportAI',
            text: mensaje,
            footer: 'Verifica la consola para más detalles',
            confirmButtonText: 'Entendido',
            html: `
                <p>${mensaje}</p>
                <div class="mt-3 text-left">
                    <small><strong>Checklist de troubleshooting:</strong></small>
                    <ul class="text-left small">
                        <li>✓ Archivos JS/CSS en assets/js/</li>
                        <li>✓ Métodos ReportAI en controller</li>
                        <li>✓ Rutas configuradas</li>
                        <li>✓ Base de datos conectada</li>
                    </ul>
                </div>
            `
        });
    } else {
        alert('Error ReportAI: ' + mensaje);
    }
}

/**
 * Función de utilidad para verificar dependencias CodeIgniter
 */
function verificarDependenciasReportAI() {
    const dependencias = [
        { nombre: 'jQuery', objeto: 'jQuery', requerido: true },
        { nombre: 'Bootstrap', objeto: 'bootstrap', requerido: false },
        { nombre: 'SweetAlert2', objeto: 'Swal', requerido: false }
    ];
    
    const faltantes = [];
    const opcionales = [];
    
    dependencias.forEach(dep => {
        if (typeof window[dep.objeto] === 'undefined') {
            if (dep.requerido) {
                faltantes.push(dep.nombre);
            } else {
                opcionales.push(dep.nombre);
            }
        }
    });
    
    if (faltantes.length > 0) {
        console.error('❌ Dependencias REQUERIDAS faltantes:', faltantes.join(', '));
        return false;
    }
    
    if (opcionales.length > 0) {
        console.warn('⚠️ Dependencias opcionales faltantes:', opcionales.join(', '));
        console.warn('💡 El sistema funcionará, pero con funcionalidad limitada');
    }
    
    console.log('✅ Dependencias verificadas correctamente');
    return true;
}

/**
 * Función de utilidad para debugging de rutas
 */
function debugRutasCodeIgniter() {
    console.group('🔍 Debug de Rutas CodeIgniter');
    console.log('URL actual:', window.location.href);
    console.log('Pathname:', window.location.pathname);
    console.log('Origin:', window.location.origin);
    
    // Detectar si estamos en el entorno correcto
    if (window.location.href.includes('aplicacionesasig.com/nom035/')) {
        console.log('✅ Entorno de producción detectado');
    } else if (window.location.href.includes('localhost')) {
        console.log('🔧 Entorno de desarrollo detectado');
    } else {
        console.warn('⚠️ Entorno no reconocido');
    }
    
    console.groupEnd();
}

/**
 * Función para testear conexión manual
 */
function testearConexionReportAI() {
    console.log('🧪 Iniciando test de conexión...');
    
    const baseUrl = 'https://aplicacionesasig.com/reportnom035/';
    
    $.ajax({
        type: "post",
        url: baseUrl + "obtener_empresas",
        cache: false,
        dataType: 'json',
        timeout: 5000,
        success: function(response) {
            console.log('✅ Test exitoso:', response);
        },
        error: function(xhr, status, error) {
            console.error('❌ Test fallido:', { status, error, response: xhr.responseText });
        }
    });
}

// Verificar dependencias al cargar
$(document).ready(function() {
    verificarDependenciasReportAI();
    debugRutasCodeIgniter();
});

// Log de inicialización
console.log('📋 ReportAI Loader CodeIgniter v2.1 - Sistema con barra de progreso');
console.log('🔧 Dependencias: jQuery (requerido), Bootstrap (opcional), SweetAlert2 (opcional)');
console.log('📁 Archivos requeridos: reportai-core.js, reportai-templates.js, reportai-styles.css');
console.log('🌐 Target: https://aplicacionesasig.com/reportnom035/');
console.log('💡 Para test manual: testearConexionReportAI()');
console.log('🎯 Nueva característica: Barra de progreso interactiva con log en tiempo real');

// ============================================================================
// FIN DEL CÓDIGO CARGADOR REPORTAI CODEIGNITER v2.1
// Incluye: Sistema de barra de progreso interactiva con log en tiempo real
// ============================================================================
// ============================================================================
// FIN DEL CÓDIGO - TODAS LAS LLAVES CERRADAS CORRECTAMENTE
// ============================================================================