
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="S.Prabhu, STVAT Consultancy, s.prabhu.mtech88@gmail.com">
    <meta name="generator" content="v4.1.1">
    <title>E - Invoice Login</title>
    <!-- Bootstrap core CSS -->
<!-- <link href="/docs/4.5/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous"> -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link rel="stylesheet" href="css/login.css">
    <!-- Favicons -->
<meta name="theme-color" content="#563d7c">    
    <!-- Custom styles for this template -->    
  </head>
  <body>
    <form class="form-signin" type="post" id="login" name="login" action="javascript;;">
  <div class="text-center mb-4">
    <img class="mb-4" src="images/logoLMS.gif" alt="" width="72" height="72">
    <h1 class="h3 mb-3 font-weight-normal">E-Invoice Login</h1>    
  </div>
  <div class="form-label-group">
    <input type="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
    <label for="inputEmail">Email address</label>
  </div>

  <div class="form-label-group">
    <input type="password" id="inputPassword" class="form-control" placeholder="Password" required>    
    <label for="inputPassword" class="fa fa-eye">Password<span id="udyp" data-feather="eye" class="float-right"></span></label>    
  </div>

  <div class="checkbox mb-3">
    <label>
      <input type="checkbox" id="setCookie" value="remember-me"> Remember me
    </label>
  </div>
  <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
  <p class="mt-5 mb-3 text-muted text-center">&copy; STVAT 2017-2020</p>
</form>
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

    <script src="https://unpkg.com/feather-icons/dist/feather.min.js"></script>
    <script
  src="https://code.jquery.com/jquery-3.5.1.js"
  integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc="
  crossorigin="anonymous"></script>
    <script>
      feather.replace()
    </script>

    <script>
    $(()=>{
      var name = $.cookie("name");
  var pwd = $.cookie("pass");

  if(name != null && pwd != null){
    $('#inputEmail').val(name);
    $('#inputPassword').val(pwd);
    $('input[type="checkbox"]').prop('checked','checked');
  }

  $('input[type="checkbox"]').click(function(){
    if($(this).prop("checked") == true){
      console.log("Checkbox is checked.");
      $.cookie("name",$('#inputEmail').val());
      $.cookie("pass",$('#inputPassword').val());
    }
    else if($(this).prop("checked") == false){
      $.cookie("name", null);
      $.cookie("pass", null);
    }
  });

  

    })
    </script>
<script>
$(document).ready(function(){  
  $('#inputPassword').mouseover(function(){
      var type_ = $(this).attr('type');
      if(type_ == 'password'){
        $(this).attr('type','text');
      }      
  });

  $('#inputPassword').mouseout(function(){
      var type_ = $(this).attr('type');
      if(type_ == 'text'){
        $(this).attr('type','password');
      }      
  });

    $('#login').on('submit',function(event){
        event.preventDefault();
        var formData = new FormData();        
        formData.append('inputEmail',$('#inputEmail').val());
        formData.append('inputPassword',$('#inputPassword').val());
        $.ajax({
          url : 'class/save_session.php',
          type: 'POST',                   
          data: formData,
          datatype: 'JSON',
          contentType: false,
          processData: false,
          resetForm: true,
          success: function(response){            
            var result = $.parseJSON(response);
            if(result.status_code == 1){
              setTimeout(() => {
                window.location.href = 'index.php?stvat=home';
              }, 2000);              
            }
            else if(result.status_code == 11){
              setTimeout(() => {
                window.location.href = 'admin.php?stvat=home';
              }, 1000);
            }
            else if(result.status_code == 2){
              setTimeout(() => {
                window.location.href = 'rane.php?stvat=home';
              }, 1000);
            }
            else{
              swal('Warning',result.status_info);
            }
            
          }
        });
    });
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js" integrity="sha512-3j3VU6WC5rPQB4Ld1jnLV7Kd5xr+cq9avvhwqzbH/taCRNURoeEpoPBK9pDyeukwSxwRPJ8fDgvYXd6SkaZ2TA==" crossorigin="anonymous"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
</body>
</html>
