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

<!-- This page unique styles -->
<style>
/*Core setup styles*/
.sideNav{
    height: 100%;
    /*width: 220px;*/
    position: fixed;
    z-index: 9;
}
.navbar{
    top: 0;
    position: fixed;
    z-index: 9999;
}
.the-links{
    padding-top: 10px;
}
/*.nav-links{
    height: 100%;
    overflow-y: auto;
}*/
.insider{
    margin-top: 10px;
    position: relative;
}
.card{
    height: auto;
}
.cat-pag{
    position: relative;
}
.cat-page-header{
    position: sticky;
    width: 100%;
    height: 50px;
    background:#F7F9FB; 
    top: 60px;
    right: 60px;
    z-index: 1;
}
@media(max-width: 992px){
.insider{
    margin-top: 10px;
    padding-left: 10px;
    padding-right: 10px;
    }        
}
.card-header h5{
    font-size: 14px;
}

@media(max-width: 992px){
    .negative h5{
        font-size: 15px;
    }
    .negative a{
        font-size: 14px;
    }
    .negative a i{
        font-size: 14px;
    }
    .text-sm{
        font-size: 12px;
    }
}
.card-header h3{
    font-size: 18px;
    font-weight: bold;
    font-family: sans-serif;
    color: #3C763D;
}
.card-header h5{
    font-size: 14px;
    /*font-weight: bold;*/
    font-family: sans-serif;

}
.cat-page-header h5{
    font-family: sans-serif;
    font-size: 18px;
    font-weight: bold;
}
.success_stutus{
    background: #E8FCEF; color: #4ECA74;
}
.error_status{
    background: #F8D7DA; color: #90151C;
}
.cat-page-header .warning-text{
    color: #90151C;
    font-weight: normal;
    /*font-style: italic;*/
}
.cat-page-header .success-text{
    color: #4ECA74;
    font-weight: normal;
    /*font-style: italic;*/
}
.negative{
    width: 100%;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}
.negative i{
    font-size: 70px;
    color: #FE9C13;

}
.negative h5{
    font-size: 20px;
    color: #FE9C13;
    text-align: center;
    font-weight: bold;
    font-family: sans-serif; 
}
.negative a{
    padding: 10px;
    color: #fff;
    text-decoration: none;
    text-align: center;
    font-size: 17px;
    border-radius: 5px;
    /*font-weight: bold;*/
}
.negative a i{
    font-size: 17px;
    color: #fff;
}
.card{
    height: auto;
}
</style>
<?php



?>

<div id="notification-containers" class="notification-containers"></div>
<div class="insider">
    <div class="container">
        <div class="cat-pag">

            <div class="card mt-3">
                <div class="card-header text-center">
                    <h3>DE GOODNESS ACADEMY</h3>
                    <h5 class="text-success"><?= $current_class?> | 
                        <?= $current_term?>Term <?= $current_session?> Academic Session
                    </h5>

                </div>
                <div class="card-body">
                    <form action="" method="POST" id="mainForm">                       

                        <div class="table-responsive">
                            <table id="example" class="display table table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <th class="text-sm">S/N</th>
                                        <th class="text-sm">Subject</th>
                                        <th class="text-sm">Author</th>
                                    </tr>
                                </thead>
                                <tbody>
                                <!-- Display all student in this class -->
                                <?php
                                $sn = 0;
                                $allstd = "SELECT staffId, subject FROM teacher_assignments 
                                            WHERE class = ? ";
                                $stmt = $pdo->prepare($allstd);
                                $stmt->execute([$current_class]);
                                while ($stdRow = $stmt->fetch(PDO::FETCH_ASSOC)) {
                                    // $stdId      = $stdRow['studId'];
                                    $subject    = $stdRow['subject'];
                                    $staffId    = $stdRow['staffId'];
                                    // Get teachers
                                    $staName = "SELECT fullname, title FROM staff 
                                    WHERE staffId = ? ";
                                    $stastmt = $pdo->prepare($staName);
                                    $stastmt->execute([$staffId]);
                                    while ($stafRow = $stastmt->fetch(PDO::FETCH_ASSOC)) {
                                        $staffName = $stafRow['fullname'];
                                        $title     = $stafRow['title'];
                                    
                                    $sn = $sn + 1;
                                ?>
                                    <tr>
                                        <td class="text-sm"><?= $sn ?></td>
                                        <td class="text-sm">
                                            <?=$subject?>
                                        </td>
                                        <td class="text-sm">
                                            <?=$title.' '.$staffName?>
                                        </td>                                        
                                    </tr>
                                   <?php } } ?> 
                                </tbody>
                            </table>
                        </div>
                        
                    </form>
                </div>
            </div>
        </div>
   
    </div>
</div>



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

<!-- DataTables & jQuery -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css">
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>

<script>
    $(document).ready(function () {
        $('#example').DataTable();
        $('#SelectAllBoxes').click(function () {
            $('.checkBoxes').prop('checked', this.checked);
        });
    });

    function openModal(id) {
        document.getElementById(id).style.display = "block";
    }

    function closeModal(id) {
        document.getElementById(id).style.display = "none";
    }

    function handleDelete() {
        const checked = document.querySelectorAll("input[name='checkBoxArray[]']:checked");
        if (checked.length === 0) {
            alert("No products selected!");
            return;
        }
        openModal('modal-delete');
    }
   
</script>


<!-- Modal Styling -->
<style>
    .modal {
        display: none;
        position: fixed;
        z-index: 99999;
        left: 0; top: 0;
        width: 100%; height: 100%;
        overflow: auto;
        background-color: rgba(0,0,0,0.5);

    }

    .modal-content {
        background-color: #fff;
        margin: auto;
        padding: 20px;
        border-radius: 8px;
        width: 80%;
        max-width: 500px;
        animation: fadeIn 0.3s;
    }

    .modal-header, .modal-footer {
        font-weight: bold;
    }

    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(-20px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .label-wraps{
        width: 100%;
        padding-left: 30px;
        padding-right: 30px;
        display: flex;
        justify-content: space-between;
      
    }
    .input-wraps{
        width: 100%;
        display: flex;
        gap:8px;
        padding: 5px;
    }
    .price-box{
        width: 50%;
        height: 55px;
        /*border-bottom: 2px solid #ddd;*/
        border:2px solid #ddd;
        padding: 15px;
        border-radius: 10px;
    }
    .price-box span{
        font-size: 18px;
        color: #666;
        /*font-weight: bold;*/
    }
    .price-box input{
        width: 85%;
        
        border:none;
        outline: none;
        font-size: 16px;
        color: 888;
       /* height: 20px;*/
    }
    .quant-box{
        width: 50%;
        height: 55px;
        /*border-bottom: 2px solid #ddd;*/
        border:2px solid #ddd;
        padding: 15px;
        border-radius: 10px;
    }
    .quant-box input{
        width: 100%;
        border:none;
        outline: none;
        font-size: 16px;
        color: 888;
    }
</style>

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

