 <!DOCTYPE html>
<html lang="es">
    <head>
        <title>Reporte de Cumpleaños</title>
        <head>
        <title>Reporte de Ventas</title>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.13/datatables.min.css"/>
        <script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.13/datatables.min.js"></script> 
        <!--     -->
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.13/css/dataTables.bootstrap.min.css" />
        <script type="text/javascript" src="https://cdn.datatables.net/1.10.13/js/dataTables.bootstrap.min.js"></script>
        <script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.19/api/sum().js"></script>
        <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.html5.min.js"></script>
        <!-- <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script> -->
        <script type="text/javascript" src="<?php echo base_url()?>assets/plugins/jQuery/jquery-3.3.1.js"></script>
        
        <script type="text/javascript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
        <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.2/js/dataTables.buttons.min.js"></script>
        <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.flash.min.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
        <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.html5.min.js"></script>
        <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.print.min.js"></script>
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" />
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.5.2/css/buttons.dataTables.min.css" />
        <!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" /> -->
         <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" />
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
        <link rel="stylesheet" type="text/css" href='<?php echo base_url()?>assets/dist/css/table.css' />
        <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
        <link rel="stylesheet" href="<?php echo base_url().'assets/plugins/select/bootstrap-select.min.css'?>">
        <!-- Latest compiled and minified JavaScript -->
        <script src="<?php echo base_url().'assets/plugins/select/bootstrap-select.min.js'?>"></script>
    </head>
    <style type="text/css">
        /*table.table.table-condensed thead {
            display: none;
        }*/
        .datepicker-months table thead {
            display: none;
        }
        .boton {
            text-align: center;
        }
        .table>thead:first-child>tr:first-child>th {
            text-align: center;
        }
        .alert-warning {
            color: #8a6d3b !important;
            background-color: #fcf8e3 !important;
            border-color: #faebcc !important;
        }
        .alert-danger {
            color: #a94442 !important;
            background-color: #f2dede !important;
            border-color: #ebccd1 !important;
        }
        .alert-info {
            color: #31708f !important;
            background-color: #d9edf7 !important;
            border-color: #bce8f1 !important;
        }
        .alert-success {
            color: #3c763d !important;
            background-color: #dff0d8 !important;
            border-color: #d6e9c6 !important;
        }
        .mensajes {
            width: 50%;
            margin: auto;
            margin-top: 3%;
        }
        /*input#filtrarReportes {
            margin: 0;
        }*/
        .form-content .col-md-4 {
            width: 70%;
            
        }
        .boton {
            text-align: right;
        }
        .datepicker.dropdown-menu {
            min-width: 260px !important;
        }
         @media screen and (min-width: 768px){
            form.form-horizontal {
                width: 100%;
                margin: auto;
            }
            input#filtrarReportes {
                width: 38% !important;
            }
        }
        @media screen and (min-width: 1024px){
            .form-group {
                width: 100%;
                display: flex;
            }
            form.form-horizontal {
                width: 100%;
                margin: auto;
            }
            .form-content {
                width: 34%;
                margin: 0;
            }
             .boton {
                width: 30%;
            }   
            input#filtrarReportes {
                margin: 0;
                width: 89% !important;
            }
        }
   @media screen and (min-width: 1200px){
        input#filtrarReportes {
            margin: 0;
            width: 70%;
        }
    }
    </style>
<body>
    <div class="contenido-form">
        <form action="#" method="POST" class="form-horizontal">
               <!--  <label for="startDate">Date :</label>
                <input name="startDate" id="startDate" class="date-picker" /> -->
            <div class="form-group">
                <div class="form-content">
                    <label for="" class="col-md-1 control-label">Desde:</label>
                    <div class="col-md-4">
                        <input type="nacimiento" class="form-control date-picker" name="fechainicio" id="fechainicio" >
                    </div>
                </div>
                <div class="form-content">
                    <label for="" class="col-md-1 control-label">Hasta:</label>
                    <div class="col-md-4">
                        <input type="nacimiento" class="form-control date-picker" name="fechafin" id="fechafin">
                    </div>
                </div>
                <div class="boton">
                 <input type="submit" class="btn btn-primary fr" id="filtrarReportes" value="Buscar" />
                </div>

                <div class="boton"> 
                <input onclick=location.href="<?php echo base_url();?>reportes/Franquiciatario/reportesF" type="button" id="filtrarReportes" class="btn btn-danger" value="Regresar"/>
                 </div>
            </div>
        </form>
        <div class="mensajes"></div>
    <div class="container">
        <h1>Reporte de Cumpleaños</h1>
        <table id="book-table" class="display up table" style="width:100%">
        </table>
    </div>
       <!--  <form id="ventasReporte" class="navbar-form navbar" action="#">
            <label for="name1">Tipo Reporte  </label>
            <select class="form-control" id="queryReporte" name="queryReporte"> 
                <option value="">Selecciona una tipo de Reporte</option>
                <option value="1">Ventas General</option>
                <option value="2">Ventas Servicios Franquicia</option>
                <option value="3">Ventas Promociones </option>
                <option value="4">Ventas Productos </option>
            </select>
            <input type="submit" class="btn btn-primary" id="filtrarReportes" value="Buscar" />
        </form> -->
    </div>


    
</body>

