<?php include('partials/menu.php'); ?>

<!-- Main Content Section Starts -->
<div class="main-content">
    <div class="wrapper">
        <h1 style="text-align: center;">لوحة تحكم مسؤول النظام</h1>
        <br><br>
        <?php 
            if(isset($_SESSION['login']))
            {
                echo $_SESSION['login'];
                unset($_SESSION['login']);
            }
        ?>
        <br><br>

        <div class="col-4 text-center">
            <?php 
                //Sql Query 
                $sql = "SELECT * FROM tbl_category";
                //Execute Query
                $res = mysqli_query($conn, $sql);
                //Count Rows
                $count = mysqli_num_rows($res);
            ?>
            <h1><?php echo $count; ?></h1>
            <br />
            فئات الطعام 
        </div>

        <div class="col-4 text-center">
            <?php 
                //Sql Query 
                $sql2 = "SELECT * FROM tbl_food";
                //Execute Query
                $res2 = mysqli_query($conn, $sql2);
                //Count Rows
                $count2 = mysqli_num_rows($res2);
            ?>
            <h1><?php echo $count2; ?></h1>
            <br />
            الوجبات المتوفرة
        </div>

        <div class="col-4 text-center">
            <?php 
                //Sql Query 
                $sql3 = "SELECT * FROM tbl_order";
                //Execute Query
                $res3 = mysqli_query($conn, $sql3);
                //Count Rows
                $count3 = mysqli_num_rows($res3);
            ?>
            <h1><?php echo $count3; ?></h1>
            <br />
            جميع الطلبات
        </div>

        <div class="col-4 text-center">
            <?php 
                //Creat SQL Query to Get Total Revenue Generated
                //Aggregate Function in SQL
                $sql4 = "SELECT SUM(total) AS Total FROM tbl_order WHERE status='Delivered'";

                //Execute the Query
                $res4 = mysqli_query($conn, $sql4);

                //Get the VAlue
                $row4 = mysqli_fetch_assoc($res4);

                //GEt the Total REvenue
                $total_revenue = $row4['Total'];
            ?>
            <h1><?php echo number_format($total_revenue, 2); ?> د.ع</h1>
            <br />
            جميع الايرادات
        </div>

        <div class="col-4 text-center">
            <?php 
                //Sql Query 
                $sql6 = "SELECT * FROM tbl_order WHERE status = 'Ordered'";
                //Execute Query
                $res6 = mysqli_query($conn, $sql6);
                //Count Rows
                $count6 = mysqli_num_rows($res6);
            ?>
            <h1><?php echo $count6; ?></h1>
            <br />
            الطلبات المعلقة
        </div>

        <div class="col-4 text-center">
            <?php 
                //Sql Query 
                $sql7 = "SELECT * FROM tbl_order WHERE status = 'On Delivery'";
                //Execute Query
                $res7 = mysqli_query($conn, $sql7);
                //Count Rows
                $count7 = mysqli_num_rows($res7);
            ?>
            <h1><?php echo $count7; ?></h1>
            <br />
            طلبات ذاهبة للتسليم
        </div>

        <div class="col-4 text-center">
            <?php 
                //Sql Query 
                $sql7 = "SELECT * FROM tbl_order WHERE status = 'Cancelled'";
                //Execute Query
                $res7 = mysqli_query($conn, $sql7);
                //Count Rows
                $count7 = mysqli_num_rows($res7);
            ?>
            <h1><?php echo $count7; ?></h1>
            <br />
            الطلبات التي تم الغاءها
        </div>

        <div class="col-4 text-center">
            <?php 
                //Sql Query 
                $sql8 = "SELECT * FROM tbl_admin";
                //Execute Query
                $res8 = mysqli_query($conn, $sql8);
                //Count Rows
                $count8 = mysqli_num_rows($res8);
            ?>
            <h1><?php echo $count8; ?></h1>
            <br />
            مسؤولين النظام المسجلين
        </div>

        <div class="clearfix"></div>

    </div>
</div>
<!-- Main Content Setion Ends -->

<?php include('partials/footer.php') ?>
