From 44770fc67657412a68438bfde4c7d02625273507 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 10 Apr 2025 11:50:56 +0000 Subject: [PATCH] Bug 39593: Show library hours in OPAC This patch adds library hours to the information display on the OPAC's libraries page. To test, apply the patch and add hours to one or more libraries if necessary (Administration -> Libraries). - In the OPAC, go to the Libraries page. - The libraries you added hours for should show a table of days with opening and closing times. - If both opening and closing times on a day are empty the table shows "Closed". - Libraries without hours should not show the table of hours. Sponsored-by: Athens County Public Libraries Signed-off-by: Christopher Signed-off-by: Alexander Wagner --- .../bootstrap/en/modules/opac-library.tt | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-library.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-library.tt index 178b13922c..954db88620 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-library.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-library.tt @@ -1,6 +1,7 @@ [% USE raw %] [% USE Asset %] [% USE Koha %] +[% USE KohaTimes %] [% PROCESS 'display-library-address.inc' %] [% USE AdditionalContents %] [% IF library %][% SET OpacLibraryInfo = library.opac_info( lang => lang ) %][% END %] @@ -33,6 +34,9 @@ border: 0; border-bottom: 1px solid rgba(0, 0, 0, 0.1); } + .library_hours_table { + width: auto; + } [% END %] @@ -40,6 +44,24 @@ [% INCLUDE 'bodytag.inc' bodyid='opac-library' bodyclass='scrollto' %] [% INCLUDE 'masthead.inc' %] +[% BLOCK dayname %] + [% IF day == 0 %] + Sunday + [% ELSIF day == 1 %] + Monday + [% ELSIF day == 2 %] + Tuesday + [% ELSIF day == 3 %] + Wednesday + [% ELSIF day == 4 %] + Thursday + [% ELSIF day == 5 %] + Friday + [% ELSE %] + Saturday + [% END %] +[% END %] + [% BLOCK library_description %]
[% IF OpacLibraryInfo %][% OpacLibraryInfo.content | $raw %][% END %]
[% END %] @@ -60,6 +82,52 @@

[% library.branchurl | html %]

[% END %] [% END %] + + [% SET CalendarFirstDayOfWeek = Koha.Preference("CalendarFirstDayOfWeek") %] + [% SET set_hours = 0 %] + [% IF library.library_hours.count > 0 %] + [% FOR i IN [0..6] %] + [% IF library.library_hours.as_list.$i.open_time != null || library.library_hours.as_list.$i.close_time != null %] + [% set_hours = 1 %] + [% END %] + [% END %] + [% END %] + [% IF set_hours > 0 # Existing library %] + [% SET library_hours = library.library_hours.as_list %] +
+ + + + + + + + + + + [% FOR i IN [0..6] %] + [% SET d = ( CalendarFirstDayOfWeek + i) % 7 %] + [% SET hr = library_hours.$d %] + + + [% IF ( hr.open_time == null && hr.close_time == null ) %] + + [% ELSE %] + + + [% END %] + + [% END %] + +
Hours
 Opening timeClosing time
+ [% PROCESS dayname day=d %] + Closed + [% IF hr.open_time != null %][% hr.open_time | $KohaTimes %][% END %] + + [% IF hr.close_time != null %][% hr.close_time | $KohaTimes %][% END %] +
+
+ [% END %] [% END %]
-- 2.39.5