<?php
ob_start();
session_start();
include('config/dbcon.php');




include('authentication.php');
//session_start();

include('include/header.php');
?>
 
<div class="container-fluid px-4">
        <h1 class="mt-4">Welcome <? echo $u['user_name']; ?></h1>
        <ol class="breadcrumb mb-4">
            <li class="breadcrumb-item active">Admin Dashboard</li>
        </ol>
        <?php include('../message.php'); ?>
        <div class="row">
                <?php // if( $_SESSION['auth_role'] == 2 || $_SESSION['auth_role'] == 1 && $u['user_name'] == 'PABC Division')  :  ?>
                <?php  if( $_SESSION['auth_role'] == 2 )  :  ?>
                <div class="col-xl-3 col-md-6">
                    <div class="card bg-primary text-white mb-4">
                        <div class="card-body">Total Category
                        <?php
                        $dash_category_query = "SELECT * FROM categories Where status = 0";
                        $dash_category_query_run= mysqli_query($con, $dash_category_query);

                            if($category_total= mysqli_num_rows($dash_category_query_run))
                            {
                                echo '<h4 class="mb-0">'.$category_total.'</h4>';
                            }else{
                                echo '<h4 class="mb-0">No data found</h4>';
                            }

                        ?>
                        </div>
                            <div class="card-footer d-flex align-items-center justify-content-between">
                            <a class="small text-white stretched-link" href="category-view.php">View Details</a>
                            <div class="small text-white"><i class="fas fa-angle-right"></i></div>
                        </div>
                    </div>
                </div>
                <?php endif; ?>
               
                <?php  if( $_SESSION['auth_role'] == 2 || $_SESSION['auth_role'] == 1 && $u['user_name'] == 'PABC Division')  :  ?>
                <div class="col-xl-3 col-md-6">
                    <div class="card bg-warning text-white mb-4">
                        <div class="card-body">Total Post
                        <?php
                        $dash_post_query = "SELECT * FROM posts";
                        $dash_post_query_run= mysqli_query($con, $dash_post_query);

                            if($post_total= mysqli_num_rows($dash_post_query_run))
                            {
                                echo '<h4 class="mb-0">'.$post_total.'</h4>';
                            }else{
                                echo '<h4 class="mb-0">No data found</h4>';
                            }

                        ?>    
                       </div>
                        <div class="card-footer d-flex align-items-center justify-content-between">
                            <a class="small text-white stretched-link" href="post-view.php">View Details</a>
                            <div class="small text-white"><i class="fas fa-angle-right"></i></div>
                        </div>
                    </div>
                </div>
                <?php endif; ?>
                 <?php  if( $_SESSION['auth_role'] == 2 || $_SESSION['auth_role'] == 1 && $u['user_name'] == 'PABC Division')  :  ?>
                <div class="col-xl-3 col-md-6">
                    <div class="card bg-info text-white mb-4">
                        <div class="card-body">Total Slider
                        <?php
                        $dash_post_query = "SELECT * FROM slider";
                        $dash_post_query_run= mysqli_query($con, $dash_post_query);

                            if($post_total= mysqli_num_rows($dash_post_query_run))
                            {
                                echo '<h4 class="mb-0">'.$post_total.'</h4>';
                            }else{
                                echo '<h4 class="mb-0">No data found</h4>';
                            }

                        ?>    
                       </div>
                        <div class="card-footer d-flex align-items-center justify-content-between">
                            <a class="small text-white stretched-link" href="slider-view.php">View Details</a>
                            <div class="small text-white"><i class="fas fa-angle-right"></i></div>
                        </div>
                    </div>
                </div>
                <?php endif; ?>
                
               
                <?php  if( $_SESSION['auth_role'] == 2)  :  ?>
                <div class="col-xl-3 col-md-6">
                    <div class="card bg-success text-white mb-4">
                        <div class="card-body">Total Service
                        <?php
                        $dash_service_query = "SELECT * FROM services";
                        $dash_servicery_run= mysqli_query($con, $dash_service_query);

                            if($service_total= mysqli_num_rows($dash_servicery_run))
                            {
                                echo '<h4 class="mb-0">'.$service_total.'</h4>';
                            }else{
                                echo '<h4 class="mb-0">No data found</h4>';
                            }

                        ?>     
                        </div>
                        <div class="card-footer d-flex align-items-center justify-content-between">
                            <a class="small text-white stretched-link" href="service-view.php">View Details</a>
                            <div class="small text-white"><i class="fas fa-angle-right"></i></div>
                        </div>
                    </div>
                </div>
                 <?php endif; ?>
                 
                 
                 
                <?php if ($_SESSION['auth_role'] == 2) : ?>
              
                    <div class="col-xl-3 col-md-6">
                        <div class="card bg-danger text-white mb-4">
                            <div class="card-body">Users

                            <?php
                            $dash_users_query = "SELECT * FROM users";
                            $dash_users_query_run= mysqli_query($con, $dash_users_query);

                                if($users_total= mysqli_num_rows($dash_users_query_run))
                                {
                                    echo '<h4 class="mb-0">'.$users_total.'</h4>';
                                }else{
                                    echo '<h4 class="mb-0">No data found</h4>';
                                }

                            ?>    

                            </div>
                            
                            <div class="card-footer d-flex align-items-center justify-content-between">
                                <a class="small text-white stretched-link" href="view-register.php">View Details</a>
                                <div class="small text-white"><i class="fas fa-angle-right"></i></div>
                            </div>
                        </div>
                    </div>
                <?php endif; ?>                  

            </div>
</div>

<?php
include('include/footer.php');

include('include/script.php');

?>