<div class="col-lg-10 col-md-10 col-sm-10 col-xs-10 bodyitem">
    <div class="row no-padding">
        <div class="buttons">
            <div onclick="getSettingPage('<?php echo site_url('gkpos/settings/general') ?>', '<?php echo $this->lang->line('gkpos_general_info') ?>')" class="btn btn-primary gradient text-center" style="font-size:90%;min-width: 90px;"><?php echo $this->lang->line('gkpos_general_info') ?></div>
            <div onclick="getSettingPage('<?php echo site_url('gkpos/settings/vatsetup') ?>', '<?php echo $this->lang->line('gkpos_general_vat_setup') ?>')" class="btn btn-primary gradient text-center" style="font-size: 90%;min-width: 90px;"><?php echo $this->lang->line('gkpos_general_vat_setup') ?></div>
            <div onclick="getSettingPage('<?php echo site_url('gkpos/settings/discountsetup') ?>', '<?php echo $this->lang->line('gkpos_discount') ?>')" class="btn btn-primary gradient text-center" style="font-size: 90%;min-width: 90px;"><?php echo $this->lang->line('gkpos_discount') ?></div>
            <div onclick="getSettingPage('<?php echo site_url('gkpos/settings/delivery_time') ?>', '<?php echo $this->lang->line('gkpos_delivery_time') ?>')" class="btn btn-primary gradient text-center" style="font-size: 90%;min-width: 110px;"><?php echo $this->lang->line('gkpos_delivery_time') ?></div>
            <div onclick="getSettingPage('<?php echo site_url('gkpos/settings/depliveryplan') ?>', '<?php echo $this->lang->line('gkpos_delivery_plan') ?>')" class="btn btn-primary gradient text-center" style="font-size: 90%;min-width: 110px;"><?php echo $this->lang->line('gkpos_delivery_plan') ?></div>
            <div onclick="getSettingPage('<?php echo site_url('gkpos/settings/pagination') ?>', '<?php echo $this->lang->line('gkpos_pagination') ?>')" class="btn btn-primary gradient text-center" style="font-size: 90%;min-width: 90px;" ><?php echo $this->lang->line('gkpos_pagination') ?></div>
            <?php if ($this->config->item('gk_only_online_admin') == 'no'): ?>
                <div onclick="getSettingPage('<?php echo site_url('gkpos/settings/add_cc_fee') ?>', '<?php echo $this->lang->line('gkpos_add_cce_fee') ?>')" class="btn btn-primary gradient text-center" style="font-size: 90%;min-width: 90px;" ><?php echo $this->lang->line('gkpos_add_cce_fee') ?></div>
            <?php endif; ?>
        </div>
    </div>
    <div class="row no-padding">
        <fieldset>
            <div class="col-md-offset-4 col-md-7">
                <h3 class="text-center modal-header">Default Collection and Delivery Time </h3>
            </div>
            <?php echo form_open('gkpos/settings/save_default_time', array('id' => 'DefaultTimeForm')) ?>
            <div class="form-horizontal">
                <div class="form-group">
                    <label class="col-md-4 control-label"><?php echo $this->lang->line('gkpos_collection') ?></label>  
                    <div class="col-md-7">
                        <div class="input-group">
                            <span class="input-group-addon"><a href="#"><i class="fa fa-clock-o" aria-hidden="true"></i></a></span>
                            <input  name="default_collection_time" id="name" class="form-control required"  type="text" value="<?php echo $this->config->item('default_collection_time') ?>">
                            <span class="input-group-addon"><i class="fa" aria-hidden="true"></i>Mins</span>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-4 control-label"><?php echo $this->lang->line('gkpos_delivery') ?></label>  
                    <div class="col-md-7">
                        <div class="input-group">
                            <span class="input-group-addon"><a href="#"><i class="fa fa-clock-o" aria-hidden="true"></i></a></span>
                            <input  name="default_delivery_time" id="name" class="form-control required"  type="text" value="<?php echo $this->config->item('default_delivery_time') ?>">
                            <span class="input-group-addon"><i class="fa" aria-hidden="true"></i>Mins</span>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-offset-4 col-md-7">
                        <ul id="DefaultTimeFormError" class="error_message_box"></ul>
                        <input class="btn btn-block btn-danger round btn-sm" type="submit" name="submit_form" value="<?php echo $this->lang->line('gkpos_numpad_key_enter') ?>" onclick="saveDefaultTime('DefaultTimeForm', 'DefaultTimeFormError')">
                    </div>
                </div>
            </div>
            <?php echo form_close() ?>
        </fieldset>
    </div>
</div>
<script>
    function saveDefaultTime(formId, error_message_box) {
        
        $('#' + 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',
                    success: function (response) {
                        if (response.success) {
                            alert(response.message);
                        } else {
                            alert(response.message);
                        }
                    }
                });
            },
            errorClass: "has-error",
            errorLabelContainer: "#" + error_message_box,
            wrapper: "li",
            highlight: function (e) {
                $(e).closest('.form-group').addClass('has-error');
            },
            unhighlight: function (e) {
                $(e).closest('.form-group').removeClass('has-error');
            },
            rules: {
                default_collection_time: {
                    number: true,
                    required: true
                },
                default_delivery_time: {
                    number: true,
                    required: true
                }
            },
            messages: {
                default_collection_time: "Please specify default collection time",
                default_delivery_time: "Please specify default delivery time"
            }
        });
    }
</script>