From: Terran McCanna Date: Thu, 27 Apr 2023 15:47:32 +0000 (-0400) Subject: LP2017913 Display Upcoming Closures in OPAC X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=90b7326abdd92e973d88185bd063956aaea4b501;p=evergreen%2Ftadl.git LP2017913 Display Upcoming Closures in OPAC Displays the upcoming closures (max of 10) that have been entered through the Closed Dates Editor in the OPAC on the library info pages for each branch. Signed-off-by: Terran McCanna LP2017913 Display Upcoming Closures in OPAC Adds ability to display detailed hours when closure is partial day. Signed-off-by: Terran McCanna LP2017913 Adds release note Signed-off-by: Terran McCanna LP2017913 Display Closures in OPAC Adjusted CSS due to testing feedback and also applied CSS to open hours display on the same page for consistency. Signed-off-by: Terran McCanna Signed-off-by: John Amundson Signed-off-by: Jane Sandberg --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Library.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Library.pm index d0b17a6898..1d7bb4bf15 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Library.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Library.pm @@ -3,6 +3,8 @@ use strict; use warnings; use Apache2::Const -compile => qw(OK DECLINED FORBIDDEN HTTP_INTERNAL_SERVER_ERROR REDIRECT HTTP_BAD_REQUEST); use OpenSRF::Utils::JSON; use OpenSRF::Utils::Logger qw/$logger/; +use DateTime; +use DateTime::Format::ISO8601; use OpenILS::Utils::CStoreEditor qw/:funcs/; use OpenILS::Utils::Fieldmapper; use OpenILS::Application::AppUtils; @@ -69,6 +71,21 @@ sub load_library { $ctx->{hours} = $hours; } + # Get upcoming closed dates + my $dt = DateTime->now(time_zone => 'local'); + my $start = $dt->year .'-'. $dt->month .'-'. $dt->day; + + my $dates = $self->editor->search_actor_org_unit_closed_date([ + {close_end => { ">=" => $start }, + org_unit => $lib_id + }, + {order_by => {aoucd => 'close_start'}, + limit => 10 + } + ]); + + $ctx->{closed_dates} = $dates; + return Apache2::Const::OK; } diff --git a/Open-ILS/src/templates-bootstrap/opac/parts/library/hours.tt2 b/Open-ILS/src/templates-bootstrap/opac/parts/library/hours.tt2 index 382eddfc89..8c90e18532 100755 --- a/Open-ILS/src/templates-bootstrap/opac/parts/library/hours.tt2 +++ b/Open-ILS/src/templates-bootstrap/opac/parts/library/hours.tt2 @@ -12,129 +12,205 @@

[% l('Opening hours') %]

-[%- - open = today _ ctx.hours.dow_0_open; - close = today _ ctx.hours.dow_0_close; - note = ctx.hours.dow_0_note; - IF open == close; -%] -
[% l('Monday: closed') %]
-[%- ELSE %] -
[% - l('Monday: [_1] - [_2]', '', - '') --%] -[% IF ctx.hours.dow_0_note %] - [%l('(' _ note _ ')')%] -[% END -%] -
-[%- END %] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[% l('Day') %][% l('Hours') %]
[% l('Monday') %] + [%- + open = today _ ctx.hours.dow_0_open; + close = today _ ctx.hours.dow_0_close; + note = ctx.hours.dow_0_note; + IF open == close; + %] -[%- - open = today _ ctx.hours.dow_1_open; - close = today _ ctx.hours.dow_1_close; - note = ctx.hours.dow_1_note; - IF open == close; -%] -
[% l('Tuesday: closed') %]
-[%- ELSE %] -
[% - l('Tuesday: [_1] - [_2]', '', - '') --%] -[% IF ctx.hours.dow_1_note %] - [%l('(' _ note _ ')')%] -[% END -%] +
[% l('Closed') %]
+ [%- ELSE %] +
[% + l('[_1] - [_2]', '', + '') + -%] + [% IF ctx.hours.dow_0_note %] + [%l('(' _ note _ ')')%] + [% END -%] +
+ [%- END %] +
[% l('Tuesday') %] + [%- + open = today _ ctx.hours.dow_1_open; + close = today _ ctx.hours.dow_1_close; + note = ctx.hours.dow_1_note; + IF open == close; + %] +
[% l('Closed') %]
+ [%- ELSE %] +
[% + l('[_1] - [_2]', '', + '') + -%] + [% IF ctx.hours.dow_1_note %] + [%l('(' _ note _ ')')%] + [% END -%] +
+ [%- END %] +
[% l('Wednesday') %] + [%- + open = today _ ctx.hours.dow_2_open; + close = today _ ctx.hours.dow_2_close; + note = ctx.hours.dow_2_note; + IF open == close; + %] +
[% l('Closed') %]
+ [%- ELSE %] +
[% + l('[_1] - [_2]', '', + '') + -%] + [% IF ctx.hours.dow_2_note %] + [%l('(' _ note _ ')')%] + [% END -%] +
+ [%- END %] +
[% l('Thursday') %] + [%- + open = today _ ctx.hours.dow_3_open; + close = today _ ctx.hours.dow_3_close; + note = ctx.hours.dow_3_note; + IF open == close; + %] +
[% l('Closed') %]
+ [%- ELSE %] +
[% + l('[_1] - [_2]', '', + '') + -%] + [% IF ctx.hours.dow_3_note %] + [%l('(' _ note _ ')')%] + [% END -%] +
+ [%- END %] +
[% l('Friday') %] + [%- + open = today _ ctx.hours.dow_4_open; + close = today _ ctx.hours.dow_4_close; + note = ctx.hours.dow_4_note; + IF open == close; + %] +
[% l('Closed') %]
+ [%- ELSE %] +
[% + l('[_1] - [_2]', '', + '') + -%] + [% IF ctx.hours.dow_4_note %] + [%l('(' _ note _ ')')%] + [% END -%] +
+ [%- END %] +
[% l('Saturday') %] + [%- + open = today _ ctx.hours.dow_5_open; + close = today _ ctx.hours.dow_5_close; + note = ctx.hours.dow_5_note; + IF open == close; + %] +
[% l('Closed') %]
+ [%- ELSE %] +
[% + l('[_1] - [_2]', '', + '') + -%] + [% IF ctx.hours.dow_5_note %] + [%l('(' _ note _ ')')%] + [% END -%] +
+ [%- END %] +
[% l('Sunday') %] + [%- + open = today _ ctx.hours.dow_6_open; + close = today _ ctx.hours.dow_6_close; + note = ctx.hours.dow_6_note; + IF open == close; + %] +
[% l('Closed') %]
+ [%- ELSE %] +
[% + l('[_1] - [_2]', '', + '') + -%] + [% IF ctx.hours.dow_6_note %] + [%l('(' _ note _ ')')%] + [% END -%] +
+ [%- END %] +
-[%- END %] -[%- - open = today _ ctx.hours.dow_2_open; - close = today _ ctx.hours.dow_2_close; - note = ctx.hours.dow_2_note; - IF open == close; -%] -
[% l('Wednesday: closed') %]
-[%- ELSE %] -
[% - l('Wednesday: [_1] - [_2]', '', - '') --%] -[% IF ctx.hours.dow_2_note %] - [%l('(' _ note _ ')')%] -[% END -%] -
-[%- END %] +

