<div class="col-lg-10 col-md-10 col-sm-10 col-xs-10 bodyitem">
    <div class="row no-padding">
        <fieldset>
            <table class="table table-responsive table-bordered">
                <tr>
                    <td colspan="4" class="text-right">
                        <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4 text-center btn btn-info btn-sm" onclick="getSettingPage('<?php echo site_url('gkpos/settings/view_user') ?>', '<?php echo $this->lang->line("gkpos_system_user") ?>')">View Users</div>
                        <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4 text-center btn btn-sm btn-primary" onclick="getSettingPage('<?php echo site_url('gkpos/settings/user') ?>', '<?php echo $this->lang->line("gkpos_system_user") ?>')">Add New User</div>
                    </td> 
                </tr>
            </table>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <?php echo form_open('gkpos/settings/save_user/', array('id' => 'user_form', 'enctype' => 'multipart/form-data', 'class' => 'form-horizontal')); ?>
                <input type="hidden" name="id" value="<?php isset($user->id) ? print $user->id : '' ?>"/>
                <form class="form-horizontal" action="<?php echo site_url('gkpos/orders/to_delivery') ?>" method="post" id="gkposDeliveryForm">
                    <div class="row">
                        <div class="col-md-3 no-padding-bottom">
                            <div class="form-group">
                                <label><?php echo $this->lang->line('gkpos_first_name') ?></label>  
                                <div class="input-group">
                                    <span class="input-group-addon"><a href="#"><i class="fa fa-navicon" aria-hidden="true"></i></a></span>
                                    <input  type="text" name="first_name" id="first_name" placeholder="<?php echo $this->lang->line('gkpos_first_name') ?>" class="form-control input-sm" value="<?php isset($user->first_name) ? print $user->first_name : '' ?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label"><?php echo $this->lang->line('gkpos_house') ?></label>  
                                <div class="input-group">
                                    <span class="input-group-addon"><a href="#"><i class="fa fa-navicon" aria-hidden="true"></i></a></span>
                                    <input  type="text" name="house" id="house" placeholder="<?php echo $this->lang->line('gkpos_house') ?>" class="form-control input-sm" value="<?php isset($user->house) ? print $user->house : '' ?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label"><?php echo $this->lang->line('gkpos_city') ?></label>  
                                <div class="input-group">
                                    <span class="input-group-addon"><a href="#"><i class="fa fa-navicon" aria-hidden="true"></i></a></span>
                                    <input  type="text" name="city" id="city" placeholder="<?php echo $this->lang->line('gkpos_city') ?>" class="form-control  input-sm" value="<?php isset($user->city) ? print $user->city : '' ?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label"><?php echo $this->lang->line('gkpos_national_insurance') ?></label>  
                                <div class="input-group">
                                    <span class="input-group-addon"><a href="#"><i class="fa fa-navicon" aria-hidden="true"></i></a></span>
                                    <input  type="text" name="insurance" id="insurance" placeholder="<?php echo $this->lang->line('gkpos_national_insurance') ?>" class="form-control input-sm" value="<?php isset($user->insurance) ? print $user->insurance : '' ?>">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-3 no-padding-bottom">
                            <div class="form-group">
                                <label><?php echo $this->lang->line('gkpos_middle_name') ?></label>  
                                <div class="input-group">
                                    <span class="input-group-addon"><a href="#"><i class="fa fa-navicon" aria-hidden="true"></i></a></span>
                                    <input  type="text" name="middle_name" id="middle_name" placeholder="<?php echo $this->lang->line('gkpos_middle_name') ?>" class="form-control input-sm" value="<?php isset($user->middle_name) ? print $user->middle_name : '' ?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label"><?php echo $this->lang->line('gkpos_street') ?></label>  
                                <div class="input-group">
                                    <span class="input-group-addon"><a href="#"><i class="fa fa-navicon" aria-hidden="true"></i></a></span>
                                    <input  type="text" name="street" id="street" placeholder="<?php echo $this->lang->line('gkpos_street') ?>" class="form-control input-sm" value="<?php isset($user->stree) ? print $user->street : '' ?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label"><?php echo $this->lang->line('gkpos_postal_code') ?></label>  
                                <div class="input-group">
                                    <span class="input-group-addon"><a href="#"><i class="fa fa-street-view" aria-hidden="true"></i></a></span>
                                    <input  type="text" name="postcode" id="postcode" placeholder="<?php echo $this->lang->line('gkpos_postal_code') ?>" class="form-control input-sm" value="<?php isset($user->postcode) ? print $user->postcode : '' ?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label"><?php echo $this->lang->line('gkpos_joining_date') ?></label>  
                                <div class="input-group">
                                    <span class="input-group-addon"><a href="#"><i class="fa fa-calendar" aria-hidden="true"></i></a></span>
                                    <input  type="text" name="join_date" id="join_date" placeholder="<?php echo $this->lang->line('gkpos_joining_date') ?>" class="form-control input-sm user_date" value="<?php isset($user->join_date) ? print $user->join_date : '' ?>">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label><?php echo $this->lang->line('gkpos_surname') ?></label>  
                                <div class="input-group">
                                    <span class="input-group-addon"><a href="#"><i class="fa fa-navicon" aria-hidden="true"></i></a></span>
                                    <input  type="text" name="last_name" id="surname" placeholder="<?php echo $this->lang->line('gkpos_surname') ?>" class="form-control required input-sm" value="<?php isset($user->last_name) ? print $user->last_name : '' ?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label"><?php echo $this->lang->line('gkpos_town') ?></label>  
                                <div class="input-group">
                                    <span class="input-group-addon"><a href="#"><i class="fa fa-navicon" aria-hidden="true"></i></a></span>
                                    <input  type="text" name="town" id="town" placeholder="<?php echo $this->lang->line('gkpos_town') ?>" class="form-control input-sm" value="<?php isset($user->twon) ? print $user->twon : '' ?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label"><?php echo $this->lang->line('gkpos_date_of_birth') ?></label>  
                                <div class="input-group">
                                    <span class="input-group-addon"><a href="#"><i class="fa fa-calendar" aria-hidden="true"></i></a></span>
                                    <input  type="text" name="dob" id="dob" placeholder="<?php echo $this->lang->line('gkpos_date_of_birth') ?>" class="form-control input-sm user_date" value="<?php isset($user->dob) ? print $user->dob : '' ?>">
                                </div>
                            </div>
                            <div class="form-group">	
                                <label class="control-label text-uppercase"><?php echo $this->lang->line('gkpos_gender') ?></label>
                                <div>
                                    <label class="radio-inline text-uppercase"><input type="radio" name="gender" id="gk_discount_applied1" value="1" <?php (isset($user->gender) && $user->gender == "1") ? print "checked" : '' ?> ><?php echo $this->lang->line('gkpos_male') ?></label>
                                    <label class="radio-inline text-uppercase"><input type="radio" name="gender" id="gk_discount_applied2" value="2" <?php (isset($user->gender) && $user->gender == "2") ? print "checked" : '' ?> ><?php echo $this->lang->line('gkpos_female') ?></label>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group text-center">
                                <?php echo form_label($this->lang->line('gkpos_user_image'), 'image', array('class' => 'control-label')); ?>
                                <div class="input-group">
                                    <div class="fileinput-preview fileinput-exists thumbnail" style="width: 100%; height: 150px;">
                                        <img data-src="holder.js/100%x100%" alt="<?php echo $this->lang->line('gkpos_user_image'); ?>" src="<?php
                                        if (!isset($user->image))
                                            echo '';
                                        else
                                            echo UPLOAD_PATH . 'gkpos/user/' . $user->image;
                                        ?>">
                                    </div>
                                    <div>
                                        <span class="btn btn-default btn-sm btn-file">
                                            <input type="file" name="image">
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group form-group-md">	
                        <?php
                        echo form_submit(array(
                            'name' => 'submit_form',
                            'id' => 'submit_form',
                            'value' => $this->lang->line('gkpos_numpad_key_enter'),
                            'class' => 'btn btn-block btn-danger round btn-sm'));
                        ?>
                    </div>
                </form>
            </div>
            <div class="col-lg-12 col-md-12 col-sm-12">
                <ul id="user_form_error_message_box" class="error_message_box"></ul>
            </div>
        </fieldset>
    </div>
    <script type='text/javascript'>

        $(document).ready(function ()
        {
            keyboard('clientsCTA1');
            keyboard('clientsCTA');
            $(".user_date").datepicker({
                dateFormat: "dd/mm/yy",
                changeMonth: true,
                changeYear: true
            });
            $('#user_form').validate({
                submitHandler: function () {
                    var myform = document.getElementById('user_form');
                    var formdata = new FormData(myform);
                    $.ajax({
                        url: $('#user_form').attr('action'),
                        data: formdata,
                        cache: false,
                        processData: false,
                        contentType: false,
                        type: 'POST',
                        dataType: 'json',
                        success: function (response) {
                            if (response.success) {
                                ALERT_TITLE = "Success!";
                                alert(response.message);

                            } else {
                                ALERT_TITLE = "Error!";
                                alert(response.message);
                            }
                        }
                    });
                },
                errorClass: "has-error",
                errorLabelContainer: "#user_form_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: {
                    first_name: {
                        lettersonly: true
                    },
                    middle_name: {
                        lettersonly: true
                    },
                    last_name: {
                        lettersonly: true,
                        required: true
                    },
                    postcode: {
                        postcodeUK: true
                    },
                    password: {
                        required: true,
                        number: true
                    }

                },
                messages: {
                    first_name: 'Please letters only in first name',
                    middle_name: 'Please letters only in middle name',
                    last_name: 'Surname with only letters, please',
                    postcode: 'Specify valid uk postcode',
                    password: 'please specify user access pin in number'
                }
            });
        });
    </script>
</div>

<script>
    function updateGiftcard(voucher_id, url, action) {
        $.ajax({
            url: url,
            data: {
                id: voucher_id,
                action: action
            },
            dataType: 'json',
            type: "POST",
            success: function (output) {
                if (output.success) {
                    ALERT_TITLE = "Success!";
                    alert(output.message);
                    getSettingPage('<?php echo site_url("gkpos/settings/giftcard") ?>', 'Giftcard');
                } else {
                    ALERT_TITLE = "Error!";
                    alert(output.message);
                }

            }
        });
    }
</script>