{% trans_default_domain 'product' %}

{{ form_start(list_form) }}
<div class="box pad">
    <div class="box-header">
        <i class="fa fa-list-ul"></i>
        <h3 class="box-title">Productos</h3>
        <!-- tools box -->
        &nbsp;&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>
            <a  href="{{ path('product_upload') }}" class="btn btn-default"
                    title="Cargar Productos"><span
                        class="glyphicon glyphicon-upload"></span></a>
            <a  href="{{ path('product_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="products">
            <thead>
            <tr>
                <th class="cell-size-tiny cell-align-center">
                    <input type="checkbox" name="all"/>
                </th>
                <th class="cell-size-medium">
                    {{ knp_pagination_sortable(products, 'list.reference'|trans, 'p.reference') }}
                </th>
                <th>
                    {{ knp_pagination_sortable(products, 'list.description'|trans, 'p.description') }}
                </th>
                <th class="cell-size-medium cell-align-right">
                    {{ knp_pagination_sortable(products, 'list.price'|trans, 'p.price') }}
                </th>
                <th class="cell-size-medium cell-align-right">
                    IVA
                </th>
                <th class="cell-size-small-medium cell-align-right">
                    {{ knp_pagination_sortable(products, 'list.num_sold'|trans, 'num_sold') }}
                </th>
                <th class="cell-size-medium cell-align-right">
                    {{ knp_pagination_sortable(products, 'list.revenue'|trans, 'revenue') }}
                </th>
            </tr>
            </thead>
            <tbody>
            {% if products|length == 0 %}
                <tr>
                    <td colspan="6">{% trans %}list.no_results{% endtrans %}</td>
                </tr>
            {% endif %}
            {% for key, result in products %}
                {% set entity = result[0] %}
                <tr data-link="{{ path('product_edit', { 'id': entity.id , 'slug': entity.slug}) }}">
                    <td class="table-action cell-align-center no-link">
                        {{ form_row(list_form.invoices[key]) }}
                    </td>
                    <td class="cell-size-medium">{{ entity.reference }}</td>
                    <td>{{ entity.description }}</td>
                    <td class="cell-align-right">{{ entity.price|localizedcurrency(currency, app.request.locale, decpunit) }}</td>
                    <td class="cell-align-right">{{ entity.taxes }}</td>
                    <td class="cell-align-right">{{ result.num_sold }}</td>
                    <td class="cell-align-right">{{ result.revenue|localizedcurrency(currency, app.request.locale) }}</td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
    <div class="box-footer clearfix">
        <div class="navigation">
            {{ knp_pagination_render(products) }}
        </div>
    </div>
</div>
{{ form_end(list_form) }}

