<?php
require_once("../../config/conexion.php");
require_once("../../models/Permisos.php");
$permiso = new Permisos();
$resultado = $permiso->Permisos_por_Perfil("CALIFICACIONES", $_SESSION["perfil"]);
foreach ($resultado as $row) {
    $actualizar = $row["actualizar"];
}
if (isset($_SESSION["usuariodbk"])) {
    ?>
    <!DOCTYPE html>
    <html lang="es">
        <head>
            <?php
            require_once '../html/MainHead.php';
            ?>
            <title>SIED | CALIFICACIONES</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">CALIFICACIONES - POR ASIGNATURA</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"><a href="../Calificacion/">Calificaciones</a></li>
                                    <li class="breadcrumb-item active">Por Asignatura</li>
                                </ol>
                            </div>
                        </div>
                    </div>
                </div>
                <?php 
                if ($_SESSION["perfil"] != "DOCENTE"){ ?>
                <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="formPorAsignatura" enctype="multipart/form-data">
                                            <input type="hidden" name="carreradbk" id="carreradbk"/>
                                            <div class="form-layout form-layout-1">
                                                <div class="row mg-b-25">
                                                    <div class="col-lg-4">
                                                        <div class="form-group mg-b-10-force">
                                                            <label for="periodo" class="form-label">Periodo:</label>
                                                            <select class="form-control select2" name="periodo" id="periodo" data-placeholder="Seleccione">
                                                            </select>                                                                    
                                                            <div class="invalid-feedback" id="invalid-periodo">Seleccione el periodo.</div>
                                                            <div class="valid-feedback" id="valid-periodo">¡Campo validado!</div>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-8">
                                                        <div class="form-group mg-b-10-force">
                                                            <label for="carrera" class="form-label">Carrera:</label>
                                                            <select class="form-control select2" name="carrera" id="carrera" data-placeholder="Seleccione" required>
                                                            </select>                                                                        
                                                            <div class="invalid-feedback" id="invalid-carrera">Seleccione la carrera.</div>
                                                            <div class="valid-feedback" id="valid-carrera">¡Campo validado!</div>
                                                        </div>
                                                    </div>  
                                                    <div class="col-lg-12">
                                                        <div class="form-group mg-b-10-force">
                                                            <label for="asignatura" class="form-label">Asignatura:</label>
                                                            <select class="form-control select2" name="asignatura" id="asignatura" data-placeholder="Seleccione" required>
                                                            </select>                                                                        
                                                            <div class="invalid-feedback" id="invalid-asignatura">Seleccione la asignatura.</div>
                                                            <div class="valid-feedback" id="valid-asignatura">¡Campo validado!</div>
                                                        </div>
                                                    </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                 
                }else{?>
                <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="formPorAsignaturaDocente" enctype="multipart/form-data">
                                            <div class="form-layout form-layout-1">
                                                <div class="row mg-b-25">      
                                                    <div class="col-lg-12">
                                                        <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>
                                                    </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 } ?>

                
                <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="calificacion-data" class="table table-bordered display table-striped responsive nowrap tablas" cellspacing="0" width="100%">
                                                <thead>
                                                    <tr>
                                                        <th>Código</th>
                                                        <th>Estudiante</th>
                                                        <th>Aporte I</th>
                                                        <th>Aporte II</th>
                                                        <th>Aporte III</th>
                                                        <th>Examen</th>
                                                        <th>Nota Final</th>
                                                        <?php                                                       
                                                        if ($actualizar == 1) {
                                                            echo"<th>Acciones</th>";
                                                        }
                                                        ?>                                                       
                                                    </tr>
                                                </thead>
                                                <tbody>                                                    
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </div> 
                
            </div>
            <?php require_once '../html/MainFooter.php'; ?> 
            <aside class="control-sidebar control-sidebar-dark">
            </aside>            
            <?php require_once '../html/MainJS.php'; ?>
            <script type="text/javascript" src="asignatura.js"></script>            
        </body>
    </html>
    <?php
} else {
    header("Location:" . Conexion::ruta() . "view/404/");
}
?>