{% load custom_tags_and_filters %}
<table class="table table-condensed table-double-stripped thead-light" style="border: 1px solid #ddd">
    <thead>
        <tr>
            <th>Created</th>
            {% if user_is_reviewer or user.is_any_part_of_staff %}<th>User</th>{% endif %}
            <th class="text-center">Tool</th>
            {% if qualification_levels_exist %}<th class="text-center">Qualification Level</th>{% endif %}
            <th class="text-center">Shadowed User</th>
            <th class="text-center">Shadowed On</th>
            <th class="text-right text-nowrap">
                {% if request_status == 'pending' and user_is_reviewer %}
                    Action
                {% elif request_status == 'approved' %}
                    Approved by
                {% elif request_status == 'denied' %}
                    Denied by
                {% endif %}
            </th>
        </tr>
    </thead>
    <tbody>
        {% for s_request in request_list %}
            <tr>
                <td style="vertical-align: middle">
                    {% if s_request.id in request_notifications %}<span class="label label-success">New</span>{% endif %}
                    {{ s_request.creation_time|date:'SHORT_DATETIME_FORMAT' }}
                </td>
                {% if user_is_reviewer or user.is_any_part_of_staff %}
                    <td style="vertical-align: middle">{{ s_request.creator.get_name }}</td>
                {% endif %}
                <td class="text-center" style="vertical-align: middle">{{ s_request.tool.name }}</td>
                {% if qualification_levels_exist %}
                    <td class="text-center" style="vertical-align: middle">{{ s_request.qualification_level.name|default:"N/A" }}</td>
                {% endif %}
                <td class="text-center" style="vertical-align: middle">{{ s_request.shadowed_qualified_user.get_name }}</td>
                <td class="text-center" style="vertical-align: middle">{{ s_request.event_date|date }}</td>
                <td class="text-right text-nowrap" style="vertical-align: middle">
                    {% if request_status == 'approved' or request_status == 'denied' %}
                        {{ s_request.reviewer.get_name }}
                    {% elif allowed_tools_exist %}
                        {% if request_status == 'pending' and user in s_request.reviewers %}
                            <a class="btn btn-sm btn-default"
                               title="Approve/Deny"
                               href="{% url 'edit_shadowing_verification' s_request.id %}"><i class="glyphicon glyphicon-ok-circle success-highlight"></i>&nbsp;&nbsp;<i class="glyphicon glyphicon-ban-circle danger-highlight"></i> Review</a>
                        {% endif %}
                        {% if request_status == 'pending' and s_request.creator == user %}
                            {% url 'edit_shadowing_verification' s_request.id as edit_request_url %}
                            {% url 'delete_shadowing_verification' s_request.id as delete_request_url %}
                            {% button type="edit" size="small" value="Edit" title="Edit" url=edit_request_url %}
                            {% button type="delete" size="small" value="Delete" title="Delete" url=delete_request_url onclick="return confirm('Are you sure you want to delete this shadowing verification?');" %}
                        {% endif %}
                    {% endif %}
                </td>
            </tr>
            <tr>
                <td colspan="{{ table_col_number }}">
                    <strong>Details</strong>
                    <br>
                    {{ s_request.description }}
                </td>
                <td style="border-top: none"></td>
            </tr>
        {% endfor %}
    </tbody>
</table>
