<footer id="gkposFooter">
    <?php if ($this->config->item('is_touch') == 'enable') : ?>
        <div id="clientsDropDown">
            <div id="clientsDashboard">
                <p id="clientsCTA"</p>
            </div>
        </div>
    <?php endif; ?>
    <div class="container-fluid">
        <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4  pull-left text-left" style="margin: 5px 0px;">
            <?php if ($this->config->item('is_touch') == 'enable') : ?>
            <button onclick="addFooterKeyboard()" style="z-index: 999"><span class="fa fa-keyboard-o fa-3x"></span></button>
            <?php endif; ?>
            <div style="float: right;display: none;" class="online-order-btn-visibility"><button class="btn btn-danger" style="padding: 14px;  background: transparent;font-weight: bold;" onclick="getPage('<?php echo site_url('gkpos/online_order') ?>', 'online order')">Online Orders</button></div>
        </div>
        <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
            <p class="text-center" style="margin-top: 20px;"><a href="javascript:void(0)"onclick="showCompanyInfo()"><span style="margin-top: 10px"><?php echo $this->lang->line('gkpos_powered_by') ?></span>:<img src="<?php echo ASSETS_GKPOS_PATH ?>images/gk-logo.png" width="100" height="24"/></a></p>
        </div>
        <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4  pull-right text-right" style="margin: 5px 0px;">
            <?php if ($this->config->item('is_touch') == 'enable') : ?>
            <button onclick="addFooterKeyboard()"  style="z-index: 999;"><span class="fa fa-keyboard-o fa-3x"></span></button>
            <?php endif; ?>
            <div style="float: left; display: none; " class="online-order-btn-visibility"><button class="btn btn-danger" style="padding: 14px; background: transparent;font-weight: bold " onclick="getPage('<?php echo site_url('gkpos/online_order') ?>', 'online order')">Online Orders</button></div>
        </div>
    </div>
</footer>    
<a class='warningPopup' href="#warningPopup" style="display:none"></a>
<div style="display:none">
    <div id="warningPopup" class="popupouter">
        <div class="popup-header row">
            <div id="warningPopupHeader" class="warningPopupHeader col-lg-10 col-md-10 col-sm-10 col-xs-10 pull-left "></div>
            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 pull-left closeWarningPopup text-center times">&times;</div>
        </div>
        <div class="popup-body row">
            <div id="warningPopupContent" class="warningPopupContent col-lg-12 col-md-12 col-sm-12 col-xs-12"></div>
        </div>
        <div class="popup-footer row">
            <a href="javascript:void(0)" class="closeWarningPopup text-center btn btn-default col-md-offset-5 col-md-2 col-md-offset-5"><?php echo $this->lang->line('gkpos_close') ?></a>
        </div>
    </div>
</div>
<style>
    #cboxClose{
        display: none;
    }
