<?php
    include "../../db.php";
    require '../../auth.php';
    restrictAccess(['Sub Associate']);
    date_default_timezone_set('Asia/Kolkata');
    $currentTime = date('M j, Y g:i a');

    if ( !isset($_SESSION['uid']) && !isset($_SESSION['uref']) && !isset($_SESSION['utype']) ) {
        header("Location: ../logout.php");
        exit();
    }

    $adm_sql = mysqli_query($con, "SELECT * FROM users WHERE uid = '$_SESSION[uid]' ");
    if($adm_row = mysqli_fetch_assoc($adm_sql)){
        $uadmin = $adm_row["uadmin"];
        $admin_ref = $adm_row["admin_ref"];
    }
?>

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

<head>
    <?php include "include/meta.php"; ?>
    <?php include "include/css.php"; ?>
    <?php include "include/php-functions.php"; ?>
</head>

<body>
    <!--  Header -->
    <?php 
    include "include/header.php"; 
    ?>
    <!-- #header -->

    <section id="inner-body">
        <div class="body-content">
            <div class="container-fluid">
                <div class="row align-items-center">
                    <div class="col-lg-3 col-md-3 col-12 mb-2">
                        <a href="new_entry.php" class="text-dark" style="text-decoration:none;">
                            <div class="card">
                                <div class="card-body">
                                    <div class="row align-items-center">
                                        <div class="col-md-8 col-6">
                                            <h5 class="card-title text-uppercase color-4b4be9">New Entry</h5>
                                        </div>
                                        <div class="col-md-4 col-6">
                                            <div class="text-end">
                                                <h2 class="color-f25f00">
                                                    <i class="fa fa-user-plus"></i>
                                                </h2>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </a>
                    </div>
                    <div class="col-lg-3 col-md-3 col-12 mb-2">
                        <a href="all-Data.php" class="text-dark" style="text-decoration:none;">
                            <div class="card">
                                <div class="card-body">
                                    <div class="row align-items-center">
                                        <div class="col-md-8 col-6">
                                            <h5 class="card-title text-uppercase color-4b4be9">All Data</h5>
                                        </div>
                                        <div class="col-md-4 col-6">
                                            <div class="text-end">
                                                <h2 class="color-f25f00">
                                                    <i class="fa fa-users"></i>
                                                </h2>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </a>
                    </div>

                    <div class="col-lg-3 col-md-3 col-12 mb-2">
                        <a href="global-Data.php" class="text-dark" style="text-decoration:none;">
                            <div class="card">
                                <div class="card-body">
                                    <div class="row align-items-center">
                                        <div class="col-md-8 col-6">
                                            <h5 class="card-title text-uppercase color-4b4be9">Global Data</h5>
                                        </div>
                                        <div class="col-md-4 col-6">
                                            <div class="text-end">
                                                <h2 class="color-f25f00">
                                                    <i class="fa fa-globe"></i>
                                                </h2>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </a>
                    </div>

                    <?php
                        $sql = "SELECT * FROM status WHERE s_by = '$uadmin' ORDER BY s_pos ASC";
                        $run = mysqli_query($con, $sql);
                        while ( $rows = mysqli_fetch_assoc($run) ) {
                    ?>
                    <div class="col-lg-3 col-md-3 col-12 mb-2">
                        <a href="status_view.php?<?php echo 'st='.$rows['s_id']; ?>" class="text-dark"
                            style="text-decoration:none;">
                            <div class="card">
                                <div class="card-body">
                                    <div class="row align-items-center">
                                        <div class="col-md-8 col-6">
                                            <h5 class="card-title text-uppercase color-4b4be9">
                                                <?php echo $rows['s_name']; ?></h5>
                                        </div>
                                        <div class="col-md-4 col-6">
                                            <div class="text-end">
                                                <h2 class="color-f25f00">
                                                    <i class="fa fa-tasks"></i>
                                                </h2>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </a>
                    </div>
                    <?php } ?>
                </div>
            </div>
        </div>

        <?php include "include/footer.php"; ?>
    </section>

    <!-- JavaScript Libraries -->

    <?php include "include/js.php"; ?>


</body>

</html>