8c90e18532bd983f7aea397966bc9fb675844cfb
[evergreen-equinox.git] / Open-ILS / src / templates-bootstrap / opac / parts / library / hours.tt2
1 [%
2    UNLESS TIME_FORMAT;
3        TIME_FORMAT = '%l:%M %p';
4    END;
5
6    time_format = TIME_FORMAT;
7
8    USE date (format = time_format);
9    today = date.format(format = '%Y-%m-%d ');
10    # We need to add "today" to the opening/closing hours for Date input
11 -%]
12 <div class="my-3">
13 <h3>[% l('Opening hours') %]</h3>
14
15 <table title="[% l('Open Hours') %]" class="table table-striped w-auto">
16     <thead>
17         <tr>
18           <th scope="col">[% l('Day') %]</th>
19           <th scope="col">[% l('Hours') %]</th>
20         </tr>
21     </thead>
22     <tr>
23         <td>[% l('Monday') %]</td>
24         <td>
25         [%-
26             open = today _ ctx.hours.dow_0_open;
27             close = today _ ctx.hours.dow_0_close;
28             note = ctx.hours.dow_0_note;
29             IF open == close;
30         %]
31
32         <div class="opening-hours">[% l('Closed') %]</div>
33         [%- ELSE %]
34         <div class="opening-hours" property="openingHoursSpecification" typeof="OpeningHoursSpecification"><link property="dayOfWeek" href="http://purl.org/goodrelations/v1#Monday" />[%
35             l('[_1] - [_2]', '<time property="opens" content="' _ date.format(open, format => '%H:%M:%S') _ '">' _ date.format(open) _ '</time>',
36              '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>')
37         -%]
38         [% IF ctx.hours.dow_0_note %]
39             <span>[%l('(' _ note _ ')')%]</span>
40         [% END -%]
41         </div>
42         [%- END %]
43         </td>
44     </tr>
45     <tr>
46         <td>[% l('Tuesday') %]</td>
47         <td>
48         [%-
49             open = today _ ctx.hours.dow_1_open;
50             close = today _ ctx.hours.dow_1_close;
51             note = ctx.hours.dow_1_note;
52             IF open == close;
53         %]
54         <div class="opening-hours">[% l('Closed') %]</div>
55         [%- ELSE %]
56         <div class="opening-hours" property="openingHoursSpecification" typeof="OpeningHoursSpecification"><link property="dayOfWeek" href="http://purl.org/goodrelations/v1#Tuesday" />[%
57             l('[_1] - [_2]', '<time property="opens" content="' _ date.format(open, format => '%H:%M:%S') _ '">' _ date.format(open) _ '</time>',
58              '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>')
59         -%]
60         [% IF ctx.hours.dow_1_note %]
61             <span>[%l('(' _ note _ ')')%]</span>
62         [% END -%]
63         </div>
64         [%- END %]
65         </td>
66     </tr>
67     <tr>
68         <td>[% l('Wednesday') %]</td>
69         <td>
70         [%-
71             open = today _ ctx.hours.dow_2_open;
72             close = today _ ctx.hours.dow_2_close;
73             note = ctx.hours.dow_2_note;
74             IF open == close;
75         %]
76         <div class="opening-hours">[% l('Closed') %]</div>
77         [%- ELSE %]
78         <div class="opening-hours" property="openingHoursSpecification" typeof="OpeningHoursSpecification"><link property="dayOfWeek" href="http://purl.org/goodrelations/v1#Wednesday" />[%
79             l('[_1] - [_2]', '<time property="opens" content="' _ date.format(open, format => '%H:%M:%S') _ '">' _ date.format(open) _ '</time>',
80              '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>')
81         -%]
82         [% IF ctx.hours.dow_2_note %]
83             <span>[%l('(' _ note _ ')')%]</span>
84         [% END -%]
85         </div>
86         [%- END %]
87         </td>
88     </tr>
89     <tr>
90         <td>[% l('Thursday') %]</td>
91         <td>
92         [%-
93             open = today _ ctx.hours.dow_3_open;
94             close = today _ ctx.hours.dow_3_close;
95             note = ctx.hours.dow_3_note;
96             IF open == close;
97         %]
98         <div class="opening-hours">[% l('Closed') %]</div>
99         [%- ELSE %]
100         <div class="opening-hours" property="openingHoursSpecification" typeof="OpeningHoursSpecification"><link property="dayOfWeek" href="http://purl.org/goodrelations/v1#Thursday" />[%
101             l('[_1] - [_2]', '<time property="opens" content="' _ date.format(open, format => '%H:%M:%S') _ '">' _ date.format(open) _ '</time>',
102              '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>')
103         -%]
104         [% IF ctx.hours.dow_3_note %]
105             <span>[%l('(' _ note _ ')')%]</span>
106         [% END -%]
107         </div>
108         [%- END %]
109         </td>
110     </tr>
111     <tr>
112         <td>[% l('Friday') %]</td>
113         <td>
114         [%-
115             open = today _ ctx.hours.dow_4_open;
116             close = today _ ctx.hours.dow_4_close;
117             note = ctx.hours.dow_4_note;
118             IF open == close;
119         %]
120         <div class="opening-hours">[% l('Closed') %]</div>
121         [%- ELSE %]
122         <div class="opening-hours" property="openingHoursSpecification" typeof="OpeningHoursSpecification"><link property="dayOfWeek" href="http://purl.org/goodrelations/v1#Friday" />[%
123             l('[_1] - [_2]', '<time property="opens" content="' _ date.format(open, format => '%H:%M:%S') _ '">' _ date.format(open) _ '</time>',
124              '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>')
125         -%]
126         [% IF ctx.hours.dow_4_note %]
127             <span>[%l('(' _ note _ ')')%]</span>
128         [% END -%]
129         </div>
130         [%- END %]
131         </td>
132     </tr>
133     <tr>
134         <td>[% l('Saturday') %]</td>
135         <td>
136         [%-
137             open = today _ ctx.hours.dow_5_open;
138             close = today _ ctx.hours.dow_5_close;
139             note = ctx.hours.dow_5_note;
140             IF open == close;
141         %]
142         <div class="opening-hours">[% l('Closed') %]</div>
143         [%- ELSE %]
144         <div class="opening-hours" property="openingHoursSpecification" typeof="OpeningHoursSpecification"><link property="dayOfWeek" href="http://purl.org/goodrelations/v1#Saturday" />[%
145             l('[_1] - [_2]', '<time property="opens" content="' _ date.format(open, format => '%H:%M:%S') _ '">' _ date.format(open) _ '</time>',
146              '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>')
147         -%]
148         [% IF ctx.hours.dow_5_note %]
149             <span>[%l('(' _ note _ ')')%]</span>
150         [% END -%]
151         </div>
152         [%- END %]
153         </td>
154     </tr>
155     <tr>
156         <td>[% l('Sunday') %]</td>
157         <td>
158         [%-
159             open = today _ ctx.hours.dow_6_open;
160             close = today _ ctx.hours.dow_6_close;
161             note = ctx.hours.dow_6_note;
162             IF open == close;
163         %]
164         <div class="opening-hours">[% l('Closed') %]</div>
165         [%- ELSE %]
166         <div class="opening-hours" property="openingHoursSpecification" typeof="OpeningHoursSpecification"><link property="dayOfWeek" href="http://purl.org/goodrelations/v1#Sunday" />[%
167             l('[_1] - [_2]', '<time property="opens" content="' _ date.format(open, format => '%H:%M:%S') _ '">' _ date.format(open) _ '</time>',
168              '<time property="closes" content="' _ date.format(close, format => '%H:%M:%S') _ '">' _ date.format(close) _ '</time>')
169         -%]
170         [% IF ctx.hours.dow_6_note %]
171             <span>[%l('(' _ note _ ')')%]</span>
172         [% END -%]
173         </div>
174         [%- END %]
175         </td>
176     </tr>
177 </table>
178 </div>
179
180 <h3>[% l('Upcoming closures') %]</h3>
181
182 [% IF ctx.closed_dates.size %]
183     <table title="[% l('Closed Dates') %]" class="table table-striped w-auto">
184     <thead>
185         <tr>
186           <th scope="col">[% l('Date') %]</th>
187           <th scope="col">[% l('Reason for Closure') %]</th>
188         </tr>
189     </thead>
190     [% FOR cdate IN ctx.closed_dates %]
191     <tr>
192         <td>
193             [% display_start_date = date.format(ctx.parse_datetime(cdate.close_start), DATE_FORMAT) %]
194             [% display_end_date = date.format(ctx.parse_datetime(cdate.close_end), DATE_FORMAT) %]
195             [% display_start_time = date.format(ctx.parse_datetime(cdate.close_start), TIME_FORMAT) %]
196             [% display_end_time = date.format(ctx.parse_datetime(cdate.close_end), TIME_FORMAT) %]
197
198             [% display_start_date %]
199             [% IF cdate.full_day == 'f'; %]
200                 [% display_start_time %] -
201                 [% IF display_start_date != display_end_date %]
202                     [% display_end_date %]
203                 [% END %]
204                 [% display_end_time %]
205             [% END %]
206             [% IF cdate.multi_day == 't' %]
207                 - [% display_end_date %]
208             [% END %]
209         </td>
210         <td>[% cdate.reason %]</td>
211     </tr>
212     [% END %]
213     </table>
214 [% ELSE %]
215         [% l("No closures scheduled") %]
216 [% END; %]