{% extends request.is_ajax|yesno:'nullcont.htm,taskapp/ext.htm' %}
{% load i18n %}

{% block title %}{% trans 'Scheduled tasks me' %}{% endblock %}

{% block content %}
    <div class="table-responsive">
        <table class="table table-striped table-bordered">
            <thead>
            <tr>
                <th class="hidden-xs">#</th>
                <th class="col-md-2 col-sm-3">{% trans 'Name' %}</th>
                <th class="col-md-2 col-sm-1">{% trans 'Address' %}</th>
                <th class="col-sm-1">{% trans 'The nature of the damage' %}</th>
                <th class="col-sm-4">{% trans 'Description' %}</th>
                <th class="col-sm-1">{% trans 'Condition' %}</th>
                <th class="col-sm-1 hidden-xs">{% trans 'Date of create' %}</th>
                <th class="col-sm-1">{% trans 'Actions' %}</th>
            </tr>
            </thead>
            <tbody>
            {% with can_change_task=perms.taskapp.change_task can_remind=perms.taskapp.can_remind can_del_task=perms.taskapp.delete_task %}
            {% for task in tasks %}

                {% if task.is_relevant %}
                    <tr class="text-muted">
                {% else %}
                    {% if task.priority == 'E' %}
                        <tr class="success">
                    {% elif task.priority == 'C' %}
                        <tr>
                    {% elif task.priority == 'A' %}
                        <tr class="danger">
                    {% else %}
                        <tr>
                    {% endif %}
                {% endif %}

                <td class="hidden-xs"><a href="{% url 'taskapp:edit' task.id %}">{{ task.id }}</a></td>

                {% if task.abon and task.abon.group %}
                    <td>
                        <a href="{% url 'abonapp:abon_home' task.abon.group.pk task.abon.username %}">
                            {{ task.abon.get_full_name }}
                        </a>
                    </td>
                    <td>
                        {{ task.abon.group.title }}, {{ task.abon.street|default:_('Not assigned') }}
                        {{ task.abon.house|default:_('Not assigned') }}
                    </td>
                {% else %}
                    <td>{% trans 'User does not exist' %}</td>
                    <td>---</td>
                {% endif %}

                <td>{{ task.get_mode_display }}</td>
                <td>{{ task.descr|default:'' }}</td>
                <td>{{ task.get_state_display }}</td>
                <td class="hidden-xs">{{ task.time_of_create|date:'d E H:i' }}</td>

                <td class="btn-group btn-group-justified">
                    {% if can_change_task %}
                    <a href="{% url 'taskapp:edit' task.id %}" class="btn btn-sm btn-default" title="{% trans 'Edit' %}">
                        <span class="glyphicon glyphicon-edit"></span>
                    </a>
                    {% endif %}
                    {% if can_remind %}
                        <a href="{% url 'taskapp:remind' task.id %}" class="btn btn-default btn-sm" title="{% trans 'Remind' %}">
                            <span class="glyphicon glyphicon-bell"></span>
                        </a>
                    {% endif %}
                    {% if can_del_task %}
                        <a href="{% url 'taskapp:delete' task.id %}" class="btn btn-sm btn-danger" title="{% trans 'Delete' %}">
                            <span class="glyphicon glyphicon-remove-circle"></span>
                        </a>
                    {% endif %}
                </td>
                </tr>
            {% empty %}
                <tr>
                    <td colspan="8">{% trans 'All your tasks has been performed' %}</td>
                </tr>
            {% endfor %}
            {% endwith %}
            </tbody>
            <tfoot>
            <tr>
                <td colspan="8">
                    {% include 'taskapp/footer_btns.html' %}
                </td>
            </tr>
            </tfoot>
        </table>
    </div>

{% endblock %}
