<?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><?= $formname ?></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">

    <script type="text/javascript" src="MyScript/index.js"></script>
    <style>
        /* Style the form to be centered and positioned over the carousel */
        .login-form {
            position: absolute;
            top: 55%;
            left: 75%;
            transform: translate(-50%, -50%);
            background: rgba(255, 255, 255, 0.8);
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
            z-index: 1000;
            width: 25%;
            max-width: 400px;
            /* Ensure form doesn't get too wide on larger screens */
        }

        #signup {
            color: #2dbd6e;
            font-family: "Raleway", sans-serif;
            font-size: 10pt;
            margin-top: 16px;
            text-align: center;
        }

        #sub-otp, #otp-btn, #submit-btn {
            background: linear-gradient(90deg, rgba(47, 191, 254, 1) 0%, rgba(47, 191, 254, 1) 100%);
            border: none;
            border-radius: 21px;
            cursor: pointer;
            color: white;
            font-family: "Raleway SemiBold", sans-serif;
            height: 42.3px;
            margin: 0 auto;
            margin-top: 20px;
            transition: 0.25s;
            width: 50%;
        }

        .carousel-item {
            height: 100vh;
            background-size: contain;
            background-position: contain;
            background-repeat: no-repeat;
            top: -30%;
        }

        .navbar {
            z-index: 1100;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .navbar-nav {
            flex-direction: row;
            gap: 15px;
            margin-right: 12%;
        }

        .navbar-nav .nav-item {
            margin-left: 20px;
        }

        .nav-link {
            position: relative;
            display: inline-block;
            color: #333;
            font-weight: bold;
            text-decoration: none;
        }

        .nav-link::after {
            content: '';
            position: absolute;
            width: 0;
            height: 2px;
            background-color: #333;
            left: 0;
            bottom: -5px;
            transition: width 0.3s ease-in-out;
        }

        .nav-link:hover::after {
            width: 100%;
        }
        /* Fixed underline for the active page */
.nav-item.active .nav-link::after {
    width: 100%;
    background-color: #333;
}

        /* Adjustments for small screens */
        @media (max-width: 576px) {
            .login-form {
                width: 50%;
                padding: 15px;
                top: 70%;
                left: 50%;
            }

            .navbar-brand img {
                width: 80px;
                height: auto;
            }

            .carousel {
                display: none;
            }

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

<body>
    <!-- Responsive Navbar -->
    <!-- <nav class="navbar navbar-expand-lg navbar-light bg-light">
        <a class="navbar-brand" href="#">
            <img src="images/AtlasTourslogo.png" style="height:30%;width:40%;margin-left: 30%;" alt="Logo">
        </a>
        <ul class="navbar-nav">
            <li class="nav-item active">
                <a class="nav-link" href="#">Home</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Booking Center</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Franchise</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Contact Us</a>
            </li>
        </ul>
    </nav> -->

    <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" 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">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" autocomplete="on" required autofocus />
            </div>
            <div class="form-group">
                <label for="user-password">Password</label>
                <input type="password" class="form-control" id="user-password" name="pass" required placeholder="Password">
            </div>
            <div class="form-group">
                <label for="" class="otptable" style="display: none;">Enter OTP</label>
                <input type="password" class="form-control otptable" style="display: none;" id="user-otp" name="user-otp">
            </div>
            <div class="form-group">
                                <button type="submit" name="submit" class="btn btn-primary btn-block" style="background-color: #47a3da">Sign in <i class="icon-circle-right2 position-right"></i></button>
                            </div>
            <!-- <div class="form-group text-center">
                <input id="submit-btn" class="btn btn-primary" type="submit" name="submit" value="LOGIN" style="display:none">
                <button id="otp-btn" class="btn btn-primary" type="button" name="otp-btn" value="LOGIN">LOGIN</button>
                <input id="sub-otp" class="btn btn-primary" type="button" name="otp-btn" value="SUBMIT" style="display:none">
            </div> -->
            <!-- <div class="form-group text-center">
                <a href="forgpaswd.php" class="forgpass" style="margin-top: 10%;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>


<!-- <style type="text/css">
    a {
        text-decoration: none;
    }

    body {
        background: #fbfbfb;
        background-repeat: no-repeat;
    }

    label {
        font-family: "Raleway", sans-serif;
        font-size: 11pt;
    }

    #card {
        background: #ffffff;
        border-radius: 10px;
        box-shadow: 1px 2px 8px rgba(0, 0, 0, 0.65);
        height: 410px;
        margin: 6rem auto 8.1rem auto;
        width: 329px;
        margin-top: 100px;
    }

    #card-content {
        padding: 12px 44px;
    }

    #card-title {
        font-family: "Raleway Thin", sans-serif;
        letter-spacing: 4px;
        padding-bottom: 14px;
        padding-top: 13px;
        text-align: center;
    }

    #signup {
        color: #2dbd6e;
        font-family: "Raleway", sans-serif;
        font-size: 10pt;
        margin-top: 16px;
        text-align: center;
    }

    #sub-otp {
        background: rgb(47, 191, 254);
        background: linear-gradient(90deg, rgba(47, 191, 254, 1) 0%, rgba(47, 191, 254, 1) 35%, rgba(47, 191, 254, 1) 100%);
        box-shadow: 0 5px 15px rgba(242, 97, 103, .4);
        /* background: -webkit-linear-gradient(right, #a6f77b, #2dbd6e); */
        border: none;
        border-radius: 21px;
        /* box-shadow: 0px 1px 8px #24c64f; */
        cursor: pointer;
        color: white;
        font-family: "Raleway SemiBold", sans-serif;
        height: 42.3px;
        margin: 0 auto;
        margin-top: 50px;
        transition: 0.25s;
        width: 153px;
    }


    #otp-btn {
        background: rgb(254, 191, 47);
        background: linear-gradient(90deg, rgba(254, 191, 47, 1) 0%, rgba(254, 191, 47, 1) 35%, rgba(254, 191, 47, 1) 100%);
        box-shadow: 0 5px 15px rgba(242, 97, 103, .4);
        /* background: -webkit-linear-gradient(right, #a6f77b, #2dbd6e); */
        border: none;
        border-radius: 21px;
        /* box-shadow: 0px 1px 8px #24c64f; */
        cursor: pointer;
        color: white;
        font-family: "Raleway SemiBold", sans-serif;
        height: 42.3px;
        margin: 0 auto;
        margin-top: 50px;
        transition: 0.25s;
        width: 153px;
    }

    #submit-btn {
        background: rgb(47, 191, 254);
        background: linear-gradient(90deg, rgba(47, 191, 254, 1) 0%, rgba(47, 191, 254, 1) 35%, rgba(47, 191, 254, 1) 100%);
        box-shadow: 0 5px 15px rgba(242, 97, 103, .4);
        /* background: -webkit-linear-gradient(right, #a6f77b, #2dbd6e); */
        border: none;
        border-radius: 21px;
        /* box-shadow: 0px 1px 8px #24c64f; */
        cursor: pointer;
        color: white;
        font-family: "Raleway SemiBold", sans-serif;
        height: 42.3px;
        margin: 0 auto;
        margin-top: 50px;
        transition: 0.25s;
        width: 153px;
    }

    #submit-btn:hover {
        box-shadow: 0 5px 15px rgba(242, 97, 103, .4);
    }

    #otp-btn:hover {
        box-shadow: 0 5px 15px rgba(242, 97, 103, .4);
    }

    .form {
        align-items: left;
        display: flex;
        flex-direction: column;
    }

    .form-border {
        background: rgb(47, 191, 254);
        background: linear-gradient(90deg, rgba(47, 191, 254, 1) 0%, rgba(47, 191, 254, 1) 35%, rgba(47, 191, 254, 1) 100%);
        height: 1px;
        width: 100%;
    }

    .form-content {
        background: #fbfbfb;
        border: none;
        outline: none;
        padding-top: 14px;
    }

    .underline-title {
        background: rgb(47, 191, 254);
        background: linear-gradient(90deg, rgba(47, 191, 254, 1) 0%, rgba(47, 191, 254, 1) 35%, rgba(47, 191, 254, 1) 100%);
        height: 2px;
        margin: -1.1rem auto 0 auto;
        width: 160px;
    }



    /*@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');*/

    .headercss {
        font-size: 40px;
        font-weight: 600;
        font-family: 'Roboto', sans-serif;
        color: #0b4c78;
        text-transform: uppercase;
    }
