<form id="cart_info">
    <?php $cart_full_width = $poc_layout_cart_panel_cols == 12; ?>
    <?= $cart_full_width ? '<div class="poc_col-md-6">' : ''; ?>
    <?php if ($products || $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>
                <?php foreach ($products as $product) { ?>
                    <tr <?= !$config_stock_checkout && empty($product['stock']) ? 'class="error_no_stock"' : ''; ?>>
                        <td class="text-center">
                            <?php if ($product['thumb']) { ?>
                                <a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-thumbnail" /></a>
                            <?php } ?>
                        </td>
                        <td class="text-left product_name">
                            <a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a>
                            <?php if ($product['option']) { ?>
                                <?php foreach ($product['option'] as $option) { ?>
                                    <br />
                                    - <small><?php echo $option['name']; ?> <?php echo $option['value']; ?></small>
                                <?php } ?>
                            <?php } ?>
                            <?php if (array_key_exists('recurring', $product) && !empty($product['recurring'])) { ?>
                                <br />
                                - <small><?php echo $text_recurring; ?> <?php echo $product['recurring']; ?></small>
                            <?php } ?>
                        </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[<?= $cart_id_enabled ? $product['cart_id'] : $product['key']; ?>]" value="<?php echo $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="<?php echo $button_remove; ?>" class="poc_btn poc_btn-danger poc_btn-xs remove_product"><?= $icon_remove; ?></button>
                        </td>
                        <td class="text-right"><?php echo $product['price']; ?></td>
                        <td class="text-right"><?php echo $product['total']; ?></td>
                    </tr>
                <?php } ?>
                <?php foreach ($vouchers as $voucher) { ?>
                    <tr>
                    <td class="text-center"></td>
                    <td class="text-left"><?php echo $voucher['description']; ?></td>
                    <td class="text-right">x&nbsp;1</td>
                    <td class="text-right"><?php echo $voucher['amount']; ?></td>
                    <td class="text-center text-danger"><button type="button" onclick="voucher.remove('<?php echo $voucher['key']; ?>');" title="<?php echo $button_remove; ?>" class="poc_btn poc_btn-danger poc_btn-xs"><?= $icon_remove; ?></button></td>
                    </tr>
                <?php } ?>
            </tbody>
        </table>
        <?= $cart_full_width ? '</div><div class="poc_col-md-6">' : ''; ?>
        <?php if(!empty($poc_coupon) || !empty($poc_gift) || !empty($poc_reward)) { ?>
            <?php $numbers_actived = 0;
                $numbers_actived += !empty($poc_coupon) ? 1 : 0;
                $numbers_actived += !empty($poc_gift) ? 1 : 0;
                $numbers_actived += !empty($poc_reward) ? 1 : 0;
                $colspan = 12/$numbers_actived;
            ?>
            <div class="discount_zone">
                <div class="poc_col-md-12 discount_container">
                    <?php if (!empty($poc_icon_background)){ ?>
                        <div class="icons">
                            <?php for ($i=0; $i < 250; $i++) { 
                                $position = $i%2 == 0 ? 'par':'unpar';
                                echo str_replace('class="', 'class="'.$position.' ', $poc_icon_background);
                            } ?>                            
                        </div>
                    <?php } ?>
                    <?php if (!empty($poc_coupon)) { ?>
                        <div class="poc_col-md-<?= $colspan ?> coupon">
                            <div class="poc_input-group">
                                <?php $icon = !empty($cart_coupon_icon) ? str_replace('classIcon', $cart_coupon_icon, $poc_icon_html) : ''; ?>
                                <?php if(!empty($cart_coupon_icon)) { ?><span class="poc_input-group-addon"><?= $icon; ?></span><?php } ?>
                                <input type="text" class="poc_form-control" name="coupon" placeholder="<?= $cart_insert_coupon; ?>" value="<?= $coupon; ?>" <?= !empty($coupon) ? 'disabled="disabled"' : ''; ?>>
                                <?php if (empty($coupon)) { ?>
                                    <span class="poc_input-group-addon poc_btn-success" onclick="apply_coupon($(this).closest('div.poc_input-group').find('input').val())"><?= $icon_apply; ?></span>
                                <?php } else { ?>
                                    <span class="poc_input-group-addon poc_btn-danger" onclick="remove_cart_discount('coupon')"><?= $icon_remove; ?></span>
                                <?php } ?>
                            </div>
                        </div>
                    <?php } ?>
                    <?php if (!empty($poc_gift)) { ?>
                        <div class="poc_col-md-<?= $colspan ?> voucher">
                            <div class="poc_input-group">
                                <?php $icon = !empty($cart_gift_icon) ? str_replace('classIcon', $cart_gift_icon, $poc_icon_html) : ''; ?>
                                <?php if(!empty($cart_gift_icon)) { ?><span class="poc_input-group-addon"><?= $icon; ?></span><?php } ?>
                                <input type="text" class="poc_form-control" name="voucher" placeholder="<?= $cart_insert_gift; ?>" value="<?= $voucher; ?>" <?= !empty($voucher) ? 'disabled="disabled"' : ''; ?>>
                                <?php if (empty($voucher)) { ?>
                                    <span class="poc_input-group-addon poc_btn-success" onclick="apply_voucher($(this).closest('div.poc_input-group').find('input').val())"><?= $icon_apply; ?></span>
                                <?php } else { ?>
                                    <span class="poc_input-group-addon poc_btn-danger" onclick="remove_cart_discount('voucher')"><?= $icon_remove; ?></span>
                                <?php } ?>
                            </div>
                        </div>
                    <?php } ?>
                    <?php if (!empty($poc_reward)) { ?>
                        <div class="poc_col-md-<?= $colspan ?> reward">
                            <div class="poc_input-group">
                                <?php $icon = !empty($cart_reward_icon) ? str_replace('classIcon', $cart_reward_icon, $poc_icon_html) : ''; ?>
                                <?php if(!empty($cart_reward_icon)) { ?><span class="poc_input-group-addon"><?= $icon; ?><span class="reward_small"><?= $points ?></span></span><?php } ?>
                                <input type="text" class="poc_form-control" name="reward" placeholder="<?= $cart_insert_reward; ?>" value="<?= $reward; ?>" <?= !empty($reward) ? 'disabled="disabled"' : ''; ?>>
                                <?php if (empty($reward)) { ?>
                                    <span class="poc_input-group-addon poc_btn-success" onclick="apply_reward($(this).closest('div.poc_input-group').find('input').val())"><?= $icon_apply; ?></span>
                                <?php } else { ?>
                                    <span class="poc_input-group-addon poc_btn-danger" onclick="remove_cart_discount('reward')"><?= $icon_remove; ?></span>
                                <?php } ?>
                            </div>
                        </div>
                    <?php } ?>
                </div>
            </div>
        <?php } ?>
        <div class="totals">
            <table class="poc_table poc_table-bordered">
            <?php foreach ($totals as $total) { ?>
                <tr>
                    <td class="text-right"><strong><?php echo $total['title']; ?></strong></td>
                    <td class="text-right total"><?php echo $total['text']; ?></td>
                </tr>
            <?php } ?>
            </table>
        </div>
        <?= $cart_full_width ? '</div>' : ''; ?>
    <?php } else { ?>
        <p class="text-center"><?php echo $text_empty; ?></p>
    <?php } ?>
</form>

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

    <?php if(!empty($coupon)) { ?>
        _insert_alert_manual($('div.discount_container'), text_cart_coupon_success, 'success', 'before');
    <?php } ?>
    <?php if(!empty($voucher)) { ?>
        _insert_alert_manual($('div.discount_container'), text_cart_gift_success, 'success', 'before');
    <?php } ?>
    <?php if(!empty($reward)) { ?>
        _insert_alert_manual($('div.discount_container'), text_cart_reward_success, 'success', 'before');
    <?php } ?>
</script>

<?php if(!empty($error)) { ?>
    <script type="text/javascript">
        cart_delete_insert_error('<?= $error; ?>');
    </script>
<?php } ?>