[% USE raw %]
[% USE Koha %]
[% USE Branches %]
[% USE KohaDates %]
[% USE TablesSettings %]
[% USE ItemTypes %]
[% USE AdditionalContents %]
[% USE AuthorisedValues %]
[% PROCESS 'i18n.inc' %]
[% PROCESS 'html_helpers.inc' %]
[% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
[% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]

[% INCLUDE 'doc-head-open.inc' %]
<title
    >[% FILTER collapse %]
 [% t("Your holds history") | html %]
 &rsaquo; [% PROCESS 'library_name_title' %]
 [% END %]</title
>
[% INCLUDE 'doc-head-close.inc' %]
[% BLOCK cssinclude %]
 <style>
        .controls .paginate_button {
            font-family: "FontAwesome";
            text-decoration: none;
        }

        .controls .paginate_button:not(.disabled) {
            cursor: pointer;
        }

        .controls .paginate_button.disabled {
            color: grey;
        }

        .controls .previous:before {
            content: "\f104";
            padding-right: 0.5em;
        }

        .controls .next:after {
            content: "\f105";
            padding-left: 0.5em;
        }
    </style>
[% END %]
</head>
[% INCLUDE 'bodytag.inc' bodyid='opac-holdshistory' %]
[% INCLUDE 'masthead.inc' %]

<main class="main">
 [% WRAPPER breadcrumbs %]
 [% WRAPPER breadcrumb_item %]
 <a href="/cgi-bin/koha/opac-user.pl">[% INCLUDE 'patron-title.inc' patron = logged_in_user %]</a>
 [% END %]
 [% WRAPPER breadcrumb_item bc_active= 1 %]
 <span>Su historial de reservas</span>
 [% END %]
 [% END #/ WRAPPER breadcrumbs %]

 <div class="container-fluid">
 <div class="row">
 <div class="col col-lg-2 order-2 order-lg-1">
 <div id="navigation"> [% INCLUDE 'navigation.inc' IsPatronPage=1 %] </div>
 </div>
 <div class="col-md-12 col-lg-10 order-1">
 <div id="userholdshistory">
 <h1>Historial de reservas</h1>

 [% IF !holds %] No hay datos disponibles [% ELSE %] [% SET show_itemtype_column = Koha.Preference('AllowHoldItemTypeSelection') %] <div id="opac-user-holdsrec">
 <div id="tabs-container">
 <div class="controls">
 <div class="resultscontrol resort d-print-none">
 <form id="sortform" action="/cgi-bin/koha/opac-holdshistory.pl" method="get">
 [% IF ( unlimit ) %]<input type="hidden" name="unlimit" value="1" />[% END %]
 <select name="sort" id="sort">
 [% IF ( sort == 'reservedate' ) %]<option value="reservedate" selected="selected">Ordenar por fecha</option>[% ELSE %]<option value="reservedate">Ordenar por fecha</option>[% END %]
 [% IF ( sort == 'biblio.title' ) %]<option value="biblio.title" selected="selected">Ordenar por título</option>[% ELSE %]<option value="biblio.title">Ordenar por título</option>[% END %]
 [% IF ( sort == 'biblio.author' ) %]<option value="biblio.author" selected="selected">Ordenar por authro</option>[% ELSE %]<option value="biblio.author">Ordenar por authro</option>[% END %]
 </select>
 <input class="submit clearfix" id="sortsubmit" type="submit" value="Ir" />
 </form>
 </div>

 [% UNLESS unlimit %]
 <p class="d-print-none"> Mostrando 50 ítems. <a href="/cgi-bin/koha/opac-holdshistory.pl?unlimit=1[% IF ( sort ) %]&amp;sort=[% sort | url %][% END %]">Mostrar todos los ítems</a> </p>
 [% ELSE %]
 <p class="d-print-none"> Mostrando todos los ejemplares. <a href="/cgi-bin/koha/opac-holdshistory.pl[% IF ( sort ) %]?sort=[% sort | url %][% END %]">Mostrar 50 ítems</a> </p>
 [% END %]
 </div>
 <table id="table_holdshistory" class="table table-bordered table-striped">
 <caption class="sr-only">Historial de reservas</caption>
 <thead>
 <tr>
 <th class="anti-the">Título</th>
 <th>Autor</th>
 <th>Código de barras</th>
 <th>Biblioteca</th>
 <th>Fecha de reserva</th>
 <th>Fecha de vencimiento</th>
 <th>Fecha de espera</th>
 <th>Fecha de cancelación</th>
 [% IF show_itemtype_column %]
 <th>Tipo de ítem solicitado</th>
 [% END %]
 <th>Estado</th>
 </tr>
 </thead>
 <tbody>
 [% FOREACH hold IN holds %]
 <tr>
 [% IF hold.biblio %]
 <td>[% INCLUDE 'biblio-title.inc' biblio=hold.biblio link=>1 %]</td>
 <td>[% hold.biblio.author | html %]</td>
 [% ELSE %]
 <td>[% INCLUDE 'biblio-title.inc' biblio=hold.deleted_biblio link=>0 deleted=>1 %]</td>
 <td>[% hold.deleted_biblio.author | html %]</td>
 [% END %]
 <td>[% hold.item.barcode | html %]</td>
 <td>[% Branches.GetName( hold.branchcode ) | html %]</td>
 <td data-order="[% hold.reservedate | html %]">[% hold.reservedate | $KohaDates %]</td>
 <td data-order="[% hold.expirationdate | html %]">
 [% IF hold.expirationdate %]
 [% hold.expirationdate | $KohaDates %]
 [% END %]
 </td>
 <td data-order="[% hold.waitingdate | html %]">
 [% IF hold.waitingdate %]
 [% hold.waitingdate | $KohaDates %]
 [% END %]
 </td>
 <td data-order="[% hold.cancellationdate | html %]">
 [% IF hold.cancellationdate %]
 [% hold.cancellationdate | $KohaDates %]
 [% END %]
 </td>
 [% IF show_itemtype_column %]
 <td>
 [% IF hold.itemtype %]
 [% ItemTypes.GetDescription( hold.itemtype ) | html %]
 [% ELSE %]
 <span>Cualquier tipo de ítem</span>
 [% END %]
 </td>
 [% END %]
 <td>
 [% IF hold.found == 'F' %]
 <span>Completado</span>
 [% ELSIF hold.cancellationdate %]
 <span>Cancelada</span>
 [% IF hold.cancellation_reason %]
 ([% AuthorisedValues.GetByCode('HOLD_CANCELLATION', hold.cancellation_reason, 1) | html %])
 [% END %]
 [% ELSIF hold.found == 'W' %]
 [% IF hold.cancellation_requests.count == 0 %]
 <span>En espera</span>
 [% ELSE %]
 <span>Cancelada</span>
 [% END %]
 [% ELSIF hold.found == 'T' %]
 <span>En tránsito</span>
 [% ELSE %]
 <span>Pendiente</span>
 [% END %]
 </td>
 </tr>
 [% END %]
 </tbody>
 </table>
 </div>
 <!-- / .tabs-container -->
 </div>
 <!-- / .opac-user-holdsrec -->
 [% END # / IF old_holds_count %]
 </div>
 <!-- / .userholdshistory -->
 </div>
 <!-- / .span10 -->
 </div>
 <!-- / .row-fluid -->
 </div>
 <!-- / .container-fluid -->
</main>
<!-- / .main -->

[% INCLUDE 'opac-bottom.inc' %]
[% BLOCK jsinclude %]
 [% INCLUDE 'datatables.inc' %]
 <script>
        $(document).ready(function () {
            $("#sort").change(function () {
                $("#sortform").submit();
            });
            var table = $("#table_holdshistory").kohaTable({
                dom: '<"top"<"table_entries"i><"table_controls"fB>>t',
                autoWidth: false,
                sorting: [[4, "desc"]],
                language: {
                    search: "_INPUT_",
                    searchPlaceholder: _("Buscar"),
                },
            });
        });
    </script>
[% END %]
