<?php
session_start();
$dbtype = "root";
require("includes/dbconnect.php");
require("includes/config.php");
require("includes/function.php");

$zheadroot = $_SESSION['zheadroot'] = $dbname;
//browse($zheadroot);
$zdir = $dbname;
$zcomp = 1;
$zdbroot = $zdir;
$focusfield = "user";
$formname = "EVA";
$addflag = '';
if (isset($_POST["submit"])) {
    $udbf = $zdbroot;
    //    browse($udbf);
    //    die();

    $login = mysqli_query($conn, "SELECT * FROM `passmain` WHERE `user` = '" . mysqli_real_escape_string($conn, $_POST['user']) . "'
                         AND `password` = '" . mysqli_real_escape_string($conn, $_POST['pass']) . "'") or die(mysqli_error($conn));

    //    browse(mysqli_num_rows($login));


    $_SESSION["zdbroot"] = $zdbroot;
    $_SESSION["zdir"] = $zdir;

    $_SESSION["zcompany"] = '';

    if (mysqli_num_rows($login) == 1) {

        $_SESSION['username_' . $dbname] = $_POST["user"];
        $_SESSION['logged-in'] = true;
        $getuser_dtl = mysqli_fetch_object($login);
        $admin = $getuser_dtl->admin;
        $_SESSION["series_" . $dbname] = $getuser_dtl->series;
        $_SESSION["usercode_" . $dbname] = $getuser_dtl->code;
        $_SESSION["usertype"] = $getuser_dtl->usertype;
        $_SESSION["username"] = $getuser_dtl->user;
        $_SESSION["admin_" . $dbname] = $admin;
        $_SESSION["zdbyear_$dbname"] = $dbyear;

        browse($getuser_dtl->series);

        header("Location: comp.php");
    } else {

        print '<script type="text/javascript">';
        print 'alert("Invalid Login Credentials")';
        print '</script>';
    }
}
// include("includes/linkshead_2.php");
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>EVA</title>
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet" />
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <link rel="icon" type="image/x-icon" href="images/evalogo.ico">
    <style>
        body {
            background: #fbfbfb;
            font-family: 'Raleway', sans-serif;
            margin: 0;
            padding: 0;
        }

        .navbar {
            z-index: 1100;
        }

        .navbar-brand img {
            height: 40px;
        }

        .carousel-item {
            height: 100vh;
            background-size: cover;
            background-position: center;
        }

        .login-form {
            position: absolute;
            top: 50%;
            left: 80%;
            transform: translate(-50%, -50%);
            background: rgba(255, 255, 255, 0.9);
            padding: 30px;
            border-radius: 15px;
            box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.2);
            width: 90%;
            max-width: 400px;
        }

        .form-group label {
            font-weight: bold;
        }

        .btn-custom {
            background-color: #5D5F63;
            border-radius: 21px;
            transition: background-color 0.3s;
        }

        .btn-custom:hover {
            background-color: #3694c1;
        }

        .title {
            background: linear-gradient(90deg, rgba(255,255,255,1) 0%, rgba(255,234,35,1) 0%, rgba(251,20,20,1) 100%);
            background-size: 200%;
            background-clip: text;
            color: transparent ;
            animation: text-animation 1.5s linear infinite;
        }

        @keyframes text-animation {
            0% {
                background-position: 0%;
            }
            100% {
                background-position: 200%;
            }
        }

        @media (max-width: 576px) {
            .login-form {
                padding: 20px;
                top: 60%;
            }

            .navbar-nav {
                flex-direction: column;
                align-items: center;
                gap: 5px;
            }
        }
    </style>
</head>

<body>
    <div id="carouselExample" class="carousel slide" data-ride="carousel">
        <div class="carousel-inner">
            <!-- <div class="carousel-item active" style="background-image: url('images/banner1.jpg');"></div> -->
            <div class="carousel-item active" style="background-image: url('images/evalogo1_enhanced_enhanced.png');"></div>
            <!-- <div class="carousel-item active" style="background-image: url('images/banner2.png');"></div> -->
            <!--<div class="carousel-item" style="background-image: url('images/banner3.jpg');"></div> -->
        </div>
        <a class="carousel-control-prev" href="#carouselExample" role="button" data-slide="prev">
            <span class="carousel-control-prev-icon" aria-hidden="true"></span>
            <span class="sr-only">Previous</span>
        </a>
        <a class="carousel-control-next" href="#carouselExample" role="button" data-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"></span>
            <span class="sr-only">Next</span>
        </a>
    </div>

    <!-- Login Form -->
    <div class="login-form">
        <h3 class="text-center title">Login</h3>
        <form method="post" action="">
            <div class="form-group">
                <label for="user-email">Username</label>
                <input type="text" class="form-control" id="user-email" name="user" placeholder="Enter Username" required autofocus />
            </div>
            <div class="form-group">
                <label for="user-password">Password</label>
                <input type="password" class="form-control" id="user-password" name="pass" placeholder="Password" required />
            </div>
            <div class="form-group text-center">
                <button type="submit" name="submit" class="btn btn-custom btn-block">Sign In</button>
            </div>
            <!--                <div class="form-group text-center">
                    <a href="forgpaswd.php" style="color: #0b4c78;"><u>Forgot Password?</u></a>
                </div>-->
        </form>
    </div>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</body>

</html>