<!DOCTYPE html>
<html lang="en">

<head>

  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">
  <script defer src="https://use.fontawesome.com/releases/v5.8.1/js/all.js" integrity="sha384-g5uSoOSBd7KkhAMlnQILrecXvzst9TdC09/VM+pjDTCM+1il8RHz5fKANTFFb+gQ" crossorigin="anonymous"></script>
  <title>Admin - Login</title>

  <!-- Custom fonts for this template-->
  <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">

  <!-- Custom styles for this template-->
  <link href="assets/css/sb-admin-2.min.css" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Athiti&display=swap" rel="stylesheet">
  <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

</head>

<body  style="background-color:#00695C; font-family: 'Athiti', sans-serif;">

  <div class="container">

    <!-- Outer Row -->
    <div class="row justify-content-center">

      <div class="col-xl-10 col-lg-12 col-md-9">

        <div class="card o-hidden border-0 shadow-lg my-5">
          <div class="card-body p-0">
            <!-- Nested Row within Card Body -->
            <div class="row">
              <div class="col-lg-6 d-none d-lg-block"><img src="../img/admin.jpg" alt="Smiley face" height="100%" width="110%"></div>
              <div class="col-lg-6">
                <div class="p-5">
                  <div class="text-center">
                    <h1 class="h4 text-gray-800 mb-4">ERP-Login</h1>
                  </div>
                  <form class="user" action="{!!url('checklogin')!!}" method="post" id="form1">
                    @csrf
                    <div class="form-group">
                      <input type="text" class="form-control" name="username">
                    </div>
                    <div class="form-group">
                      <input type="password" class="form-control"  placeholder="รหัสผ่าน" name="pass" autocomplete="off">
                    </div>
                    <button class="btn btn-primary btn-user btn-block" onclick="login()">
                      Login
                    </button>
                    <hr>
                  </form>
                  <hr>
                </div>
              </div>
            </div>
          </div>
        </div>

      </div>

    </div>

  </div>

  <!-- Bootstrap core JavaScript-->
  <script src="vendor/jquery/jquery.min.js"></script>
  <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

  <!-- Core plugin JavaScript-->
  <script src="vendor/jquery-easing/jquery.easing.min.js"></script>

  <!-- Custom scripts for all pages-->
  <script src="assets/js/sb-admin-2.min.js"></script>
  <script>
    function login(){ 
      if($("input[name='username']").val() == ""){
        swal({
          title: "ขออภัย !!!",
          text: "คุณยังไม่ได้กรอกUserName",
          icon: "info",
          button: "ตกลง",
        });
        /*alert("Choose");*/
        return false;
      }else if($("input[name='pass']").val() == ""){
        swal({
          title: "ขออภัย !!!",
          text: "คุณยังไม่ได้กรอกPassWord",
          icon: "info",
          button: "ตกลง",
        });
        /*alert("Choose");*/
        return false;
      }
      $("#form1").submit();
      $(".md-Load").show();           
      $('.js-tilt').tilt({
        scale: 1.1
      })

    }

    @if(session()->has("state"))
    swal({
      title: "ล็อกอินล้มเหลว!",
      text: "username หรือ password ผิด",
      icon: "error",
      button: "ตกลง",
    });
    @endif

    function infor(){
      swal({
        title: "มีปัญหาในการ login หรือป่าว!",
        text: " คุณสามารถใช้รหัสบัตรประชาชนแทน username และเบอร์โทรแทน password ได้ครับ",
        icon: "warning",
        button: "ตกลง",
      });
    }
  </script>

</body>

</html>
