<?php $__env->startSection('content'); ?>
    <h1 class="page-title">
        Reporte de pr&eacute;stamos
    </h1>

    <div class="portlet light portlet-fit portlet-datatable bordered">
        <div class="portlet-title">

            <div class="form-group col-lg-6">
                <label class="caption-subject font-green bold uppercase">Tipo Reporte</label>
                <select id="SelectTipoReporte" class="bs-select form-control" onchange="DatatableGenerator()">
                    <option value="1">Usuarios</option>
                    <option value="2">Bibliogr&aacute;fias</option>
                </select>
            </div>

            <div class="form-group  col-lg-6">
                <label class="caption-subject font-green bold uppercase">Ciclo acad&eacute;mico</label>
                <select id="SelectCicloAcademico" class="bs-select form-control" onchange="DatatableGenerator()">
                    <?php $__currentLoopData = $ciclos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ciclo): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($ciclo->id); ?>"> <?php echo e($ciclo->nombre); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>

        </div>

        <div class="portlet-body">
            <div class="row" style="padding-top: 5%;">
                <div class="col-lg-12">
                    <div id="sectionTable" class="Forum-ForumTopicList"></div>
                </div>
            </div>

            <div class="row" style="padding-top: 5%;">
                <div class="col-lg-12">
                    <div class="Forum-ForumTopicList">
                        <table class="table table-hover nowrap dataTable dtr-inline collapsed tbreportebibliografias" id="tbreportebibliografias"
                               width="100%" role="grid" aria-describedby="tbreportebibliografias_info">
                            <thead class="thead-default">
                            <tr>
                                <th>Nombre bibliografia</th>
                                <th>Cantidad reservas</th>
                                <th>Cantidad prestamos</th>
                                <th>Cantidad descarga</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php $__currentLoopData = $tablabibliografias; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td> <?php echo e($item->nombre); ?></td>
                                    <td> <?php echo e($item->cantReserva); ?></td>
                                    <td> <?php echo e($item->cantPrestamo); ?></td>
                                    <td> <?php echo e($item->num_descarga); ?></td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

        </div>

    </div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>

    <script src="<?php echo e(asset('plugins/datatables/datatables.all.min.js')); ?>" type="text/javascript"></script>
    <script src="<?php echo e(asset('plugins/datatables/datatables.min.js')); ?>" type="text/javascript"></script>
    <script src="<?php echo e(asset('plugins/datatables/plugins/bootstrap/datatables.bootstrap.js')); ?>" type="text/javascript"></script>

    <script>
        $('#tbreportebibliografias').DataTable({
            "lengthMenu": [[25, 20, 50, -1], [25, 20, 50, "Todas"]],
            bFilter: true,
            "bLengthChange": false,
            bInfo: true,
            "responsive":true,
            "autoWidth": false,
            "language": {
                "lengthMenu": "Mostrar _MENU_ Entradas",
                "zeroRecords": "No se encontraron registros",
                "info": "Mostrando la página _PAGE_ de _PAGES_",
                "infoEmpty": "No hay registros disponibles",
                "infoFiltered": "(filtrado de _MAX_ registros totales)",
                "search": "Buscar: ",
                "paginate": {
                    "first": "Primero",
                    "last": "Último",
                    "next": "Siguiente",
                    "previous": "Anterior"
                },
            },
            "order": [],
            "aoColumns": [
                { "bSearchable": false },
                { "bSearchable": false },
                { "bSearchable": false },
                { "bSearchable": false },
            ],
            "columns": [
                { "orderable": false },
                { "orderable": false },
                { "orderable": false },
                { "orderable": false },
            ],
            dom: 'Bfrtip',
            buttons: [
                'excel', 'pdf'
            ]
        });

        $( document ).ready(function() {

            var tipoReporte = $("#SelectTipoReporte").val();
            var cicloAcademico = $("#SelectCicloAcademico").val();

            if (tipoReporte == 1) {

                $.ajax({
                    url: "<?php echo e(url('reporte/prestamosusuarios')); ?>" +"/"+cicloAcademico,
                    dataType : 'html',
                    cache: false,
                    success: function (result) {
                        $("#sectionTable").empty();
                        $("#sectionTable").append(result);
                    }
                });

            } else {

                $.ajax({
                    url: "<?php echo e(url('reporte/prestamosbibliografia')); ?>" +"/"+cicloAcademico,
                    dataType : 'html',
                    cache: false,
                    success: function (result) {
                        $("#sectionTable").empty();
                        $("#sectionTable").append(result);
                    }
                });

            }

        });

        function DatatableGenerator() {
            var tipoReporte = $("#SelectTipoReporte").val();
            var cicloAcademico = $("#SelectCicloAcademico").val();

            $("#sectionTable").empty();

            if (tipoReporte == 1) {

                $.ajax({
                    url: "<?php echo e(url('reporte/prestamosusuarios')); ?>" +"/"+cicloAcademico,
                    dataType : 'html',
                    cache: false,
                    success: function (result) {
                        $("#sectionTable").append(result);
                    }
                });

            } else {

                $.ajax({
                    url: "<?php echo e(url('reporte/prestamosbibliografia')); ?>" +"/"+cicloAcademico,
                    dataType : 'html',
                    cache: false,
                    success: function (result) {
                        $("#sectionTable").append(result);
                    }
                });

            }

        }

    </script>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('template.layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>