

/*=============================================
RANGO DE FECHAS (DATERANGEPICKER)
=============================================*/
$('#daterange-btn-auditoria').daterangepicker(
  {
    ranges   : {
      'Hoy'       : [moment(), moment()],
      'Ayer'      : [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
      'Últimos 7 días' : [moment().subtract(6, 'days'), moment()],
      'Este Mes'  : [moment().startOf('month'), moment().endOf('month')],
      'Mes Pasado'  : [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
    },
    startDate: moment(),
    endDate  : moment()
  },
  function (start, end) {
    var fechaInicial = start.format('YYYY-MM-DD');
    var fechaFinal = end.format('YYYY-MM-DD');

    window.location = "index.php?ruta=auditoria&fechaInicial="+fechaInicial+"&fechaFinal="+fechaFinal;
  }
);

$('.tablaAuditoria').DataTable({
    "autoWidth": false,
    "deferRender":true,
    "retrieve":true,
    "scrollCollapse": true,
    "paging": false,
    "processing": false,
    "sScrollY": "75vh",
    "stateSave":  true,
    "language": {

            "decimal": "",
            "sEmptyTable": "No hay información",
            "sInfo": "Mostrando _START_ a _END_ de _TOTAL_ Entradas",
            "sInfoEmpty": "Mostrando 0 to 0 of 0 Entradas",
            "sInfoFiltered": "(Filtrado de _MAX_ total entradas)",
            "sInfoPostFix": "",
            "sInfoThousands": ",",
            "sLengthMenu": "Mostrar _MENU_ Entradas",
            "sLoadingRecords": "Cargando...",
            "sProcessing": "Procesando...",
            "sSearch": "Buscar:",
            "sZeroRecords": "Sin resultados encontrados",
            "oPaginate": {
                "sFirst": "Primero",
                "sLast": "Ultimo",
                "sNext": "Siguiente",
                "sPrevious": "Anterior"
            },
            "oAria": {
                "sSortAscending": ": Activar para ordenar la columna de manera ascendete",
                "sSortDescending": ": Activar para ordenar la columna de manera descendete",
            }
        },
        "dom": "Bfrtilp",
                "buttons": [
                    {
                        "extend": "excel",
                        "text": "<i class='fas fa-file-excel'></i>",
                        "titleAttr" : "Exportar a Excel",
                        "className": 'btn btn-success',
                        "filename": function() {
                            return "AUDITORIA"      
                          },
                        "exportOptions": {
                            "columns": ["1","2","3","4","5"]
                        }
                    },
                    {
                        "extend": "pdfHtml5",
                        "download": "open",
                        "text": "<i class='fas fa-file-pdf'></i>",
                        "titleAttr" : "Exportar a pdf",
                        "className": 'btn btn-danger',
                        "filename" : function() {
                            return "AUDITORIA"      
                          },      
                        "customize": function(doc) {
                            doc.defaultStyle.fontSize = 8; 
                            doc.defaultStyle.alignment = 'justify'
                            
                         
                        },
                         "exportOptions": {
                            "columns": ["1","2","3","4","5"],
                            "page": 'current'
                        },
                        "footer": true

                    },
                    {
                        "extend": "print",
                        "text": "<i class='fa fa-print'></i>",
                        "titleAttr" : "Imprimir",
                        "className": 'btn btn-info',
                        "customize": function (win) {
                            $(win.document.body)
                                .css( "font-size", "8pt" )
                            $(win.document.body).find( "table" )
                                .addClass( "compact" )
                                .css( "font-size", "8pt" );
                        },
                        "exportOptions": {
                            "columns": ["1","2","3","4","5"]
                        }
                    }
                ]
      
});