{% load permissions %}

<table class="table table-striped trips-attendee-list">
    <thead>
    <tr>
        <th>Name</th>
        <th>Qualification</th>
        {% permission request.user can_view_attendee_details trip %}
            <th>Membership</th>
            <th>Requirements</th>
        {% endpermission %}
    </tr>
    </thead>
    <tbody>
    {% for attendee in attendees %}
        <tr>
            <td>
                <a href="{{ attendee.member.get_absolute_url }}" class="no-underline">
                    <img src="{{ attendee.member.avatar_xs }}" class="avatar avatar-xs" alt="Avatar"/>
                    <span class="underline">{{ attendee.member }}</span>
                </a>

                {% permission request.user can_remove trip %}
                    <form action="action/remove/" method="POST">
                        {% csrf_token %}
                        <input type="hidden" name="pk" value="{{ attendee.member.pk }}"/>
                        <button type="submit" class="btn btn-outline-danger btn-sm push-right">Remove</button>
                    </form>
                {% endpermission %}
            </td>
            <td {% if attendee.qualification_issue %}class="table-danger"{% endif %}>
                {% if attendee.member.top_qual %}
                    {{ attendee.member.top_qual }}
                {% else %}
                    No qualification
                {% endif %}
            </td>
            {% permission request.user can_view_attendee_details trip %}
                <td {% if attendee.member.membership_problem %}class="table-danger">{% endif %}
                    {% if attendee.member.membership_problem %}
                        <div class="popover-button error" data-title="Problems With Membership"
                             data-content="{{ attendee.member.first_name }}'s {% if attendee.member.no_expiry_data %}has not got any forms with the club, probably a new member {% elif attendee.member.bsac_expired %}BSAC membership has expired, {% elif attendee.member.club_expired %}club membership has expired, {% elif attendee.member.club_expired %}medical form has expired.{% endif %}"
                             data-trigger="hover" data-placement="top">
                            Missing Forms
                        </div>
                    {% else %}
                        <i class="fa fa-check"></i>
                    {% endif %}
                </td>
                <td>
                    {% if attendee.member.veggie %}
                        <p>Veggie</p>
                    {% endif %}

                    {% if attendee.member.alergies %}
                        <div class="popover-button error" data-title="Other Requirements"
                             data-content="{{ attendee.member.alergies }}"
                             data-trigger="hover" data-placement="top">
                            Yes
                        </div>
                    {% endif %}

                </td>
            {% endpermission %}

            </td>
        </tr>
    {% endfor %}
    </tbody>
</table>
