{% extends "base.html" %}
{% load i18n range units humanize %}
{% block extra_head %}
{{form.media}}
{% endblock %}
{% block content %}

<h2>{% trans "Operations" %}</h2>

<div class='dashboard' id='dashboard-operations'>
  <h3>{% trans "Global informations" %}</h3>
  <div>
    <div class='clean-table'>
    <h4>{% trans "total" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        <th>{% trans "Status" %}</th><th>{% trans "Number" %}</th>
      </tr>
      {% for lbl, nb in dashboard.total %}
      <tr>
        <th class='sub'>{{lbl}}</th><td>{{nb|intcomma}}</td>
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
    <h4>{% trans "area by type of operation" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        <th>{% trans "Status" %}</th><th>{% trans "Area (ha)" %}</th>
      </tr>
      {% for surface in dashboard.surface_by_type %}
      <tr>
        <th class='sub'>{{surface.operation_type__label}}</th><td>{{surface.number|m2_to_ha|intcomma}}</td>
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
    <h4>{% trans "by types" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        {% for typ in dashboard.types %}
            {% if forloop.counter0|divisibleby:5 %}
            <th class='sub'>{% trans "State" %}</th>
            {% endif %}
            <th>{{typ.label}}</th>
        {% endfor %}
      </tr>
      {% for lbl, types in dashboard.by_type %}
      <tr>
        {%for nb in types %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{{lbl}}</th>{% endif %}
        <td>{{nb|intcomma}}</td>{% endfor %}
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
    <h4>{% trans "by year" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        {% for yr in dashboard.years %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{% trans "State" %}</th>
        {% endif %}
        <th>{{yr|default_if_none:''}}</th>{% endfor %}
      </tr>
      {% for lbl, years in dashboard.by_year %}
      <tr>
        {% for nb in years %}
        {% if forloop.counter0|divisibleby:5 %}
            <th class='sub'>{{lbl}}</th>{% endif %}
            <td>{{nb|intcomma}}</td>
        {% endfor %}
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "by realisation year" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        {%for yr in dashboard.realisation_years %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{% trans "State" %}</th>
        {% endif %}
        <th>{{yr.year|default_if_none:''}}</th>{% endfor %}
      </tr>
      {% for lbl, years in dashboard.by_realisation_year %}
      <tr>
        {% for nb in years %}
        {% if forloop.counter0|divisibleby:5 %}
            <th class='sub'>{{lbl}}</th>{% endif %}
            <td>{{nb|intcomma}}</td>
        {% endfor %}
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "effective operation by type and year" %}</h4>
    <div class='clean-table-wrap'>
    <table class='mini-table'>
      {% for lbl, years in dashboard.effective %}

      {% if forloop.counter0|divisibleby:6 %}
      <tr>
        {%for yr in dashboard.years %}
        {% if forloop.counter0|divisibleby:5 %}
        <th></th>
        {% endif %}
        <th>{{yr|default_if_none:''}}</th>{% endfor %}
      </tr>
      {% endif %}
      <tr>
        {% for nb in years %}
        {% if forloop.counter0|divisibleby:5 %}
            <th class='sub'>{{lbl}}</th>{% endif %}
            <td>{{nb|intcomma}}</td>
        {% endfor %}
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "by realisation month" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        {%for mt in dashboard.last_months %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{% trans "State" %}</th>
        {% endif %}
        <th>{{mt.date|date:"N Y"|capfirst}}</th>{% endfor %}
      </tr>
      {% for lbl, months in dashboard.by_realisation_month %}
      <tr>
        {%for nb in months %}
        {% if forloop.counter0|divisibleby:5 %}
            <th class='sub'>{{lbl}}</th>{% endif %}
            <td>{{nb|intcomma}}</td>
        {% endfor %}
      </tr>
      {% endfor %}
    </table></div></div>

  </div>

  <h3>{% trans "Survey informations" %}</h3>
  <div>

    <div class='clean-table'>
      <h4>{% trans "total" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        <th>{% trans "Status" %}</th><th>{% trans "Number" %}</th>
      </tr>
      {% for lbl, nb in dashboard.survey.total %}
      <tr>
        <th class='sub'>{{lbl}}</th><td>{{nb|intcomma}}</td>
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "by year" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        {%for yr in dashboard.years %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{% trans "State" %}</th>
        {% endif %}
        <th>{{yr|default_if_none:''}}</th>{% endfor %}
      </tr>
      {% for lbl, years in dashboard.survey.by_year %}
      <tr>
        {% for nb in years %}
        {% if forloop.counter0|divisibleby:5 %}
            <th class='sub'>{{lbl}}</th>{% endif %}
            <td>{{nb|intcomma}}</td>
        {% endfor %}
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "by realisation year" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        {%for yr in dashboard.realisation_years %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{% trans "State" %}</th>
        {% endif %}
        <th>{{yr.year|default_if_none:''}}</th>{% endfor %}
      </tr>
      {% for lbl, years in dashboard.survey.by_realisation_year %}
      <tr>
        {% for nb in years %}
        {% if forloop.counter0|divisibleby:5 %}
            <th class='sub'>{{lbl}}</th>{% endif %}
            <td>{{nb|intcomma}}</td>
        {% endfor %}
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "current year" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        <th></th>{% for lbl in dashboard.filters_label %}<th>{{lbl}}</th>{%endfor%}
      </tr>
      <tr>
        <th class='sub'>{% trans "Area"%}</th>{% for nb in dashboard.survey.area %}<td>{{nb|intcomma}}</td>{%endfor%}
      </tr>
      <tr>
        <th class='sub'>{% trans "Man-day"%}</th>{% for nb in dashboard.survey.manday %}<td>{{nb|intcomma}}</td>{%endfor%}
      </tr>
      <tr>
        <th class='sub'>{% trans "Man-day/hectare"%}</th>{% for nb in dashboard.survey.mandayhect %}<td>{{nb|intcomma}}</td>{%endfor%}
      </tr>
    </table></div></div>
    <p><strong>{% trans "Man-day/hectare for effective operations (current year):" %}</strong> {{dashboard.survey.mandayhect_effective}}</p>
    <div class='clean-table'>
      <h4>{% trans "organizations (current year)" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        <th>&nbsp;</th><th>{% trans "Area" %}</th><th>{% trans "Man-day" %}</th><th>{% trans "Man-day/hectare" %}</th>
      </tr>
      {% for org in dashboard.survey.org %}
      <tr>
        <th class='sub'>{{org.scientist__attached_to__name}}</th><td>{{org.area|intcomma}}</td><td>{{org.manday|intcomma}}</td><td>{{org.mandayhect|intcomma}}</td>
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "current realisation year" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        <th>{% trans "Status" %}</th>{% for lbl in dashboard.filters_label %}<th>{{lbl}}</th>{%endfor%}
      </tr>
      <tr>
        <th class='sub'>{% trans "Area"%}</th>{% for nb in dashboard.survey.area_realised %}<td>{{nb|intcomma}}</td>{%endfor%}
      </tr>
      <tr>
        <th class='sub'>{% trans "Man-day"%}</th>{% for nb in dashboard.survey.manday_realised %}<td>{{nb|intcomma}}</td>{%endfor%}
      </tr>
      <tr>
        <th class='sub'>{% trans "Man-day/hectare"%}</th>{% for nb in dashboard.survey.mandayhect_realised %}<td>{{nb|intcomma}}</td>{%endfor%}
      </tr>
    </table></div></div>

    <p><strong>{% trans "Man-day/hectare for effective operations (current realisation year):" %}</strong> {{dashboard.survey.mandayhect_real_effective}}</p>

    <div class='clean-table'>
      <h4>{% trans "organizations (current realisation year)" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        <th>&nbsp;</th><th>{% trans "Area" %}</th><th>{% trans "Man-day" %}</th><th>{% trans "Man-day/hectare" %}</th>
      </tr>
      {% for org in dashboard.survey.org_realised %}
      <tr>
        <th class='sub'>{{org.scientist__attached_to__name}}</th><td>{{org.area|intcomma}}</td><td>{{org.manday|intcomma}}</td><td>{{org.mandayhect|intcomma}}</td>
      </tr>
      {% endfor %}
    </table></div></div>
    <div class='clean-table'>
      <h4>{% trans "area by organization by year" %}</h4>
    <div class='clean-table-wrap'>
    <table class='mini-table'>
      <tr>
      </tr>
      {% for org, vals in dashboard.survey.org_by_year %}
        {% if forloop.counter0|divisibleby:4 %}
        {% for yr in dashboard.years %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{% trans "Organization" %}</th>
        {% endif %}
        <th>{{yr|default_if_none:''}}</th>
        {% endfor %}
        {% endif %}

      <tr>
        {% for area, cost in vals %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{{org}}</th>
        {% endif %}
        <td>{{area|intcomma}}</td>{% endfor %}
      </tr>
      {% endfor %}
      <tr>
        {% for area in dashboard.survey.org_by_year_area_mean %}
        {% if forloop.counter0|divisibleby:5 %}
        <th>{% trans "Mean" %}</th>{% endif%}
        <td>{{area|intcomma}}</td>{% endfor %}
      </tr>
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "effective operations areas (ha)" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        {%for yr in dashboard.years %}
        {% if forloop.counter0|divisibleby:5 %}
        <th></th>
        {% endif %}
        <th>{{yr|default_if_none:''}}</th>{% endfor %}
      </tr>
      <tr>
        {% for nb, mean in dashboard.survey.effective %}
        {% if forloop.counter0|divisibleby:5 %}<th>{% trans "Sum" %}</th>{%endif%}
        <td>{{nb|m2_to_ha|intcomma}}</td>{% endfor %}
      </tr>
      <tr>
        {% for nb, avg in dashboard.survey.effective %}
        {% if forloop.counter0|divisibleby:5 %}<th>{% trans "Average" %}</th>{%endif%}
        <td>{{avg|m2_to_ha|intcomma}}</td>{% endfor %}
      </tr>
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "man-days/hectare by year" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        {%for yr in dashboard.years %}
        {% if forloop.counter0|divisibleby:5 %}
        <th></th>
        {% endif %}
        <th>{{yr|default_if_none:''}}</th>{% endfor %}
      </tr>
      <tr>
        {% for nb, mean in dashboard.survey.mandayshect %}
        {% if forloop.counter0|divisibleby:5 %}<th>{% trans "Man-Days/hectare" %}</th>{%endif%}
        <td>{{nb|intcomma}}</td>{% endfor %}
      </tr>
      <tr>
        {% for nb, avg in dashboard.survey.mandayshect %}
        {% if forloop.counter0|divisibleby:5 %}
        <th>{% trans "Average" %}</th>
        {%endif%}
        <td>{{avg|intcomma}}</td>{% endfor %}
      </tr>
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "by month" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        {% for mt in dashboard.last_months %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{% trans "State" %}</th>{% endif %}
        <th>{{mt.date|date:"N Y"|capfirst}}</th>{% endfor %}
      </tr>
      {% for lbl, months in dashboard.survey.by_month %}
      <tr>
        {%for nb in months %}
        {% if forloop.counter0|divisibleby:5 %}
            <th class='sub'>{{lbl}}</th>{% endif %}
            <td>{{nb|intcomma}}</td>
        {% endfor %}
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "by department" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        {% for yr in dashboard.years %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{% trans "Department" %}</th>
        {% endif %}
        <th>{{yr|default_if_none:''}}</th>{% endfor %}<th>{% trans "Sum" %}</th>
      </tr>
      {% for lbl, years in dashboard.survey.by_dpt %}
      <tr>
        {% for nb in years %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{{lbl}}</th>{% endif %}
        <td{%if forloop.last%} class='sub'{%endif%}>{{nb|intcomma}}</td>{% endfor %}
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "effective operation by department" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        {% for yr in dashboard.years %}
        {% if forloop.counter0|divisibleby:4 %}
        <th rowspan='2'>{% trans "Department" %}</th>{% endif %}
        <th class='sub' colspan='2'>{{yr|default_if_none:''}}</th>{% endfor %}<th colspan='2'>{% trans "Sum" %}</th>
      </tr>
      <tr>
        {%for yr in dashboard.years %}<th>{%trans "Nb."%}</th><th>{%trans "Area"%}</th>{% endfor %}<th>{%trans "Nb."%}</th><th>{%trans "Area"%}</th>
      </tr>
      {% for lbl, years in dashboard.survey.effective_by_dpt %}
      <tr>
        {%for nb, area, cost, fnap in years %}
        {% if forloop.counter0|divisibleby:4 %}
        <th class='sub'>{{lbl}}</th>{% endif %}
        <td{%if forloop.last%} class='sub'{%endif%}>{{nb|intcomma}}</td><td{%if forloop.last%} class='sub'{%endif%}>{{area|intcomma}}</td>{% endfor %}
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "main towns by number" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        <th>{% trans "Town" %}</th><th>{% trans "Number" %}</th>
      </tr>
      {% for lbl, nb in dashboard.survey.towns %}
      <tr>
        <th class='sub'>{{lbl}}</th><td>{{nb|intcomma}}</td>
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "main towns by surface" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        <th>{% trans "Town" %}</th><th>{% trans "Total surface (ha)" %}</th>
      </tr>
      {% for lbl, nb in dashboard.survey.towns_surface %}
      <tr>
        <th class='sub'>{{lbl}}</th><td>{{nb|m2_to_ha|intcomma}}</td>
      </tr>
      {% endfor %}
    </table></div></div>
  </div>

  <h3>{% trans "Excavation informations" %}</h3>
  <div>
    <div class='clean-table'>
      <h4>{% trans "total" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        <th>{% trans "Status" %}</th><th>{% trans "Number" %}</th>
      </tr>
      {% for lbl, nb in dashboard.excavation.total %}
      <tr>
        <th class='sub'>{{lbl}}</th><td>{{nb|intcomma}}</td>
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "by year" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        {%for yr in dashboard.years %}
        {% if forloop.counter0|divisibleby:5 %}
        <th>{% trans "State" %}</th>{% endif %}
        <th>{{yr|default_if_none:''}}</th>{% endfor %}
      </tr>
      {% for lbl, years in dashboard.excavation.by_year %}
      <tr>
        {% for nb in years %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{{lbl}}</th>{% endif %}
        <td>{{nb|intcomma}}</td>{% endfor %}
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "by realisation year" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        {% for yr in dashboard.realisation_years %}
        {% if forloop.counter0|divisibleby:5 %}
        <th>{% trans "State" %}</th>{% endif %}
        <th>{{yr.year}}</th>{% endfor %}
      </tr>
      {% for lbl, years in dashboard.excavation.by_realisation_year %}
      <tr>
        {% for nb in years %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{{lbl}}</th>{% endif %}
        <td>{{nb}}</td>{% endfor %}
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "current realisation year" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        <th>{% trans "Status" %}</th>{% for lbl in dashboard.filters_label %}<th>{{lbl}}</th>{%endfor%}
      </tr>
      <tr>
        <th class='sub'>{% trans "Area"%}</th>{% for nb in dashboard.excavation.area_realised %}<td>{{nb|default_if_none:'-'|intcomma}}</td>{%endfor%}
      </tr>
      <tr>
        <th class='sub'>{% trans "Man-day"%}</th>{% for nb in dashboard.excavation.manday_realised %}<td>{{nb|default_if_none:'-'|intcomma}}</td>{%endfor%}
      </tr>
      <tr>
        <th class='sub'>{% trans "Man-day/hectare"%}</th>{% for nb in dashboard.excavation.mandayhect_realised %}<td>{{nb|default_if_none:'-'|intcomma}}</td>{%endfor%}
      </tr>
    </table></div></div>

    <p><strong>{% trans "Man-day/hectare for effective operations (current realisation year):" %}</strong> {{dashboard.excavation.mandayhect_real_effective}}</p>

    <div class='clean-table'>
      <h4>{% trans "organizations (current realisation year)" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        <th>&nbsp;</th><th>{% trans "Area" %}</th><th>{% trans "Man-day" %}</th><th>{% trans "Man-day/hectare" %}</th>
      </tr>
      {% for org in dashboard.excavation.org_realised %}
      <tr>
        <th class='sub'>{{org.scientist__attached_to__name}}</th><td>{{org.area|default_if_none:'-'|intcomma}}</td><td>{{org.manday|default_if_none:'-'|intcomma}}</td><td>{{org.mandayhect|default_if_none:'-'|intcomma}}</td>
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "area by organization by year" %}</h4>
    <div class='clean-table-wrap'>
    <table class='mini-table'>
      {% for org, vals in dashboard.excavation.org_by_year %}
      {% if forloop.counter0|divisibleby:5 %}
      <tr>
        {% for yr in dashboard.years%}
        {% if forloop.counter0|divisibleby:5 %}
        <th>{% trans "Organization" %}</th>{% endif %}
        <th>{{yr|default_if_none:'-'}}</th>{% endfor %}
      </tr>
      {% endif %}
      <tr>
        {% for area, cost in vals %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{{org}}</th>{% endif %}
        <td>{{area|default_if_none:'-'|intcomma}}</td>{% endfor %}
      </tr>
      {% endfor %}
      <tr>
        {% for area in dashboard.excavation.org_by_year_area_sum %}
        {% if forloop.counter0|divisibleby:5 %}
        <th>{% trans "Sum" %}</th>{% endif %}
        <td>{{area|intcomma}}</td>{% endfor %}
      </tr>
      <tr>
        {% for area in dashboard.excavation.org_by_year_area_mean %}
        {% if forloop.counter0|divisibleby:5 %}
        <th>{% trans "Mean" %}</th>{% endif %}
        <td>{{area|intcomma}}</td>{% endfor %}
      </tr>
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "area by organization by realisation year" %}</h4>
    <div class='clean-table-wrap'>
    <table class='mini-table'>
      {% for org, vals in dashboard.excavation.org_by_year %}

        {% if forloop.counter0|divisibleby:5 %}
      <tr>
        {% for yr in dashboard.years%}
        {% if forloop.counter0|divisibleby:5 %}
        <th>{% trans "Organization" %}</th>{% endif %}
        <th>{{yr|default_if_none:'-'}}</th>{% endfor %}
      </tr>
        {% endif %}

      <tr>
        {% for area, cost in vals %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{{org}}</th>{% endif %}
        <td>{{area|default_if_none:'-'|intcomma}}</td>{% endfor %}
      </tr>
      {% endfor %}
      <tr>
        {% for area in dashboard.excavation.org_by_year_area_sum %}
        {% if forloop.counter0|divisibleby:5 %}
        <th>{% trans "Sum" %}</th>{% endif %}
        <td>{{area|default_if_none:'-'|intcomma}}</td>{% endfor %}
      </tr>
      <tr>
        {% for area in dashboard.excavation.org_by_year_area_mean %}
        {% if forloop.counter0|divisibleby:5 %}
        <th>{% trans "Mean" %}</th>{% endif %}
        <td>{{area|default_if_none:'-'|intcomma}}</td>{% endfor %}
      </tr>
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "by month" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        {% for mt in dashboard.last_months %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{% trans "State" %}</th>{% endif %}
        <th>{{mt.date|date:"N Y"|capfirst}}</th>{% endfor %}
      </tr>
      {% for lbl, months in dashboard.excavation.by_month %}
      <tr>
        {% for nb in months %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{{lbl}}</th>{% endif %}
        <td>{{nb|default_if_none:'-'|intcomma}}</td>{% endfor %}
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "by department" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        {% for yr in dashboard.years %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{% trans "Department" %}</th>{% endif %}
        <th>{{yr|default_if_none:'-'}}</th>{% endfor %}
        <th>{% trans "Sum" %}</th>
      </tr>
      {% for lbl, years in dashboard.excavation.by_dpt %}
      <tr>
        {% for nb in years %}
        {% if forloop.counter0|divisibleby:5 %}
        <th class='sub'>{{lbl}}</th>{% endif %}
        <td{%if forloop.last%} class='sub'{%endif%}>{{nb|default_if_none:'-'|intcomma}}</td>{% endfor %}
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "effective operation by department" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        {% for yr in dashboard.years %}
        {% if forloop.counter0|divisibleby:3 %}
        <th rowspan='2' class="sub">{% trans "Department" %}</th>{% endif %}
        <th colspan='3'>{{yr|default_if_none:'-'}}</th>{% endfor %}
        <th rowspan='2' class="sub">{% trans "Department" %}</th>
        <th colspan='3'>{% trans "Sum" %}</th>
      </tr>
      <tr>
        {% for yr in dashboard.years %}<th>{%trans "Nb."%}</th><th>{%trans "Cost"%}</th><th>{%trans "FNAP cost"%}</th>{% endfor %}<th>{%trans "Nb."%}</th><th>{%trans "Cost"%}</th><th>{%trans "FNAP cost"%}</th>
      </tr>
      {% for lbl, years in dashboard.excavation.effective_by_dpt %}
      <tr>
        {% for nb, area, cost, fnap in years %}
        {% if forloop.counter0|divisibleby:3 %}
        <th class='sub'>{{lbl}}</th>{% endif %}
        <td{%if forloop.last%} class='sub'{%endif%}>{{nb|intcomma}}</td><td{%if forloop.last%} class='sub'{%endif%}>{{cost|intcomma}}</td><td{%if forloop.last%} class='sub'{%endif%}>{{fnap|intcomma}}</td>{% endfor %}
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "main towns by number" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        <th>{% trans "Town" %}</th><th>{% trans "Number" %}</th>
      </tr>
      {% for lbl, nb in dashboard.excavation.towns %}
      <tr>
        <th class='sub'>{{lbl}}</th><td>{{nb|intcomma}}</td>
      </tr>
      {% endfor %}
    </table></div></div>

    <div class='clean-table'>
      <h4>{% trans "main towns by cost" %}</h4>
    <div class='clean-table-wrap'>
    <table>
      <tr>
        <th>{% trans "Town" %}</th><th>{% trans "Cost (euros)" %}</th>
      </tr>
      {% for lbl, nb in dashboard.excavation.towns_cost %}
      <tr>
        <th class='sub'>{{lbl}}</th><td>{{nb|intcomma}}</td>
      </tr>
      {% endfor %}
    </table></div></div>


  </div>
</div>
<script>
  $( function() {
    $( "#dashboard-operations" ).accordion({
      collapsible: true,
      heightStyle: "content"
    });
  } );
</script>
{% endblock %}
