<div style="display: none;">
    <div id="OrderModifyContent">
        <div class="popup-header toolbar-header">
            <div class="popup-title"><?php echo $this->lang->line('Modifiers') ?></div>
            <div class="popup-close-btn" onclick="zamanEposPopupcloser()"><span class="icon icon-cancel"></span></div>
        </div>
        <div class="popup-content">
            <div class="clearfix item-group">
                <div class="menu-list special-modify-btn-groups" id="globalModifierList"></div>
            </div>
            <div style="padding: 0px 10px;">
                <div class="form-group"><input id="zamanOrderModifier" type="text" class="form-control" placeholder="<?php echo $this->lang->line('modifier') ?>"></div>
                <div class="tab-group config-submit"><button type="button" onclick="AddGlobalModifierToItem($('#zamanOrderModifier').val())"><span class="icon icon-plus"></span>&nbsp;<?php echo $this->lang->line('add') ?></button></div>
            </div>
            <div class="clearfix"></div>
            <div class="order-modify-keyboard"></div>
        </div>
    </div>
</div>
<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())) {
                        if ($('#Keyboard').length > 0) {
                            $('#Keyboard').empty();
                            $('#Keyboard').removeAttr('id');
                        }
                        $('.order-modify-keyboard').attr('id', 'Keyboard');
                        keyboard('Keyboard');
                        $.colorbox({
                            inline: true,
                            scrolling: false,
                            href: "#OrderModifyContent",
                            width: '100%',
                            height: 'auto',
                            maxWidth: "100%",
                            bottom: '0',
                            open: true,
                            closeButton: false,
                            transition: 'none',
                            overlayClose: false,
                            left: '0px',
                            className: 'transparent-overlay',
                            onOpen: function () {
                                playBeepSound();
                            },
                            onLoad: function () {
                                jsKeyboard.currentElement = $('#zamanOrderModifier');
                            },
                            onComplete: function () {
                                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>';
                                        });
                                        $('#globalModifierList').html(globalModifierList);
                                        $('#colorbox').colorbox.resize();
                                    }
                                });
                            },
                            onCleanup: function () {
                            },
                            onClosed: function () {
                                $('#zamanOrderModifier').val('');
                            }
                        });
                    } 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>