From f84adb75db202f50dfdb72ff8ade0d38bc7f33eb Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 3 Sep 2021 17:27:00 +0000 Subject: [PATCH] Bug 28949: Use Flatpickr on reports pages This patch replaces the use of jQueryUI's datepicker on reports pages. To test, apply the patch and test the following reports pages to confirm that datepickers work correctly. "Linked" date fields should prevent a "to" selection which preceeds the selected "from" date. - Acquisitions statistic wizard: Linked pairs of fields for "placed on" and "received on." - Patrons with the most checkouts: Linked pairs of fields for "Checkout date from" and "Check-in date from" - Patrons who haven't checked out: "Not checked out since" field. - Cash register statistics wizard: Linked "From" and "To" fields. - Most-circulated items: Linked pairs of fields for "Checkout date from" and "Check-in date from" - Catalog statistics wizard: Linked pairs of fields for "Date acquired (item)" and "Date deleted (item)" The latter is shown by checking the "Count deleted items" radio button. - View dictionary -> New definition: - Enter a definition name - Select table Circulation - Choose a date column, e.g. "Date of birth" or "Registration date" - Select "Date range" - Test that the "Start of date range" and "End of date range" fields are linked correctly. - Create guided report: - Module: catalog - Type: Tabular - Select columns (any) - Select criteria to limit on: There should be three pairs of linked fields, "Creation date," "Modification date," and "Due date." - Confirm that the report is saved correctly with the dates you chose. - Create from SQL -> Test a report with one or more date fields, e.g. https://wiki.koha-community.org/wiki/SQL_Reports_Library#Items_added_by_Collection - Average loan time: Linke pairs of fields for "Checkout date" and "Returns." - Reports -> Circulation statistics wizard: Linked "Period" fields. - Reports -> Holds statistics wizard: Linked pairs of fields "Hold date," "Notification date," "Reminder date," "Waiting date," and "Cancellation date." Signed-off-by: David Nind --- .../prog/en/includes/calendar.inc | 3 + .../en/modules/reports/acquisitions_stats.tt | 64 ++++---- .../prog/en/modules/reports/bor_issues_top.tt | 63 ++++---- .../prog/en/modules/reports/borrowers_out.tt | 7 +- .../en/modules/reports/cash_register_stats.tt | 4 +- .../prog/en/modules/reports/cat_issues_top.tt | 62 +++---- .../en/modules/reports/catalogue_stats.tt | 42 +++-- .../prog/en/modules/reports/dictionary.tt | 4 +- .../modules/reports/guided_reports_start.tt | 27 +++- .../en/modules/reports/issues_avg_stats.tt | 56 +++---- .../prog/en/modules/reports/issues_stats.tt | 11 +- .../prog/en/modules/reports/reserves_stats.tt | 152 +++++++++--------- 12 files changed, 272 insertions(+), 223 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index bdb793ca67..e7d3bcd644 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -34,6 +34,9 @@ if( $(instance.input).hasClass("futuredate") ){ instance.set("minDate", new Date().fp_incr(1)); } + if( $(instance.input).hasClass("pastdate") ){ + instance.set("maxDate", new Date().fp_incr(-1)); + } $(instance.input) /* Add a wrapper element so that we can prevent the clear button from wrapping */ .wrap("") diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt index af06dc3e35..2f9dee8e43 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt @@ -119,11 +119,12 @@ Placed on - From - [% INCLUDE 'date-format.inc' %] - To - [% INCLUDE 'date-format.inc' %] - + + From + [% INCLUDE 'date-format.inc' %] + To + [% INCLUDE 'date-format.inc' %] +   @@ -141,11 +142,12 @@ Received on - From - [% INCLUDE 'date-format.inc' %] - To - [% INCLUDE 'date-format.inc' %] - + + From + [% INCLUDE 'date-format.inc' %] + To + [% INCLUDE 'date-format.inc' %] +   @@ -339,33 +341,29 @@ [% INCLUDE 'calendar.inc' %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/bor_issues_top.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/bor_issues_top.tt index 502ac75124..2d819f6262 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/bor_issues_top.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/bor_issues_top.tt @@ -117,12 +117,21 @@

Patrons with the most checkouts

-
  1. - - [% INCLUDE 'date-format.inc' %]
  2. -
  3. - - [% INCLUDE 'date-format.inc' %]
  4. +
      +
    1. + + + + + [% INCLUDE 'date-format.inc' %] +
    2. +
    3. + + + + + [% INCLUDE 'date-format.inc' %] +
    4. -
    5. +
