<!-- Enter Student Attendance.php -->
<?php
include('session_validator.php');
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>SRMS Admin Manage Subjects</title>
    <link rel="stylesheet" href="css/bootstrap.min.css" media="screen">
    <link rel="stylesheet" href="css/font-awesome.min.css" media="screen">
    <link rel="stylesheet" href="css/animate-css/animate.min.css" media="screen">
    <link rel="stylesheet" href="css/lobipanel/lobipanel.min.css" media="screen">
    <link rel="stylesheet" href="css/prism/prism.css" media="screen">
    <link rel="stylesheet" href="css/select2/select2.min.css">
    <link rel="stylesheet" href="css/main.css" media="screen">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="js/modernizr/modernizr.min.js"></script>
</head>

<body class="top-navbar-fixed">
    <div class="main-wrapper">
        <?php include('includes/topbar.php'); ?>
        <div class="content-wrapper">
            <?php include('includes/leftbar.php'); ?>
            <div class="main-page">
                <div class="container-fluid">
                    <!-- Your existing HTML content -->
                </div>
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="panel">
                                <div class="panel-heading">
                                    <div class="panel-title">
                                        <h5>Enter Attendance</h5>
                                    </div>
                                </div>
                                <div class="panel-body">

                                    <form method="POST" action="process_attendance.php">
                                        <div class="form-group col-md-8">
                                            <label for="exam_type">Exam Type</label>
                                            <select id="exam_type" name="exam_type" class="form-control" required>
                                                <option value="">Select Exam Type</option>
                                                <!-- Options filled dynamically from the database -->
                                                <?php
                                                include("includes/db.php");
                                                $fetchExamTypesQuery = "SELECT id, exam_type FROM examination_type";
                                                $examTypesResult = $conn->query($fetchExamTypesQuery);
                                                if ($examTypesResult->num_rows > 0) {
                                                    while ($row = $examTypesResult->fetch_assoc()) {
                                                        echo '<option value="' . $row['id'] . '">' . $row['exam_type'] . '</option>';
                                                    }
                                                }
                                                ?>
                                            </select>
                                        </div>
<br>
                                        <div class="form-group col-md-8">
                                            <label for="class_id">Select Class:</label>
                                            <select id="class_id" name="class_id" class="form-control" required>
                                                <option value="">Select Class</option>
                                                <?php
                                                include("includes/db.php");
                                                $query = "SELECT class_id, class_name, section FROM classes";
                                                $result = $conn->query($query);
                                                while ($row = $result->fetch_assoc()) {
                                                    echo "<option value='" . $row['class_id'] . "'>" . $row['class_name'] . " - " . $row['section'] . "</option>";
                                                }
                                                ?>
                                            </select>
                                        </div>
<br>

                            <!-- Inside your form -->
                                <div class="form-group col-md-8">
                                    
                                    <div id="attendance-days-list"></div>
                                </div>
<br><br>
<div class="form-group col-md-8">
                                        <div style="margin-left: 5px;">
                                            <button type="submit" name="submit" class="btn btn-primary">Submit Attendance</button>
                                        </div>
                                    </div>
                                    </form>

                               </div>
                                            </div>
                                        </div>
                                    </div>
                                    <!-- /.col-md-12 -->
                                </div>
                    </div>
                </div>
                <!-- /.content-container -->
            </div>
            <!-- /.content-wrapper -->
        </div>
        <!-- /.main-wrapper -->
        <script src="js/jquery/jquery-2.2.4.min.js"></script>
        <script src="js/bootstrap/bootstrap.min.js"></script>
        <script src="js/pace/pace.min.js"></script>
        <script src="js/lobipanel/lobipanel.min.js"></script>
        <script src="js/iscroll/iscroll.js"></script>
        <script src="js/prism/prism.js"></script>
        <script src="js/select2/select2.min.js"></script>
        <script src="js/main.js"></script>


    <script>
$(document).ready(function () {
    // Triggered when class is selected
    $('#class_id').change(function () {
        var classId = $(this).val();

        // AJAX request to fetch students based on class
        $.ajax({
            type: 'POST',
            url: 'get_stn_atted.php',
            data: { classId: classId },
            success: function (response) {
                // Display student attendance day entry fields in the attendance-days-list div
                $('#attendance-days-list').html(response);
            }
        });
    });
});
</script>


      </body>
</html>