<?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-4">
                <a href="index.php?action=Assigned">
                    <div class="card gradient-deepblue">
                        <div class="card-body text-center">
                            <?php
                            $statusValues = array('Assigned To Sub-Admin', 'Replied By Sub-Admin');
                            $statusList = implode("', '", $statusValues);
                            $count_query = "SELECT COUNT(*) AS total_questions FROM `questions` WHERE status IN ('$statusList')";
                            $count_sql = $dbconn->prepare($count_query);
                            $count_sql->execute();
                            $total_questions_result = $count_sql->fetch(PDO::FETCH_ASSOC);
                            $total_questions = $total_questions_result['total_questions'];
                            ?>
                            <p class="mb-5 text-white small-font" style="font-size: 15px;">
                                <span class="float-right">
                                    Total Questions
                                </span>
                            </p>
                            <p class="mb-5 text-white small-font" style="font-size: 20px;">
                                <span class="float-right">
                                    <?= $total_questions ?>
                                </span>
                            </p>
                        </div>

                    </div>
                </a>
            </div>
            <div class="col-12 col-lg-6 col-xl-4">
                <a href="index.php?action=Answered-Question">
                    <div class="card gradient-orange">
                        <div class="card-body text-center">
                            <?php
                            $count_query = "SELECT COUNT(*) AS answered_questions FROM questions WHERE status = 'Replied By Sub-Admin'";
                            $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 class="col-12 col-lg-6 col-xl-4">
                <a href="index.php?action=Answered-Question">
                    <div class="card gradient-ohhappiness">
                        <div class="card-body text-center">
                            <?php
                            $count_query = "SELECT COUNT(*) AS unanswered_questions FROM questions WHERE status = 'Replied 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">
                                    Total Answered by Team
                                </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 Row-->
        <!-- 2nd row starts here  -->
        <div class="row">
            <div class="col-12 col-lg-6 col-xl-6">
                <a href="index.php?action=Assigned">
                    <div class="card gradient-ohhappiness">
                        <div class="card-body text-center">
                            <?php
                            $count_query = "SELECT COUNT(*) AS forwarded_questions FROM questions WHERE status = 'Assigned To Sub-Admin'";
                            $count_sql = $dbconn->prepare($count_query);
                            $count_sql->execute();
                            $forwarded_questions_result = $count_sql->fetch(PDO::FETCH_ASSOC);
                            $forwarded_questions = $forwarded_questions_result['forwarded_questions'];
                            ?>
                            <p class="mb-5 text-white small-font" style="font-size: 15px;">
                                <span class="float-right">
                                    Total Unanswered
                                </span>
                            </p>
                            <p class="mb-5 text-white small-font" style="font-size: 20px;">
                                <span class="float-right">
                                    <?= $forwarded_questions ?>
                                </span>
                            </p>
                        </div>

                    </div>
                </a>
            </div>
            <div class="col-12 col-lg-6 col-xl-6">
                <a href="index.php?action=Assigned">
                    <div class="card gradient-ibiza">
                        <div class="card-body text-center">
                            <?php
                            $count_query = "SELECT COUNT(*) AS forwarded_questions FROM questions WHERE status = 'Assigned To Sub-Admin'";
                            $count_sql = $dbconn->prepare($count_query);
                            $count_sql->execute();
                            $forwarded_questions_result = $count_sql->fetch(PDO::FETCH_ASSOC);
                            $forwarded_questions = $forwarded_questions_result['forwarded_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">
                                    <?= $forwarded_questions ?>
                                </span>
                            </p>
                        </div>

                    </div>
                </a>
            </div>
        </div>
        <div class="row">
            <div class="col-12 col-lg-6 col-xl-6">
                <a href="index.php?action=Assigned">
                    <div class="card gradient-ibiza">
                        <div class="card-body text-center">
                            <?php
                            $count_query = "SELECT COUNT(*) AS forwarded_questions FROM questions WHERE status = 'Assigned To Expert'";
                            $count_sql = $dbconn->prepare($count_query);
                            $count_sql->execute();
                            $forwarded_questions_result = $count_sql->fetch(PDO::FETCH_ASSOC);
                            $forwarded_questions = $forwarded_questions_result['forwarded_questions'];
                            ?>
                            <p class="mb-5 text-white small-font" style="font-size: 15px;">
                                <span class="float-right">
                                    Waiting for Acceptance
                                </span>
                            </p>
                            <p class="mb-5 text-white small-font" style="font-size: 20px;">
                                <span class="float-right">
                                    <?= $forwarded_questions ?>
                                </span>
                            </p>
                        </div>

                    </div>
                </a>
            </div>
            <div class="col-12 col-lg-6 col-xl-6">
                <a href="index.php?action=Assigned">
                    <div class="card gradient-ohhappiness">
                        <div class="card-body text-center">
                            <?php
                            $count_query = "SELECT COUNT(*) AS forwarded_questions FROM questions WHERE status = 'Rejected By Sub-Admin'";
                            $count_sql = $dbconn->prepare($count_query);
                            $count_sql->execute();
                            $forwarded_questions_result = $count_sql->fetch(PDO::FETCH_ASSOC);
                            $forwarded_questions = $forwarded_questions_result['forwarded_questions'];
                            ?>
                            <p class="mb-5 text-white small-font" style="font-size: 15px;">
                                <span class="float-right">
                                    Total Rejected Answer
                                </span>
                            </p>
                            <p class="mb-5 text-white small-font" style="font-size: 20px;">
                                <span class="float-right">
                                    <?= $forwarded_questions ?>
                                </span>
                            </p>
                        </div>

                    </div>
                </a>
            </div>
        </div>
        <!-- ends here  -->

        <!--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-->