From 9b9fa4efc541f96f4d60a9c5030b258ea60e1eb7 Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Mon, 4 Jun 2018 12:43:37 +0100 Subject: [PATCH] Bug 20600: (follow-up) Add date range filtering It makes more sense to be able to filter placed and updated dates by range. This patch adds that. Signed-off-by: Owen Leonard Signed-off-by: Katrin Fischer --- .../intranet-tmpl/prog/css/src/staff-global.scss | 6 +- .../prog/en/modules/ill/ill-requests.tt | 77 ++++++++++++---------- 2 files changed, 45 insertions(+), 38 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index 599dc2d742..808f683153 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -4060,8 +4060,10 @@ span { } } -#illfilter_dateplaced, -#illfilter_datemodified { +#illfilter_dateplaced_start, +#illfilter_datemodified_start, +#illfilter_dateplaced_end, +#illfilter_datemodified_end { width: 80%; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt index 98b9810673..0502fa3a3f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt @@ -154,43 +154,13 @@ } }, dateModified: { - listener: function() { - var me = 'dateModified'; - $('#illfilter_datemodified').change(function() { - var val = $('#illfilter_datemodified').val(); - if (val && val.length > 0) { - activeFilters[me] = function() { - table.column(10).search(val); - } - } else { - if (activeFilters.hasOwnProperty(me)) { - delete activeFilters[me]; - } - } - }); - }, clear: function() { - $('#illfilter_datemodified').val(''); + $('#illfilter_datemodified_start, #illfilter_datemodified_end').val(''); } }, datePlaced: { - listener: function() { - var me = 'datePlaced'; - $('#illfilter_dateplaced').change(function() { - var val = $('#illfilter_dateplaced').val(); - if (val && val.length > 0) { - activeFilters[me] = function() { - table.column(8).search(val); - } - } else { - if (activeFilters.hasOwnProperty(me)) { - delete activeFilters[me]; - } - } - }); - }, clear: function() { - $('#illfilter_dateplaced').val(''); + $('#illfilter_dateplaced_start, #illfilter_dateplaced_end').val(''); } } }; @@ -484,6 +454,33 @@ } })); + // Custom date range filtering + $.fn.dataTable.ext.search.push(function(settings, data, dataIndex) { + var placedStart = $('#illfilter_dateplaced_start').datepicker('getDate'); + var placedEnd = $('#illfilter_dateplaced_end').datepicker('getDate'); + var modifiedStart = $('#illfilter_datemodified_start').datepicker('getDate'); + var modifiedEnd = $('#illfilter_datemodified_end').datepicker('getDate'); + var rowPlaced = data[8] ? new Date(data[8]) : null; + var rowModified = data[10] ? new Date(data[10]) : null; + var placedPassed = true; + var modifiedPassed = true; + if (placedStart && rowPlaced && rowPlaced < placedStart) { + placedPassed = false + }; + if (placedEnd && rowPlaced && rowPlaced > placedEnd) { + placedPassed = false; + } + if (modifiedStart && rowModified && rowModified < modifiedStart) { + modifiedPassed = false + }; + if (modifiedEnd && rowModified && rowModified > modifiedEnd) { + modifiedPassed = false; + } + + return placedPassed && modifiedPassed; + + }); + } ); @@ -553,12 +550,20 @@
  • - - + + +
  • +
  • + + +
  • +
  • + +
  • - - + +
  • -- 2.11.0