{% extends 'base.html' %}
{% load staticfiles %}
{% load i18n %}
{% block stylesheets %}
    {{ block.super }}
    <link rel="stylesheet" href="{% static 'css/select2.css' %}"/>
{% endblock %}
{% block button_bar %}

    <form method="get" action="{% url 'lab_history_print' %}" target="_blank">
        <table class="table">
            <tbody>
            <tr>
                <td style="vertical-align: middle; width:15%;">
                    <button type="submit"><span class="icon-printer on-left"></span>{% trans 'print'|capfirst %}
                    </button>
                </td>
                <td style="width: 80%;">
                    <label for="print_view_timespan">{% trans 'timespan'|capfirst %}</label>
                    <select name="timespan" id="print_view_timespan" class="select2" style="width: 200px;">
                        <option value="r">{% trans 'most recent' %}</option>
                        <option value="y">{% trans 'last twelve months' %}</option>
                        <option value="a">{% trans 'all' %}</option>
                    </select>
                </td>
            </tr>
            </tbody>
        </table>
    </form>

{% endblock button_bar %}
{% block content %}
    <h3>{% trans 'lab performance' %}</h3>

    <table style="background: transparent; width: 220px;">
        <tr>
            <td colspan="2">&mu; = {{ MU }}</td>
        </tr>
        <tr>
            <td>A<sub>w</sub>={{ Aw_20|floatformat:4 }} (n = 20)</td>
            <td align="right">t={{ t_20 }}</td>
        </tr>
    </table>

    {% if history_data %}
        <table class="table striped" id="lab_history_table">
            <thead>
            <tr>
                <th>{% trans 'date'|capfirst %}</th>
                <th>ITE</th>
                <th>n-Butanol (ppm)</th>
                <th>&mu;mol/mol</th>
                <th>&sigma;</th>
                <th>y<sub>ite</sub></th>
                <th>r</th>
                <th>d<sub>w</sub></th>
                <th>A<sub>od</sub></th>
            </tr>
            </thead>
            {% for data in history_data %}
                <tr>
                    <td>{{ data.date }}</td>
                    <td>
                        <a href="{% url 'measurement_detail' pk=data.measurement %}">{{ data.ite|floatformat:2 }}</a>
                    </td>
                    <td>
                        <a href='{% url 'reference gas_detail' pk=data.cylinder_pk %}'>{{ data.concentration|floatformat:2 }}</a>
                    </td>
                    <td>{{ data.ppm|floatformat:4 }}</td>
                    <td>{{ data.site|floatformat:4 }}</td>
                    <td>{{ data.y_ite|floatformat:4 }}</td>
                    <td style="color: {% if data.r_ok %}green{% else %}red{% endif %};">{{ data.r|floatformat:4 }}</td>
                    <td>{{ data.dw|floatformat:4 }}</td>
                    <td style="color: {% if data.A_ok %}green{% else %}red{% endif %};">{{ data.A|floatformat:4 }}</td>
                </tr>
            {% endfor %}
        </table>
    {% else %}
        no results yet.
    {% endif %}



    <script type="text/javascript" src="{% static 'js/select2.min.js' %}"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            // initialize jquery stuff after page load, fancier datepicker and select dropdown
            $(".select2").select2(
                    {
                        allowClear: false,
                        minimumResultsForSearch: -1
                    }
            );
        });
    </script>

    <script>
        $(document).ready(function () {
            $('#lab_history_table').DataTable({
                'filter': false,
                'ordering': false,
                'info': false
            });
        });
    </script>


{% endblock content %}