{% extends 'training_template.html' %}

{% block training_content %}
    <div class="row">
        <form action="." method="post">
            <div class="row">
                <div class="col-sm-9">
                    <h1>{{ object.uid }} – Session Planning</h1>
                </div>
                <div class="col-sm-3">
                    <div class="btn-toolbar push-right">
                        <a href="{% url 'xsd_training:SessionHistory' object.pk %}" class="btn btn-secondary">
                            <i class="fa fa-history"></i> History
                        </a>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-12">

                    <h2>Session Details</h2>
                    {% csrf_token %}
                    <input type="hidden" name="form_def" value="session"/>
                    <div class="row">
                        <div class="col-md-6">
                            {% include 'forms/field.html' with field=form.name %}
                            {% include 'forms/field.html' with field=form.when %}
                            {% include 'forms/field.html' with field=form.where %}
                        </div>
                        <div class="col-md-6">
                            {% include 'forms/field.html' with field=form.notes %}
                        </div>
                    </div>
                </div>
                <div class="col-md-7">
                    <h2>Trainees</h2>
                </div>
            </div>

            <div class="col-md-7">

                {{ performed_lessons_formset.management_form }}
                <table class="table table-sm table-striped table-session">
                    <tr>
                        <th>Trainee</th>
                        <th>Lesson</th>
                        <th>Instructor</th>
                        <th></th>
                    </tr>
                    {% for form in performed_lessons_formset %}
                        <tr>
                            <td>{{ form.id }}{{ form.instance.trainee.get_full_name }}</td>
                            <td>{{ form.lesson }}</td>
                            <td>{{ form.instructor }}</td>
                            <td><a href="?remove-pl={{ form.instance.pk }}"
                                   class="btn btn-danger btn-mini pull-right"><i
                                    class="fa fa-remove"></i></a></td>
                        </tr>
                        {% empty %}
                        <h2 class="no-trainee">No Trainees Added Yet</h3>
                    {% endfor %}

                </table>
                <div class="form-actions ">

                    <button type="submit" class="btn btn-primary alignright"><i class="fa fa-save"></i> Save</button>
                    {% if session.in_past %}
                        <a class="btn btn-secondary" href="{% url 'xsd_training:SessionComplete' session.pk %}"><i
                                class="fa fa-check-square"></i> Complete Session</a>{% endif %}

                </div>


            </div>
        </form>

        <div class="col-md-5">
            <h3 class="no-top">Add Trainees</h3>
            <div>
                Individually
                {% include 'base/bulk_select_members.html' %}
                <form method="POST" action="action/add_tg/">
                    {% csrf_token %}
                    <div class="form-horizontal">
                        {{ traineegroup_select }}
                        <button type="submit" class="btn btn-secondary">Select</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
{% endblock %}
