<div class="body-vertical-align-center">
    <form class="form-horizontal" action="<?php echo site_url('gkpos/orderinitiate') ?>" method="post"  id="gkposTableForm">
        <div class="pin-calculatorbg collection-pin-calculatorbg">
            <div id="TableNumber" class="col-md-6 pull-left">
                <input data-error="#tableNumberError" type="text" id="table_number" name="table_number" class="form-control" id="inputEmail3" placeholder="<?php echo $this->lang->line('gkpos_table') ?>&nbsp;<?php echo $this->lang->line('gkpos_number') ?>">
                <div id="tableNumberError" class="text-center"></div>
                <ul>
                    <li class="numkey"><?php echo $this->lang->line('gkpos_numpad_key1') ?></li>
                    <li class="numkey"><?php echo $this->lang->line('gkpos_numpad_key2') ?></li>
                    <li class="numkey"><?php echo $this->lang->line('gkpos_numpad_key3') ?></li>
                </ul>
                <ul>
                    <li class="numkey"><?php echo $this->lang->line('gkpos_numpad_key4') ?></li>
                    <li class="numkey"><?php echo $this->lang->line('gkpos_numpad_key5') ?></li>
                    <li class="numkey"><?php echo $this->lang->line('gkpos_numpad_key6') ?></li>
                </ul>
                <ul>
                    <li class="numkey"><?php echo $this->lang->line('gkpos_numpad_key7') ?></li>
                    <li class="numkey"><?php echo $this->lang->line('gkpos_numpad_key8') ?></li>
                    <li class="numkey"><?php echo $this->lang->line('gkpos_numpad_key9') ?></li>
                </ul>
                <ul>
                    <li class="btnPin"><?php echo $this->lang->line('gkpos_numpad_key_del') ?></li>
                    <li class="numkey"><?php echo $this->lang->line('gkpos_numpad_key0') ?></li>
                    <li class="btnPin"><?php echo $this->lang->line('gkpos_numpad_key_clr') ?></li>
                </ul>
            </div>
            <div id="GuestQuantity" class="col-md-6 pull-right">
                <input data-error="#guestQuantityError" type="text" name="guest_quantity" id="guest_quantity" class="form-control" placeholder="<?php echo $this->lang->line('gkpos_quantity_of_guest') ?>">
                <div id="guestQuantityError" class="text-center"></div>
                <ul>
                    <li class="numkey2"><?php echo $this->lang->line('gkpos_numpad_key1') ?></li>
                    <li class="numkey2"><?php echo $this->lang->line('gkpos_numpad_key2') ?></li>
                    <li class="numkey2"><?php echo $this->lang->line('gkpos_numpad_key3') ?></li>
                </ul>
                <ul>
                    <li class="numkey2"><?php echo $this->lang->line('gkpos_numpad_key4') ?></li>
                    <li class="numkey2"><?php echo $this->lang->line('gkpos_numpad_key5') ?></li>
                    <li class="numkey2"><?php echo $this->lang->line('gkpos_numpad_key6') ?></li>
                </ul>
                <ul>
                    <li class="numkey2"><?php echo $this->lang->line('gkpos_numpad_key7') ?></li>
                    <li class="numkey2"><?php echo $this->lang->line('gkpos_numpad_key8') ?></li>
                    <li class="numkey2"><?php echo $this->lang->line('gkpos_numpad_key9') ?></li>
                </ul>
                <ul>
                    <li class="btnPin2"><?php echo $this->lang->line('gkpos_numpad_key_del') ?></li>
                    <li class="numkey2"><?php echo $this->lang->line('gkpos_numpad_key0') ?></li>
                    <li class="btnPin2"><?php echo $this->lang->line('gkpos_numpad_key_clr') ?></li>
                </ul>
            </div>

        </div>
        <div class="last-calculatorbg collection-last-calculatorbg table-order-numpad-enter">
            <input type="hidden" name="order_type" value="<?php (isset($info) && ($info != '' || $info != null) && $info = 'table' ) ? print strtolower($info) : print"table" ?>">
            <input class="form-submit-button mainsystembg2 waiting-bg img-responsive delivery-info-submit-btn" type="submit" name="submit_form" value="<?php echo $this->lang->line('gkpos_numpad_key_enter') ?>" onclick="saveTableInfo('gkposTableForm')">
        </div>
    </form>

</div>
<script type="text/javascript">
    jQuery(document).ready(function () {
        setnumkeys('table_number');
        setnumkeys2('guest_quantity');
    });
    function saveTableInfo(formId) {
        
        $('#' + formId).validate({
            submitHandler: function () {
                var myform = document.getElementById(formId);
                var formdata = new FormData(myform);
                $.ajax({
                    url: $('#' + formId).attr('action'),
                    data: formdata,
                    cache: false,
                    processData: false,
                    contentType: false,
                    type: 'POST',
                    dataType: 'json',
                    beforeSend: function () {
                        $("#waitingAjaxLoading").show();
                    },
                    success: function (response) {
                        $("#waitingAjaxLoading").hide();
                        if (response.success) {
                            getBaseAjaxPage('<?php echo site_url('gkpos/orders/indexajax/') ?>' + response.order_id, 'Waiting-' + response.name);
                        } else {
                            alert(response.message);
                        }
                    }
                });
            },
            errorClass: "has-error",
            highlight: function (e) {
                $(e).closest('.form-group').addClass('has-error');
            },
            unhighlight: function (e) {
                $(e).closest('.form-group').removeClass('has-error');
            },
            rules: {
                table_number: {number: true, min: 1, required: true},
                guest_quantity: {number: true, min: 1, required: true}
            },
            messages: {
                table_number: "Table number is required",
                guest_quantity: "Guest quantity, Please"
            },
            errorPlacement: function (error, element) {
                errorPlacement(error, element);
            }
        });
    }
</script>