{% extends 'AppBundle:Admin/Voucher:layout.html.twig' %}

{% block content %}
    <div class="col-md-10 main">
        <h3>Kod rabatowy: historia</h3>
        <div class="table-responsive">
            <table class="table table-striped">
                <colgroup>
                    <col class="col-xs-2">
                    <col class="col-xs-2">
                    <col class="col-xs-2">
                    <col class="col-xs-2">
                    <col class="col-xs-2">
                    <col class="col-xs-2">
                </colgroup>
                <thead>
                <tr>
                    <th{% if pagination.isSorted('vh.name') %} class="sorted"{% endif %}>
                        {{ knp_pagination_sortable(pagination, 'nazwa', 'vh.name') }}
                    </th>
                    <th{% if pagination.isSorted('vh.code') %} class="sorted"{% endif %}>
                        {{ knp_pagination_sortable(pagination, 'kod', 'vh.code') }}
                    </th>
                    <th{% if pagination.isSorted('vh.value') %} class="sorted"{% endif %}>
                        {{ knp_pagination_sortable(pagination, 'wartość', 'vh.value') }}
                    </th>
                    <th{% if pagination.isSorted('vh.isActive') %} class="sorted"{% endif %}>
                        {{ knp_pagination_sortable(pagination, 'aktywny', 'vh.isActive') }}
                    </th>
                    <th{% if pagination.isSorted('vh.createdAt') %} class="sorted"{% endif %}>
                        {{ knp_pagination_sortable(pagination, 'zmodyfikowany', 'vh.createdAt') }}
                    </th>
                    <th>Użytkownik</th>
                </tr>
                </thead>
                <tbody>
                {% for voucher in pagination %}
                    <tr {{ voucher.isRemoved ? 'class="text-danger"' : '' }}>
                        <td>{{ voucher.name is defined ? voucher.name : '' }}</td>
                        <td>{{ voucher.code is defined ? voucher.code : '' }}</td>
                        <td>{{ voucher.value is defined ? voucher.value ~ ' %' : '' }}</td>
                        <td>{{ voucher.isActive ? 'tak' : 'nie' }}</td>
                        <td>{{ voucher.createdAt is defined ? voucher.createdAt|date('d.m.Y H:i') : '' }}</td>
                        <td>
                            {% if voucher.user.id is defined %}
                                <a href="{{ path('app_admin.user.edit', { user: voucher.user.id }) }}">
                                    {{ voucher.user.fullName }}
                                </a>
                            {% endif %}
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>

            <div class="text-center">
                {{ knp_pagination_render(pagination, 'KnpPaginatorBundle:Pagination:twitter_bootstrap_v3_pagination.html.twig') }}
            </div>
        </div>
    </div>
{% endblock %}