{% if area_defined %}
{% if not facility_occupants %}

Nobody is in an access controlled
{{ facility_name }} area

{% else %} {% regroup facility_occupants by area as area_occupants %}

Area occupancy

Staff members are highlighted in green

{% for area in area_occupants %} {# Panel is used to make table borders rounded. #}
{% for o in area.list %} {% endfor %}
{{ area.grouper }} {% if area.list|length > 1 %} {% if area.grouper.maximum_capacity != 0 and area.grouper.occupancy_count >= area.grouper.danger_capacity %} {% elif area.grouper.maximum_capacity != 0 and area.grouper.occupancy_count >= area.grouper.warning_capacity %} {% else %}{% endif %} {{ area.grouper.occupancy_count }} {% if area.grouper.maximum_capacity != 0 %} / {{ area.grouper.maximum_capacity }}{% endif %} people {% if area.list|length != area.grouper.occupancy_count %} {% with occupancy=area.grouper.occupancy_count|stringformat:"d" %} {% with negative_occupancy="-"|add:occupancy %} (+ {{ area.list|length|add:negative_occupancy }} staff) {% endwith %} {% endwith %} {% endif %} {% endif %}
User Since Working on project...
{{ o.customer.first_name }} {{ o.customer.last_name }} {{ o.start|date:"l @ g:i A" }} {{ o.project }}
{% endfor %} {% endif %}
{% endif %}
{% if usage_events %}

Tool usage

{% if usage_events|length > 1 %}{{ usage_events|length }} tools are in use{% endif %} 

{# Panel is used to make table borders rounded. #}
{% for u in usage_events %} {% endfor %}
Tool User In use since...
{{ u.tool }} {{ u.operator.first_name }} {{ u.operator.last_name }}{% if u.user != u.operator %} on behalf of {{ u.user.first_name }} {{ u.user.last_name }}{% endif %} {{ u.start|date:"l @ g:i A" }}
{% else %}

No {{ facility_name }} tools are in use

{% endif %}
{% if alerts or disabled_resources %}

Alerts and outages

{# For spacing #} 

{% for a in alerts %}
{% if a.title %}{{ a.title }}
{% endif %} {{ a.contents|linebreaks }}
{% endfor %} {% for r in disabled_resources %}
Resource outage: {{ r }}
{{ r.restriction_message }}
{% endfor %}
{% endif %}