[% l('Upcoming closures') %]

-[%- - open = today _ ctx.hours.dow_3_open; - close = today _ ctx.hours.dow_3_close; - note = ctx.hours.dow_3_note; - IF open == close; -%] -
[% l('Thursday: closed') %]
-[%- ELSE %] -
[% - l('Thursday: [_1] - [_2]', '', - '') --%] -[% IF ctx.hours.dow_3_note %] - [%l('(' _ note _ ')')%] -[% END -%] -
-[%- END %] +[% IF ctx.closed_dates.size %] + + + + + + + + [% FOR cdate IN ctx.closed_dates %] + + + + + [% END %] +
[% l('Date') %][% l('Reason for Closure') %]
+ [% display_start_date = date.format(ctx.parse_datetime(cdate.close_start), DATE_FORMAT) %] + [% display_end_date = date.format(ctx.parse_datetime(cdate.close_end), DATE_FORMAT) %] + [% display_start_time = date.format(ctx.parse_datetime(cdate.close_start), TIME_FORMAT) %] + [% display_end_time = date.format(ctx.parse_datetime(cdate.close_end), TIME_FORMAT) %] -[%- - open = today _ ctx.hours.dow_4_open; - close = today _ ctx.hours.dow_4_close; - note = ctx.hours.dow_4_note; - IF open == close; -%] -
[% l('Friday: closed') %]
-[%- ELSE %] -
[% - l('Friday: [_1] - [_2]', '', - '') --%] -[% IF ctx.hours.dow_4_note %] - [%l('(' _ note _ ')')%] -[% END -%] -
-[%- END %] - -[%- - open = today _ ctx.hours.dow_5_open; - close = today _ ctx.hours.dow_5_close; - note = ctx.hours.dow_5_note; - IF open == close; -%] -
[% l('Saturday: closed') %]
-[%- ELSE %] -
[% - l('Saturday: [_1] - [_2]', '', - '') --%] -[% IF ctx.hours.dow_5_note %] - [%l('(' _ note _ ')')%] -[% END -%] -
-[%- END %] - -[%- - open = today _ ctx.hours.dow_6_open; - close = today _ ctx.hours.dow_6_close; - note = ctx.hours.dow_6_note; - IF open == close; -%] -
[% l('Sunday: closed') %]
-[%- ELSE %] -
[% - l('Sunday: [_1] - [_2]', '', - '') --%] -[% IF ctx.hours.dow_6_note %] - [%l('(' _ note _ ')')%] -[% END -%] -
-[%- END %] - \ No newline at end of file + [% display_start_date %] + [% IF cdate.full_day == 'f'; %] + [% display_start_time %] - + [% IF display_start_date != display_end_date %] + [% display_end_date %] + [% END %] + [% display_end_time %] + [% END %] + [% IF cdate.multi_day == 't' %] + - [% display_end_date %] + [% END %] +
[% cdate.reason %]
+[% ELSE %] + [% l("No closures scheduled") %] +[% END; %] diff --git a/docs/RELEASE_NOTES_NEXT/OPAC/upcoming_closed_dates.adoc b/docs/RELEASE_NOTES_NEXT/OPAC/upcoming_closed_dates.adoc new file mode 100644 index 0000000000..afa01c250d --- /dev/null +++ b/docs/RELEASE_NOTES_NEXT/OPAC/upcoming_closed_dates.adoc @@ -0,0 +1,5 @@ +== Display Upcoming Closures in OPAC == + +Adds display of upcoming closures (as entered in +the Closed Dates Editor) to the library information +pages in the OPAC. \ No newline at end of file