<?php
require("../config/koneksi.php");
require("../config/function.php");
require("../config/apk.php");
if ($setting['id_server'] == '') {
	echo "<script>location.href = '../install.php';</script>";
}
?>
<!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">
    <meta name="description" content="New Sandik MBS">
    <meta name="keywords" content="admin,dashboard">
    <meta name="author" content="stacks">
    <title>NEW SANDIK MBS</title>

    <link rel='shortcut icon' href="../<?= $setting['logo'] ?>" />
    <link href="../assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="../assets/plugins/perfectscroll/perfect-scrollbar.css" rel="stylesheet">
    <link href="../assets/plugins/pace/pace.css" rel="stylesheet">
    <link href="../assets/css/main.css" rel="stylesheet">
    <link href="../assets/css/custom.css" rel="stylesheet">
    <link rel="icon" type="image/png" sizes="32x32" href="../<?php echo $setting['logo'] ?>" />
    <link rel="icon" type="image/png" sizes="16x16" href="../<?php echo $setting['logo'] ?>" />
    <link rel='stylesheet' href='../plugins/izitoast/css/iziToast.min.css'>
   
</head>
<body>
    <div class="app app-auth-sign-in align-content-stretch d-flex flex-wrap justify-content-end">
        <div class="app-auth-background" style="background-image: url('../<?= $setting['background'] ?>');">

        </div>
        <div class="app-auth-container">
            <div class="logo">
			 <img src="<?= $homeurl . '/' . $setting['logo'] ?>" height="50px">
                <a href="sign-in.php" style="margin-top:-50px">NEW SANDIK</a>
            </div>
            <p class="auth-description">Silahkan Login dengan akun yang anda miliki untuk menuju ke dashboard. Don't have an account? <a href="#">Sign Up</a></p>
           <form id="form-login" name="fmLogin">
            <div class="auth-credentials m-b-xxl">
                <label for="signInEmail" class="form-label">Username</label>
                <input type="text" class="form-control m-b-md" id="username" name="username" aria-describedby="signInEmail" placeholder="newsandik" required>

                <label for="signInPassword" class="form-label">Password</label>
                <input type="password" class="form-control" id="signInPassword" name="password" aria-describedby="signInPassword" placeholder="&#9679;&#9679;&#9679;&#9679;&#9679;&#9679;&#9679;&#9679;" required>
            </div>

            <div class="auth-submit">
               <button type="submit" class="btn btn-primary btn-block btn-login" id="btnLogin">
                                            Masuk
                                        </button>
                <a href="#" class="auth-forgot-password float-end">Forgot password?</a>
            </div>
			 </form>
            <div class="divider"></div>
            <div class="auth-alts">
                <a href="#" class="auth-alts-google"></a>
                <a href="#" class="auth-alts-facebook"></a>
                <a href="#" class="auth-alts-twitter"></a>
            </div>
        </div>
    </div>
    
    <script src="../assets/plugins/jquery/jquery-3.5.1.min.js"></script>
    <script src="../assets/plugins/bootstrap/js/bootstrap.min.js"></script>
    <script src="../assets/plugins/perfectscroll/perfect-scrollbar.min.js"></script>
    <script src="../assets/plugins/pace/pace.min.js"></script>
    <script src="../assets/js/main.min.js"></script>
    <script src="../assets/js/custom.js"></script>
	<script src='../plugins/izitoast/js/iziToast.min.js'></script>
                <script type="text/javascript">
$(document).ready(function() {
			$('#form-login').submit(function(e) {
				var homeurl;
				homeurl = '<?php echo $homeurl; ?>';
				e.preventDefault();
				$.ajax({
					type: 'POST',
					url: 'ceklogin.php',
					data: $(this).serialize(),
					success: function(data) {
						console.log(data);
						if (data == "ok") {
							iziToast.success({
							   title: 'Login Berhasil!',
								message: "Anda akan dialihkan",
								titleColor: '#FFFF00',
								messageColor: '#fff',
								backgroundColor: 'rgba(0, 0, 0, 0.5)',
								progressBarColor: '#FFFF00',
								position: 'topRight'
							});
							setTimeout(function() {
								location.href = '.';
							}, 2000);
						}
						if (data == "nopass") {
							iziToast.error({
								title: 'Maaf!',
								message: 'Password Salah',
								titleColor: '#FFFF00',
								messageColor: '#fff',
								backgroundColor: 'rgba(0, 0, 0, 0.5)',
								progressBarColor: '#FFFF00',
								position: 'topRight'
							});

						}
						if (data == "td") {
							iziToast.error({
								title: 'Maaf!',
								message: 'Akun Tidak Terdaftar',
								titleColor: '#FFFF00',
								messageColor: '#fff',
								backgroundColor: 'rgba(0, 0, 0, 0.5)',
								progressBarColor: '#FFFF00',
								position: 'topRight'
							});
						}

					}
				})
				return false;
			});

		});

		function showpass() {
			var x = document.getElementById("pass");
			if (x.type === "password") {
				x.type = "text";
			} else {
				x.type = "password";
			}
		}
                </script>
                
</body>
</html>