{% extends "base.html" %}
{% block title %}RB{{ experiment.reference_number|default:" not found" }}{% endblock %}
{% load colour_table_row %}
{% load naturaltime from humanize %}
{% load render_table from django_tables2 %}

{% block body %}
    {% if not experiment %}
        <div class="text-center col-md-6 col-md-offset-3 card card-body">
            Experiment not found or error encountered: {{ error }}.
        </div>
    {% else %}
        <div class="row">
            <div class="col-md-12 text-center">
                <h2>RB{{ experiment.reference_number }}</h2>
            </div>
        </div>
        <div class="d-flex flex-column mb-3">
            <div class="p-2">
                <div class="card card-2-column experiment_panel">
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-6">
                                <div>
                                    <strong>Title:</strong> {{ experiment_details.title }}
                                </div>
                                <div>
                                    <strong>Principal Investigator:</strong> {{ experiment_details.pi }}
                                </div>
                                <div>
                                    <strong>Instrument:</strong>
                                    {% if experiment_details.instrument %}
                                        <a href="{% url 'runs:list' instrument=experiment_details.instrument %}">
                                            {{ experiment_details.instrument }}
                                        </a>
                                    {% endif %}
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div>
                                    <strong>Start Date:</strong> {{ experiment_details.start_date }}
                                </div>
                                <div>
                                    <strong>End Date:</strong> {{ experiment_details.end_date }}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <h3>Reduction Jobs ({{ run_count }})</h3>
        <div class="row" id="experiment_summary_table">
            <div class="tab-content col-md-12">
                {% render_table experiment_summary_table %}
            </div>
        </div>
    {% endif %}
{% endblock %}
