@extends('template.layout')
@section('styles')
    <link href="{{ asset('plugins/datatables/datatables.min.css') }}" rel="stylesheet" type="text/css" />
    <link href="{{ asset('plugins/datatables/plugins/bootstrap/datatables.bootstrap.css') }}" rel="stylesheet" type="text/css" />
@endsection

@section('content')
    <h1 class="page-title">
        Historial de Pr&eacute;stamos
    </h1>

    <div class="portlet light portlet-fit portlet-datatable bordered">
        <div class="portlet-title">
            <div class="caption">
                <span class="caption-subject font-green sbold uppercase"> Pr&eacute;stamos realizados </span>
            </div>
        </div>
        <div class="portlet-body">
            <div class="row">
                <div>
                    <div class="Forum-ForumTopicList" style="margin:15px;">
                        <table class="table table-hover nowrap dataTable dtr-inline collapsed tbEncuestas"
                               id="tbPrestamos"
                               width="100%" role="grid" aria-describedby="tbPrestamos_info" style="text-align: center;">
                            <thead class="thead-default">
                            <tr>
                                <th>N°</th>
                                <th>Nombre de la bibliograf&iacute;a</th>
                                <th>Autor</th>
                                <th>Materia</th>
                                <th>A&ncaron;o</th>
                                <th>Edici&oacute;n</th>
                                <th>Fecha de pr&eacute;stamo</th>
                                <th>N&uacute;mero de d&iacute;as de pr&eacute;stamo</th>
                            </tr>
                            </thead>
                            <tbody>
                            @php ($count = 1)
                            @foreach($datas as $item)
                                <tr>
                                    <td> {{ $count }} </td>
                                    <td> {{ $item->nombre }} </td>
                                    <td> {{ $item->nombres }} </td>
                                    <td> {{ $item->materia }} </td>
                                    <td> {{ $item->anio }} </td>
                                    <td> {{ $item->edicion }} </td>
                                    <td> {{ date("d-m-Y", strtotime($item->fecha_inicio)) }} </td>
                                    <td> {{ (\Carbon\Carbon::parse($item->fecha_devolucion)->diffInDays(\Carbon\Carbon::parse($item->fecha_inicio))) }}</td>

                                </tr>
                                @php ($count++)
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

        </div>
    </div>
@endsection

@section('scripts')
    <script src="{{ asset('plugins/datatables/datatables.min.js') }}" type="text/javascript"></script>
    <script src="{{ asset('plugins/datatables/plugins/bootstrap/datatables.bootstrap.js') }}" type="text/javascript"></script>
    <script>
        $('#tbPrestamos').DataTable({
            "lengthMenu": [[25, 20, 50, -1], [25, 20, 50, "Todas"]],
            bFilter: true,
            "bLengthChange": false,
            bInfo: true,
            responsive: true,
            "autoWidth": true,
            "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": true},
                {"bSearchable": true},
                {"bSearchable": true},
                {"bSearchable": false},
                {"bSearchable": false},
                {"bSearchable": true},
                {"bSearchable": false}

            ],
            "columns": [
                {"orderable": false},
                {"orderable": false},
                {"orderable": true},
                {"orderable": false},
                {"orderable": false},
                {"orderable": false},
                {"orderable": false}
            ],
            dom: 'Bfrtip',
            buttons: [
                'excel', 'pdf'
            ]
        });
    </script>
@endsection