diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt
index a5aa3585ba..750c44f980 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt
@@ -56,6 +56,30 @@
Current holds
[% IF patron.holds.count %]
+
@@ -81,6 +105,22 @@
Historical holds
[% IF patron.old_holds.count %]
+
@@ -129,12 +169,46 @@
//Remove item type column settings
table_settings['columns'] = table_settings['columns'].filter(function(c){return c['columnname'] != 'itemtype';});
[% END %]
- build_holds_table("#table_holdshistory");
- build_holds_table("#table_oldholdshistory", 1);
+ let current_holds_table = build_holds_table("#table_holdshistory");
+ let old_holds_table = build_holds_table("#table_oldholdshistory", 1);
function build_holds_table(table_id, old){
+ let additional_filters = {
+ "-or": function(){
+ let statuses = [];
+ let include_cancelled = false;
+ if ( table_id == '#table_holdshistory' ) {
+ if ( $("#current_pending_filter").is(":checked") ) {
+ statuses.push(null);
+ }
+ if ( $("#current_waiting_filter").is(":checked") ) {
+ statuses.push("W");
+ }
+ if ( $("#current_processing_filter").is(":checked") ) {
+ statuses.push("P");
+ }
+ if ( $("#current_transit_filter").is(":checked") ) {
+ statuses.push("T");
+ }
+ } else {
+ if ( $("#old_fulfilled_filter").is(":checked") ) {
+ statuses.push("F");
+ }
+ if ( $("#old_cancelled_filter").is(":checked") ) {
+ include_cancelled = true;
+ }
+ }
+ if ( include_cancelled ) {
+ return [{status: statuses}, { cancellation_date: {"<": new Date().toISOString() } } ]; // cancellation_date cannot be in the future. Would be better a 'not null' here however.
+ } else {
+ return [{status: statuses}];
+ }
+ },
+
+ };
+
let table_url = '/api/v1/patrons/[% patron.borrowernumber | uri %]/holds';
if (old){table_url += '?old=1'}
- $(table_id).kohaTable({
+ return $(table_id).kohaTable({
ajax: {
url: table_url,
},
@@ -232,8 +306,8 @@
},
[% END %]
{
- data: "found", // FIXME filter with dropdown list
- searchable: true,
+ data: "status",
+ searchable: false,
orderable: true,
render: function (data, type, row, meta) {
if ( row.status == 'F' ) {
@@ -256,8 +330,21 @@
}
},
],
- }, table_settings);
+ }, table_settings, true, additional_filters);
}
+ $("#current_holds_filters :checkbox, #old_holds_filters :checkbox").on("change", function(e){
+ e.preventDefault();
+ let container = $(this).closest("div");
+ if ( $(this).hasClass("show_all") ) {
+ if ( $(this).is(":checked") ) {
+ container.find(":checkbox").prop("checked", true);
+ }
+ } else if ( $(this).not(":checked") ) {
+ container.find(".show_all").prop("checked", false);
+ }
+ let table_dt = $("#"+container.data("table-id")).DataTable();
+ table_dt.draw();
+ });
});
[% END %]