-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hours_exceptions.html.twig
51 lines (44 loc) · 2.46 KB
/
hours_exceptions.html.twig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{# @parameters: only_after ; suppress_if_empty #}
{% set calendar_name = calendar_name|default('opening') %}
{% set calendar = quando[calendar_name] %}
{% set headings = calendar.getMeta('headings') %}
{% set periods = calendar.getTimetable('periods') %}
{% set exceptions = calendar.getTimetable('exceptions') %}
{# filter exceptions and periods if only_fater is provided .. #}
{% if only_after is defined %}
{% set exceptions = exceptions|only_dates_from(only_after) %}
{% set periods = periods|only_periods_from(only_after) %}
{% endif %}
{# suppress all this if there are none coming up and suppress_if_empty is true #}
{% if not (suppress_if_empty and periods|merge(exceptions) is empty) %}
<h4>{{ headings.irregular }}</h4>
{# TODO: maybe some translatable text here under the heading in place of the block below
if the results are empty #}
<div class="exceptions">
{% set display_items = {} %}
{% for period in periods %}
{% set begins = date(period.begin ?: period.start) %} {# TODO: deprecated property name period.start #}
{% set ends = date(period.end ?: period.finish) %} {# TODO: deprecated property name period.finish #}
{% set display_item_value %}
<div class="period">
<p>{{ begins|date('l') }} <strong>{{ begins|date('F j') }}</strong>{% if 'now'|date('Y') != begins|date('Y') %}, {{ begins|date('Y') }}{% endif %} to {{ ends|date('l') }} <strong>{{ ends|date('F j') }}</strong>{% if 'now'|date('Y') != ends|date('Y') %}, {{ ends|date('Y') }} {% endif %}:</p>
<p style="margin-left: 2em">{{ period.description }}<em> ({{ period.name }})</em></p>
{# TODO: show any hours here, hey !!! issue #4 #}
</div>
{% endset %}
{% set display_item_key = begins|date('Y-m-d') %}
{% set display_items = display_items|merge({ (display_item_key): display_item_value}) %}
{% endfor %}
{% for d, exception in exceptions %}
{% set day = date(d) %}
{% set display_item_value %}
<p>{{ day|date('l') }} <strong>{{ day|date('F j') }}</strong>{% if 'now'|date('Y') != day|date('Y') %}, {{ day|date('Y') }}{% endif %}: {% include 'partials/times_short.html.twig' with { 'schedule': exception.hours, 'calendar_name': calendar_name } %}{% if exception.comment is defined %} <em>({{ exception.comment }})</em>{% endif %}</p>
{% endset %}
{% set display_item_key = day|date('Y-m-d') %}
{% set display_items = display_items|merge({ (display_item_key): display_item_value}) %}
{% endfor %}
{% for display in display_items|ksort %}
{{ display }}
{% endfor %}
</div>
{% endif %}