<form id="cart_info">
    {% set cart_full_width = poc_layout_cart_panel_cols == 12 %}
    {{ cart_full_width ? '<div class="poc_col-md-6">' : '' }}
    
    {% if products or vouchers %}
        <table class="poc_table poc_table-striped products_info_cart">
            <thead>
                <tr>
                    <th>{{ cart_thead_image }}</th>
                    <th>{{ cart_thead_name }}</th>
                    <th>{{ cart_thead_quantity }}</th>
                    <th>{{ cart_thead_price }}</th>
                    <th>{{ cart_thead_total }}</th>
                </tr>
            </thead>
            <tbody>
                {% for product in products %}
                    <tr {{ not config_stock_checkout and product.stock is empty ? 'class="error_no_stock"' : '' }}>
                        <td class="text-center">
                            {% if product.thumb %}
                                <a href="{{ product.href }}"><img src="{{ product.thumb }}" alt="{{ product.name }}" title="{{ product.name }}" class="img-thumbnail" /></a>
                            {% endif %}
                        </td>
                        <td class="text-left product_name">
                            <a href="{{ product.href }}">{{ product.name }}</a>
                            {% if product.option %}
                                {% for option in product.option %}
                                    <br />
                                    - <small>{{ option.name }} {{ option.value }}</small>
                                {% endfor %}
                            {% endif %}
                            {% if product.recurring %}
                                <br />
                                - <small>{{ text_recurring }} {{ product.recurring }}</small>
                            {% endif %}
                        </td>
                        <td class="text-right quantity_td">
                            <button type="button" onclick="cart_change_quantity($(this), '-');" class="poc_btn poc_btn-default poc_btn-xs quantity_less">{{ icon_rest }}
