<!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="card">
    <div class="card-body login-card-body">
	  <div class="text-center mb-4">
		<a href="<?php echo base_url();?>"><img src="<?php echo base_url();?>assets/img/logo.png" height="150" border="0" /></a>
	  </div>
	  <p class="login-box-msg login-logo"><?php echo $this->lang->line('hf_forgot_password');?></p>
	  <div class="text-center p-3">
	    <a href="<?php echo base_url();?>language/change/zh-CN/">
          <img src="<?php echo base_url();?>assets/img/round_flags/cn.png" border="0" /> &nbsp; 
        </a>
        <a href="<?php echo base_url();?>language/change/en/">
          <img src="<?php echo base_url();?>assets/img/round_flags/uk.png" border="0" />
        </a>
      </div>
      <form id="forgot-form">
        <div class="input-group mb-3">
          <input type="text" class="form-control" name="username" placeholder="<?php echo $this->lang->line('login_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="email" class="form-control" name="email" placeholder="<?php echo $this->lang->line('forgot_password_email');?>">
          <div class="input-group-append">
            <div class="input-group-text">
              <span class="fas fa-envelope"></span>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-12">
			<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="reset_password()" type="button" class="btn btn-gold btn-block"><?php echo $this->lang->line('forgot_password_submit');?></button>
          </div>
        </div>
      </form>
	  
	  <p class="mt-3 text-center">
        <a href="<?php echo base_url();?>login/"><?php echo $this->lang->line('login_login_to_your_account');?></a>
      </p>
    </div>
  </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 reset_password() {
		$.ajax({url: api_url + 'forgot/submit/',
			data: $('#forgot-form').serialize(),
			type: 'post',                  
			async: 'true',
			beforeSend: function() {
				$('.loading').show();
			},
			complete: function() {
				$('.loading').hide();
			},
			success: function (result) {
				var arr = result.split('|');
				if(arr[0] == 1) {
					layer.alert(arr[1], {icon: 1, title: '<?php echo $this->lang->line('js_text_info');?>', btn: '<?php echo $this->lang->line('js_text_close');?>'});
					$("#forgot-form")[0].reset();
				}
				else {
					layer.alert(arr[1], {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>