From 39eaef63096665dd2f772865648cf3c53dc9d128 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 --- .../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 1da543b..b233ef2 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -4031,8 +4031,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 e084aa5..bc51a95 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 @@ -152,43 +152,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(''); } } }; @@ -456,6 +426,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; + + }); + } ); @@ -525,12 +522,20 @@
  • - - + + +
  • +
  • + + +
  • +
  • + +
  • - - + +
  • -- 2.1.4