<?php $ci = get_instance();?>
<!DOCTYPE html>
<html lang="en">

<head>
	<?php $this->load->view("includes/header", array('no_pace'=>TRUE));?>
</head>

<body>
	<?php //$this->load->view("includes/nav");?>
	<div class="wrapper-page animated fadeInDown" style="width: auto;">
		<div class="col-xs-12 col-sm-offset-3 col-sm-6 col-md-offset-4 col-md-4">
			<div class="panel panel-color panel-primary">
				<div class="panel-heading" style="text-align: center; background-color: #2F353F;">
					<br/>
					<img src="<?php echo base_url("assets/img/logo.png");?>" style="width: 100px;">
					<br/><br/>
					<h3 class="text-center m-t-10" style="color: white">
						<?php echo $ci->fm->decrypt($this->company_name);?>
					</h3>
				</div>
				<form onSubmit="remember_username(); logging_in();" action="<?php echo base_url("login")?>" method="post" class="form-horizontal m-t-40">
					<div class="form-group">
						<div class="col-xs-12">
							<input type="text" id="username" name="CODE" onClick="input_assist(this, 1);" placeholder="Username" class="form-control" required="required" autocomplete="OFF">
						</div>
					</div>
					<div class="form-group">
						<div class="col-xs-12">
							<input type="password" id="password" name="PASSWORD" onClick="input_assist(this, 2);" placeholder="Password" class="form-control" required="required" autocomplete="OFF">
						</div>
					</div>
					<div id="div_login_error" class="alert alert-danger" style="display: none;" role="alert">
						<button type="button" class="close" onClick="$(this).parent().hide('fast');"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
						<p><?php echo $this->session->flashdata('login_error');?></p>
					</div>
					<div class="form-group">
						<div class="col-xs-12">
							<label class="cr-styled">
								<input type="checkbox" id="remember_me">
								<i class="fa"></i> 
								Remember me
							</label>
						</div>
					</div>
					<div class="form-group text-right">
						<div class="col-xs-12">
							<button type="submit" id="btn_submit" class="btn btn-primary w-md" style="background-color: #2F353F;">
								<i class="fa fa-sign-in"></i>
								Sign In
							</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
	
	<?php $this->load->view("includes/footer", array('no_footer'=>TRUE));?>
	<script>
		$(document).ready(function(){
			//Login Error---
			<?php if($this->session->flashdata('login_error') != ""):?>
				$("#div_login_error").show("fast");
			<?php endif;?>
			//--------------
	
			if(localStorage.<?php echo $ci->config->item('project');?>_remember_username != null){
				$("#username").val(localStorage.<?php echo $ci->config->item('project');?>_remember_username);
				$("#remember_me").prop("checked", true);
				$("#password").focus();
			}
			else{
				$("#username").focus();
			}
		});
		
		function remember_username(){
			if ($("#remember_me").is(":checked")) {
				localStorage.<?php echo $ci->config->item('project');?>_remember_username = $("#username").val();
			}
			else{
				localStorage.removeItem("<?php echo $ci->config->item('project');?>_remember_username");
			}
		}

		function logging_in(){
			$("#btn_submit").prop("disabled", true);
			$("#btn_submit").css("opacity", "0.5");
			$("#btn_submit").html("<i class='fa fa-spinner fa-pulse'></i> Signing In...");
		}
	</script>
</body>
</html>
