LP2017913 Display Upcoming Closures in OPAC
[evergreen-equinox.git] / Open-ILS / src / perlmods / lib / OpenILS / WWW / EGCatLoader / Library.pm
index d0b17a6..1d7bb4b 100644 (file)
@@ -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;
 }