1 package OpenILS::WWW::EGCatLoader;
2 use strict; use warnings;
3 use Apache2::Const -compile => qw(OK DECLINED FORBIDDEN HTTP_INTERNAL_SERVER_ERROR REDIRECT HTTP_BAD_REQUEST);
4 use OpenSRF::Utils::Logger qw/$logger/;
5 use OpenILS::Utils::CStoreEditor qw/:funcs/;
6 use OpenILS::Utils::Fieldmapper;
7 use OpenILS::Application::AppUtils;
8 my $U = 'OpenILS::Application::AppUtils';
11 # library : aou object
17 $ctx->{page} = 'library';
19 $self->timelog("load_library() began");
21 my $lib_id = $ctx->{page_args}->[0];
22 $lib_id = $self->_resolve_org_id_or_shortname($lib_id);
24 return Apache2::Const::HTTP_BAD_REQUEST
27 my $aou = $ctx->{get_aou}->($lib_id);
28 my $sname = $aou->parent_ou;
30 $ctx->{library} = $aou;
31 if ($aou->parent_ou) {
32 $ctx->{parent} = $ctx->{get_aou}->($aou->parent_ou);
35 $self->timelog("got basic lib info");
38 if ($aou->mailing_address) {
39 my $session = OpenSRF::AppSession->create("open-ils.actor");
40 $ctx->{mailing_address} =
41 $session->request('open-ils.actor.org_unit.address.retrieve',
42 $aou->mailing_address)->gather(1);
45 # Get current hours of operation
46 my $hours = $self->editor->retrieve_actor_org_unit_hours_of_operation($lib_id);
48 $ctx->{hours} = $hours;
49 # Generate naive schema.org format
50 $ctx->{hours_schema} = "Mo " . substr($hours->dow_0_open, 0, 5) . "-" . substr($hours->dow_0_close, 0, 5) .
51 ",Tu " . substr($hours->dow_1_open, 0, 5) . "-" . substr($hours->dow_1_close, 0, 5) .
52 ",We " . substr($hours->dow_2_open, 0, 5) . "-" . substr($hours->dow_2_close, 0, 5) .
53 ",Th " . substr($hours->dow_3_open, 0, 5) . "-" . substr($hours->dow_3_close, 0, 5) .
54 ",Fr " . substr($hours->dow_4_open, 0, 5) . "-" . substr($hours->dow_4_close, 0, 5) .
55 ",Sa " . substr($hours->dow_5_open, 0, 5) . "-" . substr($hours->dow_5_close, 0, 5) .
56 ",Su " . substr($hours->dow_6_open, 0, 5) . "-" . substr($hours->dow_6_close, 0, 5);
59 return Apache2::Const::OK;