From acffc1c195f71053871d9f8bf3ecce6fc4d6a7c0 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 Signed-off-by: Nick Clemens --- .../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 b2647feb80..d4acb08186 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -4093,8 +4093,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 293935f479..cfc5e590d2 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.39.5