<header class="toolbar toolbar-header">
    <h1 class="text-center" style="font-size: 12px;"><?php echo $this->lang->line('company_epos') ?></h1>
</header>
<div class="window-content" id="WindowContent">
    <div class="page-loader" style="display: none;"></div>
    <div class="pane-group">
        <div class="pane sidebar login-sidebar user-list-block"></div>
        <div class="pane-one-half">
            <div style="width:70%; margin:10% auto; top: 10%">
                <?php echo form_open('user/login/validateEnginner', array('id' => 'eposUserLoginForm')); ?>
                <div class="neworder-table-guest collection-phone ccfee login-pad text-center">
                    <div class="clearfix brand-time text-center" id="ZamanEposClock" style="border-radius: 50px 50px 0px 0px;padding: 10px;"><span class="icon icon-lock"></span>&nbsp;<?php echo $this->lang->line('please_login') ?></div>
                    <div class="form-group"><input type="text" name="email" id="email" class="form-control" placeholder="<?php echo $this->lang->line('email') ?>" autocomplete="off" onfocus="if (this.hasAttribute('readonly')) {this.removeAttribute('readonly');this.blur();this.focus();}"></div>
                    <div class="form-group"><input type="text" name="username" id="username" class="form-control" placeholder="<?php echo $this->lang->line('username') ?>" autocomplete="off" onfocus="if (this.hasAttribute('readonly')) {this.removeAttribute('readonly');this.blur();this.focus();}"></div>
                    <div class="form-group"><input type="password" name="password" id="zamanccFeePrimaryNumpad" class="form-control" placeholder="<?php echo $this->lang->line('password') ?>" autocomplete="new-password" onfocus="if (this.hasAttribute('readonly')) {this.removeAttribute('readonly');this.blur();this.focus();}"></div>
                    <div class="clearfix"></div>
                    <div class="tab-group config-submit">
                        <button type="submit" onclick="validateEngineer('eposUserLoginForm')"><?php echo $this->lang->line('go') ?></button>
                    </div>
                </div>
                <?php echo form_close() ?>
            </div>
        </div>
        <div class="pane sidebar login-sidebar"></div>
    </div>
</div>
<?php $this->load->view('settings/partials/footer') ?>

<script type="text/javascript">
    function validateEngineer(formId) {
        if (!$('.page-loader').is(":visible")) {
            $('#' + formId).validate({
                submitHandler: function () {
                    var myform = document.getElementById(formId);
                    var formdata = new FormData(myform);
                    if (checkInternetConnection()) {
                        $.ajax({
                            url: $('#' + formId).attr('action'),
                            data: formdata,
                            cache: false,
                            processData: false,
                            contentType: false,
                            type: 'POST',
                            dataType: 'json',
                            beforeSend: function () {
                                $('.page-loader').show();
                            },
                            success: function (response) {
                                if (response.status) {
                                    if (response.userData) {
                                        zamanEposCart.setUserData(response.userData);
                                    }
                                    window.location.href = '<?php echo site_url('settings/index/verified') ?>';
                                } else {
                                    warning('<?php echo $this->lang->line('error') ?>', response.message, '<?php echo $this->lang->line('ok') ?>');
                                }
                            }
                        });
                    } else {
                        warning('<?php echo $this->lang->line('lost_connection') ?>', '<?php echo $this->lang->line('lost_connection_message') ?>', '<?php echo $this->lang->line('close') ?>');
                    }
                },
                errorClass: "has-error",
                highlight: function (e) {
                    $(e).closest('.form-group').addClass('has-error');
                },
                unhighlight: function (e) {
                    $(e).closest('.form-group').removeClass('has-error');
                },
                rules: {
                    email: {required: true},
                    username: {required: true},
                    password: {required: true}
                },
                messages: {
                    email: '<?php echo sprintf($this->lang->line('item_required'), $this->lang->line('email')) ?>',
                    username: '<?php echo sprintf($this->lang->line('item_required'), $this->lang->line('username')) ?>',
                    password: '<?php echo sprintf($this->lang->line('item_required'), $this->lang->line('password')) ?>',
                },
                errorPlacement: function (error, element) {
                    errorPlacement(error, element);
                }
            });
        }
    }
</script>