</button><input type="text" class="poc_form-control product_quantity" onchange="ajax_update_cart(true)" name="quantity[{{ more_oc_2 ? product.cart_id : product.key }}]" value="{{ product.quantity }}"><button type="button" onclick="cart_change_quantity($(this), '+');" class="poc_btn poc_btn-default poc_btn-xs quantity_more">{{ icon_sum }}</button><button type="button" onclick="cart_delete_product($(this));" title="{{ button_remove }}" class="poc_btn poc_btn-danger poc_btn-xs remove_product">{{ icon_remove }}</button>
                        </td>
                        <td class="text-right">{{ product.price }}</td>
                        <td class="text-right">{{ product.total }}</td>
                    </tr>
                {% endfor %}

                {% for voucher in vouchers %}
                    <tr>
                    <td class="text-center"></td>
                    <td class="text-left">{{ voucher.description }}</td>
                    <td class="text-right">x&nbsp;1</td>
                    <td class="text-right">{{ voucher.amount }}</td>
                    <td class="text-center text-danger"><button type="button" onclick="voucher.remove('{{ voucher.key }}');" title="{{ button_remove }}" class="poc_btn poc_btn-danger poc_btn-xs">{{ icon_remove }}</button></td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
        {{ cart_full_width ? '</div><div class="poc_col-md-6">' : '' }}

        {% if poc_coupon is not empty or poc_gift is not empty or poc_reward is not empty %}

            {% set numbers_actived = 0 %}
            {% if poc_coupon is not empty %}{% set numbers_actived = numbers_actived + 1 %}{% endif %}
            {% if poc_gift is not empty %}{% set numbers_actived = numbers_actived + 1 %}{% endif %}
            {% if poc_reward is not empty %}{% set numbers_actived = numbers_actived + 1 %}{% endif %}
            {% set colspan = 12/numbers_actived %}
            
            <div class="discount_zone">
                <div class="poc_col-md-12 discount_container">
                    {% if poc_icon_background is not empty %}
                        <div class="icons">
                            {% for i in 0..249 %}
                                {% set position = i%2 == 0 ? 'par ':'unpar ' %}
                                {{ poc_icon_background|replace({'class="': 'class="'~position}) }}
                            {% endfor %}                       
                        </div>
                    {% endif %}
                    {% if poc_coupon is not empty %}
                        <div class="poc_col-md-{{ colspan }} coupon">
                            <div class="poc_input-group">
                                {% set icon = cart_coupon_icon is not empty ? poc_icon_html|replace({'classIcon': cart_coupon_icon}) : '' %}

                                {% if cart_coupon_icon is not empty %}<span class="poc_input-group-addon">{{ icon }}</span>{% endif %}
                                <input type="text" class="poc_form-control" name="coupon" placeholder="{{ cart_insert_coupon }}" value="{{ coupon is not empty ? coupon : '' }}" {{ coupon ? 'disabled="disabled"' : '' }}>
                                {% if coupon is empty %}
                                    <span class="poc_input-group-addon poc_btn-success" onclick="apply_coupon($(this).closest('div.poc_input-group').find('input').val())">{{ icon_apply }}</span>
                                {% else %}
                                    <span class="poc_input-group-addon poc_btn-danger" onclick="remove_cart_discount('coupon')">{{ icon_remove }}</span>
                                {% endif %}
                            </div>
                        </div>
                    {% endif %}
                    {% if poc_gift is not empty %}
                        <div class="poc_col-md-{{ colspan }} voucher">
                            <div class="poc_input-group">
                                {% set icon = cart_gift_icon is not empty ? poc_icon_html|replace({'classIcon': cart_gift_icon}) : '' %}

                                {% if cart_gift_icon is not empty %}<span class="poc_input-group-addon">{{ icon }}</span>{% endif %}
                                <input type="text" class="poc_form-control" name="voucher" placeholder="{{ cart_insert_gift }}" value="{{ voucher is not empty }}" {{ voucher ? 'disabled="disabled"' : '' }}>
                                {% if voucher is empty %}
                                    <span class="poc_input-group-addon poc_btn-success" onclick="apply_voucher($(this).closest('div.poc_input-group').find('input').val())">{{ icon_apply }}</span>
                                 {% else %}
                                    <span class="poc_input-group-addon poc_btn-danger" onclick="remove_cart_discount('voucher')">{{ icon_remove }}</span>
                                {% endif %}
                            </div>
                        </div>
                    {% endif %}
                    {% if poc_reward is not empty %}
                        <div class="poc_col-md-{{ colspan }} reward">
                            <div class="poc_input-group">
                                {% set icon = cart_reward_icon is not empty ? poc_icon_html|replace({'classIcon': cart_reward_icon}) : '' %}
                                
                                {% if cart_reward_icon is not empty %}<span class="poc_input-group-addon">{{ icon }}</span><span class="reward_small">{{ points }}</span>{% endif %}
                                <input type="text" class="poc_form-control" name="reward" placeholder="{{ cart_insert_reward }}" value="{{ reward is not empty }}" {{ reward ? 'disabled="disabled"' : '' }}>
                                {% if reward is empty %}
                                    <span class="poc_input-group-addon poc_btn-success" onclick="apply_reward($(this).closest('div.poc_input-group').find('input').val())">{{ icon_apply }}</span>
                                {% else %}
                                    <span class="poc_input-group-addon poc_btn-danger" onclick="remove_cart_discount('reward')">{{ icon_remove }}</span>
                                {% endif %}
                            </div>
                        </div>
                    {% endif %}
                </div>
            </div>
        {% endif %}
        <div class="totals">
            <table class="poc_table poc_table-bordered">
                {% for total in totals %}
                    <tr>
                        <td class="text-right"><strong>{{ total.title }}</strong></td>
                        <td class="text-right total">{{ total.text }}</td>
                    </tr>
                {% endfor %}
            </table>
        </div>
        {{ cart_full_width ? '</div>' : '' }}
    {% else %}
        <p class="text-center">{{ text_empty }}</p>
    {% endif %}
</form>

<script type="text/javascript">
    $('table.products_info_cart').stacktable({headIndex:1});

    {% if coupon is not empty %}
        _insert_alert_manual($('div.discount_container'), text_cart_coupon_success, 'success', 'before');
    {% endif %}

    {% if voucher is not empty %}
        _insert_alert_manual($('div.discount_container'), text_cart_gift_success, 'success', 'before');
    {% endif %}

    {% if reward is not empty %}
        _insert_alert_manual($('div.discount_container'), text_cart_reward_success, 'success', 'before');
    {% endif %}
</script>

{% if error is not empty %}
    <script type="text/javascript">
        cart_delete_insert_error('{{ error }}');
    </script>
{% endif %}