<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title><?php echo $page_title;?></title>

  <link rel="shortcut icon" href="<?php echo base_url();?>assets/img/favicon.ico">
  <!-- Google Font: Source Sans Pro -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="<?php echo base_url();?>assets/plugins/fontawesome-free/css/all.min.css">
  <!-- icheck bootstrap -->
  <link rel="stylesheet" href="<?php echo base_url();?>assets/plugins/icheck-bootstrap/icheck-bootstrap.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="<?php echo base_url();?>assets/dist/css/adminlte.min.css">
  <link rel="stylesheet" href="<?php echo base_url();?>assets/css/custom.css">
</head>
<body class="hold-transition login-page">
<div class="login-box">
  <div class="login-logo">
    <a href="<?php echo base_url();?>"><img src="<?php echo base_url();?>assets/img/logo.png" border="0" /></a>
  </div>
  <!-- /.login-logo -->
  <div class="card">
    <div class="card-body login-card-body">
	  <p class="login-box-msg login-logo"><?php echo $this->lang->line('hf_login');?></p>
      <form id="login-form">
        <div class="input-group mb-3">
          <input type="text" class="form-control" name="username" placeholder="<?php echo $this->lang->line('login_username');?>" value="<?php echo $this->session->userdata('remember_username');?>">
          <div class="input-group-append">
            <div class="input-group-text">
              <span class="fas fa-user"></span>
            </div>
          </div>
        </div>
        <div class="input-group mb-3">
          <input type="password" class="form-control" name="password" placeholder="<?php echo $this->lang->line('login_password');?>" value="<?php echo $this->session->userdata('remember_password');?>">
          <div class="input-group-append">
            <div class="input-group-text">
              <span class="fas fa-lock"></span>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-8">
            <div class="icheck-primary">
              <input type="checkbox" id="remember" name="remember_password" checked="checked">
              <label for="remember">
                <?php echo $this->lang->line('login_remember_password');?>
              </label>
            </div>
          </div>
          <!-- /.col -->
          <div class="col-4">
			<input type="hidden" id="<?php echo $this->security->get_csrf_token_name(); ?>" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>" />
            <button onclick="login()" type="button" class="btn btn-primary btn-block"><?php echo $this->lang->line('login_login_button');?></button>
          </div>
          <!-- /.col -->
        </div>
      </form>
	  
      <p class="mb-1">
        <a href="<?php echo base_url();?>forgot/"><?php echo $this->lang->line('login_forgot_password');?></a>
      </p>
    </div>
	
	<div class="text-center mb-3">
        <a href="<?php echo base_url();?>language/change/en/">
          <img src="<?php echo base_url();?>assets/img/flags/us.png" border="0" /> &nbsp; 
        </a>
        <a href="<?php echo base_url();?>language/change/zh-CN/">
          <img src="<?php echo base_url();?>assets/img/flags/cn.png" border="0" /> &nbsp; 
        </a>
		<a href="<?php echo base_url();?>language/change/vi/">
          <img src="<?php echo base_url();?>assets/img/flags/vn.png" border="0" />
        </a>
    </div>
    <!-- /.login-card-body -->
  </div>
</div>
<!-- /.login-box -->

<!-- jQuery -->
<script src="<?php echo base_url();?>assets/plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="<?php echo base_url();?>assets/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- AdminLTE App -->
<script src="<?php echo base_url();?>assets/dist/js/adminlte.min.js"></script>
<script src="<?php echo base_url();?>assets/js/layer/layer.js"></script>
<script type="text/javascript">
	var api_url = '<?php echo base_url();?>';
	
	function login() {
		$.ajax({url: api_url + 'login/submit/',
			data: $('#login-form').serialize(),
			type: 'post',                  
			async: 'true',
			beforeSend: function() {
				$('.loading').show();
			},
			complete: function() {
				$('.loading').hide();
			},
			success: function (result) {
				if(result == "<?php echo STATUS_200;?>") {
					location.href = api_url + 'home/';
				}
				else {
					layer.alert(result, {icon: 2, title: '<?php echo $this->lang->line('js_text_info');?>', btn: '<?php echo $this->lang->line('js_text_close');?>'});
				}	
			},
			error: function (request,error) {
			}
		});  
	}
</script>
</body>
</html>