{% extends "base.html" %}
{% load i18n range units humanize %}
{% block extra_head %}
{{form.media}}
{% endblock %}
{% block content %}
<h2>{% trans "Archaeological files" %}</h2>
<div class='dashboard' id='dashboard-files'>

  <h3>{% trans "Global informations" %}</h3>
  <div>
    <p><label>{% trans "Total:" %}</label> <span class='value numeric'>{{dashboard.total_number|intcomma}}</span></p>
    {% for type in dashboard.types %}
    <p><label>{{type.file_type__label}}{% trans ":"%}</label> <span class='value numeric'>{{type.number|intcomma}}</span></p>
    {% endfor %}

    <div class='clean-table'>
      <h4>{% trans "by year"%}</h4>
      <div class='clean-table-wrap'>
        <table>
          <tr>
          {% for year in dashboard.by_year %}<th>{% if year.date.year %}{{year.date.year}}{% else %}{% trans "no year" %}{% endif %}</th>{% endfor %}
          </tr>
          <tr>
          {% for year in dashboard.by_year %}<td>{{year.number|intcomma}}</td>{% endfor%}
          </tr>
        </table>
      </div>
    </div>

    <div class='clean-table'>
    <h4>{% trans "by month"%}</h4>
    <table>
      <tr>
      {% for month in dashboard.by_month %}<th>{{month.date|date:"N Y"|capfirst}}</th>{% endfor %}
      </tr>
      <tr>
      {% for month in dashboard.by_month %}<td>{{month.number|intcomma}}</td>{% endfor%}
      </tr>
    </table>
    </div>

  </div>

  <h3>{% trans "Research archaeology" %}</h3>
  <div>
    <p><label>{% trans "Total:" %}</label><span class='value numeric'>{{dashboard.research.total_number|intcomma}}</span></p>
    <div class='clean-table'>
    <h4>{% trans "by year"%}</h4>
    <table>
      <tr>
      {% for year in dashboard.research.by_year %}<th>{{year.date.year}}</th>{% endfor %}
      </tr>
      <tr>
      {% for year in dashboard.research.by_year %}<td>{{year.number|intcomma}}</td>{% endfor%}
      </tr>
    </table>
    </div>

    <div class='clean-table'>
    <h4>{% trans "by month"%}</h4>
    <table>
      <tr>
      {% for month in dashboard.research.by_month %}<th>{{month.date|date:"F Y"|capfirst}}</th>{% endfor %}
      </tr>
      <tr>
      {% for month in dashboard.research.by_month %}<td>{{month.number|intcomma}}</td>{% endfor%}
      </tr>
    </table>
    </div>

    <div class='clean-table'>
    <h4>{% trans "by department"%}</h4>
    <table>
      <tr>
      {% for dpt in dashboard.research.by_dpt %}<th>{{dpt.department__label}}</th>{% endfor %}
      </tr>
      <tr>
      {% for dpt in dashboard.research.by_dpt %}<td>{{dpt.number|intcomma}}</td>{% endfor%}
      </tr>
    </table>
    </div>

    <div class='clean-table'>
    <h4>{% trans "main towns"%}</h4>
      <div class='clean-table-wrap'>
    <table>
      <tr>
      {% for town in dashboard.research.towns %}<th>{{town.town__name}}</th>{% endfor %}
      </tr>
      <tr>
      {% for town in dashboard.research.towns %}<td>{{town.number|intcomma}}</td>{% endfor%}
      </tr>
    </table>
      </div>
    </div>

  </div>

  <h3>{% trans "Rescue archaeology" %}</h3>
  <div>
    <p><label>{% trans "Total:" %}</label> <span class='value numeric'>{{dashboard.rescue.total_number|intcomma}}</span></p>

    <div class='clean-table'>
    <h4>{% trans "by saisine type"%}</h4>
      <div class='clean-table-wrap'>
    <table>
      <tr>
      {% for saisine in dashboard.rescue.saisine %}<th>{{saisine.saisine_type__label}}</th>{% endfor %}
      </tr>
      <tr>
      {% for saisine in dashboard.rescue.saisine %}<td>{{saisine.number|intcomma}}</td>{% endfor%}
      </tr>
    </table>
    </div>
    </div>

    <div class='clean-table'>
    <h4>{% trans "by administrative act"%}</h4>
      <div class='clean-table-wrap'>
    <table>
      <tr>
      {% for act in dashboard.rescue.administrative_act %}<th>{{act.act_type__label}}</th>{% endfor %}
      </tr>
      <tr>
      {% for act in dashboard.rescue.administrative_act %}<td>{{act.number|intcomma}}</td>{% endfor%}
      </tr>
    </table>
    </div>
    </div>

    <div class='clean-table'>
    <h4>{% trans "by year"%}</h4>
      <div class='clean-table-wrap'>
    <table>
      <tr>
      {% for year in dashboard.rescue.by_year %}<th>{{year.date.year}}</th>{% endfor %}
      </tr>
      <tr>
      {% for year in dashboard.rescue.by_year %}<td>{{year.number|intcomma}}</td>{% endfor%}
      </tr>
    </table>
    </div>
    </div>

    <div class='clean-table'>
    <h4>{% trans "by month"%}</h4>
      <div class='clean-table-wrap'>
    <table>
      <tr>
      {% for month in dashboard.rescue.by_month %}<th>{{month.date|date:"F Y"|capfirst}}</th>{% endfor %}
      </tr>
      <tr>
      {% for month in dashboard.rescue.by_month %}<td>{{month.number|intcomma}}</td>{% endfor%}
      </tr>
    </table>
    </div>
    </div>

    <p><label>{% trans "Archaeological files linked to at least one operation:" %}</label> <span class='value numeric'>{{dashboard.rescue.with_associated_operation|intcomma}}</span></p>
    <p><label>{% trans "Archaeological files linked to at least one operation (%):" %}</label> <span class='value numeric'>{{dashboard.rescue.with_associated_operation_percent|intcomma}}</span></p>

    <div class='clean-table'>
    <h4>{% trans "archaeological files linked to at least one operation (%)"%}</h4>
      <div class='clean-table-wrap'>
    <table>
      <tr>
      {% for year in dashboard.rescue.operational_by_year %}<th>{{year.date.year}}</th>{% endfor %}
      </tr>
      <tr>
      {% for year in dashboard.rescue.operational_by_year %}<td>{{year.number|intcomma}}</td>{% endfor%}
      </tr>
    </table>
    </div>
    </div>

    <div class='clean-table'>
    <h4>{% trans "by department"%}</h4>
      <div class='clean-table-wrap'>
    <table>
      <tr>
      {% for dpt in dashboard.rescue.by_dpt %}<th>{{dpt.department__label}}</th>{% endfor %}
      </tr>
      <tr>
      {% for dpt in dashboard.rescue.by_dpt %}<td>{{dpt.number|intcomma}}</td>{% endfor%}
      </tr>
    </table>
    </div>
    </div>

    <div class='clean-table'>
    <h4>{% trans "surface by department (ha)"%}</h4>
      <div class='clean-table-wrap'>
    <table>
      <tr>
      {% for dpt in dashboard.rescue.surface_by_dpt %}<th>{{dpt.department__label}}</th>{% endfor %}
      </tr>
      <tr>
      {% for dpt in dashboard.rescue.surface_by_dpt %}<td>{{dpt.number|m2_to_ha|intcomma}}</td>{% endfor%}
      </tr>
    </table>
    </div>
    </div>

    <div class='clean-table'>
    <h4>{% trans "main towns by number"%}</h4>
      <div class='clean-table-wrap'>
    <table>
      <tr>
      {% for town in dashboard.rescue.towns %}<th>{{town.town__name}}</th>{% endfor %}
      </tr>
      <tr>
      {% for town in dashboard.rescue.towns %}<td>{{town.number|intcomma}}</td>{% endfor%}
      </tr>
    </table>
    </div>
    </div>

    <div class='clean-table'>
    <h4>{% trans "main towns by surface (ha)"%}</h4>
      <div class='clean-table-wrap'>
    <table>
      <tr>
      {% for town in dashboard.rescue.surface_by_town %}<th>{{town.town__name}}</th>{% endfor %}
      </tr>
      <tr>
      {% for town in dashboard.rescue.surface_by_town %}<td>{{town.number|m2_to_ha|intcomma}}</td>{% endfor%}
      </tr>
    </table>
    </div>
    </div>

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