From 9192007ec074d84cc698bdbfb09922aa916a47fe Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 9 Feb 2024 16:59:45 +0000 Subject: [PATCH] Bug 6796: Take CalenderFirstDayOfWeek into account This patch adds accounting for the CalendarFirstDayOfWeek preference in the libraries summary display table --- .../prog/en/modules/admin/branches.tt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt index 7da93b93234..1e4e26c0dca 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt @@ -638,6 +638,7 @@ var table_settings = [% TablesSettings.GetTableSettings( 'admin', 'libraries', 'libraries', 'json' ) | $raw %]; var saved_table = localStorage.getItem("DataTables_libraries_/cgi-bin/koha/admin/branches.pl"); var updated_settings = get_columns_saved_state(saved_table, table_settings); + var calendarFirstDayOfWeek = '[% Koha.Preference('CalendarFirstDayOfWeek') | html %]'; $(document).ready(function() { @@ -747,16 +748,18 @@ }, { "data": function( row, type, val, meta ) { - const daynames = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']; - var daycount = 0; + const daysOfWeek = [ _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday") ]; + var result = ''; - while ( row.library_hours[daycount] ) { - result += ''; - result += ''; - result += ''; - result += ''; + let counter = 0; + for (let i = calendarFirstDayOfWeek; counter < 7; i++) { + const index = i % 7; // Wrap around the index using modulo operator + result += ''; + result += ''; + result += ''; + result += ''; result += ''; - daycount++; + counter++; } result += '
DayOpen timeClose time
'+daynames[daycount]+''+row.library_hours[daycount].open_time+''+row.library_hours[daycount].close_time+'
'+daysOfWeek[index]+''+row.library_hours[index].open_time+''+row.library_hours[index].close_time+'
'; return result; -- 2.43.0