{% extends 'detail_view.html' %}
{% load wnsq_tags %}
{% block button_bar %}
    {{ block.super }}
    {% if object.project %}
        <a href="{% url 'sample_create' %}?project={{ object.project.pk }}" class="button"><span
                class="icon-plus on-left"></span>Add Sample</a>
    {% else %}
        <a href="{% url 'sample_create' %}" class="button"><span class="icon-plus on-left"></span>Add Sample</a>
    {% endif %}
{% endblock button_bar %}
{% block extra %}
    {% if measurements %}
        <table class="table striped">
            <thead>
            <tr>
                <th colspan="3">Measurements</th>
            </tr>
            <tr>
                <th>Date</th>
                <th>Result</th>
                <th>Method</th>
            </tr>
            </thead>

            <tbody>
            {% for m in measurements %}
                <tr>
                    <td><a href="{% url 'measurement_detail' pk=m.id %}">{{ m.started_at }}</a></td>
                    <td>{% if m.analysis_result %}
                        {{ m.analysis_result|floatformat:2 }}
                    {% else %}
                        {% nothing %}
                    {% endif %}
                    </td>
                    <td>{{ m.used_method }}</td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    {% endif %}
    {% if dilution_back_log %}
        <table class="table striped">
            <thead>
            <tr>
                <th colspan="2">prediluted from</th>
            </tr>
            <tr>
            <th>Origin</th>
                <th>Factor</th>
            </tr>
            </thead>

            <tbody>
            {% for entry in dilution_back_log %}
                <tr>
                    <td>{{ entry.origin }}</td>
                    <td>{{ entry.factor|floatformat:1 }}</td>
                </tr>
            {% endfor %}
            </tbody>

            <tfoot>
            <tr>
                <td colspan="2">Total factor: {{ object.total_dilution|floatformat:1 }}</td>
            </tr>
            </tfoot>

        </table>
    {% endif %}

    {% if dilution_forward_log %}
        <table class="table striped">
            <thead>
            <tr>
                <th colspan="2">prediluted into</th>
            </tr>
            </thead>
            <tbody>
            {% for entry in dilution_forward_log %}
                <tr>
                    <td>
                        <a href="{% url 'sample_detail' pk=entry.pk %}">{{ entry.name }}</a>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
            <tfoot>
            <tr>
                <td>
                    {{ dilution_forward_log.count }} Item{{ dilution_forward_log|pluralize }}
                </td>
            </tr>
            </tfoot>
        </table>
    {% endif %}

{% endblock extra %}
