{% extends "base.html" %}
{% load url from future %}

{% load xray_tags %}
{% load humanize %}

{% block title %}Event Reports{% endblock title %}

{% block extra_stylesheets %}
  <link type="text/css" rel="stylesheet" href="{{ STATIC_URL }}xray/stylesheets/xray.css" />
{% endblock extra_stylesheets %}

{% block content %}
<div class="span12 event_data">
<div class="page-header"><h3>Event cohorts</h3></div>
<table class="cohort_table" cellpadding="0" cellspacing="0">
    <thead>
    <tr>
	<th><span class="event_name">{{ select1 }}</span></th>
        <th>People</th>
	<th colspan=13>{{ time_group|capfirst }}&nbsp;later&nbsp;<span class="event_name">{{ select2 }}</span></th>
    </tr>
    <tr>
	<th></th>
	<th></th>
        {% mkrange 13 as range13 %}
        {% for i in range13 %}
            <th class="entry">{{ i }}</th>
        {% endfor %}
    </tr>
    </thead>

    <tbody>
    {% for row_data in dates_data %}
         <tr>
            <td> 
                <div class="date">
                  {% if time_group == 'months' %}
                      {{ row_data.0|date:'b Y'|capfirst }}
                  {% elif time_group == 'weeks' %}
                      Week&nbsp;{{ row_data.0|date:'W (d b)' }}
                  {% else %}
                      {{ row_data.0|date:'d b Y' }}
                  {% endif %}
                </div>
            </td>
            <td>
                <div class="total_count">{{ row_data.1 }}</div>
            </td>

	    {% for i in row_data|slice:"2:" %}
                {% if i != '' %}
                    {% if as_percent %}
                        <td style="{{ i|cell_style }}">
                            {{ i|floatformat:2 }}
                        </td>
                    {% else %}
                        <td>
                            {{ i|intcomma }}
                        </td>
                    {% endif %}
                {% else %}
                    <td></td>
                {% endif %}
            {% endfor %}
        </tr>
    {% endfor %}

    {% if time_group != 'days' %}
    {% if averages %}
    <tr class="avg_row">

        <td colspan=2></td>

        {% for avg in averages %}
            <td>
                {% if as_percent %}
                    {{ avg|floatformat:2 }}
                {% else %}
                    {{ avg|intcomma }}
                {% endif %}
            </td>
        {% endfor %}
    </tr>
    {% endif %}
    {% endif %}
    </tbody>
</table>
</div>
{% endblock content %}
