<%- include('../../Includes/begin.ejs') %>

    <link rel="stylesheet" href="../../CSS/admin-dashboard.css">

    <div class="container-fluid">

        <div id="wrapper">

            <%- include('../../Includes/admin_nav.ejs') %>

                <section id="content-wrapper">
                    <main role="main" class="pt-5 main">

                        <div class="main-content">
                            <div class="header pb-4 pb-sm-8 pt-5 pt-lg-8 d-flex align-items-center"
                                style="height: 100px; background-size: cover; background-position: center top;">

                            </div>
                            <div class="container-fluid mt--7">
                                <div class="row">
                                    <div class="col-xl-12 order-xl-1">
                                        <div class="card bg-secondary shadow">
                                            <div class="card-header bg-white border-0">
                                                <div class="row align-items-center">
                                                    <div class="col-8">
                                                        <h3 class="mb-0" style="color: brown;">ALL STUDENTS</h3>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="card-body">
                                                <%- include('../../Includes/messages') %>
                                                    <input class="form-control mb-4" id="searchInput" type="text"
                                                        placeholder="Search Students">
                                                    <h6 class="heading-small text-muted mb-4">STUDENT INFORMATION</h6>
                                                    <div class="table-responsive">
                                                        <table class="table">
                                                            <thead class="thead-dark">
                                                                <tr>
                                                                    <th scope="col">#</th>
                                                                    <th scope="col">Student Email</th>
                                                                    <th scope="col">Name</th>
                                                                    <th scope="col">Class</th>
                                                                    <th scope="col">Manage Student</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody id="studentTable">
                                                                <% for(var i=0; i < data.length; i++) { %>
                                                                    <tr>
                                                                        <th scope="row">
                                                                            <%= i + 1 %>
                                                                        </th>
                                                                        <td>
                                                                            <%= data[i].email %>
                                                                        </td>
                                                                        <td>
                                                                            <%= data[i].s_name %>
                                                                        </td>
                                                                        <td>
                                                                            <%= data[i].dept_id %>
                                                                        </td>
                                                                        <td><a href="/admin/settings/student/<%= data[i].email %>"
                                                                                class="btn btn-sm btn-primary">Settings</a>
                                                                        </td>
                                                                    </tr>
                                                                    <% } %>
                                                            </tbody>
                                                        </table>
                                                    </div>
                                                    </form>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </main>
                </section>
        </div>

    </div>

    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
        integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous">
        </script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
        integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous">
        </script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
        integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous">
        </script>

    <script>
        const $button = document.querySelector('#sidebar-toggle');
        const $wrapper = document.querySelector('#wrapper');

        $button.addEventListener('click', (e) => {
            e.preventDefault();
            $wrapper.classList.toggle('toggled');
        });
    </script>
    <script>
        $(document).ready(function () {
            $("#searchInput").on("keyup", function () {
                var value = $(this).val().toLowerCase();
                $("#studentTable tr").filter(function () {
                    $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
                });
            });
        });
    </script>
    </body>

    </html>