<?php
if (isset($_SESSION['student_id'])) {
    $CI = &get_instance();
    $CI->load->model('Admin_model');
    $query = "SELECT students.name, students.email, classroom.classroom_name,classroom.id as classroom_id, classroom.course_id FROM students INNER JOIN student_batch sb on students.id = sb.student_id inner join  classroom ON sb.classroom_id = classroom.id WHERE students.id = '" . $_SESSION['student_id'] . "'";
    $get_class = $CI->Admin_model->get_table_info('students', '', $query);
    if (!empty($get_class)) {
        $classRoomId = $get_class[0]['classroom_id'];
        $notification_query = "SELECT * from notifications where notification_read = 'No' AND student_classroom = '" . $classRoomId . "' ORDER BY notification_id DESC LIMIT 5";
        $notifications = $CI->Admin_model->get_notification_details('', $notification_query);
    }
}

$schoolInfo = $this->Admin_model->get_logo_from_setting();
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="robots" content="noindex, nofollow">
    <title><?php echo (isset($schoolInfo['school_name']) && !empty($schoolInfo['school_name'])) ? $schoolInfo['school_name'] : 'Application Name'; ?> </title>
    <link rel="icon" type="image/x-icon" href="<?php echo base_url(); ?>common_assets/fav.png">
    <!--styles links-->
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets_admin/css/bootstrap.min.css">
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets_admin/css/jquery-ui.min.css">
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets_student/css/font-family.css">
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets_student/css/all.css">
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets_admin/owl-carousel/css/owl.carousel.min.css">
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets_student/css/fontawesome.min.css" />
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets_admin/css/jquery.dataTables.min.css" />
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets_student/css/style.css">
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets_student/css/style-responsive.css">
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets_student/css/mobile.css">
    <script src="<?php echo base_url(); ?>assets_student/js/jquery-3.6.0.min.js"></script>
    <script src="<?php echo base_url(); ?>assets_student/js/jquery.validate.js"></script>
    <script src="<?php echo base_url(); ?>assets_student/js/jquery-ui.min.js"></script>
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets_admin/css/nepali.datepicker.v3.7.min.css">
    <script src="<?php echo base_url(); ?>assets_admin/js/nepali.datepicker.v3.7.min.js" type="text/javascript"></script>
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets_admin/css/datatable/buttons.dataTables.min.css">
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets_admin/css/datatable/dt-custom.css">

    <link rel="stylesheet" href="<?php echo base_url(); ?>assets_admin/css/bootstrap-float-label.min.css" />
    <!--sweet alert -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert-dev.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css">
    <?php

    if (empty($notifications)) { ?>
        <style>
            .notification-icon-wrap:after {
                content: none;
            }
        </style>
    <?php }

    ?>
</head>

<body>

    <?php if (isset($_SESSION['student_id'])) {  ?>
        <header class="common_margin">
            <div class="search-bar-wrappp">
                <!-- <input type="text" name="" placeholder="Search.."> -->
            </div>
            <div class="user-login-section">
                <div class="notification-icon-wrap">
                    <img src="<?php echo base_url(); ?>assets_student/images/notification.png">
                    <span></span>
                    <div class="notifications-wrap">
                        <div class="notifications">
                            <h4>Notifications</h4>
                            <ul>
                                <?php if (!empty($notifications)) { ?>
                                    <?php foreach ($notifications as $key => $value) { ?>
                                        <li class="notification-row">
                                            <a class="text-white" href="<?php echo base_url() ?>teacher/teacher_notification">
                                                <p><?php echo $value['description'] ?></p>
                                            </a>
                                            <i class="fas fa-trash-alt" onclick="delete_notificaton('<?php echo $value['notification_id'] ?>',$(this).parent())"></i>
                                        </li>
                                    <?php } ?>
                                <?php } else {
                                    echo "<li><p>There no new notifications</p></li>";
                                } ?>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="user-wrap">
                    <div class="user-login-head">
                        <!--img src="<?php echo base_url(); ?>assets_student/images/A.png"-->
                        <h5 title="<?php echo $_SESSION['student_name']; ?>"><span class="user-name"><?php echo $_SESSION['student_name']; ?></span><i class="fa fa-caret-down" aria-hidden="true"></i><i class="fa fa-caret-up" aria-hidden="true"></i></h5>
                    </div>
                    <div class="login-wrap-open">
                        <ul>
                            <li><a href="<?= base_url(); ?>student/my-info"><span><i class="fa fa-user" aria-hidden="true"></i></span>My Profile</a></li>
                            <li><a href="<?= base_url(); ?>Student/student_logout"><span><i class="fas fa-sign-out-alt"></i></span>Sign Out</a></li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="mobileMenu">
                <i class="fas fa-bars"></i>
            </div>
        </header>

        <aside id="mySidebar" class="sideMenu">
            <div class="logo-wrap">
                <img src="<?= base_url(); ?>common_assets/<?= $schoolInfo['logo']; ?>">
            </div>
            <ul>
                <?php $url = explode(base_url(), $currentURL); ?>
                <?php foreach ($menulist as $menu) {
                ?>
                    <li class="list <?php if (str_replace('index.php/', '', $url[1]) == $menu['page_link']) {
                                        echo 'active';
                                    } ?> ">
                        <a href="<?php echo base_url(); ?><?php echo $menu['page_link']; ?>">
                            <!-- <img src="<?php echo base_url(); ?>assets_student/images/<?php echo $menu['inactive_icon']; ?>" class="icon-inactive"> -->
                            <img src="<?php echo base_url(); ?>assets_student/images/<?php echo $menu['active_icon']; ?>" class="icon-active">
                            <span><?php echo $menu['menu_name']; ?></span>
                        </a>
                    </li>
                <?php } ?>
            </ul>
        </aside>
    <?php } ?>