<%-- 
    Document   : profesores
    Created on : jun 6, 2017, 2:51:57 a.m.
    Author     : ryuuji
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Profesores</title>
        <link rel="stylesheet" href="css.css"/>
        <script>
            function crear(){
                document.getElementById("crear").submit();
            }
            function eliminar(){
                document.getElementById("eliminar").submit();
            }
        </script>
    </head>
    <body>
        <ul>
            <li style="float: right"><a href="index.jsp">Volver</a></li>
        </ul>
        <div class="bottom">
            <div class="overflow">
                <table class="table">
                    <tr class="tr">
                        <th class="th">Nombre</th>
                        <th class="th">Rut</th>
                        <th class="th" colspan="50">Asignaturas</th>
                    </tr>
                    <c:forEach items="${profesores}" var="profesor">
                        <tr class="tr">
                            <td class="td"><c:out value="${profesor.key.nombre}"/></td>
                            <td class="td"><c:out value="${profesor.key.rut}"/></td>
                            <c:forEach items="${profesor.value}" var="asignatura">
                                <td class="td"><c:out value="${asignatura.nombre}"/></td>
                            </c:forEach>
                        </tr>
                    </c:forEach>
                </table>
            </div>
            <div class="query">
                <form action="CrearProfesor" method="post" id="crear">
                    <table style="width: 20em">
                        <tr><td>Nombre</td></tr>
                        <tr>
                            <td><input type="text" name="nombre"/></td>
                        </tr>
                        <tr><td>Rut</td></tr>
                        <tr>
                            <td><input type="text" name="rut"/></td>
                            <td><input type="text" name="id" maxlength="1" style="width: 5em"/></td>
                        </tr>
                        <tr>
                            <td><button onclick="crear()">Crear</button></td>
                        </tr>
                        <tr><td><c:out value="${errorCrear}"/></td></tr>
                    </table>
                </form>
            </div>
            <div class="query">
                <form action="EliminarProfesor" method="post" id="eliminar">
                    <table style="width: 20em">
                        <tr><td>Rut</td></tr>
                        <tr>
                            <td><input type="text" name="rut"/></td>
                            <td><input type="text" name="id" maxlength="1" style="width: 5em"/></td>
                        </tr>
                        <tr>
                            <td><button onclick="eliminar()">Eliminar</button></td>
                        </tr>
                        <tr><td><c:out value="${errorEliminar}"/></td></tr>
                    </table>
                </form>
            </div>
        </div>
    </body>
</html>
