<fieldset style="max-height: 200px;">
    <form class="form-horizontal" action="<?php echo site_url('gkpos/orders/to_waiting') ?>" method="post"  id="gkposToWaitingForm">
        <!-- Text input-->
        <div class="form-group">
            <label class="col-md-3 control-label required"><?php echo $this->lang->line('gkpos_name') ?></label>  
            <div class="col-md-8">
                <div class="input-group">
                    <span class="input-group-addon"><a href="#"><i class="fa fa-navicon" aria-hidden="true"></i></a></span>
                    <input data-error="#gkposToWaitingFormNameError"  name="name" id="name" placeholder="<?php echo $this->lang->line('gkpos_name') ?>" class="form-control required"  type="text" value="<?php (isset($order_info->name) && ($order_info->name != '' || $order_info->name != null)) ? print $order_info->name : print '' ?>">
                </div>
            </div>
            <div id="gkposToWaitingFormNameError" class="col-md-offset-4"></div>
        </div>

        <div class="form-group">
            <label class="col-md-3 control-label required" ><?php echo $this->lang->line('gkpos_phone') ?></label> 
            <div class="col-md-8">
                <div class="input-group">
                    <input name="phone" id="phone" placeholder="<?php echo $this->lang->line('gkpos_phone') ?>" class="form-control" id="phone"  type="text" value="<?php (isset($order_info->phone) && ($order_info->phone != '' || $order_info->phone != null)) ? print $order_info->phone : print '' ?>">
                    <span class="input-group-addon" style="background-color: #FF0000;" data-toggle="tooltip-collection-phone" data-placement="top"  title="<?php echo $this->lang->line('gkpos_click_to_get_customer_by_phone') ?>"><a href="javascript:void(0)" onclick="searchCustomerByKey('phone')"><i class="fa fa-search" aria-hidden="true"></i></a></span>
                </div>
            </div>
        </div>

        <div class="form-group"> 
            <div class="col-md-12">
                <ul id="gkposWaitingFormErrorMsgBox" class="error_message_box"></ul>
            </div>
        </div>
        <div class="form-group"> 
            <div class="col-md-6 col-md-offset-3">
                <input type="hidden" name="existing_type" value="<?php (isset($existing_type) && ($existing_type != '' || $existing_type != null) ) ? print strtolower($existing_type) : print"" ?>">
                <input type="hidden" name="new_type" value="<?php (isset($new_type) && ($new_type != '' || $new_type != null) ) ? print strtolower($new_type) : print"" ?>">
                <input type="hidden" name="order_id" value="<?php echo $order_id ?>">
                <input class="btn btn-danger btn-block round btn-sm" type="submit" name="submit_form" value="<?php echo $this->lang->line('gkpos_numpad_key_enter') ?>" onclick="saveWaitingInfo('gkposToWaitingForm')">
            </div>
        </div>
    </form>
</fieldset>
<div class="numpad collection-numpad">
    <?php if (!isset($isPhoneCall) || $isPhoneCall != 'yes'): ?>
        <div class="pin-calculatorbg collection-pin-calculatorbg conversion-pin-calculatorbg">
            <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>
    <?php endif; ?>
</div>
<script type="text/javascript">
    jQuery(document).ready(function () {
        setnumkeys('phone');
        $('[data-toggle="tooltip-collection-phone"]').tooltip();
    });
    function saveWaitingInfo(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 () {
                        $("#collectionAjaxLoading").show();
                    },
                    success: function (response) {
                        $("#collectionAjaxLoading").hide();
                        if (response.success && response.order_id) {
                            getBaseAjaxPage('<?php echo site_url('gkpos/orders/indexajax/') ?>' + response.order_id);
                        } 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: {
                name: {lettersonly: true, required: true},
                phone: {phone: true, required: false}
            },
            messages: {
                name: "customer name, please",
                phone: "<?php echo $this->lang->line('gkpos_valid_phone_required') ?>"
            },
            errorPlacement: function (error, element) {
                errorPlacement(error, element);
            }
        });
    }
</script>