<?php 
	session_start();
    include "../../connection.php";
    
	
if (!isset($_SESSION['userid'])) {
    // Check if the cookie exists
    if (isset($_COOKIE['userid'])) {
        $_SESSION['userid'] = $_COOKIE['userid'];
    } else {
        header("Location: ../index.php");
        exit();
    }
}
?>

<?php 
        

        $sql = "SELECT COUNT(*) AS TopUpRqst FROM mobile_topup WHERE status = 'Pending'";
        $stmt = $con->prepare($sql);
        $stmt->execute();
        $stmt->bind_result($TopUpRqst);
        $stmt->fetch();
        $stmt->close();

        // Set a default value if there are no pending records
        $TopUpRqst = $TopUpRqst ?? 0; 




        $sql = "SELECT COUNT(*) AS addBalAuto FROM balance_history WHERE status = 'Pending'";
        $stmt = $con->prepare($sql);
        $stmt->execute();
        $stmt->bind_result($addBalAuto);
        $stmt->fetch();
        $stmt->close();

        // Set a default value if there are no pending records
        $addBalAuto = $addBalAuto ?? 0; 


        $sql = "SELECT COUNT(*) AS addBalMan FROM manual_add_money WHERE status = 'Pending'";
        $stmt = $con->prepare($sql);
        $stmt->execute();
        $stmt->bind_result($addBalMan);
        $stmt->fetch();
        $stmt->close();

        // Set a default value if there are no pending records
        $addBalMan = $addBalMan ?? 0; 



        $sql = "SELECT COUNT(*) AS MobileBank FROM mobile_banking WHERE status = 'Pending'";
        $stmt = $con->prepare($sql);
        $stmt->execute();
        $stmt->bind_result($MobileBank);
        $stmt->fetch();
        $stmt->close();

        // Set a default value if there are no pending records
        $MobileBank = $MobileBank ?? 0; 



        $sql = "SELECT COUNT(*) AS Bank FROM banking WHERE status = 'Pending'";
        $stmt = $con->prepare($sql);
        $stmt->execute();
        $stmt->bind_result($Bank);
        $stmt->fetch();
        $stmt->close();

        // Set a default value if there are no pending records
        $Bank = $Bank ?? 0; 



        $sql = "SELECT COUNT(*) AS billPay FROM bill_pay WHERE status = 'Pending'";
        $stmt = $con->prepare($sql);
        $stmt->execute();
        $stmt->bind_result($billPay);
        $stmt->fetch();
        $stmt->close();

        // Set a default value if there are no pending records
        $billPay = $billPay ?? 0; 



        $sql = "SELECT COUNT(*) AS BuyPack FROM drive_package_rqst WHERE status = 'Pending'";
        $stmt = $con->prepare($sql);
        $stmt->execute();
        $stmt->bind_result($BuyPack);
        $stmt->fetch();
        $stmt->close();

        // Set a default value if there are no pending records
        $BuyPack = $BuyPack ?? 0; 

    ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="stylesheet" href="https://site-assets.fontawesome.com/releases/v6.5.2/css/all.css">

    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800;900&display=swap" rel="stylesheet">

    <!-- CDN Start -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>

    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
    <!-- CDN End -->

    <!-- Link to style.css -->
    <link rel="stylesheet" href="style.css">
    <script src="main.js"></script>
    <title> EMT Admin </title>
</head>
<body>
<header> <!-- Navigation Menu -->
        <div class="navbar fixed-bottom nav-card">
            <div class="container">
                <div class="row w-100 text-center">
                    <div class="col-6">
                        <a href="index.php" class="nav-link nav-comp"><i class="font fa-regular fa-home"></i> <br>Home</a>
                    </div>
                  
                   
                    <div class="col-6">
                        <a href="logout.php" class="nav-link nav-comp text-danger"><i class="font fa-regular fa-arrow-up-from-square fa-rotate-270"></i> <br>LogOut</a>
                    </div>
                </div>
            </div>
        </div>
    </header> <!-- Navigation Menu -->
<main>
        <section> <!-- Top bar -->
            <div class="top-card mb-3">
                <div class="container text-center">
                    <div class="row  justify-content-center topbar">
                        <div class="col-7">
                            <a href="index.php" class="nav-link my-2" title="Home"> EMT Admin Panel </a>
                        </div>


                    </div>
                </div>
            </div>
        </section><!-- Top bar -->
    