{% extends 'training_template.html' %}
{% load staticfiles %}

{% block training_content %}
    <div class="row">
    <div class="col-lg-4">
        <h2>{{ psdc.sdc.title }}</h2>
        <p>This skill development course is planned for {{ psdc.datetime }}</p>
        <p>{{ psdc.notes|linebreaks }}</p>

    </div>
    <div class="col-lg-8">
        <h3>Trainees</h3>
        {% if psdc.trainees %}
            <p>So far {{ psdc.trainees.count }} people are booked on this course.</p>
            <table class="table table-sm table-striped">
                <tr>
                    <th>Name</th>{% if is_training %}
                    <th>Qualification</th>
                    <th>Membership Issue</th>{% endif %}</tr>
                {% for trainee in psdc.trainees.all %}
                    <tr>
                        <td>{% if is_training %}
                            <a href="{% url 'xsd_members:MemberDetail' trainee.pk %}">{{ trainee.get_full_name }}</a>
                            {% else %}{{ trainee.get_full_name }} {% endif %}</td>
                        {% if is_training %}
                            <td>{{ trainee.top_qual }}</td>
                            <td>{% if trainee.membership_problem %}
                                <div class="popover-button error" data-title="Problems With Membership"
                                     data-content="{{ trainee.first_name }}'s {% if trainee.no_expiry_data %}has not got any forms with the club, probably a new member {% elif trainee.bsac_expired %}BSAC membership has expired, {% elif trainee.club_expired %}club membership has expired, {% elif trainee.club_expired %}medical form has expired.{% endif %}"
                                     data-trigger="hover" data-placement="top">Yes
                                </div>
                            {% endif %}</td>
                        {% endif %}
                    </tr>
                {% endfor %}
            </table>
        {% else %}
            <p>No trainees are confirmed on this course yet</p>
        {% endif %}
    </div>
    {% if is_training %}
        <div class="col-md-12">
        <div class="form-actions">
            {% if not psdc.completed %}
                <a class="btn btn-secondary" href="{% url 'xsd_training:PerformedSDCUpdate' psdc.pk %}"><i
                        class="fa fa-pencil"></i> Edit</a>
            {% endif %}
            <a class="btn btn-secondary" href="{% url 'xsd_training:PerformedSDCHistory' psdc.pk %}"><i
                    class="fa fa-history"></i> History</a>
            <div class="btn-group pull-right">
                <a class="btn btn-danger" href="{% url 'xsd_training:PerformedSDCDelete' psdc.pk %}"><i
                        class="fa fa-remove"></i> Cancel Course</a>
                <a class="btn btn-success" href="{% url 'xsd_training:PerformedSDCComplete' psdc.pk %}"><i
                        class="fa fa-ok"></i> Complete Course</a>
            </div>
        </div>
    {% endif %}
    <div class="row">
{% endblock %}
