<?php
require_once("../../config/conexion.php");
require_once("../../models/Permisos.php");
$permiso = new Permisos();
$resultado = $permiso->Permisos_por_Perfil("BIBLIOTECA", $_SESSION["perfil"]);
foreach ($resultado as $row) {
    $asignar = $row["asignar"];
    $leer = $row["leer"];
    $crear = $row["crear"];
}
if (isset($_SESSION["usuariodbk"])) {
    ?>
    <!DOCTYPE html>
    <html lang="es">
        <head>
            <?php
            require_once '../html/MainHead.php';
            ?>
            <title>SIED | BIBLIOTECA</title>
        </head>
        <body class="hold-transition sidebar-mini layout-fixed">           
            <?php require_once '../html/MainMenu.php'; ?> 
            <?php require_once '../html/MainHeader.php'; ?>             
            <div class="content-wrapper ">
                <div class="content-header">
                    <div class="container-fluid">
                        <div class="row mb-2">
                            <div class="col-sm-6">
                                <h1 class="m-0">BIBLIOTECA - BIBLIOGRAFIA RECOMENDADA</h1>
                            </div>
                            <div class="col-sm-6">
                                <ol class="breadcrumb float-sm-right">
                                    <li class="breadcrumb-item"><a href="../UsuHome/">Inicio</a></li>
                                    <li class="breadcrumb-item active">Bibliografía Recomendada</li>
                                </ol>
                            </div>
                        </div>
                    </div>
                </div>
                <?php 
                if ($_SESSION["perfil"] == "DOCENTE" || $_SESSION["perfil"] == "ESTUDIANTE"){ ?>
                    <div class="br-pagebody mg-t-5 pd-x-30">
                    <section class="content">
                        <div class="container-fluid">
                            <div class="col-12">
                                <div class="card">
                                    <div class="card-body responsive">
                                        <form method="post" id="formAsignarBibliografia" enctype="multipart/form-data">
                                            <div class="form-layout form-layout-1">
                                                <div class="row mg-b-25">      
                                                    <div class="col-lg-12">
                                                        <?php if($_SESSION["perfil"] == "DOCENTE"){ ?>
                                                        <div class="form-group mg-b-10-force">
                                                            <label for="asignaturaD" class="form-label">Asignatura:</label>
                                                            <select class="form-control select2" name="asignaturaD" id="asignaturaD" data-placeholder="Seleccione" required>
                                                            </select>                                                                        
                                                            <div class="invalid-feedback" id="invalid-asignaturaD">Seleccione la asignatura.</div>
                                                            <div class="valid-feedback" id="valid-asignaturaD">¡Campo validado!</div>
                                                        </div>
                                                        <?php }?>
                                                        <?php if($_SESSION["perfil"] == "ESTUDIANTE"){ ?>
                                                        <div class="form-group mg-b-10-force">
                                                            <label for="asignaturaE" class="form-label">Asignatura:</label>
                                                            <select class="form-control select2" name="asignaturaE" id="asignaturaE" data-placeholder="Seleccione" required>
                                                            </select>                                                                        
                                                            <div class="invalid-feedback" id="invalid-asignaturaE">Seleccione la asignatura.</div>
                                                            <div class="valid-feedback" id="valid-asignaturaE">¡Campo validado!</div>
                                                        </div>
                                                        <?php }?>                                                        
                                                    </div>                                                                    
                                                </div>                                                   
                                                <div class='form-layout-footer'>
                                                    <button type='submit' name='action' value='add' class='btn btn-primary tx-11 tx-uppercase pd-y-12 pd-x-25 tx-mont tx-medium'>Buscar</button>                
                                                </div>                                                        
                                            </div>                                                        
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </div>    
                <?php                 
                }?> 
                <?php if($_SESSION["perfil"]=="DOCENTE"){?>
                
                <div class="br-pagebody mg-t-5 pd-x-30">
                    <section class="content">
                        <div class="container-fluid">
                            <div class="row row-sm mg-t-20">
                                <div class="col-12">
                                    <div class="card">
                                        <div class="card-body responsive">                                            
                                            <table id="calificacionD-data" class="table table-bordered display table-striped responsive nowrap tablas" cellspacing="0" width="100%">
                                                <thead>
                                                    <tr>
                                                        <th>Código</th>
                                                        <th>Nombre</th>
                                                        <th>Clase</th>
                                                        <th>Docente</th>                                                           
                                                        <?php
                                                        if ($leer == 1) {
                                                            echo"<th>Estado</th>";
                                                        }
                                                        if ($leer == 1) {
                                                            echo"<th>Acciones</th>";
                                                        }
                                                        ?>                                                         
                                                    </tr>
                                                </thead>
                                                <tbody>                                                    
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </div>             
                <?php } ?>
                <?php if($_SESSION["perfil"]=="ESTUDIANTE"){?>
                <div class="br-pagebody mg-t-5 pd-x-30">
                    <section class="content">
                        <div class="container-fluid">
                            <div class="row row-sm mg-t-20">
                                <div class="col-12">
                                    <div class="card">
                                        <div class="card-body responsive">                                            
                                            <table id="calificacionE-data" class="table table-bordered display table-striped responsive nowrap tablas" cellspacing="0" width="100%">
                                                <thead>
                                                    <tr>
                                                        <th>Código</th>
                                                        <th>Nombre</th>
                                                        <th>Clase</th>                                                           
                                                        <?php
                                                        if ($leer == 1) {
                                                            echo"<th>Acciones</th>";
                                                        }
                                                        ?>                                                         
                                                    </tr>
                                                </thead>
                                                <tbody>                                                    
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </div>
                <?php } ?>
            </div>
            <?php require_once '../html/MainFooter.php'; ?> 
            <aside class="control-sidebar control-sidebar-dark">
            </aside>   
            <?php require_once 'verLibro.php'; ?>
            <?php require_once '../html/MainJS.php'; ?>
            <script type="text/javascript" src="asignarBibliografia.js"></script>            
        </body>
    </html>
    <?php
} else {
    header("Location:" . Conexion::ruta() . "view/404/");
}
?>