{% trans_default_domain 'customer' %}
{{ form_start(list_form) }}

<div class="box pad">
    <div class="box-header">
        <i class="fa fa-list-ul"></i>
        <h3 class="box-title">Clientes</h3>
        <!-- tools box -->
        &nbsp;
        <div class="btn-group">

            <button type="submit" name="delete" class="btn btn-default"
                    title="{% trans %}list.bulk_delete{% endtrans %}"
                    data-confirm="{% trans %}list.bulk_delete_confirm{% endtrans %}"><span
                        class="glyphicon glyphicon-trash"></span></button>

            {#<button type="submit" name="print" class="btn btn-default" title="{% trans %}list.bulk_print{% endtrans %}">
                <span class="glyphicon glyphicon-print"></span></button>
            <button type="submit" name="pdf" class="btn btn-default" title="{% trans %}list.bulk_pdf{% endtrans %}">
                <span class="glyphicon glyphicon-download-alt"></span></button>#}

            <a  href="{{ path('customer_upload') }}" class="btn btn-default"
                title="Cargar Clientes"><span
                        class="glyphicon glyphicon-upload"></span></a>
            {#
            <a  href="{{ path('customer_download_all') }}" class="btn btn-default"
                title="Descarga Excel"><span
                        class="fa fa-file-excel-o"></span>
                        </a>
                        #}
        </div>
    </div>
    <div class="box-body">
        <table class="table table-condensed table-striped align-middle" data-type="customers">
            <thead>
            <tr>
                <th class="cell-size-tiny cell-align-center">
                    <input type="checkbox" name="all"/>
                </th>
                <th class="cell-size-medium">
                    {{ knp_pagination_sortable(customers, 'list.name'|trans, 'c.name') }}
                </th>
                <th>
                    {{ knp_pagination_sortable(customers, 'list.identification'|trans, 'c.identification') }}
                </th>
                <th class="cell-size-medium cell-align-right">
                    {{ knp_pagination_sortable(customers, 'list.due_amount'|trans, 'due_amount') }}
                </th>
                <th class="cell-size-small-medium cell-align-right">
                    {{ knp_pagination_sortable(customers, 'list.gross_amount'|trans, 'gross_amount') }}
                </th>
                <th class="cell-size-medium cell-align-right"></th>
            </tr>
            </thead>
            <tbody>
            {% if customers|length == 0 %}
                <tr>
                    <td colspan="6">{% trans %}list.no_results{% endtrans %}</td>
                </tr>
            {% endif %}
            {% for key, result in customers %}
                {% set entity = result[0] %}
                <tr data-link="{{ path('customer_edit', { 'slug': entity.slug, 'id':entity.id }) }}">
                    <td class="table-action cell-align-center no-link">
                        {{ form_row(list_form.invoices[key]) }}
                    </td>
                    <td class="cell-size-medium">{{ entity.name }}</td>
                    <td>{{ entity.identification }}</td>
                    <td class="cell-align-right">{{ result.due_amount|localizedcurrency(currency, app.request.locale) }}</td>
                    <td class="cell-align-right">{{ result.gross_amount|localizedcurrency(currency, app.request.locale) }}</td>
                    <td class="cell-align-right"><a
                                href="{{ path('invoice_index', {'search_invoice': {'customer': entity.name}}) }}"
                                class="btn btn-info"><span
                                    class="glyphicon glyphicon-book"></span> {% trans %}
                            list.invoices{% endtrans %}</a></td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
    <div class="box-footer clearfix">
        <div class="navigation">
            {{ knp_pagination_render(customers) }}
        </div>
    </div>
</div>
{{ form_end(list_form) }}
