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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Auditoría asistencial</title>
    <?php
    include 'import/html_css_files.php';
    ?>
    <link rel="stylesheet" type="text/css" href="https://unpkg.com/trix@2.0.0/dist/trix.css">
    <style>
        [v-cloak] {
            display: none;
        }
    </style>
    <script src="js/jquery.min.js"></script>
    <script src="js/jquery-ui.js"></script>
    <script src="js/bootstrap/bootstrap.min.js"></script>
</head>

<body>
    <?
    $redirect = $_SERVER['PHP_SELF'];
    include "import/html_header.php";
    global $user;

    html_header(
        "Carreras",
        "Sistema de gestión de checador",
    );
    ?>
    <main class="container-fluid px-4 my-4" id="app" v-cloak @vue:mounted="mounted" style="min-height: 70vh;">
        <section class="row mt-4">
            <div class="col-12 position-relative">
                <!-- Loop for messages -->
                <div class="toast show shadow-sm mb-3 bg-white"
                    style="position: fixed; top: 15%; right: 1%; max-width: 300px;" role="alert" aria-live="assertive"
                    aria-atomic="true"
                    @vue:mounted="$('.toast').toast({delay: 5000}).toast('show').on('hidden.bs.toast', () => { message.text = '' })"
                    v-if="message.text">
                    <div class="toast-header">
                        <strong class="mr-auto text-primary text-uppercase text-center w-100 px-4">
                            {{ message.title }}
                        </strong>
                        <small class="text-muted">{{ message.timestamp }}</small>
                        <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close"
                            @click="message.text = ''">
                            <span aria-hidden="true">
                                <i class="fas fa-times"></i>
                            </span>
                        </button>
                    </div>
                    <div class="toast-body">
                        <div :class="message.type == 'success' ? 'text-success' : 'text-danger'"><i
                                :class="message.type == 'success' ? 'fas fa-check-circle' : 'fas fa-times-circle'"></i>
                            {{ message.text }}
                        </div>
                    </div>
                </div>
            </div>
        </section>
        <div class="container">
            <div class="row" v-for="facultad in carreras">
                <!-- Facultad Card -->
                <div class="card col-12 mb-4 shadow-lg">
                    <div class="card-header bg-primary text-white">
                        <h3 class="mb-1">{{ facultad.facultad_nombre }}</h3>
                    </div>
                    <div class="card-body bg-white">
                        <div class="row justify-content-center">
                            <!-- Loop for Carreras -->
                            <div class="col-md-6 mb-3" v-for="carrera in facultad.carreras">
                                <div class="card border-secondary mb-3 shadow-sm">
                                    <div class="card-body">
                                        <h5 class="card-title text-primary text-uppercase text-center w-100 px-4 mb-3 text-truncate text-break border-bottom border-secondary pb-2"
                                            :title="carrera.carrera_nombre">
                                            {{ carrera.carrera_nombre }}
                                        </h5>

                                        <!-- Dropdown for Niveles -->
                                        <div class="dropdown">
                                            <button class="btn btn-outline-secondary dropdown-toggle" type="button"
                                                data-toggle="dropdown" aria-expanded="false"
                                                @vue:mounted="$('.dropdown-toggle').dropdown()">
                                                {{ carrera.nivel_nombre }}
                                            </button>
                                            <div class="dropdown-menu shadow">
                                                <a class="dropdown-item" v-for="nivel in niveles" key="nivel.nivel_id"
                                                    style="cursor: pointer; user-select: none;"
                                                    @click="setNivel(carrera, nivel)"
                                                    :class="nivel.nivel_id == carrera.nivel_id ? 'active' : ''"
                                                    :disabled="nivel.nivel_id == carrera.nivel_id">
                                                    {{ nivel.nivel_nombre }}
                                                </a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div> <!-- End of Carreras loop -->
                        </div>
                    </div>
                </div>
                <!-- End of Facultad Card -->
            </div>
        </div>
    </main>
    <?
    include "import/html_footer.php"; ?>
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js"
        integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
        crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"
        integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"
        crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.min.js"
        integrity="sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+"
        crossorigin="anonymous"></script>
    <script src="js/datalist.js"></script>
    <script src="js/carreras.js?<?= rand(0, 2) ?>" type="module"></script>
    <script src="js/scrollables.js"></script>
</body>

</html>