{% extends 'layouts/admin.twig' %}

{% block content %}

    <ul class="breadcrumbs el">
        <li><a href="/admin/">Home</a> /</li>
        <li class="end">Satisfactory</li>
    </ul>

    {% include 'membersmessaging/admin/widgets/tabnav.twig' %}

    <h1>Satisfactory</h1>

    <form action="" method="GET" class="style">
        <fieldset class="show">
            <h1><a class="show el">Search <i class="fa fa-caret-right"></i></a></h1>
            <div class="row">
                <label for="satisfactory">Rating</label>
                <select id="satisfactory" name="satisfactory">
                    <option value="">All</option>
                    {% for key, option in satisfactory_options %}
                        <option value="{{ key|e }}"
                                {% if selected_satisfactory == key %}selected{% endif %}>
                            {{ option|e }}
                        </option>
                    {% endfor %}
                </select>
            </div>

            <div class="search-button">
                <input type="hidden" name="action" value="search"/>
                <input type="submit" value="Search" class="BUTTON"/>
            </div>
        </fieldset>
    </form>

    <table class="manage-items">
        <tr>
            <th>Customer</th>
            <th>Admin user</th>
            <th>Date</th>
            <th>Rating date</th>
            <th>Rating</th>
            <th>Comment</th>
            <th></th>
        </tr>
        <tbody class="tabular">
        {% if messages_result|length > 0 %}
            {% for message in messages_result %}
                <tr>
                    <td>{{ message.thread.getThreadMemberName() }}</td>
                    <td>{{ message.admin_user.name|e }}</td>
                    <td>{{ message.created_at|date('d/m/Y H:i') }}</td>
                    <td>{{ message.updated_at|date('d/m/Y H:i') }}</td>
                    <td>{{ message.satisfactory_name|e }}</td>
                    <td>{{ message.comment|e }}</td>
                    <td><a href="{{ route('admin.messaging.view_thread', message.thread.url) }}">View Thread</a></td>
                </tr>
            {% endfor %}
        {% else %}
            <tr>
                <td colspan="7" style="text-align: center;">
                    {% if selected_satisfactory is defined and selected_satisfactory %}
                        No messages found with the selected rating.
                    {% else %}
                        No messages found.
                    {% endif %}
                </td>
            </tr>
        {% endif %}
        </tbody>
    </table>



{% endblock %}
