<!doctype html>
<html class="no-js" lang="zxx">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Sudila Printers - Kurunegala Sri Lanka</title>
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Favicons -->
<link rel="shortcut icon" href="images/favicon.ico">

<!-- Google font (font-family: 'Roboto', sans-serif; Poppins ; Satisfy) -->
<link type="text/css" href="css/font_opensans.css" rel="stylesheet">
<link type="text/css" href="css/font_poppins.css" rel="stylesheet">
<link type="text/css" href="css/font_roboto.css" rel="stylesheet">
<!-- Stylesheets -->
<link type="text/css" rel="stylesheet" href="css/bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="css/plugins.css">
<link type="text/css" rel="stylesheet" href="css/style.css">
<!-- Cusom css -->
<link type="text/css" rel="stylesheet" href="css/custom.css">
<!-- Modernizer js -->
<script type="text/javascript" src="js/vendor/modernizr-3.5.0.min.js"></script>
</head>
<body>
<!-- Main wrapper -->
<div class="wrapper" id="wrapper"> 
  <!-- Header -->
  <?php include 'common/header.php';
	if (isset($_SESSION['normal_user_bb'])) {
		$redirectUrl = "index";
		echo "<script type=\"text/javascript\">";
		echo "window.location.href = '$redirectUrl'";
		echo "</script>";
	}
  ?>
  <!-- //Header --> 
  <!-- Start Bradcaump area -->
  <div class="ht__bradcaump__area bg-image--4">
    <div class="container">
      <div class="row">
        <div class="col-lg-12">
          <div class="bradcaump__inner text-center">
            <h2 class="bradcaump-title">Sign In</h2>
            <nav class="bradcaump-content"> <a class="breadcrumb_item" href="index">Home</a> <span class="brd-separetor">/</span> <span class="breadcrumb_item active">Sign In</span> </nav>
          </div>
        </div>
      </div>
    </div>
  </div>
  <!-- End Bradcaump area --> 
	<!-- Start My Account Area -->
	<section class="my_account_area pt--30 pb--30 bg--white text-center">
		<div class="container">
			<div class="row">
				<div class="col-lg-3 col-12">
				</div>
				<div class="col-lg-6 col-12">
					<div class="my__account__wrapper">
						<form method="post" id="login_form" action="javascript:void(0);">
							<div class="account__form">
							<h3 class="account__title">LOGIN</h3><hr class="pb--30">
							<div id="errorDiv"></div>
								<div class="input__box">
									<label>Username:<span>*</span></label>
									<input type="text" id="username" name="username" required>
									<span class="help-block"></span>
								</div>
								<div class="input__box">
									<label>Password:<span>*</span></label>
									<input type="password" id="password" autocomplete="off" name="password" required>
									<span class="help-block"></span>
								</div>
								<div class="form__btn">
									<input type="submit" value="Login" name="login_btn" id="login_btn" class="button"/>
								</div>
								<a class="forget_pass" href="#">Forgot your password?</a>
								<a class="forget_pass pull-right" href="create-account">Create an Account</a>
								<?php if(isset($_SESSION['temp_user_bb'])) { ?> <hr class="mt--10">
								<div class="mt--20 product-add-to-cart chkt">
									<a href="connection/guest-login">CONTINUE AS A GUEST</a>
								</div>
								<?php } ?>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</section>
	<!-- End My Account Area --> 
  <!-- Footer Area -->
  <?php include 'common/footer.php'; ?>
  <!-- //Footer Area --> 
</div>
<!-- //Main wrapper -->
<!-- JS Files --> 
<script type="text/javascript" src="js/vendor/jquery-3.2.1.min.js"></script> 
<script type="text/javascript" src="js/popper.min.js"></script> 
<script type="text/javascript" src="js/bootstrap.min.js"></script> 
<script type="text/javascript" src="js/plugins.js"></script> 
<script type="text/javascript" src="js/active.js"></script>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script type="text/javascript" src="js/add-to-cart.js"></script>
<script type="text/javascript">
$('document').ready(function () {
	// JavaScript Validation For Login Form	
	$("#login_form").validate({
		rules: {
			username: {
				required: true
			},
			password: {
				required: true
			}
		},
		messages: {
			password: {
				required: "Password is Required.",
			},
			username: {
				required: "Username is Required.",
			}
		},
		errorPlacement: function (error, element) {
			$(element).closest('.input__box').find('.help-block').html(error.html());
		},
		highlight: function (element) {
			$(element).closest('.input__box').removeClass('has-success').addClass('has-error');
		},
		unhighlight: function (element, errorClass, validClass) {
			$(element).closest('.input__box').removeClass('has-error');
			$(element).closest('.input__box').find('.help-block').html('');
		},
		submitHandler: loginForm
	});

	function loginForm() {
		$.ajax({
		url: 'connection/user_login',
		type: 'POST',
		data: $('#login_form').serialize(),
		dataType: 'json'
		})
		.done(function (data) {
			$('input[name=login_btn]').val('Signing...').prop('disabled', true);
			$('input[type=text],input[type=password]').prop('disabled', true);
			setTimeout(function () {
				<?php //if(empty($file)) { ?>
					if (data.status === '1') {
						window.location.href = 'checkout';

					} else if (data.status === '2') {
						window.location.href = 'index';

					} else {
						$('#errorDiv').slideDown(200, function () {
							$('#errorDiv').html('<div class="alert alert-danger">' + data.message + '</div>');
							$('#errorDiv').delay(5000).slideUp(100);
							$('input[type=text],input[type=password]').prop('disabled', false);
							$('input[name=login_btn]').val('Log in').prop('disabled', false);
							$('#password').focus();
							$('#password').val('');
						});
					}
				<?php //} else { ?>
					//window.location.href = '<?php //echo $file; ?>';
				<?php //} ?>
			}, 1000);
		})
		.fail(function () {
			$('input[name=login_btn]').val('Signing...').prop('disabled', true);
			$('input[type=text],input[type=password]').prop('disabled', true);
			setTimeout(function () {
				//alert('An unknown error occoured, Please try again Later...!')
				$('#errorDiv').slideDown(200, function () {
					$('#errorDiv').html('<div class="alert alert-danger">An unknown error occoured, Please try again Later...!</div>');
					$('#errorDiv').delay(5000).slideUp(100);
					$('input[type=text],input[type=password]').prop('disabled', false);
					$('input[name=login_btn]').val('Log in').prop('disabled', false);
				});
			}, 1000);
		});
	}
});
</script>
</body>
</html>