<?php session_start();?>
<?php include'includes/header.php'; ?>
<?php include'includes/sidebar.php';?>
<?php include'includes/functions.php';?>
<?php include'includes/navbar.php'; ?>

<!-- Handle Add Slider -->
<style>
 
.form-wraps{
    width: 100%;
    height: 500px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding-bottom: 20px;
}
.form-responsive{
    width: 450px;
    height: auto;
    padding: 15px;
    border:1px solid #ccc;
    border-radius: 6px;
    /*background: #fff;*/
}
@media(max-width: 992px){
    .form-responsive{
        width: 100%;
        /*padding-left: 20px;
        padding-right: 20px;*/
    }
}   
.card-header{
    width: 100%;
    display: flex;
    align-items: center;
    gap:15px;
}
.card-header span{
    font-size: 13px;
    font-weight: bold;
    font-family: sans-serif;
    color: #3C763D;
}

    

.sing-form{
    width: 100%;
    margin-top: 20px;
}
.sing-form span{
    font-size: 17px;
    font-weight: bold;
}
.sing-form select{
    width: 100%;
    height: 45px;
    border:2px solid #ccc;
    padding-left: 10px;
    padding-right: 10px;
    border-radius: 5px;
    outline: none;
}
.sing-form button{
    width: 100%;
    padding: 10px;
    color: #fff;
    font-size: 18px;
    font-weight: bold;
    border-radius: 6px;
    border:none;
    outline: none;
}
</style>


<div id="notification-containers" class="notification-containers"></div>
<div class="insider" style="background: #F9FAFC;">
    <div class="container">
        <div class="cat-pag">
            <!-- <div class="cat-page-header d-flex justify-content-between align-items-center">
                
                <div>
                    <a href="test_score.php?class=<?=$class.'*'.$subject?>" class="btn info text-white">Add New Student <i class="fa fa-user-plus"></i></a>

                    <a href="exam_score.php?class=<?=$class.'*'.$subject?>" class="btn invoice text-white">Remove <i class="fa fa-user-minus"></i></a>
                </div>
            </div> -->
            <form action="" method="POST">
                <div class="form-wraps">
                    <div class="form-responsive">
                        <div class="card-header">
                            <span>Continue With Current Result</span>
                            <button class="btn info text-white" name="check-btn">Check 
                                <i class="fa fa-search"></i>
                            </button>
                        </div>
                        <div class="sing-form">
                            <span>Class</span>
                            <select name="class">
                                <?php
                                $getClass = "SELECT DISTINCT class FROM results WHERE stdId = ?";
                                $stmt = $pdo->prepare($getClass);
                                $stmt->execute([$stdId]);
                                while ($classRow = $stmt->fetch(PDO::FETCH_ASSOC)) {
                                   $dataClass = $classRow['class'];?>
                                ?>
                                <option value="" hidden="">-- Select --</option>
                                <option value="<?=$dataClass?>"><?=$dataClass?></option>
                                <?php } ?>
                            </select>
                        </div>

                        <div class="sing-form">
                            <span>Session</span>
                            <select name="session">
                                <?php
                                $getSession = "SELECT DISTINCT session FROM results 
                                            WHERE stdId = ?";
                                $stmt = $pdo->prepare($getSession);
                                $stmt->execute([$stdId]);
                                while ($sessionRow = $stmt->fetch(PDO::FETCH_ASSOC)) {
                                   $dataSession = $sessionRow['session'];?>
                                ?>
                                <option value="" hidden="">--Select--</option>
                                <option value="<?=$dataSession?>"><?=$dataSession?></option>
                                <?php } ?>
                            </select>
                        </div>

                        <div class="sing-form">
                            <span>Term</span>
                            <select name="term">
                                <?php
                                $getTerm = "SELECT DISTINCT term FROM results WHERE stdId = ?";
                                $stmt = $pdo->prepare($getTerm);
                                $stmt->execute([$stdId]);
                                while ($termRow = $stmt->fetch(PDO::FETCH_ASSOC)) {
                                   $dataTerm = $termRow['term'];?>
                                ?>
                                <option value="" hidden="">--Select--</option>
                                <option value="<?=$dataTerm?>"><?=$dataTerm?></option>
                                <?php } ?>
                            </select>
                        </div>
                        <div class="sing-form">
                            <button class="info" name="search-btn">Search <i class="fa fa-search"></i></button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
   
    </div>
</div>

<?php
if (isset($_POST['check-btn'])) {
    $term = $current_term;
    $session = $current_session;
    $class = $current_class;

    $_SESSION['req-term'] = $term;
    $_SESSION['req-session'] = $session;
    $_SESSION['req-class'] = $class;

    header('Location:my-result.php');
}
if (isset($_POST['search-btn'])) {
    
    
    $_SESSION['req-term'] = $_POST['term'];
    $_SESSION['req-session'] = $_POST['session'];
    $_SESSION['req-class'] = $_POST['class'];

    header('Location:my-result.php');
}
?>


<?php include 'includes/footer.php'; ?>



<!-- Notifications alert -->
<?php include'includes/notification-alert-js.php';?>

