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

{% block content %}
    <div class="col-md-10 main">
        <h3>Kody rabatowe</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('v.name') %} class="sorted"{% endif %}>
                        {{ knp_pagination_sortable(pagination, 'nazwa', 'v.name') }}
                    </th>
                    <th{% if pagination.isSorted('v.code') %} class="sorted"{% endif %}>
                        {{ knp_pagination_sortable(pagination, 'kod', 'v.code') }}
                    </th>
                    <th{% if pagination.isSorted('v.value') %} class="sorted"{% endif %}>
                        {{ knp_pagination_sortable(pagination, 'wartość', 'v.value') }}
                    </th>
                    <th{% if pagination.isSorted('v.isActive') %} class="sorted"{% endif %}>
                        {{ knp_pagination_sortable(pagination, 'aktywny', 'v.isActive') }}
                    </th>
                    <th{% if pagination.isSorted('v.updatedAt') %} class="sorted"{% endif %}>
                        {{ knp_pagination_sortable(pagination, 'zmodyfikowany', 'v.updatedAt') }}
                    </th>
                    <th>opcje</th>
                </tr>
                </thead>
                <tbody>
                {% for voucher in pagination %}
                    <tr>
                        <td>{{ voucher.name }}</td>
                        <td>{{ voucher.code }}</td>
                        <td>{{ voucher.value ~ ' %' }}</td>
                        <td>{{ voucher.isActive ? 'tak' : 'nie' }}</td>
                        <td>{{ voucher.updatedAt|date('d.m.Y H:i') }}</td>
                        <td>
                            <a href="{{ path('app_admin.voucher.history', { voucher: voucher.id }) }}">Historia</a> ,
                            <a href="{{ path('app_admin.voucher.edit', { voucher: voucher.id }) }}">Edytuj</a> ,
                            <a href="{{ path('app_admin.voucher.remove', { voucher: voucher.id }) }}">Usuń</a>
                        </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 %}