<script type="text/javascript">

    $(document).ready(function() {
        $('.alert').alert();
        
        $.fn.datepicker.dates['en'] = {
            days: ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"],
            daysShort: ["Dom", "Lun", "Mar", "Mier", "Jue", "Vier", "Sab"],
            daysMin: ["D", "L", "Ma", "Mi", "J", "V", "S"],
            months: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"],
            monthsShort: ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"],
            today: "Today",
            clear: "Clear",

            weekStart: 0
        };

        $.datepicker.setDefaults($.datepicker.regional['en']);
        $(".date-picker").datepicker( {
            isRTL: false,
            format: "0000-mm-00",
            yearRange: "0000",
            viewMode: "months", 
            minViewMode: "months",
        });
        $('.date-picker').datepicker('setDate', 'today');
        //end data-picker

        $('#filtrarReportes').click(function(){
            var fechainicio = $('#fechainicio').val();
            var fechafin = $("#fechafin").val();
            console.log(fechainicio);
            console.log(fechafin);

            $.ajax({
                url:"<?php echo base_url();?>reportes/Franquiciatario/ReportesCumple/reporteCumpleanios",
                type:'POST',
                dataType: 'json',
                data:{finicio : fechainicio, ffin : fechafin},
                success:function(response){
                    console.log("exito");
                    console.log(response);
                    $('.alert').alert('close'); 
                    toastr.success('Se realizó tu busqueda se encontraron '+ response.length +' resultados').css("width","100%");
                    /*$(".mensajes").append('<div class="alert alert-success"><strong>Se realizó tu busqueda se encontraron '+ response.length +' resultados</strong><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>');*/
                    var columns = [
                        { "title":"Nombre" },
                        { "title":"Fecha Nacimiento" },
                        { "title":"Teléfono" },
                        { "title":"Celular" },
                        { "title":"Email" },
                        { "title":"Dirección" },
                        { "title":"Sexo" },
                        { "title":"Edad" },
                        { "title":"Medio de Información" },
                        { "title":"Recomendado Por" },
                        { "title":"Autorización uso Datos" },
                        { "title":"Fecha de Registro" },


                    ];   

                     var hide = [
                            { targets: [0, 1,2,3,4,5,6,7,8,9,10,11], visible: true},
                           /* { targets: [8], visible: false }*/
                        ];
                      

                    $('#book-table').DataTable( {
                        dom: 'T<"clear">Bfrtip',
                        responsive: true,
                        columnDefs: hide,
                        data: response,
                        columns: columns,
                        ServerSide: true,
                         destroy: true,
                         footer: true,
                         processing: true,
                         buttons: [
                        {
                            extend: 'print',
                            text:"IMPRIMIR",
                            footer: true,
                            /*messageTop: 'Reporte de Ventas',*/
                            title: '',
                            customize: function ( win ) {

                                $(win.document.body)
                                .css( 'font-size', '10pt' )
                                .prepend(
                                    '<div class="top" style="width: 100%; text-align:center; display:flex; align-items: center; align-content: center;">  <div style="width: 50%;"><img src="<?php echo base_url();?>assets/dist/img/logo.png" style="width: 50%;" /></div><div style="width: 50%; font-size:2em">Reporte de Cumpleaños</div></div>'
                                    );

                                $(win.document.body).find( 'table' )
                                .addClass( 'compact' )
                                .css( 'font-size', 'inherit' );
                                $(win.document.body).find( 'table' )
                                .addClass( 'mayus' )
                                .css( 'text-transform', 'uppercase' );
                            },
                            
                        },
                        {
                            extend: 'pdf',
                            footer: true,
                            filename: 'ReporteCumpleanios',
                            /*messageTop: 'Reporte de Ventas',*/
                            title: '',
                            orientation: 'landscape',
                            pageSize: 'A4',
                            key: { 
                                key: 'e',
                                altKey: false
                            }
                            , content: [{ style: 'fullWidth' }]
                            , styles: { 
                                fullWidth: { fontSize: 10, bold: true, alignment: 'right', margin: [0,0,0,0],   }

                            },
                            exportOptions: {
                                modifier: {
                                    pageMargins: [ 0, 0, 0, 0 ],  
                                    margin: [ 0, 0, 0, 0 ],  
                                    alignment: 'center',
                                     page: 'all',
                                   
                                }
                                , body : {margin: [ 0, 0, 0, 0 ], pageMargins: [ 0, 0, 0, 0 ]},
                                footer: true,
                                columns: [ 0, 1, 2, 3, 4, 5, 6,7,8,9,10,11]//son las columnas q quiero q se vean al exportarse          

                            },
                            body : {margin: [ 0, 0, 0, 0 ], pageMargins: [ 0, 0, 0, 0 ]},
                            customize: function ( doc ) {
                                console.log(doc.content);

                            },
                        },
                        {
                            extend: 'excel',
                            footer: true,
                            filename: 'ReporteCumpleanios',
                            title: 'Reporte De Cumpleaños',
                            footer: true,
                        }
                        /*'copy', 'csv', 'excel',*/
                        ],

                        language: {
                            "lengthMenu": "Mostrar _MENU_ registros por pagina",
                            "zeroRecords": "No se encontraron resultados en su busqueda",
                            "searchPlaceholder": "Buscar registros",
                            "info": "Mostrando registros de _START_ al _END_ de un total de  _TOTAL_ registros",
                            "infoEmpty": "No existen registros",
                            "infoFiltered": "(filtrado de un total de _MAX_ registros)",
                            "search": "Buscar:",
                            "paginate": {
                                "first": "Primero",
                                "last": "Último",
                                "next": "Siguiente",
                                "previous": "Anterior"
                            },
                        },
                        
                        
                    });

                    return false;

                },//end success ajax response
                error:function(){
                    $('.alert').alert('close'); 
                    console.log("error");

                    toastr.error("Ocurrio Algun Error verifica los datos ingresados");
                    /*$(".mensajes").append('<div class="alert alert-danger"><strong>Ocurrió algun error verifica los datos Ingresados</strong><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>');*/
                },

                });//end ajax





            return false;//para q no haga reload
        }); //end filtrar reportes buscar  



    });   

</script>
</html>