</style>
<script>
    jQuery(document).ready(function () {
        jQuery(".closeWarningPopup").click(function () {
            
            jQuery.colorbox.close();
            return false;
        });
        $("#name").autocomplete({
            delay: 0,
            source: '<?php echo site_url('gkpos/get_customer') ?>',
            minLength: 2
        });
        $("#phone").autocomplete({
            delay: 0,
            source: '<?php echo site_url('gkpos/get_customer_phone') ?>',
            minLength: 6
        });
        manageWindowHeight();
    });
    function pageExit(returnUrl, info) {
        
        getBaseAjaxPage(returnUrl, info);
    }
    function searchCustomerByKey(key) {
        
        var value = $('#' + key).val();
        if (value == '') {
            ALERT_TITLE = "<?php echo $this->lang->line('gkpos_caller_information_error') ?>"
            alert("<?php echo $this->lang->line('gkpos_caller_field_alert') . ' ' ?>" + key);
        } else {
            $.ajax({
                url: "<?php echo site_url('gkpos/search_customer') ?>",
                type: "POST",
                data: {
                    key: key,
                    value: value
                },
                success: function (output) {
                    var obj = $.parseJSON(output);
                    if (true == obj.status) {
                        var customer = obj.customer;
                        $(".customer-phone").val(customer.phone);
                        $(".customer-name").val(customer.name);
                        if ($("#postal_code").length > 0) {
                            $("#floor_or_apt").val(customer.floor_or_apt);
                            $("#building").val(customer.building);
                            $("#street_number").val(customer.house);
                            $("#route").val(customer.street);
                            $("#postal_code").val(customer.postcode);
                            $("#locality").val(customer.city);
                            $("#administrative_area_level_1").val(customer.state);
                            $("#country").val(customer.country);
                        }
                    } else {
                        ALERT_TITLE = "<?php echo $this->lang->line('gkpos_invalid_customer') ?>"
                        alert("<?php echo $this->lang->line('gkpos_customer_not_found') . ' ' ?>" + key + "=>" + value);
                    }
                }
            });
        }
    }
    function showCompanyInfo() {
        jQuery("#warningPopupHeader").text("<?php echo $this->lang->line('gkpos_company_info') ?>");
        var ownerInfo = "<span class='owner-info'>GKSOFT</span><br/>";
        ownerInfo += "<span class='owner-info'>07450116256</span><br/>";
        ownerInfo += "<span class='owner-info'><a style='color:#000;' href='mailto:info@gksoft.co.uk'>info@gksoft.co.uk</a></span><br/>";
        ownerInfo += "<span class='owner-info'><a style='color:#000;' href='http://gksoft.co.uk' target='_blank'>gksoft.co.uk</a></span><br/>";
        ALERT_TITLE = "<?php echo $this->lang->line('gkpos_company_info') ?>";
        ALERT_BUTTON_TEXT = "<?php echo $this->lang->line('gkpos_close') ?>";
        alert(ownerInfo);
    }
    function RefreshMenu(clearItems, returnUrl) {
        $.ajax({
            url: "<?php echo site_url('gkpos/refresh'); ?>",
            type: "POST",
            dataType: "json",
            data: {
                clearItems: clearItems
            },
            success: function (output) {
                getBaseAjaxPage(returnUrl);
            }
        });

    }
    function RefreshPage(returnUrl) {
        getBaseAjaxPage(returnUrl);
    }
    function isOccupied(order_id) {
        $.ajax({
            url: '<?php echo site_url('gkpos/orders/is_order_occupied') ?>',
            type: 'POST',
            data: {
                order_id: order_id
            },
            dataType: 'json',
            success: function (response) {
                if (response.success) {
                    getBaseAjaxPage('<?php echo site_url("gkpos/orders/indexajax/") ?>' + order_id, 'Create Order');
                } else {
                    alert(response.message);
                }
            }

        });
    }
    function orderExit(orderId) {
        var has_new = $.trim($('#hasNew').val());
        var has_update = $.trim($('#hasUpdate').val());
        if (has_new === 'yes' || has_update === 'yes') {
            $.confirm({
                'title': '<?php echo $this->lang->line("gkpos_alert_title_warning") ?>',
                'message': '<?php echo $this->lang->line('gkpos_order_exit_text') ?>',
                'buttons': {
                    'Yes': {
                        'class': 'btn btn-success',
                        'action': function () {
                            $.ajax({
                                url: '<?php echo site_url('gkpos/orders/unlock_order') ?>',
                                type: 'POST',
                                dataType: 'json',
                                data: {
                                    order_id: orderId
                                },
                                success: function (response) {
                                    if (response.success) {
                                        pageExit('<?php echo site_url("gkpos/indexajax") ?>', 'Mainboard');
                                    } else {
                                        alert(response.message);
                                    }
                                }
                            });
                        }
                    },
                    'No': {
                        'class': 'btn btn-danger',
                        'action': function () {
                        }
                    }
                }
            });
        } else {
            $.ajax({
                url: '<?php echo site_url('gkpos/orders/unlock_order') ?>',
                type: 'POST',
                dataType: 'json',
                data: {
                    order_id: orderId
                },
                success: function (response) {
                    if (response.success) {
                        pageExit('<?php echo site_url("gkpos/indexajax") ?>', 'Mainboard');
                    } else {
                        alert(response.message);
                    }
                }
            });
        }
    }


    function showItemDescription() {
        
        var isShown = $('#showItemDescription').val();
        if (isShown == 'no') {
            $('#showItemDescription').val('yes');
        } else {
            $('#showItemDescription').val('no');
        }
    }
     function clearUserLogs(table, url, targetUrl) {
        $.confirm({
            'title': 'Order Delete Warning',
            'message': 'Are you sure? You want clear user log',
            'buttons': {
                'YES': {
                    'class': 'btn btn-danger btn-sm',
                    'action': function () {
                        $.ajax({
                            url: url,
                            data: {
                                table: table
                            },
                            type: "POST",
                            dataType: 'json',
                            success: function (output) {
                                if (output.success) {
                                    getSettingPage(targetUrl, '');
                                } else {
                                    alert(output.message);
                                }
                            }
                        });
                    }
                },
                'NO': {
                    'class': 'btn btn-success btn-sm',
                    'action': function () {}
                }
            }
        });
    }
    function openTopingBox(id, item_table, hook,category) {
        $.ajax({
            url: '<?php echo site_url('gkpos/menumanagement/opentoppingbox') ?>',
            type: 'POST',
            data: {
                id: id,
                item_table: item_table,
                hook: hook,
                category:category
            },
            success: function (output) {
                $('#TopingToolBoxHolder').html(output);
                $.colorbox({inline: true, scrolling: false, href: "#loginFormPopup", maxWidth: "95%", open: true, closeButton: false, transition: 'elastic', speed: '5000'});
            }
        });

    }
</script>