@@ -143,11 +143,6 @@ [% MACRO jsinclude BLOCK %] [% INCLUDE 'calendar.inc' %] - [% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt index 4ec821bc6d..d442c6981f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt @@ -58,12 +58,12 @@
  • - +
    [% INCLUDE 'date-format.inc' %]
  • - +
    [% INCLUDE 'date-format.inc' %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cat_issues_top.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cat_issues_top.tt index ecd1d44026..7d4aa27b51 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cat_issues_top.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cat_issues_top.tt @@ -95,12 +95,20 @@
      -
    1. - - [% INCLUDE 'date-format.inc' %]
    2. -
    3. - - [% INCLUDE 'date-format.inc' %]
    4. +
    5. + + + + + [% INCLUDE 'date-format.inc' %] +
    6. +
    7. + + + + + [% INCLUDE 'date-format.inc' %] +
    8. - + - + @@ -263,9 +263,9 @@ - + - + @@ -353,16 +353,30 @@ } $(document).ready(function() { - $('#acqdateFrom, #deldateFrom') - .datepicker('option', 'onSelect', function(selectedDate) { - var id = $(this).attr('id').replace('From', 'To'); - $('#' + id).datepicker('option', 'minDate', selectedDate); - }); - $('#acqdateTo, #deldateTo') - .datepicker('option', 'onSelect', function(selectedDate) { - var id = $(this).attr('id').replace('To', 'From'); - $('#' + id).datepicker('option', 'maxDate', selectedDate); - }); + + var acqdateFrom = $("#acqdateFrom").flatpickr({ + onClose: function( selectedDates, dateText, instance) { + validate_date( selectedDates, instance ); + acqdateTo.set('minDate', selectedDates[0]); + } + }); + var acqdateTo = $("#acqdateTo").flatpickr({ + onClose: function( selectedDates, dateText, instance) { + validate_date( selectedDates, instance ); + }, + }); + + var deldateFrom = $("#deldateFrom").flatpickr({ + onClose: function( selectedDates, dateText, instance) { + validate_date( selectedDates, instance ); + deldateTo.set('minDate', selectedDates[0]); + } + }); + var deldateTo = $("#deldateTo").flatpickr({ + onClose: function( selectedDates, dateText, instance) { + validate_date( selectedDates, instance ); + }, + }); $("input[name='Cellvalue']").change(function() { changeRemovedDateTrStatus(); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt index 30e83f8f6b..fd1bd3e223 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt @@ -259,10 +259,10 @@
    9. Start of date range - +
      [% INCLUDE 'date-format.inc' %]
      End of date range - +
      [% INCLUDE 'date-format.inc' %]
    10. [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt index 4afd8b7179..3b197dd6f8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt @@ -603,7 +603,7 @@ [% IF ( criteri.date ) %] - + [% INCLUDE 'date-format.inc' %] @@ -619,9 +619,9 @@ [% IF ( criteri.daterange ) %] from - + to - + [% INCLUDE 'date-format.inc' %] @@ -858,7 +858,7 @@ [% IF sql_param.input == 'date' %]
    11. - +
    12. [% ELSIF ( sql_param.input == 'text' ) %]
    13. @@ -1320,7 +1320,7 @@
      1. - +
        [% INCLUDE 'date-format.inc' %]
      2. @@ -2189,6 +2189,23 @@ readOnly: true }); } + [% IF ( build4 ) %] + [% FOREACH criteri IN criteria %] + [% IF ( criteri.daterange ) %] + var from_[% criteri.name.remove('\.') | html %]_value = $("#from_[% criteri.name.remove('\.') | html %]_value").flatpickr({ + onClose: function( selectedDates, dateText, instance) { + validate_date( selectedDates, instance ); + to_[% criteri.name.remove('\.') | html %]_value.set('minDate', selectedDates[0]); + } + }); + var to_[% criteri.name.remove('\.') | html %]_value = $("#to_[% criteri.name.remove('\.') | html %]_value").flatpickr({ + onClose: function( selectedDates, dateText, instance) { + validate_date( selectedDates, instance ); + }, + }); + [% END %] + [% END %] + [% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_avg_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_avg_stats.tt index f976f1cffe..47138b735d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_avg_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_avg_stats.tt @@ -103,8 +103,11 @@ Checkout date - - + + + + + [% INCLUDE 'date-format.inc' %] @@ -124,8 +127,11 @@ Returns - - + + + + + [% INCLUDE 'date-format.inc' %] @@ -262,33 +268,29 @@ [% INCLUDE 'calendar.inc' %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_stats.tt index ddf42c2bec..97e1f0f76c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_stats.tt @@ -126,11 +126,14 @@ Period - - + + + + + [% INCLUDE 'date-format.inc' %] - - + + - - - - + + + + + + + Notification date - - - + + + + + + Reminder date - - - + + + + + + Waiting date - - - + + + + + + Cancellation date - - - + + + + + + Patron category @@ -325,72 +340,65 @@ [% INCLUDE 'calendar.inc' %] [% END %] -- 2.20.1