{% comment %} Permission-filtered calendar dataview with day, week, month, year, and list modes. {% endcomment %} {% load bloomerp %}
{% if not start_field %}

No date field selected

Select a start date field in the display options.

{% else %}

{% if view_mode == 'day' %} {{ calendar_current_date|date:"l, F j, Y" }} {% elif view_mode == 'week' or view_mode == 'list' %} {{ calendar_date_range.start|date:"M j" }} – {{ calendar_date_range.end|date:"M j, Y" }} {% elif view_mode == 'year' %} {{ calendar_current_date|date:"Y" }} {% else %} {{ calendar_current_date|date:"F Y" }} {% endif %}

{% if calendar_legend %}
Legend
{% for legend_item in calendar_legend %}
{{ legend_item.label }}
{% endfor %}
{% endif %}
{% if view_mode == 'month' %}
{% for day_name in "Mon,Tue,Wed,Thu,Fri,Sat,Sun"|make_list_by_comma %}
{{ day_name }}
{% endfor %}
{% for week in calendar_weeks %}
{% for day in week %} {% with unit_key=day.key %}
{% endwith %} {% endfor %} {% with week_segments=calendar_month_segments_by_week|get_item:forloop.counter0 %} {% for event in week_segments %} {% endfor %} {% endwith %}
{% endfor %}
{% elif view_mode == 'day' or view_mode == 'week' %}
{% for day in calendar_days %}
{{ day|date:"D j" }}
{% endfor %}
All day
{% for day_unit in calendar_day_units %} {% with unit=calendar_events_by_unit|get_item:day_unit.key %}
{% if view_mode == 'day' %}
{% include "components/objects/dataview_calendar_events.html" with events=unit.events calendar_unit=day_unit.key calendar_has_more=unit.has_more calendar_next_unit_offset=5 calendar_view_mode=view_mode %}
{% endif %}
{% endwith %} {% endfor %} {% if view_mode == 'week' %} {% for event in calendar_week_segments %} {% endfor %} {% endif %}
{% for hour in calendar_hours %}
{{ hour|stringformat:"02d" }}:00
{% endfor %}
{% for day_column in calendar_day_columns %}
{% for hour_unit in day_column.hours %} {% with unit_key=hour_unit.key %} {% with unit=calendar_events_by_unit|get_item:unit_key %}
{% include "components/objects/dataview_calendar_events.html" with events=unit.events calendar_unit=unit_key calendar_has_more=unit.has_more calendar_next_unit_offset=5 calendar_view_mode=view_mode %}
{% endwith %} {% endwith %} {% endfor %}
{% endfor %}
{% elif view_mode == 'year' %}
{% for month in calendar_months %} {% with unit_key=month.key %} {% with unit=calendar_events_by_unit|get_item:unit_key %}
{% include "components/objects/dataview_calendar_events.html" with events=unit.events calendar_unit=unit_key calendar_has_more=unit.has_more calendar_next_unit_offset=5 calendar_view_mode=view_mode %}
{% endwith %} {% endwith %} {% endfor %}
{% else %} {% if calendar_events_by_unit %}
{% for day in calendar_day_units %} {% with unit_key=day.key %} {% with unit=calendar_events_by_unit|get_item:unit_key %} {% if unit.events %}
{% include "components/objects/dataview_calendar_events.html" with events=unit.events calendar_unit=unit_key calendar_has_more=unit.has_more calendar_next_unit_offset=5 calendar_view_mode=view_mode %}
{% endif %} {% endwith %} {% endwith %} {% endfor %}
{% else %}

No calendar items in this period.

{% endif %} {% endif %}
{% if calendar_unscheduled_events %}

Unscheduled

{% for event in calendar_unscheduled_events %}
{{ event.object }}
{% endfor %}
{% endif %} {% endif %}