{% extends 'detail_view.html' %}
{% load wnsq_tags %}
{% load i18n %}
{% block button_bar %}
    {{ block.super }}
    <a class="button" href="#report"><span class="on-left icon-files"></span>{% trans 'Report' %}</a>
{% endblock %}
{% block content %}
    <table class="table striped">
        <thead>
        <tr>
            <th colspan="2">
                {{ view.model.verbose_name }}
            </th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>{% trans 'sample'|capfirst %}</td>
            <td><a href='{% url 'sample_detail' pk=sample %}'>{{ sample__name }}</a></td>
        </tr>
        <tr>
            <td>{% trans 'bag'|capfirst %}</td>
            <td><a href="{% url 'bag_detail' pk=sample__contained_in %}">{{ sample__contained_in__name }}</a></td>
        </tr>
        <tr>
            <td>{% trans 'started'|capfirst %}</td>
            <td>{{ started_at }}</td>
        </tr>
        <tr>
            <td>{% trans 'finished'|capfirst %}</td>
            <td>{{ finished_at }}</td>
        </tr>
        <tr>
            <td>{% trans 'location'|capfirst %}</td>
            <td>{{ location }}</td>
        </tr>
        <tr>
            <td>
                {% trans 'temperature'|capfirst %}
            </td>
            <td>{{ temperature|floatformat:1 }}</td>
        </tr>

        <tr>
            <td>{% trans 'method'|capfirst %}</td>
            <td>{{ used_method }}</td>
        </tr>
        <tr>
            <td>{% trans 'presentation time'|capfirst %}</td>
            <td>{{ presentation_time }}</td>
        </tr>
        <tr>
            <td>{% trans 'olfactometer'|capfirst %}</td>
            <td><a href="{% url 'olfactometer_detail' pk=olfactometer %}">{{ olfactometer__name }}</a></td>
        </tr>
        <tr>
            <td>{% trans 'calibration'|capfirst %} {% trans 'expires' %}</td>
            <td><a href="{% url 'calibration_detail' pk=calibration %}">{{ calibration__valid_to }}</a></td>
        </tr>
        <tr>
            <td>{% trans 'analysis result'|capfirst %}</td>
            <td>{{ analysis_result|floatformat:2 }}</td>
        </tr>
        <tr>
            <td><strong>{% trans 'measurement result'|capfirst %}</strong></td>
            <td>
                <strong>
                    {% if not compliant_result %}({% endif %}
                    {{ result|floatformat:2|value_or_nothing }}
                    {% if not compliant_result %}){% endif %}
                </strong></td>
        </tr>
        <tr>
            <td>{% trans 'comments'|capfirst %}</td>
            <td>{{ comments }}</td>
        </tr>
        </tbody>

    </table>



    {% for round in round_info %}
        <table class="table striped"
               style="margin-top: 8px; {% if not round.is_included %}opacity: 0.7;{% endif %}"
                >
            <thead>
            <tr>
                <th colspan="4">
                    {% trans 'round'|capfirst %} {{ round.number }}
                    {% if not round.is_included %}
                        &NonBreakingSpace; ({% trans 'discarded' %})
                    {% endif %}
                </th>
            </tr>
            <tr>
                <th>{% trans 'panelist'|capfirst %}</th>
                <th>ITE</th>
                <th>&Delta;Z</th>
                <th>{% trans 'blank' %}</th>
            </tr>
            </thead>

            <tbody>

            {% for p in round.results %}
                <tr
                        {% if not p.valid %}
                            style="color: darkgray;"
                        {% endif %}
                        >
                    <td><a href='{% url 'panelist_detail' pk=p.panelist.pk %}'>{{ p.panelist }}</a></td>

                    <td>
                        {% if p.valid %}
                            {{ p.ite|floatformat:2 }}
                        {% else %}
                            ({{ p.ite|floatformat:2 }})
                        {% endif %}
                    </td>
                    <td>{{ p.dz|floatformat:2 }}</td>
                    <td>{{ p.blank }}</td>
                </tr>
            {% endfor %}
            <tr>
                <td colspan="4">
                    <div class="panel collapsed" data-role="panel" style="font-size: 11pt;">
                        <div class="panel-header">
                            <small>
                                {% trans 'Details' %}
                            </small>
                        </div>
                        <div class="panel-content" style="display: none;">
                            <table>
                                <tbody>

                                <tr>
                                    <td>{% trans 'Operator' %}</td>
                                    <td>
                                        <a href="{% url 'user_detail' pk=round.operator_id %}">{{ round.operator }}</a>
                                    </td>
                                </tr>
                                <tr>
                                    <td>{% trans 'started' %}</td>
                                    <td>{{ round.started_at }}</td>
                                </tr>
                                <tr>
                                    <td>{% trans 'finished' %}</td>
                                    <td>{{ round.finished_at }}</td>
                                </tr>

                                <tr>
                                    <td colspan="2">
                                        <a href="{% url 'round_detail' round.round_pk %}"
                                           class="button">{% trans 'Matrix' %}</a>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
    {% endfor %}

    <a name="report"></a>
    <form method="get" action="{% url 'sample_reporter' pk=object.pk %}" target="_blank">
        <table class="table">
            <thead>
            <tr>
                <th colspan="2">{% trans 'Report' %}</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td><label for="id_matrices">{% trans 'include matrices' %}</label></td>
                <td><input name="matrices" id="id_matrices" type="checkbox" data-transform="input-control"/></td>
            </tr>
            </tbody>
            <tfoot>
            <tr>
                <td colspan="2">
                    <button type="submit" class="button primary">{% trans 'create'|capfirst %}</button>
                </td>
            </tr>
        </table>
    </form>

{% endblock content %}
