<?php
if ($master_user_role == 'Branch-Manager') {
    header("Location: index.php?action=Branch-Dashboard");
}
?>

<div class="clearfix"></div>
<div class="content-wrapper">
    <div class="container-fluid">
        <!--Start Dashboard Content-->

        <div class="row mt-3">
            <div class="col-12 col-lg-6 col-xl-6">
                <a href="index.php?action=Assigned-To-Me">
                    <div class="card gradient-orange">
                        <div class="card-body text-center">
                            <?php
                            $statusValues = array('Assigned To Expert', 'Replied By Expert');
                            $statusList = implode("', '", $statusValues);
                            $count_query = "SELECT COUNT(*) AS answered_questions FROM questions WHERE status = 'Assigned To Expert'";
                            $count_sql = $dbconn->prepare($count_query);
                            $count_sql->execute();
                            $answered_questions_result = $count_sql->fetch(PDO::FETCH_ASSOC);
                            $answered_questions = $answered_questions_result['answered_questions'];
                            ?>
                            <p class="mb-5 text-white small-font" style="font-size: 15px;">
                                <span class="float-right">
                                    Total Assigned To Me
                                </span>
                            </p>
                            <p class="mb-5 text-white small-font" style="font-size: 20px;">
                                <span class="float-right">
                                    <?= $answered_questions ?>
                                </span>
                            </p>
                        </div>
                    </div>
                </a>
            </div>
            <div class="col-12 col-lg-6 col-xl-6">
                <a href="index.php?action=Answered-Ques">
                    <div class="card gradient-deepblue">
                        <div class="card-body text-center">
                            <?php
                            $count_query = "SELECT COUNT(*) AS answered_questions FROM questions WHERE status = 'Replied By Expert'";
                            $count_sql = $dbconn->prepare($count_query);
                            $count_sql->execute();
                            $answered_questions_result = $count_sql->fetch(PDO::FETCH_ASSOC);
                            $answered_questions = $answered_questions_result['answered_questions'];
                            ?>
                            <p class="mb-5 text-white small-font" style="font-size: 15px;">
                                <span class="float-right">
                                    Total Answered By Me
                                </span>
                            </p>
                            <p class="mb-5 text-white small-font" style="font-size: 20px;">
                                <span class="float-right">
                                    <?= $answered_questions ?>
                                </span>
                            </p>
                        </div>
                    </div>
                </a>
            </div>
        </div><!--End Row-->
        
        <!-- 2nd row starts here  -->
        <div class="row">
            <div class="col-12 col-lg-6 col-xl-6">
                <a href="index.php?action=Rejected-by-sub-admin">
                    <div class="card gradient-ohhappiness">
                        <div class="card-body text-center">
                            <?php
                            $count_query = "SELECT COUNT(*) AS unanswered_questions FROM questions WHERE status = 'Rejected By Sub-Admin'";
                            $count_sql = $dbconn->prepare($count_query);
                            $count_sql->execute();
                            $unanswered_questions_result = $count_sql->fetch(PDO::FETCH_ASSOC);
                            $unanswered_questions = $unanswered_questions_result['unanswered_questions'];
                            ?>
                            <p class="mb-5 text-white small-font" style="font-size: 15px;">
                                <span class="float-right">
                                    Waiting for Answers
                                </span>
                            </p>
                            <p class="mb-5 text-white small-font" style="font-size: 20px;">
                                <span class="float-right">
                                    <?= $unanswered_questions ?>
                                </span>
                            </p>
                        </div>
                    </div>
                </a>
            </div>
            <div class="col-12 col-lg-6 col-xl-6">
                <a href="index.php?action=Rejected-by-sub-admin">
                    <div class="card gradient-ibiza">
                        <div class="card-body text-center">
                            <?php
                            $count_query = "SELECT COUNT(*) AS unanswered_questions FROM questions WHERE status = 'Rejected By Sub-Admin'";
                            $count_sql = $dbconn->prepare($count_query);
                            $count_sql->execute();
                            $unanswered_questions_result = $count_sql->fetch(PDO::FETCH_ASSOC);
                            $unanswered_questions = $unanswered_questions_result['unanswered_questions'];
                            ?>
                            <p class="mb-5 text-white small-font" style="font-size: 15px;">
                                <span class="float-right">
                                    Rejected By Sub-Admin
                                </span>
                            </p>
                            <p class="mb-5 text-white small-font" style="font-size: 20px;">
                                <span class="float-right">
                                    <?= $unanswered_questions ?>
                                </span>
                            </p>
                        </div>
                    </div>
                </a>
            </div>
        </div>
        <!--End 2nd Row-->

        <!--End Dashboard Content-->
        <div class="overlay toggle-menu"></div>
        <!--end overlay-->
    </div>
</div><!--End content-wrapper-->

<!--Start Back To Top Button-->
<a href="javaScript:void();" class="back-to-top"><i class="fa fa-angle-double-up"></i> </a>
<!--End Back To Top Button-->