</style>
<script type="text/javascript" src="MyScript/index.js"></script>
</head>

<body class="animated fadeIn">
    <div id="card">
        <div id="card-content">
            <div id="card-title">
                <h2 class="headercss"><?= $project_title ?></h2>
            </div>

            <form method="post" class="form">

                <label for="user-email" style="padding-top:13px">
                    &nbsp;Username
                </label>

                <input id="user-email" class="form-content" type="text" name="user" autocomplete="on" required autofocus />

                <div class="form-border"></div>

                <label for="user-password" style="padding-top:22px">&nbsp;Password</label>

                <input id="user-password" class="form-content" type="password" name="pass" required />

                <label for="" class="otptable" style="padding-top:22px;display: none">&nbsp;Enter OTP</label>

                <input id="user-otp" class="form-content otptable" type="password" name="user-otp" style="display:none"/>

                <div class="form-border"></div>

                <input id="submit-btn" type="submit" name="submit" value="LOGIN" style="display:none" />
                <input id="otp-btn" type="button" name="otp-btn" value="LOGIN" />
                <input id="sub-otp" type="button" name="otp-btn" value="SUBMIT" style="display:none"/>
                <a href="forgpaswd.php" class="forgpass" style="margin-left: 24%;margin-top: 10%;color: #0b4c78;"><u>Forgot Password</u></a>
            </form>
        </div>
    </div>

<?php // include("includes/linksfoot.php") ?>
</body>

</html> -->