From ba7861914ad74fc38e74366543e071c737e36360 Mon Sep 17 00:00:00 2001 From: Maryse Simard Date: Thu, 20 Oct 2022 16:52:19 -0400 Subject: [PATCH] Bug 17015: Add an option to view past holiday details in table --- Koha/DiscreteCalendar.pm | 10 ++-- .../en/modules/tools/discrete_calendar.tt | 59 ++++++++++++++++--- tools/discrete_calendar.pl | 4 +- 3 files changed, 59 insertions(+), 14 deletions(-) diff --git a/Koha/DiscreteCalendar.pm b/Koha/DiscreteCalendar.pm index b6d4c3bfcc..6b5ef2c0f5 100644 --- a/Koha/DiscreteCalendar.pm +++ b/Koha/DiscreteCalendar.pm @@ -337,7 +337,7 @@ Returns an array of all the date objects that are unique holidays. sub get_unique_holidays { my $self = shift; - my $exclude_past = shift || 1; + my $exclude_past = shift // 1; my $branchcode = $self->{branchcode}; my @unique_holidays; my $schema = Koha::Database->new->schema; @@ -377,7 +377,7 @@ Returns an array of all the date objects that are float holidays. sub get_float_holidays { my $self = shift; - my $exclude_past = shift || 1; + my $exclude_past = shift // 1; my $branchcode = $self->{branchcode}; my @float_holidays; my $schema = Koha::Database->new->schema; @@ -417,7 +417,7 @@ Returns an array of all the date objects that are float holidays in need of vali sub get_need_validation_holidays { my $self = shift; - my $exclude_past = shift || 1; + my $exclude_past = shift // 1; my $branchcode = $self->{branchcode}; my @need_validation_holidays; my $schema = Koha::Database->new->schema; @@ -457,7 +457,7 @@ Returns an array of all the date objects that are repeatable holidays. sub get_repeatable_holidays { my $self = shift; - my $exclude_past = shift || 1; + my $exclude_past = shift // 1; my $branchcode = $self->{branchcode}; my @repeatable_holidays; my $schema = Koha::Database->new->schema; @@ -497,7 +497,7 @@ Returns an array of all the date objects that are weekly holidays. sub get_week_days_holidays { my $self = shift; - my $exclude_past = shift || 1; + my $exclude_past = shift // 1; my $branchcode = $self->{branchcode}; my @week_days; my $schema = Koha::Database->new->schema; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/discrete_calendar.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/discrete_calendar.tt index 863d39c0cf..cfd6e4f359 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/discrete_calendar.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/discrete_calendar.tt @@ -225,7 +225,7 @@
[% IF ( NEED_VALIDATION_HOLIDAYS ) %]

Need validation holidays

- +
@@ -247,7 +247,7 @@ [% IF ( WEEKLY_HOLIDAYS ) %]

Weekly - Repeatable holidays

- +
@@ -269,7 +269,7 @@ [% IF ( REPEATABLE_HOLIDAYS ) %]

Yearly - Repeatable holidays

- +
[% IF ( dateformat == "metric" ) %] @@ -299,7 +299,11 @@ [% IF ( UNIQUE_HOLIDAYS ) %]

Unique holidays

- + +
@@ -309,7 +313,7 @@ [% FOREACH HOLIDAYS_LOO IN UNIQUE_HOLIDAYS %] - + @@ -321,7 +325,11 @@ [% IF ( FLOAT_HOLIDAYS ) %]

Floating holidays

- + +
@@ -331,7 +339,7 @@ [% FOREACH float_holiday IN FLOAT_HOLIDAYS %] - + @@ -601,6 +609,25 @@ return true; } + /* Custom table search configuration: If a table row + has an "expired" class, hide it UNLESS the + show_expired checkbox is checked */ + $.fn.dataTable.ext.search.push( + function( settings, searchData, index, rowData, counter ) { + var table = settings.nTable.id; + var row = $(settings.aoData[index].nTr); + if( row.hasClass("date_past") && !$("#show_past_" + table ).prop("checked") ){ + return false; + } else { + return true; + } + } + ); + + // Create current date variable + var date = new Date(); + var datestring = date.toISOString().substring(0, 10); + $(document).ready(function() { $(".hint").hide(); $("#days_of_week").hide(); @@ -616,6 +643,24 @@ var first_td = $(this).find('td').first(); first_td.html(weekdays[first_td.html()]); }); + $("#holidayweeklyrepeatable").dataTable($.extend(true, {}, dataTablesDefaults, { + "sDom": 't', + "bPaginate": false + })); + var tables = $("#holidaysyearlyrepeatable, #holidaysunique, #holidaysfloat").DataTable($.extend(true, {}, dataTablesDefaults, { + "sDom": 't', + "bPaginate": false, + "createdRow": function( row, data, dataIndex ) { + var holiday = $(row).data("date"); + if( holiday < datestring ){ + $(row).addClass("date_past"); + } + } + })); + + $(".show_past").on("change", function(){ + tables.draw(); + }); $("a.helptext").click(function () { $(this).parent().find(".hint").toggle(); diff --git a/tools/discrete_calendar.pl b/tools/discrete_calendar.pl index f7c041520f..96dd7daa31 100755 --- a/tools/discrete_calendar.pl +++ b/tools/discrete_calendar.pl @@ -146,9 +146,9 @@ my @week_days = $calendar->get_week_days_holidays(); my @repeatable_holidays = $calendar->get_repeatable_holidays(); #discrete_calendar unique holidays -my @unique_holidays =$calendar->get_unique_holidays(); +my @unique_holidays =$calendar->get_unique_holidays(0); #discrete_calendar floating holidays -my @float_holidays =$calendar->get_float_holidays(); +my @float_holidays =$calendar->get_float_holidays(0); #discrete_caledar need validation holidays my @need_validation_holidays =$calendar->get_need_validation_holidays(); -- 2.34.1