{% extends "ShopCatalogBundle:AdminProposal:proposalLayout.html.twig" %}
{% block page_content %}

    <div class="page-buttons">
        <a href="{{ path('proposal_price', {'proposalId' : proposal.id}) }}" class="btn btn-default">
            Добавить цену
        </a>
    </div>

    <table id="prices-table" class="table table-striped">
        <thead>
        <tr>
            <th>ID</th>
            <th>Артикул</th>
            <th>Цена</th>
            <th>Описание</th>
            <th></th>
        </tr>
        </thead>
        <tbody>
        {% for price in proposal.prices %}
            <tr>
                <td>
                    {{ price.id }}
                </td>
                <td>
                    <a href="{{ path('proposal_price', {'proposalId' : proposal.id, 'id' : price.id}) }}" class="primary-link">
                        {{ price.sku|default('-') }}
                    </a>
                </td>
                <td>
                    <span class="{% if price.status == constant('STATUS_OFF', price) %}label-danger label{% endif %}">{{ price|shop_price }}</span>
                    {% set contractor = price.contractor|default(proposal.defaultContractor) %}
                    {% if contractor %}
                        <div>
                            ({{ contractor.name }})
                        </div>
                    {% endif %}
                </td>
                <td>{{ price.description|default('-')|raw}}</td>
                <td>
                    <div class="btn-group">
                        <a href="{{ path('proposal_price', {'proposalId' : proposal.id, 'id' : price.id}) }}" class="btn btn-default">
                            Изменить
                        </a>
                        <a href="{{ path('delete_proposal_price', {'proposalId' : proposal.id, 'id' : price.id}) }}" onclick="return confirm('Вы уверены, что хотите удалить?')" class="btn btn-danger">
                            Удалить
                        </a>
                    </div>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
    <script>
        $(function(){

            $('#prices-table').dataTable({
                "columnDefs": [
                    { "orderable": false, "targets": 4 }
                ]
            });

        });
    </script>
{% endblock %}
