{% extends "base.html" %}
{% load humanize %}

{% block extratitle %}
    {{ object.filename }}
{% endblock %}


{% block breadcrumbs %}
    {{ block.super }}
    <li><a href="{% url "integrator2:main" %}">integrator</a></li>
    <li class="current">{{ object.filename }}</li>

{% endblock %}

{% block content %}
    <h1>{{ object.verbose_name }} - plik {{ object.filename }}</h1>


    <table>
        <tr>
            <td>Status</td>
            <td>{{ object.get_status_display }}</td>

            <td>Ostatnia zmiana</td>
            <td>{{ object.last_updated_on|naturaltime }}</td>
        </tr>
        <tr>
            <td>Kod błędu</td>
            <td>{{ object.extra_info|default:"brak" }}</td>
            <td>Wszystkich rekordów</td>
            <td>{{ object.records.count }}</td>
        </tr>
        <tr>
            <td>Zintegrowano automatycznie</td>
            <td>{{ object.integrated.count }}</td>
            <td>Nie zintegrowano</td>
            <td>{{ object.not_integrated.count }}</td>
        </tr>
    </table>

    {% if object.status > 1 and object.not_integrated.count %}
        <p>Rekordy niezintegrowane:</p>


        {% if is_paginated %}
            <ul class="pagination">
                <li class="arrow {% if not page_obj.has_previous %}unavailable{% endif %}">
                    <a href="?page={% if page_obj.has_previous %}{{ page_obj.previous_page_number }}{% endif %}">
                        &laquo;</a>
                </li>

                {% for page in page_obj.paginator.page_range %}
                    <li class="{% if page == page_obj.number %}current{% endif %}"><a
                            href="?page={{ page }}">{{ page }}</a></li>
                {% endfor %}

                <li class="arrow {% if not page_obj.has_next %}unavailable{% endif %}">
                    <a href="?page={% if page_obj.has_next %}{{ page_obj.next_page_number }}{% endif %}">&raquo;</a>
                </li>
            </ul>
        {% endif %}


        <table width="100%">
            <tr>
                {% for col in object.header_columns %}
                    <th>{{ col }}</th>
                {% endfor %}
            </tr>
            {% for row in object_list %}
                <tr>
                    {% for col in row %}
                        <td>{{ col }}</td>
                    {% endfor %}
                </tr>
            {% endfor %}

        </table>
    {% endif %}

{% endblock %}