<script type="text/javascript">
    function zamanOrderItemModifyControllerPopup() {
        zamanEposDb.epos_order.get({orderId: Number(zamanEposCart.getEposCurrentId())}).then(function (anOrder) {
            if (typeof (anOrder) !== 'undefined') {
                if (Number(anOrder.isPaid) === 3) {
                    orderPaymentPreProcessor(anOrder);
                } else {
                    if ($.trim($('#cartSelectedLine').val())) {
                        $('#placeOrderTypeBlock').hide();
                        clearEposWorkArea();
                        $('.breadcurmb-category').html('<span style="color:#ddfc0d;">Choose Modifier</span>');
                        $('.breadcurmb-menu').html('');
                        $('.menu-category.menu-button-inner').removeClass('active');
                        zamanEposDb.epos_modifier.where({'status': '3'}).toArray().then(function (modObject) {
                            if (modObject.length > 0) {
                                var globalModifierList = '';
                                modObject.forEach(function (amod) {
                                    globalModifierList += '<div class="menu-button"><div class="menu-button-inner" onclick="AddGlobalModifierToItem(\'' + amod.title + '\')">' + amod.title + '</div></div>';
                                });
                                $('#eposCategoryMenuList').html(globalModifierList);
                            }
                        });
                    } else {
                        warning('<?php echo $this->lang->line('warning') ?>', '<?php echo $this->lang->line('cart_item_select_msg') ?>', '<?php echo $this->lang->line('close') ?>');
                    }
                }
            } else {
                warning('<?php echo $this->lang->line('warning') ?>', '<?php echo $this->lang->line('load_order_in_cart') ?>', '<?php echo $this->lang->line('ok') ?>');
            }
        });
    }
    function AddGlobalModifierToItem(title) {
        if ($.trim(title)) {
            var line = $('#cartSelectedLine').val();
            var itemModData = {};
            itemModData.title = title;
            var activeLine = zamanEposCart.addGlobalMod(line, itemModData);
            displayEposCart();
            setCartLine(activeLine);
            zamanEposPopupcloser();
        }
    }
</script>