<table class="table">
    <thead>
    <tr class="small text-muted border-white">
        <th scope="col">Наименование</th>
        <th scope="col">Стоимость, шт</th>
        <th scope="col" class="text-center">Количество</th>
        <th scope="col">Сумма</th>
        <th scope="col"></th>
    </tr>
    </thead>

    <tfoot>
    <tr class="border-white ">
        <td colspan="5" class="">

            <div class="w-25 float-end text-end">

                <div class="d-flex align-items-stretch justify-content-end">
                    <span class="small me-3 pt-1">Итого: </span>

                    {% set discount = user_profile_discount(total_summ_product) %}

                    <span id='total_result' class="fw-bolder h3">
						{{ discount ?  money(discount) : money(total_summ_product) }}
					</span>
                </div>

                <a href="#ordering" class="btn btn-danger"
                   title="К оформлению заказа" aria-label="К оформлению заказа">
                    Оформить заказ
                </a>
            </div>
        </td>
    </tr>
    </tfoot>


    <tbody>


    {% for product in form.product %}



        {% set card = product.vars.data.card %}


        <tr id='item_{{ product.vars.id }}'>
            <td>
                <div class="row">
                    <div class="col-2">


                        {% set img_path = card.product_image_cdn == true ? CDN_HOST : '' %}
                        {% set product_image_ext = card.product_image_cdn == true ? 'small.'~card.product_image_ext : card.product_image_ext %}

                        <a href="{# {{ path('Product:user.detail', {
							url : card.product_url ,
							offer: card.product_offer_value,
							variation: card.product_variation_value,
							modification: card.product_modification_value
						}) }} #}" class="icon rounded-4 mb-2 lazy bg-contain p-1"
                           data-bg="{{ card.product_image ? img_path ~ card.product_image ~ product_image_ext : '/assets/img/blank.svg' }}"
                           style="width: 75px; height: 75px;"
                        ></a>

                    </div>

                    <div class="col align-self-center">

                        <a href="{# {{ path('Product:user.detail', {
							url : card.product_url ,
							offer: card.product_offer_value,
							variation: card.product_variation_value,
							modification: card.product_modification_value
						}) }} #}" class="text-dark me-3 text-uppercase text-decoration-none">

                            {{ card.product_name }}

                            {{ card.product_offer_value|call_twig_func(card.product_offer_reference) }}
                            {{ card.product_variation_value|call_twig_func(card.product_variation_reference) }}
                            {{ card.product_modification_value|call_twig_func(card.product_modification_reference) }}

                        </a>

                        {% if date() < card.product_active_from|date_modify("+1 month") %}
                            <span class="badge bg-success rounded-2 mt-1 mx-1">Новинка</span>
                        {% endif %}


                        {# <span class="badge bg-hit rounded-2 mt-1 mx-1">Хит</span> #}
                        <div class="small text-muted">Артикул: {{ card.product_article }}</div>
                    </div>
                </div>

            </td>

            <td class="vertical-middle">

                {{ money(card.product_price, card.product_currency) }}
                {# <span class="badge bg-danger rounded-2 ms-1">
					<span class="text-uppercase">-20%</span>
				</span> #}
            </td>

            <td class="vertical-middle">

                <div class="d-flex justify-content-center align-items-center text-center">


                    <button type="button" class="btn btn-sm minus"
                            aria-label="Уменьшить количество"
                            data-id='{{ product.price.total.vars.id }}'
                    >
                        <span class="h4 text-muted opacity-50">-</span>
                    </button>

                    {# <input type="text" value="4" class="form-control form-control-sm mx-1 rounded-3"
						   aria-label="Количество"
						   style="width: 50px;"> #}

                    {{ form_widget(product.price.total, {
                        label: false,
                        attr: {
                            class : 'form-control-sm mx-1 rounded-3 total',
                            style: 'width: 60px;',
                            'data-price' : ''~card.product_price,
                            'data-discount' : baks_profile.profile_discount is defined ? baks_profile.profile_discount,
                            'data-currency' : card.product_currency|upper,
                            'data-max' : card.product_quantity
                        } } ) }}


                    <button type="button" class="btn btn-sm plus"
                            aria-label="Увеличить количество"
                            data-id='{{ product.price.total.vars.id }}'
                    >
                        <span class="h5 text-muted opacity-50">+</span>
                    </button>
                </div>
            </td>


            <td class="vertical-middle">
                {% set summ = (product.price.vars.data.total * card.product_price) %}

                {% set discount = user_profile_discount(summ) %}

                <strong id='summ_{{ product.price.total.vars.id }}'
                        data-price='{{ card.product_price }}'
                        data-discount='{{ baks_profile.profile_discount is defined ? baks_profile.profile_discount }}'
                        data-currency='{{ card.product_currency|upper }}'
                >
                    {{ discount ? money(discount, card.product_currency) : money(summ, card.product_currency) }}
                    {# {{ card.product_currency|upper|currency_symbol(app.request.locale) }} #}
                </strong>


                {% if discount %}
                    <span class="badge bg-danger rounded-2 ms-2">- {{ baks_profile.profile_discount }}%</span>
                {% endif %}

            </td>

            <td class="vertical-middle text-end">

                <button class="btn btn-link"
                        aria-label="Добавить в избранное"
                >
                    <img data-src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNCMUI2QkIiIHZpZXdCb3g9IjAgMCAxNiAxNiI+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOCAxLjMxNEMxMi40MzgtMy4yNDggMjMuNTM0IDQuNzM1IDggMTUtNy41MzQgNC43MzYgMy41NjItMy4yNDggOCAxLjMxNHoiPjwvcGF0aD48L3N2Zz4K"
                         width="16" height="16"
                         src="/assets/img/empty.png"
                         class="lazy"
                    >
                </button>

                <br>


                {# УДАЛИТЬ #}
                <a
                        href='{# {{ path('orders-order:user.delete', {
							product : card.event ,
							offer: card.product_offer_uid,
							variation: card.product_variation_uid,
							modification: card.product_modification_uid
						}) }} #}'
                        class="btn btn-sm btn-link text-decoration-underline small text-muted delete-product"
                        data-id='item_{{ product.vars.id }}'
                >
                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
                         class="bi bi-x me-1" viewBox="0 0 16 16">
                        <path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"></path>
                    </svg>
                    <span class="small">Удалить</span>
                </a>
            </td>

        </tr>
    {% endfor %}

    </tbody>
</table>