<style>
    .item-btn-special {
        background-color: #00AEEF;
        color: #FFFFFF;
        height: 55px!important;
    }
</style>
<div style="display:none">
    <div id="toppingsPopup" class="popupouter">
        <?php $defaultToppings = get_record_list('toppings',array('status'=>1)); ?>
        <?php if (!empty($defaultToppings)): ?>
            <?php foreach ($defaultToppings as $adTopping): ?>
                <a class="inline item-btn item-btn-special col-lg-4 col-md-4 col-sm-4 col-xs-4 menu-item text-center" onclick="submitToppingForm('defaultToppingForm_<?php echo $adTopping->id?>')"><?php echo ucwords(strtolower($adTopping->title)) ?></a>
                <form id="defaultToppingForm_<?php echo $adTopping->id ?>">
                    <input type="hidden" name="title" value="<?php echo $adTopping->title?>" >
                    <input type="hidden" name="price" value="<?php echo $adTopping->price?>" >
                    <input type="hidden" name="order_id" value="<?php isset($order_id) ? print $order_id : print $this->Orders_Model->get_current_orderid() ?>">
                    <input type="hidden" class="default-toppings-line" name="line" value="">
                </form>
            <?php endforeach; ?>
        <?php else: ?>
            <p style="color: #ffffff">No Toppings found. Please list them first</p>
        <?php endif; ?>

    </div>
    <script>
        function addToppings(order_id) {
            
            var line = $('#selectedRow').val();
            var CurrentOrderTotal = $('#CurrentOrderTotal').val();
            ALERT_TITLE = "<?php echo $this->lang->line('gkpos_alert_title_warning') ?>";
            if (!order_id) {
                alert("<?php echo $this->lang->line('gkpos_make_order_sure') ?>");
            } else {
                if (CurrentOrderTotal <= 0) {
                    alert("<?php echo $this->lang->line('gkpos_put_item_on_cart') ?>");
                } else if (!line) {
                    alert("<?php echo $this->lang->line('gkpos_select_item_row_to_change_quantity') ?>");
                } else {
                    var element = '<a href="javascript:void(0)" onclick="addToppings(\'' + order_id + '\')">' + 'Add Toppings' + '</a>';
                    $('#menuBreadcurmb').html(element);
                    $('#selectrionBreadcurmb').html('');
                    var ToppingPopup = $("#toppingsPopup").html();
                    $('#menuListArea').html(ToppingPopup);
                    return false;
                }
            }

        }
        function submitToppingForm(specialItemForm) {
            var line = $('#selectedRow').val();
            $('.default-toppings-line').val(line);
            var myform = document.getElementById(specialItemForm);
            var formdata = new FormData(myform);
            $.ajax({
                url: '<?php echo site_url('gkpos/orders/updatecarttoppings') ?>',
                data: formdata,
                cache: false,
                processData: false,
                contentType: false,
                type: 'POST',
                dataType: 'json',
                success: function (output) {
                    if (typeof output.line !== 'undefined') {
                        loadCart(output.order_id, output.line);
                    } else {
                        loadCart(output.order_id, false);
                    }
                }
            });
        }
    </script>
</div>